public function action_template_toggle_recommended($project_id) { $project = Project::find($project_id); $project->recommended = $project->recommended == 1 ? 0 : 1; $project->save(); return Redirect::back(); }
/** List all projects, this is the default Route. */ public function all() { $this->projects = Project::find('all', array('order by' => 'created_at desc')); if ($this->projects->count() == 0) { $this->projects = array(); } }
public static function bid($attributes = array(), $project_id = false) { $faker = Faker\Factory::create(); $p = $project_id ? Project::find($project_id) : Project::where_not_null('posted_to_fbo_at')->order_by(\DB::raw('RAND()'))->first(); $v = Vendor::order_by(\DB::raw('RAND()'))->first(); $prices = array(); foreach (array_keys($p->deliverables) as $d) { $prices[$d] = rand(100, 10000); } $b = new Bid(array('project_id' => $p->id, 'approach' => $faker->paragraph, 'previous_work' => $faker->paragraph, 'employee_details' => "Adam Becker\n" . "Craig Collyer", 'prices' => $prices)); $b->starred = rand(0, 1); $b->vendor_id = $v->id; $b->save(); if (rand(0, 6) === 0) { $b->delete_by_vendor(); } else { if (rand(0, 1) === 0) { $submitted_at = new \DateTime(); $b->submitted_at = rand(0, 1) === 0 ? $submitted_at : null; $b->submit(); // Dismiss 1/3 of the bids if (rand(0, 2) === 0) { $b->dismiss(Bid::$dismissal_reasons[array_rand(Bid::$default_dismissal_reasons)], $faker->paragraph(2)); // Un-dismiss 1/2 of these if (rand(0, 1) === 0) { $b->undismiss(); } } } } }
public function save() { // Get all inputs $input = Input::all(); // Retrive the project details $project = Project::find($input['project_id']); // Assign values $project->name = $input['name']; $project->project_type = $input['project_type']; $project->description = $input['description']; $project->client_name = $input['client_name']; $project->start_at = $input['start_at']; $project->complete_at = $input['complete_at']; // Identify if this project is on hold or not if (isset($input['status'])) { $project->status = 2; } else { $project->status = 1; } // Update the project details $project->save(); // Assign each user in a project foreach (array_merge($input['developers'], $input['qc']) as $key => $value) { $user = ProjectUsers::firstOrCreate(array('project_id' => $input['project_id'], 'user_id' => $value)); $user->key = Crypt::encrypt(time()); $user->save(); } // Redirect to project page with message return Redirect::to('/project/' . $project->slug)->with('flash_msg', 'This project was successfully updated!'); }
public function completeProject() { $id = $_GET['id']; $Project = Project::find($id); $Project->complete(); return Redirect::back(); }
public function dopublish() { $id = intval(Input::get('id')); $this->check_own($id); $project = Project::find($id); if (!$id || !$project) { return Response::json(array("result" => false, 'msg' => '项目不存在')); } $version = trim(Input::get('project_select_version')); if (!preg_match('/^\\w+$/i', $version)) { return Response::json(array("result" => false, 'msg' => '请选择正确的版本')); } $task_ids = array('upd_prj' => '', 'sync_svr' => array()); $task_ids['upd_prj'] = Task::create('update', Auth::id(), array('project_id' => $id, "version" => $version)); $servers_id = Input::get('publish_box'); $servers = Server::whereIn("id", $servers_id)->get(); foreach ($servers as $key => $value) { if ($value->project_id != $id) { //检查服务器是不是属于project continue; } $task_ids['sync_svr'][$value->id] = Task::create('rsync', Auth::id(), array('server_id' => $value->id), $task_ids['upd_prj']); } return Response::json(array("result" => true, 'msg' => '', 'tasks' => $task_ids)); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = Auth::user(); $project = Project::find($request->input('id')); if ($project->user_id != $user->id) { return redirect('/'); } return $next($request); }
/** * @desc: Shows a project */ public function show() { try { $this->template->assign('project', Project::find($this->request->getParameter('id'))); } catch (ActiveRecordException $rnfEx) { $this->flash('error', $rnfEx->getMessage()); $this->redirect_to('index'); } }
public function index($projectId) { $images = Project::find($projectId)->images; if (count($images)) { return Response::json($images); } else { return Response::json(['alert' => 'Images' . Messages::$notFound], 404); } }
public function activity($activity_limit = 5) { $users = $comments = $activity_type = array(); $issue = $this; $project_id = $this->project_id; $project = \Project::find($project_id); foreach (\Activity::all() as $row) { $activity_type[$row->id] = $row; } $activities = array(); foreach (\User\Activity::where('item_id', '=', $issue->id)->order_by('created_at', 'ASC')->get() as $activity) { $activities[] = $activity; switch ($activity->type_id) { case 2: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } if (!isset($comments[$activity->action_id])) { $comments[$activity->action_id] = \Project\Issue\Comment::find($activity->action_id); } break; case 5: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } if (!isset($users[$activity->action_id])) { $users[$activity->action_id] = \User::find($activity->action_id); } break; default: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } break; } } /* Loop through the projects and activity again, building the views for each activity */ $return = array(); foreach ($activities as $row) { switch ($row->type_id) { case 2: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'comment' => $comments[$row->action_id], 'activity' => $row)); break; case 3: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'activity' => $row)); break; case 5: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'assigned' => $users[$row->action_id], 'activity' => $row)); break; default: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'activity' => $row)); break; } } return $return; }
public function updateProject() { $id = Input::get('id'); $fieldname = Input::get('field'); $value = Input::get('value'); $project = Project::find($id); $project->{$fieldname} = $value; $project->save(); return $this->success(null, null); }
public function destroy($id) { //project $project = Project::find($id); if (sizeof($project->iterations) < 1) { $project->delete(); } $organization = app('organization'); return Redirect::to('organization/name/' . $organization->auxName . '/projects')->with('message', 'Registro eliminado'); }
public function upload() { if (Auth::user() !== null) { $project = Project::find(Auth::user()->project_id); //$project = Project::find($id); return View::make('uploads.uploads', compact('project')); } else { return Redirect::to('index'); } }
public function show() { if (Auth::user() !== null) { $project = Project::find(Auth::user()->project_id); $id = $project->id; $construction = DB::table('constructions')->where('project_id', $id)->first(); return View::make('portal.construction', compact('construction', 'id')); } else { return Redirect::to('index'); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show() { // if (Auth::user() !== null) { $project = Project::find(Auth::user()->project_id); $id = $project->id; return View::make('portal.sideBar.property', compact('id')); } else { return Redirect::to('index'); } }
public function update($id) { $daterange = explode('-', Input::get('range')); $start_date = trim($daterange[0]); $end_date = trim($daterange[1]); $project = Project::find($id); $project->code = Input::get('code'); $project->name = Input::get('name'); $project->start_date = $start_date; $project->end_date = $end_date; $project->save(); Session::flash('message', 'Sukses mengupdate Project'); }
public function destroy($id) { $project = Project::find($id); if (Input::has('confirmed')) { $project->bullets()->delete(); $project->links()->delete(); $project->images()->delete(); $project->tags()->delete(); $project->delete(); return Redirect::route('projects.index'); } else { return View::make('projects.delete')->withProject($project); } }
function syncPuEntries($userId) { App::import('Model', 'Project'); $projectClass = new Project(); $projectIds = $projectClass->find('list', array('fields' => array('Project.id'))); $puProjectIds = $this->find('list', array('conditions' => array('ProjectsUsers.user_id' => $userId), 'fields' => array('ProjectsUsers.project_id'))); $notYetThereProjectIds = array_diff($projectIds, $puProjectIds); $savArr = array(); foreach ($notYetThereProjectIds as $nytpid) { $savArrEntry = array('project_id' => $nytpid, 'user_id' => $userId); $savArr[] = $savArrEntry; } $this->saveAll($savArr); }
public function get_inactive_users() { $project = Project::find(Input::get('project_id')); $results = array(); if (is_null($project)) { $users = User::all(); } else { $users = $project->users_not_in(); } foreach ($users as $row) { $results[] = array('id' => $row->id, 'label' => $row->firstname . ' ' . $row->lastname); } return json_encode($results); }
public function update($id) { $project = Project::find($id); $details = Input::all(); if ($project) { if ($project->update($details)) { return Response::json(['project' => $project, 'alert' => Messages::$updateSuccess . 'project']); } else { return Response::json(['alert' => Messages::$updateFail . 'project'], 400); } } else { return Response::json(['alert' => 'Projects' . Messages::$notFound], 400); } }
public function showProject($id) { $project = Project::find($id); if ($id == 'random') { $projects = Project::all(); $project = $projects[mt_rand(0, count($projects) - 1)]; } if (!$project) { return Redirect::to('search')->with('error', 'Oops! It seems we can\'t find the page you are looking for. Try search instead.'); } $geojson = 'pin-l-circle-stroked+1abc9c(' . $project->geo()->lng . ',' . $project->geo()->lat . ')/' . $project->geo()->lng . ',' . $project->geo()->lat . '),13'; $map_image_link = 'https://api.tiles.mapbox.com/v4/codeforafrica.ji193j10/' . $geojson . '/520x293.png256?' . 'access_token=pk.eyJ1IjoiY29kZWZvcmFmcmljYSIsImEiOiJVLXZVVUtnIn0.JjVvqHKBGQTNpuDMJtZ8Qg'; $data = compact('project', 'map_image_link', 'geojson'); return view('home.project', $data); }
public function action_create() { $project = Project::find(Input::get('project_id')); if (!$project || !$project->question_period_is_open()) { return Redirect::to_route('project', $project->id); } $question = new Question(array('project_id' => Input::get('project_id'), 'question' => Input::get('question'))); $question->vendor_id = Auth::user()->vendor->id; if ($question->validator()->passes()) { $question->save(); return Response::json(array("status" => "success", "question" => $question->to_array(), "html" => View::make('projects.partials.question')->with('question', $question)->render())); } else { return Response::json(array("status" => "error", "errors" => $question->validator()->errors->all())); } }
public function testFind() { $cq = EQM::queryByPrimary(Company::class, 2); $cm = Company::find(2); $this->assertEquals($cq->id, $cm->id); $this->assertEquals($cq->name, $cm->name); $pq = EQM::queryByPrimary(Project::class, '2_2_PROJECT'); $pm = Project::find('2_2_PROJECT'); $this->assertEquals($pq->id, $pm->id); $this->assertEquals($pq->name, $pm->name); $paq = EQM::queryByPrimary(ProjectActivity::class, ['id' => 100, 'projectId' => '2_2_PROJECT']); $pam = ProjectActivity::find(['id' => 100, 'projectId' => '2_2_PROJECT']); $this->assertEquals($paq->id, $pam->id); $this->assertEquals($paq->name, $pam->name); }
function removeProject($id) { if (isset($id)) { $project = Project::find($id); if (isset($project)) { $project->status = 'removed'; $project->save(); Bug::where('project_id', '=', $id)->update(array('status' => 'removed')); echo 'done'; } else { echo 'invalid'; } } else { echo 'invalid'; } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $project = Project::find($id); $project->client_id = Input::get('client_id'); $project->company = Input::get('company'); $project->service = Input::get('service'); $project->details = Input::get('details'); $project->date = Input::get('date'); $project->amount = Input::get('amount'); $project->contact_name = Input::get('contact_name'); $project->contact_email = Input::get('contact_email'); $project->contact_phone = Input::get('contact_phone'); $project->notes = Input::get('notes'); $project->save(); Flash::message('Project Updated!'); return Redirect::route('projects')->with('flash_message', 'Project Updated'); }
public function action_do_create() { $project = Project::find(Input::get('project_id')); $new = array('title' => Input::get('title'), 'description' => Input::get('description'), 'customer_id' => $project->customer_id, 'project_id' => $project->id, 'organization_id' => Auth::user()->organization->id); $v = Todo::validate($new); if ($v->fails()) { // redirect back to the form with // errors, input and our currently // logged in user return Redirect::to_route('create_todo', $project->id)->with_errors($v)->with_input(); } // create the new post $o = new Todo($new); $o->save(); // redirect to viewing our new post return Redirect::to_route('read_customer', $project->customer_id); }
/** * Load a todo * * @param int $task_id * @return array */ public static function load_todo_extras(&$todo) { // We need the issue and project names for display, status and // assigned_to for validity. $issue = Project\Issue::find($todo->issue_id); if (!empty($issue)) { $todo->assigned_to = $issue->attributes['assigned_to']; $todo->issue_name = $issue->attributes['title']; $todo->issue_status = $issue->attributes['status']; $todo->issue_link = $issue->to(); $project = Project::find($issue->attributes['project_id']); $todo->project_name = $project->attributes['name']; $todo->project_link = $project->to(); } else { $todo->assigned_to = 0; $todo->issue_status = 0; } }
/** * [saveModel] * @param boolean $project [description] * @return [Eloquent model] [Project model] */ protected function saveModel($project = false) { if (Input::get('id')) { $project = Project::find(Input::get('id')); } if (!$project) { $project = new Project(); } $load_company_model = $project->company; $project->company_id = Input::get('company_id'); $project->name = Input::get('name'); $project->description = Input::get('description'); $project->comment = Input::get('comment'); $project->status = Input::get('status'); $project->jira_id = Input::get('jira_id'); $project->save(); return $project; }
public function savePosition() { // return "This is coming later"; $project = Project::find(Auth::user()->project_id); $id = $project->id; $users = DB::table('users')->where('project_id', '=', $project->id)->lists('id'); $input = Input::all(); foreach ($users as $user) { $userPos = User::find($user); if (isset($input[$user]) && $input[$user] === "admin") { $userPos->finance = false; $userPos->admin = true; $userPos->tech = false; $userPos->save(); } else { if (isset($input[$user]) && $input[$user] === "finance") { $userPos->finance = true; $userPos->admin = false; $userPos->tech = false; $userPos->save(); } else { if (isset($input[$user]) && $input[$user] === "tech") { $userPos->finance = false; $userPos->admin = false; $userPos->tech = true; $userPos->save(); } else { if (isset($input[$user]) && $input[$user] === "default") { $userPos->finance = false; $userPos->admin = false; $userPos->tech = false; $userPos->save(); } } } } } return Redirect::action('ProjectController@index'); }
public function generate() { if (Auth::user() !== null) { $project = Project::find(Auth::user()->project_id); $id = $project->id; $input = Input::all(); $projectName = DB::table('overviews')->where('project_id', $id)->pluck('projectName'); if ($projectName == "") { $projectName = "HaBUtek Project"; } if (isset($input['Project_overview'])) { $overview = DB::table('overviews')->where('project_id', $id)->first(); } if (isset($input['App_activities'])) { $activity = DB::table('activities')->where('project_id', $id)->first(); } if (isset($input['Site_conditions'])) { $siteCondition = DB::table('site_conditions')->where('project_id', $id)->first(); } if (isset($input['Infrastructure'])) { $infrastructure = DB::table('infrastructures')->where('project_id', $id)->first(); } if (isset($input['Climate'])) { $climate = DB::table('climates')->where('project_id', $id)->first(); } if (isset($input['Operations'])) { $operation = DB::table('wastes')->where('project_id', $id)->first(); } if (isset($input['Construction_indicators'])) { $waste = DB::table('wastes')->where('project_id', $id)->first(); } return View::make('portal.summary', compact('overview', 'activity', 'siteCondition', 'infrastructure', 'climate', 'operation', 'waste', 'projectName', 'id')); /* return Redirect::action('SummaryController@gen', array($id, $Project_overview, $App_activities, $Site_conditions, $Infrastructure, $Climate, $Operations, $Construction_indicators));*/ // return "Testing"; } else { return Redirect::to('index'); } }