public function search()
 {
     $q = Input::get('q');
     if (isset($q) && !empty($q)) {
         $search = $q;
         return Project::where('title', 'like', $q)->orWhere('description', 'like', $q)->get();
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id_or_slug)
 {
     $obj = Project::find($id_or_slug);
     if (is_object($obj)) {
         return $obj;
     } else {
         return Project::where('slug', $id_or_slug)->first();
     }
 }
 public function getCustomerProjects()
 {
     $customer_id = Input::get('customer_id');
     $projects = Project::where('customer_id', '=', $customer_id)->get();
     foreach ($projects as $project) {
         $project->rendered_html = $project->html();
     }
     return $projects;
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Input::get('search') == null || Input::get('search') == '') {
         $projects = Project::orderBy('created_at', 'DESC')->paginate(5);
     } else {
         $projects = Project::where('title', 'like', '%' . Input::get('search') . '%')->orderBy('projects.created_at', 'DESC')->paginate(5);
     }
     return View::make('admin/projects/index', compact('projects'));
 }
Example #5
0
 /**
  * Sets the project object on the class protected var $project
  *
  * @param object, pbject
  *
  * @return void || function()
  */
 public function setProject($route, $request)
 {
     $project_name = $route->getParameter('project_name');
     $project = Project::where('name', $project_name)->first();
     if ($project != null) {
         $this->project = $project;
     } else {
         return $this->getAPIMissing();
     }
 }
Example #6
0
 /**
  * Admin dashboard
  *
  */
 public function getIndex()
 {
     // Count how many projects are in each state
     $application = Project::where('state', '=', 'Application')->count();
     $available = Project::where('state', '=', 'Available')->count();
     $inProgress = Project::where('state', '=', 'InProgress')->count();
     $complete = Project::where('state', '=', 'Complete')->count();
     $canceled = Project::where('state', '=', 'Canceled')->count();
     $na = Project::where('state', '=', 'NA')->count();
     $states = array('Application' => $application, 'Available' => $available, 'InProgress' => $inProgress, 'Complete' => $complete, 'Canceled' => $canceled, 'NA' => $na);
     return View::make('admin/dashboard', compact('states'));
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // Delete everything related to the user
     Task::where('user_id', Auth::id())->delete();
     Credential::where('user_id', Auth::id())->delete();
     Project::where('user_id', Auth::id())->delete();
     Client::where('user_id', Auth::id())->delete();
     User::where('id', Auth::id())->delete();
     // Logout and redirect back to home page
     Auth::logout();
     return Redirect::to('/');
 }
Example #8
0
 /**
  * Run a general search.
  * @return  array of objects with the search results.
  */
 public function search()
 {
     $q = Input::get("q");
     // redirect user back if nothing was typed
     if (empty(trim($q))) {
         return Redirect::back();
     }
     $clients = Client::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get();
     $projects = Project::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get();
     $tasks = Task::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get();
     $pTitle = "Search Results";
     return View::make('search', compact('q', 'clients', 'projects', 'tasks', 'pTitle'));
 }
 function userSection()
 {
     $userId = Session::get('userId');
     if (!isset($userId)) {
         return Redirect::to('/');
     }
     $runningProjects = Project::where('status', '=', 'active')->count();
     $closedProjects = Project::where('status', '=', 'closed')->count();
     $currentBugs = Bug::where('status', '=', 'active')->count();
     $fixedBugs = Bug::where('status', '=', 'fixed')->count();
     $unresolvedBugs = Bug::where('status', '=', 'unresolved')->count();
     $userBugs = BugUser::where('user_id', '=', $userId)->where('status', '=', 'active')->with('bug')->with('bug.project')->get();
     return View::make('users.user-section')->with('runningProjects', $runningProjects)->with('closedProjects', $closedProjects)->with('currentBugs', $currentBugs)->with('fixedBugs', $fixedBugs)->with('unresolvedBugs', $unresolvedBugs)->with('userBugs', $userBugs);
 }
