示例#1
0
 public function addDefaultTasks($model)
 {
     // add to taskevents all the tasktemplates
     $default_tasks = TaskTemplate::all();
     $event_date_col = $model->date()->first();
     if (!$event_date_col) {
         return;
     }
     $event_date = $event_date_col->datetime_start->format('Y-m-d');
     eerror_log("Le event date : " . $event_date);
     foreach ($default_tasks as $task_ndx => $task) {
         if ($task->deadline_days_gap > 0) {
             $task_deadline = date('Y-m-d', strtotime(-$task->deadline_days_gap . ' days', strtotime($event_date)));
         } else {
             $task_deadline = date('Y-m-d', strtotime($event_date));
         }
         $new_task = new TaskEvent();
         $new_task->title = $task->title;
         $new_task->description = $task->description;
         $new_task->due_date = $task_deadline;
         $new_task->status = 'incomplete';
         $new_task->group_id = $task->group_id;
         $new_task->events_id = $model->id;
         $new_task->deadline_days_gap = $task->deadline_days_gap;
         $new_task->updated_by = Auth::user()->id;
         $new_task->owner_changed_at = date("Y-m-d H:i:s");
         eerror_log('task due date ' . json_encode($new_task->due_date) . '\\n');
         $new_task->save();
     }
 }
示例#2
0
 public function populateForm($model = false)
 {
     if ($model) {
         $hotel1 = $model->first_hotel_option()->first();
         $hotel2 = $model->second_hotel_option()->first();
         $contact = $model->contacts()->first();
         $venue = $model->venues;
         eerror_log(json_encode($hotel1));
         Former::populate($model);
         // Former::populateField('first_hotel_option', $hotel1['name']);
         // Former::populateField('second_hotel_option', $hotel2['name']);
     } else {
         $input = Input::All();
         Former::populate($input);
     }
 }
示例#3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate($event)
 {
     // ticket types are always associated with an event
     $title = 'Add New ' . ucfirst($this->singleName);
     $controller = $this->name;
     $input_validation = $this->validateModel();
     if ($input_validation !== true) {
         $this->populateForm();
         Former::withErrors($input_validation);
         return View::make('site/tickets/types/create', compact('title', 'controller'))->with('error', 'Not saved!');
     }
     $tickettype = $this->saveModel($event);
     eerror_log(json_encode($tickettype));
     eerror_log(json_encode($event));
     $this->populateForm($tickettype);
     return Redirect::to('/events/' . $event->id . '/tickettypes/' . $tickettype->id . '/edit')->with('success', 'Saved!');
 }
示例#4
0
 public function postIndex()
 {
     $all_input = Input::all();
     eerror_log(json_encode($all_input));
     $task_groups = TaskGroup::orderBy('id')->get();
     //set all the values
     $task_ndx = 1;
     foreach ($task_groups as $key => $tg) {
         if ($task_ndx > 4) {
             break;
         }
         //error_log('Le key'.json_encode($key));
         $tg->name = Input::get('group' . $task_ndx . '_name');
         $tg->order = Input::get('group' . $task_ndx . '_order');
         $tg->update();
         $task_ndx++;
     }
     $this->populateForm();
     return View::make('admin/alda/tasks/index')->with('title', 'Task Groups');
 }
示例#5
0
 public function deleteFile($taskfile)
 {
     $user = Auth::user();
     if ($user->hasRole('promoter')) {
         if ($taskfile->users_id !== $user->id) {
             return Response::make('You did not create this file, therefore you can not delete it', 403);
         }
         $minutes_diff = (strtotime("now") - strtotime($taskfile->created_at)) / 60;
         eerror_log('time_diff ' . $minutes_diff);
         if ($minutes_diff > 30) {
             return Response::make('You deletion grace period has expired', 403);
         }
     }
     $taskfile->delete();
     $task = $taskfile->taskevent()->first();
     if ($task) {
         $task->updated_by = $user->id;
         $task->cnt_updated_files = TaskFile::where('taskevents_id', $task->id)->where('users_id', '=', $user->id)->count();
         $task->save();
     }
 }
