Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateActionRequest $request)
 {
     //
     $input = Request::all();
     $id = $input['project_id'];
     Action::create(['project_id' => $input['project_id'], 'action_item' => $input['action_item'], 'status' => $input['status'], 'owner' => $input['owner'], 'comment' => $input['comment'], 'target_date' => $input['target_date']]);
     flash()->success('Action has been successfully created!');
     return redirect()->action('ProjectsController@show', [$id]);
 }
Exemplo n.º 2
0
 public function addAction(Request $request, Plan $plan)
 {
     if (isset($request->add)) {
         $newaction = Action::create($request->all());
         $newaction->date = Carbon::createFromFormat("Y-m-d", $request->duedate)->toDateTimeString();
         if (isset($request->collabs)) {
             $newaction->collaborators = implode("__,__", $request->collabs);
         }
         $newaction->save();
         return view('plans.addactions')->with('plan', $plan);
     } else {
         return view('plans.addtasks')->with('plan', $plan);
     }
 }
 public function store()
 {
     $redirectID;
     $input = Request::all();
     if (Request::has('created')) {
         $redirectID = $input['id'];
         BusinessPlan::create($input);
     }
     if (Request::has('bpid')) {
         if ($input['bp'] == 'False') {
             $input['bp'] = True;
         } else {
             $input['bp'] = False;
         }
         $input['group'] += 1;
         Goal::create($input);
         $redirectID = $input['bpid'];
     }
     if (Request::has('goal_id')) {
         // return  $input['goal_id'];
         $goals = DB::select("select * from goals where bpid = '" . $input['idbp'] . "'");
         $input['goal_id'] = $goals[$input['goal_id']]->id;
         $objectiveIdent = count(DB::table('objectives')->where('goal_id', $input['goal_id'])->get()) + 1;
         $goalIdent = $input['goal_id'];
         $input['ident'] = "{$goalIdent}.{$objectiveIdent}";
         $redirectIDArray = DB::table('goals')->where('id', $input['goal_id'])->pluck('bpid');
         $redirectID = $redirectIDArray[0];
         Objective::create($input);
     }
     if (Request::has('objective_id')) {
         $input['group'] += 1;
         $objectives = DB::select("select distinct * from goals, objectives where bpid = '" . $input['idbp'] . "' and objectives.goal_id = goals.id");
         $input['objective_id'] = $objectives[$input['objective_id']]->id;
         $input['userId'] += 1;
         $objectiveIdent = DB::table('objectives')->where('id', $input['objective_id'])->pluck('ident');
         $actionIdent = count(DB::table('actions')->where('objective_id', $input['objective_id'])->get()) + 1;
         $input['ident'] = "{$objectiveIdent['0']}.{$actionIdent}";
         $var2 = $input['idbp'];
         $redirectIDArray = DB::table('goals as g')->join('objectives as o', function ($join) use($var2) {
             $join->on('o.goal_id', '=', 'g.id')->where('g.bpid', '=', $var2);
         })->distinct()->pluck('g.bpid');
         $redirectID = $redirectIDArray[0];
         $collabs = "";
         if (array_key_exists('collaborators-groups', $input)) {
             foreach ($input['collaborators-groups'] as $x) {
                 $group = Group::find($x);
                 if ($group != null) {
                     $collabs .= Group::find($x)->name;
                     $collabs .= ", ";
                 } else {
                     $collabs .= "";
                 }
             }
         }
         if (array_key_exists('collaborators-users', $input)) {
             foreach ($input['collaborators-users'] as $x) {
                 $user = User::find($x);
                 if ($user != null) {
                     $collabs .= User::find($x)->name;
                     $collabs .= ", ";
                 } else {
                     $collabs .= "";
                 }
             }
         }
         $collabs = rtrim($collabs, ", ");
         $input['collaborators'] = $collabs;
         Action::create($input);
     }
     if (Request::has('action_id')) {
         $input['group'] += 1;
         $actions = DB::select("select distinct * from goals, objectives,actions where bpid = '" . $input['idbp'] . "' and objectives.goal_id = goals.id and actions.objective_id = objectives.id");
         $input['action_id'] = $actions[$input['action_id']]->id;
         $input['userId'] += 1;
         $actionIdent = DB::table('actions')->where('id', $input['action_id'])->pluck('ident');
         $taskIdent = count(DB::table('tasks')->where('action_id', $input['action_id'])->get()) + 1;
         $input['ident'] = "{$actionIdent['0']}.{$taskIdent}";
         $var2 = $input['idbp'];
         $redirectIDArray = DB::table('goals as g')->join('objectives as o', function ($join2) use($var2) {
             $join2->on('o.goal_id', '=', 'g.id')->where('g.bpid', '=', $var2);
         })->join('actions as a', function ($join) {
             $join->on('a.objective_id', '=', 'o.id');
         })->distinct()->pluck('g.bpid');
         $redirectID = $redirectIDArray[0];
         $collabs = "";
         if (array_key_exists('collaborators-groups', $input)) {
             foreach ($input['collaborators-groups'] as $x) {
                 $group = Group::find($x);
                 if ($group != null) {
                     $collabs .= Group::find($x)->name;
                     $collabs .= ", ";
                 } else {
                     $collabs .= "";
                 }
             }
         }
         if (array_key_exists('collaborators-users', $input)) {
             foreach ($input['collaborators-users'] as $x) {
                 $user = User::find($x);
                 if ($user != null) {
                     $collabs .= User::find($x)->name;
                     $collabs .= ", ";
                 } else {
                     $collabs .= "";
                 }
             }
         }
         $collabs = rtrim($collabs, ", ");
         $input['collaborators'] = $collabs;
         Task::create($input);
     }
     return redirect("businessplan/" . $redirectID . "");
 }
Exemplo n.º 4
0
 public function run()
 {
     DB::table('actions')->delete();
     Action::create(['id' => '1', 'action' => 'play video', 'importance' => '10']);
     Action::create(['id' => '2', 'action' => 'stop video', 'importance' => '10']);
     Action::create(['id' => '3', 'action' => 'click enrichment', 'importance' => '10']);
     Action::create(['id' => '4', 'action' => 'click ad', 'importance' => '10']);
     Action::create(['id' => '5', 'action' => 'share', 'importance' => '10']);
     Action::create(['id' => '6', 'action' => 'explicit_rf', 'importance' => '20']);
 }