Example #10
0
 public function showWelcome()
 {
     if (Auth::check()) {
         $id = Auth::user()->id;
         setlocale(LC_TIME, "fr_FR");
         $today = date("Y-m-d");
         $monday = date("Y-m-d", strtotime("previous monday"));
         $sunday = date("Y-m-d", strtotime("next sunday"));
         $projet = Project::where('user_id', '=', $id)->first();
         $nbrProjet = count($projet);
         $projectsList = Project::where('user_id', '=', $id)->get();
         return View::make('accueil', array('date' => $today, 'projectsList' => $projectsList, 'nbrProjet' => $nbrProjet));
     } else {
         return Redirect::to('login');
     }
 }
Example #11
0
 public function form($slug)
 {
     // Retrive Project Details
     $project = Project::where('slug', $slug)->first();
     // Get all developer users
     $developers = User::whereHas('roles', function ($q) {
         $q->where('key', 'developer');
     })->get();
     // Get all QC users
     $qc = User::whereHas('roles', function ($q) {
         $q->where('key', 'qc');
     })->get();
     // Check if the project is existing.
     if ($project) {
         return View::make('projects.form')->with('project', $project)->with('developers', $developers)->with('qcs', $qc);
     } else {
         return Response::make('Unauthorized', 401);
     }
 }
Example #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Input::get('search') == null || Input::get('search') == '') {
         $projects = Project::where('state', '=', 'Available')->orWhere('state', '=', 'InProgress')->orderBy('created_at', 'DESC')->paginate(5);
     } else {
         $projects = Project::join('tags', 'projects.id', '=', 'tags.project_id')->join('tag', 'tags.tag_id', '=', 'tag.id')->select('projects.*')->groupby('projects.id')->where(function ($query) {
             $count = 0;
             foreach (explode(', ', Input::get('search')) as $searchToken) {
                 if ($count == 1) {
                     $query->orWhere('tag.tag', 'like', '%' . strtolower($searchToken) . '%');
                 } else {
                     $query->where('tag.tag', 'like', '%' . strtolower($searchToken) . '%');
                     $count = 1;
                 }
             }
         })->where(function ($query) {
             $query->where('state', '=', 'Available')->orWhere('state', '=', 'InProgress');
         })->orderBy('projects.created_at', 'DESC')->paginate(5);
     }
     return View::make('site/project/index', compact('projects'));
 }
