Exemplo n.º 1
0
 public function CheckManagement($show = false)
 {
     $r = array();
     foreach ($_POST as $key => $value) {
         if ($value == "reschedule") {
             preg_match('/(.*)\\-(\\d+)/', $key, $res);
             if (!empty($res)) {
                 $r[$res[2]] = array('C' => $_POST['D_' . $res[2]], 'M' => $_POST['M_' . $res[2]]);
             }
         }
     }
     if ($r) {
         $error = array();
         foreach ($r as $key => $value) {
             $SB = SeatBooking::find($key);
             if ($SB->c_id != $value['C'] || $SB->s_id != $value['M']) {
                 if (!$this->CheckMaxCountry($value['C'], $value['M'], $SB->sb_country)) {
                     $day = $this->getD($value['C']);
                     $module = $this->getM($value['M']);
                     $error[] = "from country " . $SB->sb_country . " for " . $module->t_name . " on " . $day->c_name . " - " . $day->c_date . ", " . $module->time_start . " - " . $module->time_end;
                 }
             }
         }
         if ($show) {
             if (!empty($error)) {
                 $return = "Too many guest<br/>";
                 foreach ($error as $key => $value) {
                     $return .= $value . (count($error) - 1 == $key ? "<br/>" : " and<br/>");
                 }
                 return $return;
             }
         } else {
             if (!empty($error)) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Exemplo n.º 2
0
 public function management()
 {
     if (isset($_POST['create-guest-list'])) {
         $this->GuestList();
     }
     if (isset($_POST['send-emails'])) {
         $this->Mail();
     }
     $Model = new DBModel();
     if (!$Model->CheckManagement()) {
         $c = array();
         $r = array();
         $w = array();
         $d = array();
         foreach ($_POST as $key => $value) {
             preg_match('/(.*)\\-(\\d+)/', $key, $res);
             if (!empty($res)) {
                 if ($value == "confirm") {
                     $c[] = $res[2];
                 }
                 if ($value == "waitlist") {
                     $w[] = $res[2];
                 }
                 if ($value == "decline") {
                     $d[] = $res[2];
                 }
                 if ($value == "reschedule") {
                     $r[$res[2]] = array('C' => $_POST['D_' . $res[2]], 'M' => $_POST['M_' . $res[2]]);
                 }
             }
         }
         foreach ($c as $key => $value) {
             $SBM = SeatBooking::find($value);
             $SBM->status = 1;
             $SBM->update();
         }
         foreach ($w as $key => $value) {
             $SBM = SeatBooking::find($value);
             $SBM->status = 3;
             $SBM->update();
         }
         foreach ($d as $key => $value) {
             $SBM = SeatBooking::find($value);
             $SBM->status = 4;
             $SBM->update();
         }
         foreach ($r as $key => $value) {
             $SBM = SeatBooking::find($key);
             $SBM->c_id = $value['C'];
             $SBM->s_id = $value['M'];
             $SBM->update();
         }
     }
     $all = $Model->getAll();
     return view('management', ['res' => $all, 'Module' => $Model->getModule(), 'Day' => $Model->getDay()]);
 }