Ejemplo n.º 1
0
 /**
  * @param $configdepart
  * @return bool
  */
 private function saveFlights(Configdepart $configdepart)
 {
     // Combien de flights à créer
     $nbFlights = ceil($configdepart->nbjoueurs / $configdepart->slotbyflight) + $configdepart->startergap;
     // Met a jour Configdepart->slotcount : nombre de places disponibes créees
     $configdepart->slotcount = $nbFlights * $configdepart->slotbyflight;
     $configdepart->save();
     // Supprimer les Flight de cette config
     $configdepart->flights()->delete();
     // Boucle tous les flight à créer
     for ($i = 1; $i <= $nbFlights; $i++) {
         $addMinutes = ($i - 1) * $configdepart->interval;
         $newheure = Carbon::createFromFormat('H:i', $configdepart->startheure)->addMinutes($addMinutes);
         // New Flight
         $flight = new Flight();
         $flight->configdepart_id = $configdepart->id;
         $flight->num = $i;
         $flight->heure = $newheure;
         $flight->save();
         // Cree les slots
         for ($slotnum = 1; $slotnum <= $configdepart->slotbyflight; $slotnum++) {
             $slot = new Slot();
             $slot->flight_id = $flight->id;
             $slot->num = $slotnum;
             $slot->entree_id = 0;
             $slot->save();
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * @before _secure, _vendor
  */
 public function index()
 {
     $this->seo(array("title" => "Schedule Your Appointments", "view" => $this->getLayoutView()));
     $this->getLayoutView()->set("cal", true);
     $view = $this->getActionView();
     if (RequestMethods::post("appointment_id")) {
         if (RequestMethods::post("job_id", "")) {
             $job = Job::first(array("appointment_id = ?" => RequestMethods::post("appointment_id")));
             $job->user_id = RequestMethods::post("user_id");
         } else {
             $job = new Job(array("user_id" => RequestMethods::post("user_id"), "muser_id" => RequestMethods::post("muser_id"), "puser_id" => RequestMethods::post("puser_id"), "appointment_id" => RequestMethods::post("appointment_id"), "location_id" => RequestMethods::post("location_id"), "centre_id" => RequestMethods::post("centre_id"), "organization_id" => RequestMethods::post("organization_id")));
         }
         $job->save();
         $view->set("message", "Runner Assigned Successfully");
     }
     if (RequestMethods::post("action") == "capacity") {
         foreach (RequestMethods::post("slot") as $key => $value) {
             $slot = Slot::first(array("organization_id = ?" => $this->member->organization_id, "day = ?" => $key));
             if (isset($slot)) {
                 $slot->start = $value["start"];
                 $slot->day = $key;
                 $slot->end = $value["end"];
                 $slot->capacity = $value["hlimit"];
             } else {
                 $slot = new Slot(array("user_id" => $this->user->id, "organization_id" => $this->member->organization_id, "day" => $key, "start" => $value["start"], "end" => $value["end"], "capacity" => $value["hlimit"]));
             }
             $slot->save();
         }
         $view->set("message", "Slots Saved Successfully");
     }
     $runners = Member::all(array("organization_id = ?" => $this->member->organization_id, "designation = ?" => "runner"), array("user_id", "id"));
     $view->set("runners", $runners);
     $view->set("day", array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"));
     $view->set("slots", Slot::all(array("organization_id = ?" => $this->member->organization_id), array("start", "end", "capacity", "day")));
 }
Ejemplo n.º 3
0
 /**
  * 
  * Le joueur de l'environnement rejoind la partie /!\ SI PAS DEJA FAIT
  * ou créer un invité
  * @return Slot
  */
 public function rejoindre()
 {
     Env::requiert('partie');
     Env::requiert('jeu');
     if (!joueur()) {
         Joueur::connecterInvite();
     }
     // Refus de rejoindre si la partie n'est plus en préparation et n'est pas une room non plus.
     if ($this->etat != PARTIE::PREPARATION && !jeu()->isRoom()) {
         throw new Exception('Trop tard pour rejoindre cette partie. (code etat partie : ' . $this->etat . ')');
     }
     $slot = $this->hasJoueur(joueur());
     if (!is_null($slot)) {
         return $slot;
     }
     $s = new Slot();
     $s->partie_id = $this->getID();
     $s->joueur_id = joueur()->getID();
     $s->position = count($this->slots) + 1;
     $s->save();
     $this->slots[] = $s;
     return $s;
 }
Ejemplo n.º 4
0
 public function update_slots()
 {
     $store_id = Request::segment(3);
     $time_str = Input::get('time');
     $start_time = date("Y-m-d H:i:s", strtotime(substr($time_str, 0, 21)));
     $end_time = date("Y-m-d H:i:s", strtotime(substr($time_str, 24, 21)));
     if (Input::has('slot_id') && Input::get('slot_id') != 0) {
         $slot = Slot::find(Input::get('slot_id'));
         $message = "Successfully added the a delivery slot";
     } else {
         $slot = new Slot();
         $slot->day = 1;
         $slot->is_available = 1;
         $slot->store_id = $store_id;
         $message = "Successfully updated the a delivery slot";
     }
     $slot->start_time = $start_time;
     $slot->end_time = $end_time;
     $slot->save();
     $type = "success";
     return Redirect::to('/admin/store/' . $store_id . '/slots')->with('type', $type)->with('message', $message);
 }