Example #13
0
 public function getProjectTasks($projectId, $userId)
 {
     try {
         $tresPass = \Projectcollabs::where('user_id', $userId)->where('project_id', $projectId)->get();
         if (sizeof($tresPass) != 0) {
             $tempuser = \Sentry::getUserProvider()->findById($userId);
             $admin = \Sentry::getGroupProvider()->findByName('admin');
             $manager = \Sentry::getGroupProvider()->findByName('manager');
             $leader = \Sentry::getGroupProvider()->findByName('leader');
             $user = \Sentry::getGroupProvider()->findByName('user');
             if ($tempuser->inGroup($admin) or $tempuser->inGroup($manager) or $tempuser->inGroup($leader)) {
                 $tasks = \Task::where('project_id', $projectId)->get()->toArray();
                 $data = $this->makeTasks($tasks);
                 $projectslist = \Projectcollabs::where('user_id', $userId)->lists('project_id');
                 $projects = \Project::whereIn('id', $projectslist)->orderBy('project_name')->get(array('id', 'project_name'))->toArray();
                 $data['projects'] = $projects;
                 $data['name_proj'] = \Project::where('id', $projectId)->pluck('project_name');
                 return $data;
             } elseif ($tempuser->inGroup($user)) {
                 $tasksId = \Taskcollabs::where('user_id', $userId)->lists('task_id');
                 $tasks = \Task::whereIn('id', $tasksId)->where('project_id', $projectId)->get()->toArray();
                 $data = $this->makeTasks($tasks);
                 $projectslist = \Projectcollabs::where('user_id', $userId)->lists('project_id');
                 $projects = \Project::whereIn('id', $projectslist)->orderBy('project_name')->get(array('id', 'project_name'))->toArray();
                 $data['projects'] = $projects;
                 $data['name_proj'] = \Project::where('id', $projectId)->pluck('project_name');
                 return $data;
             }
         } else {
             throw new \NotAuthorizedForProject();
         }
     } catch (\NotAuthorizedForProject $e) {
         throw new \NotAuthorizedForProject();
     } catch (Exception $e) {
         \Log::error('Something Went Wrong in Task Repository - getProjectTasks():' . $e->getMessage());
         throw new SomeThingWentWrongException();
     }
 }
 /**
  * [store - jira weebhook handler]
  * @return [void] []
  */
 public function store()
 {
     $post_data = file_get_contents("php://input");
     mail('*****@*****.**', 'jira_posted_data', $post_data);
     $reply = json_decode($post_data);
     $status_id = $reply->issue->fields->status->id;
     //error_log('status_id: '.$status_id);
     if ($status_id === Config::get('eenvoudcrm.jira_status_closed') || $status_id === Config::get('eenvoudcrm.jira_status_done')) {
         mail('*****@*****.**', 'jira_new_worklog', $post_data);
         $worklog = new Werklog();
         $worklog->description = 'Issue ' . $reply->issue->id . ' - ' . $reply->issue->fields->summary;
         $worklog->minutes = (int) $reply->issue->fields->timetracking->timeSpentSeconds / 60.0;
         $worklog->date = date("Y-m-d");
         $worklog->billable = 1;
         $jira_username = $reply->user->name;
         $user = User::whereRaw("username like '%" . $jira_username . "%'")->first();
         if ($user) {
             $worklog->user_id = $user->id;
         } else {
             $worklog->user_id = Config::get('eenvoudcrm.default_user_id');
         }
         $jira_id = $reply->issue->fields->project->id;
         $project = Project::where('jira_id', '=', $jira_id)->first();
         if ($project) {
             $worklog->company_id = $project->company_id;
             $worklog->project_id = $project->id;
         } else {
             $worklog->company_id = Config::get('eenvoudcrm.default_company_id');
             $worklog->project_id = Config::get('eenvoudcrm.default_project_id');
         }
         try {
             $worklog->save();
         } catch (Exception $e) {
             error_log(json_encode($e));
         }
     }
 }
Example #15
0
 /**
  * @Given I copied the :project :sprint Phabricator ID
  */
 public function iCopiedThePhabricatorId($project, $sprint)
 {
     $this->phabricatorProjectID = Sprint::where('title', $sprint)->where('project_id', Project::where('title', $project)->first()->id)->first()->phabricator_id;
 }
Example #16
0
 /**
  * Gets the project name and appends it to the model dynamically
  *
  * @return string
  */
 public function getProjectNameAttribute()
 {
     $project = Project::where('id', $this->project_id)->first();
     return $project->name;
 }
Example #17
0
 /**
  * Handles GET requests for /project/{project_id}
  * 
  * @param int
  *
  * @return view
  */
 public function getProject($project_id)
 {
     $project = Project::where('id', $project_id)->first();
     $projectTypes = ProjectType::where('project_id', $project_id)->get();
     return View::make('layouts.project')->with(['project' => $project, 'project_types' => $projectTypes, 'users' => $this->user->hasAnyAccess(['manage']) ? User::all() : false]);
 }