示例#6
0
 public function postDueDate($event, $task)
 {
     $all_input = Input::all();
     $tmp_due_date = explode("-", $all_input['selected_date']);
     $new_due_date = $tmp_due_date[2] . '-' . $tmp_due_date[1] . '-' . $tmp_due_date[0];
     $task->due_date = $new_due_date;
     eerror_log("Le posted due date " . json_encode($task->due_date));
     $task->save();
     $response = Response::make('status saved', 200);
     return $response;
 }
示例#7
0
 public function postUpload($model)
 {
     $input = Input::all();
     eerror_log(json_encode($input));
     $rules = array('file' => 'image|max:3000');
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Response::make($validation->errors->first(), 400);
     }
     $file = Input::file('file');
     $destinationPath = 'uploads/venues/' . $model->id;
     if (!file_exists($destinationPath)) {
         mkdir($destinationPath, 0777, true);
     }
     //$filename = str_random(12);
     $filename = date("d") . '-' . Str::random(8) . $file->getClientOriginalName();
     eerror_log(public_path() . '/' . $destinationPath . '/' . $filename);
     $pic_exists_fs = File::exists(public_path() . '/' . $destinationPath . '/' . $filename);
     $pic_exists_db = $model->pictures()->where('filename', '=', $filename)->whereNull('deleted_at')->first();
     if ($pic_exists_db || $pic_exists_fs) {
         return Response::json(['error' => 'error', 'reload' => false]);
     }
     $upload_success = Input::file('file')->move($destinationPath, $filename);
     $picture = new Picture();
     $picture->filename = $filename;
     $picture->user_id = Auth::user()->id;
     $picture->save();
     $model->pictures()->save($picture);
     if ($upload_success) {
         // Redirect to the blog posts management page
         return Response::json(['success' => 'success', 'reload' => true]);
     } else {
         return Response::json(['error' => 'error', 'reload' => false]);
     }
 }
示例#8
0
 /**
  * Edits a user
  *
  */
 public function postEdit($user)
 {
     $oldUser = clone $user;
     $user->confirmed = 1;
     $user->username = Input::get('email');
     $user->email = Input::get('email');
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $user->prepareRules($oldUser, $user);
     // Save if valid. Password field will be hashed before save
     $edit_status = $user->amend(['first_name' => 'required|max:40', 'last_name' => 'required|max:40']);
     // attach user types id
     $posted_user_types = Input::get('types');
     eerror_log("types " . json_encode($posted_user_types));
     if (!$posted_user_types) {
         $user->types()->attach(5);
     } else {
         $user->types()->detach();
         if (!is_array($posted_user_types) && $posted_user_types !== "5" || is_array($posted_user_types) && !in_array("5", $posted_user_types)) {
             $user->types()->attach($posted_user_types);
         }
     }
     // Get validation errors (see Ardent package)
     $error = $user->errors()->all();
     if (empty($error)) {
         $this->populateForm($user);
         eerror_log('>>> Edited User ' . json_encode($user));
         //return Redirect::to('user/'.$user->id.'/edit')
         return View::make('site.user.edit')->with('user', $user)->with('title', Lang::get('admin/users/title.user_update'))->with('mode', 'edit')->with('success', Lang::get('user/user.user_account_updated'));
     } else {
         eerror_log('Edit Failed due to errors - ' . json_encode($error));
         //return Redirect::to('user/'.$user->id.'/edit')
         return View::make('site.user.edit')->withInput(Input::except('password', 'password_confirmation'))->with('title', Lang::get('admin/users/title.user_update'))->with('mode', 'edit')->with('error', $error);
     }
 }
示例#9
0
 public function getNotifications($autologin_token)
 {
     eerror_log('Task Notifications autologin' . json_encode($autologin_token));
     // logout
     Auth::logout();
     $missing_sales_autologin_entry = TaskNotificationAutologin::where('token', $autologin_token)->first();
     if (!$missing_sales_autologin_entry) {
         return Redirect::To('/');
     } else {
         $user = User::find($missing_sales_autologin_entry->users_id);
         Auth::loginUsingId($user->id);
         $event_id = $missing_sales_autologin_entry->events_id;
         $task_id = $missing_sales_autologin_entry->taskevents_id;
         $missing_sales_autologin_entry->update(['token' => null]);
         return Redirect::to('/my-events/' . $event_id . '/dashboard?taskId=' . $task_id);
     }
 }