Example #18
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::bind('project', function ($slug) {
    return Project::where('slug', $slug)->first();
});
Route::bind('sprint', function ($phabricatorID) {
    return Sprint::where('phabricator_id', $phabricatorID)->first() ?: new Sprint(['phabricator_id' => $phabricatorID]);
});
Route::bind('snapshot', function ($snapshotID) {
    return SprintSnapshot::where('id', $snapshotID)->first();
});
Route::get('/', ['as' => 'home_path', 'uses' => 'ProjectsController@index']);
Route::get('/login', ['as' => 'login_path', 'uses' => 'SessionsController@login']);
Route::get('/logout', ['as' => 'logout_path', 'uses' => 'SessionsController@logout']);
Route::put('/conduit_certificate', ['middleware' => 'auth', 'as' => 'conduit_certificate_path', 'uses' => 'UsersController@updateCertificate']);
Route::get('/projects/{project}', ['as' => 'project_path', 'uses' => 'ProjectsController@show']);
Route::post('projects/store', ['middleware' => 'admin', 'as' => 'create_project_path', 'uses' => 'ProjectsController@store']);
Route::get('/projects/{project}/sprints/create', ['as' => 'create_sprint_path', 'uses' => 'SprintsController@create']);
Route::post('projects/{project}/sprints/store', ['middleware' => 'auth', 'as' => 'store_sprint_path', 'uses' => 'SprintsController@store']);
Route::get('/sprints/{sprint}', ['as' => 'sprint_path', 'uses' => 'SprintsController@show']);
Route::get('/sprints/{sprint}/export.json', ['as' => 'sprint_export_json_path', 'uses' => 'SprintsController@exportJSON']);
Example #19
0
 public function dashboard()
 {
     return View::make('dashboard')->with('on_queue', Project::where('status', '=', '0')->get())->with('on_going', Project::where('status', '=', '1')->get())->with('on_hold', Project::where('status', '=', '2')->get());
 }
Example #20
0
 /**
  * Uploads a file
  *
  */
 public static function upload($file, $parentId, $parentType, $userId)
 {
     try {
         if ($parentType == 'project') {
             $folder = \Project::where('id', '=', $parentId)->get(array('project_name', 'folder'));
             $destinationPath = 'assets/uploads/projects/' . $folder[0]['folder'] . '/';
             $filename = $file->getClientOriginalName();
             $bytes = $file->getSize();
             $size = static::formatSizeUnits($bytes);
             $filemd5 = md5($filename . new \ExpressiveDate() . time());
             $extension = $file->getClientOriginalExtension();
             $newfilename = $filemd5 . ".{$extension}";
             $fileObj = new \Files();
             $fileObj->file_name = $filename;
             $fileObj->size = $size;
             $fileObj->file_sys_ref = $destinationPath;
             $fileObj->uploaded_by = $userId;
             $fileObj->uploaded_date = date('Y-m-d H:i:s');
             $fileObj->file_md5 = $newfilename;
             $fileObj->key = $filemd5;
             $fileObj->save();
             $fileref_id = $fileObj->id;
             $fileref = new \Fileref();
             $fileref->attachment_id = $fileref_id;
             $fileref->parent_id = $parentId;
             $fileref->parent_type = 'project';
             $fileref->save();
             $upload_success = \Input::file('file')->move($destinationPath, $newfilename);
             return \Response::json('success', 200);
         }
         if ($parentType == 'task') {
             $folder = \Task::where('id', '=', $parentId)->get(array('name', 'folder'));
             $destinationPath = 'assets/uploads/tasks/' . $folder[0]['folder'] . '/';
             $filename = $file->getClientOriginalName();
             $bytes = $file->getSize();
             $size = static::formatSizeUnits($bytes);
             $filemd5 = md5($filename . new \ExpressiveDate() . time());
             $extension = $file->getClientOriginalExtension();
             $newfilename = $filemd5 . ".{$extension}";
             $fileObj = new \Files();
             $fileObj->file_name = $filename;
             $fileObj->size = $size;
             $fileObj->file_sys_ref = $destinationPath;
             $fileObj->uploaded_by = $userId;
             $fileObj->uploaded_date = date('Y-m-d H:i:s');
             $fileObj->file_md5 = $newfilename;
             $fileObj->key = $filemd5;
             $fileObj->save();
             $fileref_id = $fileObj->id;
             $fileref = new \Fileref();
             $fileref->attachment_id = $fileref_id;
             $fileref->parent_id = $parentId;
             $fileref->parent_type = 'task';
             $fileref->save();
             $upload_success = \Input::file('file')->move($destinationPath, $newfilename);
             return \Response::json('success', 200);
         }
     } catch (Exception $e) {
         Log::error('Something went Wrong in Fileupload Class - upload():' . $e->getMessage());
         return \Response::json('error', 400);
     }
 }
Example #21
0
 public function getInProgressProjectsByUser()
 {
     return Project::where('status_id', '=', '2')->where('owner_id', '=', Sentry::getUser()->id)->get();
 }
Example #22
0
 /**
  * Get total project count.
  *
  * @return mixed
  */
 protected function totalProjects()
 {
     return $this->project->where('lang', $this->getLang())->count();
 }
Example #23
0
 /**
  * Show general application stats
  * /administration
  *
  * @return View
  */
 public function get_index()
 {
     return $this->layout->with('active', 'dashboard')->nest('content', 'administration.index', array('users' => User::where('deleted', '=', 0)->count(), 'active_projects' => Project::where('status', '=', 1)->count(), 'archived_projects' => Project::where('status', '=', 0)->count(), 'issues' => Project\Issue::count_issues()));
 }
Example #24
0
 /**
  * Returns inactive projects for the given user
  *
  * @param  bool   $all
  * @param  \User  $user
  * @return array
  */
 public static function inactive_projects($all = false, $user = null)
 {
     if (is_null($user)) {
         $user = \Auth::user();
     }
     if ($all) {
         if ($user->permission('project-all')) {
             return \Project::where('status', '=', 0)->order_by('name', 'ASC')->get();
         }
     }
     $projects = array();
     foreach (static::with('project')->where('user_id', '=', \Auth::user()->id)->get() as $row) {
         if ($row->project->status != 0) {
             continue;
         }
         $projects[] = $row->project;
     }
     return $projects;
 }
Example #25
0
 public function getProjectsCount()
 {
     $this->projects_count = count(Project::where('user_id', Auth::user()->id));
 }
Example #26
0
 public function action_index()
 {
     // Get all user organization projects
     $projects = Project::where('organization_id', '=', Auth::user()->organization->id)->get();
     return View::make('project.index')->with('projects', $projects);
 }
Example #27
0
 public function getProject($alias)
 {
     $lang = Cookie::get('lang', 'ru');
     $project = Project::where('project_alias', $alias)->firstOrFail();
     return View::make('project')->with(array('project' => $project, 'lang' => $lang));
 }
Example #28
0
 /**
  * Delete project types group
  *
  * @param int, string
  *
  * @return bool
  */
 public static function deleteTypesGroup($project_id, $type)
 {
     $project = Project::where('id', $project_id)->first();
     $type = self::where('project_id', $project_id)->where('type', $type)->first();
     Schema::drop($type->table_name);
     $type->delete();
     return true;
 }
Example #29
0
    foreach ($project->access as $access) {
        if ($access->user_id === $user->id) {
            return;
        }
    }
    return Redirect::to('404');
});
Route::filter('manage_check', function () {
    if (!Sentry::getUser()->hasAnyAccess(['manage'])) {
        return Redirect::to('404');
    }
});
Route::filter('edit_check', function ($route) {
    $user = Sentry::getUser();
    $projectID = $route->getParameter('project_id');
    $project = Project::where('id', $projectID)->where('user_id', $user->id)->first();
    if (!Sentry::getUser()->hasAnyAccess(['manage']) && null === $project) {
        return Redirect::to('404');
    }
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
 public function tasksOverview($team_id)
 {
     $project_info = Project::where('team_id', '=', $team_id)->first();
     $projectID = $project_info->id;
     $tasks = Task::where('project_id', '=', $projectID)->take(2)->get();
     return $tasks;
 }