예제 #1
0
 public function store()
 {
     // Save visitor event information to database
     $event = new Calendar();
     $event->category = Input::get('category');
     $event->event = Input::get('event');
     $event->mont = Input::get('month1');
     $event->mont2 = Input::get('month2');
     $event->da = Input::get('da');
     $event->da2 = Input::get('da2');
     $event->hour = Input::get('hour');
     $event->minute = Input::get('minute');
     //$event->address = Input::get('address');
     $event->state = Input::get('state');
     //$event->zip = Input::get('zip');
     $event->phone = Input::get('phone');
     $event->pending = "true";
     if ($event->save()) {
         /* Email admin notice of new event pending approval 
         			Mail::send('emails.new-event', ['event' => $event], function ($m) use ($event) {
                     $m->to('*****@*****.**', 'Bobby')->subject('New Pending Event!');
                 	}); */
         Mail::raw('test mail', function ($m) {
             $m->from('*****@*****.**', 'Admin')->to('*****@*****.**', 'test name')->subject('test mail');
         });
         return Redirect::to('/calendar/');
         return Redirect('/calendar/');
     } else {
         return View::make('/calendar/add', ['error' => 'Unable to save event. Please try again later or contact system administrator!']);
     }
 }
예제 #2
0
 public function actionCreate()
 {
     $model = new Family();
     if ($model->load(Yii::$app->request->post())) {
         //Se o utilizador já tiver uma familia não faz nada
         if (Yii::$app->user->identity->family_id) {
             return $this->redirect('update');
         }
         $model->login_status = \app\enum\UserStatus::Inativo;
         //$model->accepts_members = 0 ;
         if ($model->validate() && $model->save()) {
             $user = Yii::$app->user->identity;
             //inicia transação
             $transaction = Yii::$app->db->beginTransaction();
             //Cria membro
             $fme = new FamilyMember();
             $fme->family_id = $model->id;
             $fme->user_id = Yii::$app->user->getId();
             $fme->name = $user->username;
             $fme->event_color = '#ff9900';
             $fme->user_type = \app\enum\UserType::Administrador_MemoBoard;
             if (!$fme->save()) {
                 $transaction->rollBack();
                 return $this->goHome();
             }
             //Cria um calendário para o membro
             $cal = new Calendar();
             $cal->sistem = 0;
             $cal->name = Yii::$app->user->identity->username;
             $cal->member_id = $fme->id;
             if (!$cal->save()) {
                 $transaction->rollBack();
                 return $this->goHome();
             }
             $user->family_id = $model->id;
             $user->calendar_id = $cal->id;
             $user->family_member_id = $fme->id;
             if (!$user->save()) {
                 $transaction->rollBack();
                 return $this->goHome();
             }
             //Finaliza transação
             $transaction->commit();
             return $this->redirect('update');
         }
     }
     return $this->render('create', ['model' => $model]);
 }
예제 #3
0
 /**
  * Finds the Calendar model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Calendar the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Calendar::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
 public function destroy(Request $request, $id)
 {
     $v = Calendar::find($id);
     if ($v) {
         $v->delete();
         Calendar::where("id", $id)->where('user_id', Auth::user()->id)->delete();
         $request->session()->flash("notif", "schedule successfully deleted");
         return ['error' => false];
     } else {
         $request->session()->flash("notif", "schedule not available!");
         return ['error' => true];
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Calendar::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'creator' => $this->creator, 'date_event' => $this->date_event]);
     $query->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
예제 #6
0
 public function findReserveRoomsByRangeAndRoomType($start, $end, $roomType)
 {
     $dates = Calendar::getInclusiveDates($start, $end, 'Y-m-d');
     $rooms = Room::where('room_type_id', $roomType)->get();
     $sql = "select rr_id, reserve_code, room_id, status, if(checkin < '{$start}', '{$start}', checkin) as 'calstart',  if(checkin < '{$start}', 'extendleft', '') as 'startmodifier', if(checkout > '{$end}', 'extendright', '') as 'endmodifier',(datediff('{$end}', '{$start}') + if(datediff(checkout, '{$end}') < 0, datediff(checkout, '{$end}'), 0) + if(datediff('{$start}', checkin) < 0, datediff('{$start}', checkin), 0)) as 'computedlength' from reserve_rooms where checkin <= '{$end}' and checkout >= '{$start}' and room_id > 0 and room_type_id = {$roomType} order by room_id, checkin";
     $rr = DB::select($sql);
     $calendar = [];
     foreach ($rooms as $room) {
         foreach ($dates as $day) {
             $calendar[$room->door_name][$day] = $this->getRoomsForDate($rr, $room->room_id, $day);
         }
     }
     ksort($calendar);
     return $calendar;
 }
예제 #7
0
 public function search($input)
 {
     $query = Calendar::query();
     $columns = Schema::getColumnListing('calendars');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
예제 #8
0
 /** 
  * observe Takenworkleave event saving
  * 1. count quotas
  * 2. act, accept or refuse
  * 
  * @param $model
  * @return bool
  */
 public function saving($model)
 {
     $errors = new MessageBag();
     //1. count quotas
     $quota = 0;
     if ($model->person()->count() && $model->work()->count()) {
         $from = Carbon::createFromFormat('Y-m-d', $model->start);
         $to = Carbon::createFromFormat('Y-m-d', $modenl->end);
         $days = $from->diffInDays($to);
         $interval = new DateInterval('P1D');
         $to->add($interval);
         $daterange = new DatePeriod($from, $interval, $to);
         foreach ($daterange as $date) {
             //1a. check person schedule
             $ps = \App\Models\PersonSchedule::ondate($date->format('Y-m-d'))->personid($model->person_id)->first();
             if (!$ps) {
                 //1b. check schedule
                 $s = \App\Models\Schedule::ondate($date->format('Y-m-d'))->calendarid($model->work->calendar_id)->first();
                 if (!$s) {
                     //1c. check calendar
                     $c = \App\Models\Calendar::id($model->work->calendar_id)->first();
                     if ($c) {
                         $harikerja = explode(',', $c['workdays']);
                         $day = ['senin' => 'monday', 'selasa' => 'tuesday', 'rabu' => 'wednesday', 'kamis' => 'thursday', 'jumat' => 'friday', 'sabtu' => 'saturday', 'minggu' => 'sunday', 'monday' => 'monday', 'tuesday' => 'tuesday', 'wednesday' => 'wednesday', 'thursday' => 'thursday', 'friday' => 'friday', 'saturday' => 'saturday', 'sunday' => 'sunday'];
                         $workdays = [];
                         //translate to ing
                         foreach ($harikerja as $key => $value) {
                             $workdays[] = $day[strtolower($value)];
                         }
                         if (!in_array(strtolower($date->format('l')), $workdays)) {
                             $quota = $quota + 1;
                         }
                     }
                 } elseif (in_array($s['status'], ['HB', 'DN'])) {
                     $quota = $quota + 1;
                 }
             } elseif (in_array($ps['status'], ['HB', 'DN'])) {
                 $quota = $quota + 1;
             }
         }
     }
     $model->quota = $quota;
     if ($errors->count()) {
         $model['errors'] = $errors;
         return false;
     }
     return true;
 }
예제 #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Calendar::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith(['access']);
     $dataProvider->sort->attributes['access'] = ['asc' => ['tbl_access.user_owner' => SORT_ASC], 'desc' => ['tbl_access.user_owner' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['tbl_calendar.id' => $this->id, 'tbl_calendar.creator' => $this->creator, 'tbl_calendar.date_event' => $this->date_event, 'tbl_access.user_owner' => $this->access['user_owner']]);
     $query->andFilterWhere(['like', 'tbl_calendar.text', $this->text]);
     return $dataProvider;
 }
예제 #10
0
 public function findReservationsForRoomTypeInRange($start, $end, $room_type_id)
 {
     //        $dstart = new \DateTime($start);
     //        $interval = $dstart->diff(new \DateTime($end))->format('%a');
     //
     //        $output = [];
     //        for( $ctr = 0; $ctr <= $interval; $ctr++) {
     //            $caldate = $dstart->format('Y-m-d');
     //            $output[$caldate] = $this->findAllBy('cal_date', $caldate, ['reserve_room_id', 'room_id', 'status', 'modifier']);
     //            $dstart->add(new \DateInterval('P1D'));
     //        }
     //
     //        $rooms = Room::where('room_type_id', $room_type_id)->get();
     //
     //        return $this->pivotRoomsByDates($rooms, $output);
     $dates = Calendar::getInclusiveDates($start, $end);
 }
예제 #11
0
 /**
  * Creates a new Access model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Access();
     $model->user_owner = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $all_mynotes = Calendar::getDates(Yii::$app->user->id);
         $all_users = User::find()->where('id !=' . Yii::$app->user->id)->asArray()->all();
         //            print_r($all_mynotes);
         //            print_r($all_users);
         //            exit();
         if ($all_mynotes) {
             return $this->render('create', ['model' => $model, 'all_users' => $all_users, 'all_mynotes' => $all_mynotes]);
         } else {
             return $this->redirect('calendar/create');
         }
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Calendar::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith(['access']);
     $dataProvider->sort->attributes['access'] = ['asc' => ['clndr_access.user_id' => SORT_ASC], 'desc' => ['clndr_access.user_id' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['clndr_calendar.id' => $this->id, 'clndr_calendar.creator' => $this->creator, 'clndr_access.user_guest' => $this->access['user_id']]);
     $query->andWhere('clndr_access.date = date(' . $this->access['date'] . ')');
     $query->andWhere('date(clndr_calendar.date_event) = date(' . $this->access['date'] . ')');
     $query->andFilterWhere(['like', 'clndr_calendar.text', $this->text]);
     //VAR_DUMP($query->createCommand()->getRawSql());
     return $dataProvider;
 }
예제 #13
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, ReserveRoomRepository $reserveRoomRepo)
 {
     $roomTypes = BookingRoomTypes::all();
     $firstRoomType = $roomTypes->last();
     $now = new \DateTime('now');
     $startdate = $request->get('startdate', $now->format('Y-m-d'));
     $enddate = $request->get('enddate', $now->add(new \DateInterval('P10D'))->format('Y-m-d'));
     $room_type_id = $request->get('room_type_id', $firstRoomType->room_type_id);
     $reservation = new Reservation();
     if ($request->has('reserve_code')) {
         $reserve_code = $request->get('reserve_code');
         $reservation = Reservation::where('reserve_code', $reserve_code)->get()->first();
     }
     $calendar = $reserveRoomRepo->findReserveRoomsByRangeAndRoomType($startdate, $enddate, $room_type_id);
     $dates = Calendar::getInclusiveDates($startdate, $enddate);
     $partners = Partner::all();
     $request->flash();
     $cardTypes = ['AMEX', 'JBC', 'Visa', 'Mastercard', 'BDO Card', 'Express Net', 'Megalink', 'BancNet', 'BPI'];
     return view('reservations.index', compact('calendar', 'roomTypes', 'dates', 'startdate', 'enddate', 'reservation', 'partners', 'cardTypes'));
 }
예제 #14
0
 public function getCalendar()
 {
     if (self::isFamilyLogin()) {
         throw new \yii\base\Exception("Este utilizador é familiar não tem calendário.");
     }
     //Embora no futuro possam existir mais do que um
     //neste momento só existe um
     return Calendar::findOne(['id' => 'calendar_id']);
 }
예제 #15
0
 /**
  * Delete a schedule (throw to queue)
  *
  * @return Response
  */
 public function delete($org_id = null, $cal_id = null, $id = null)
 {
     //
     $schedule = \App\Models\Schedule::id($id)->calendarid($cal_id)->with(['calendar', 'calendar.calendars'])->first();
     if (!$schedule) {
         return new JSend('error', (array) Input::all(), 'Jadwal tidak ditemukan.');
     }
     $errors = new MessageBag();
     DB::beginTransaction();
     //1. store schedule of calendar to queue
     $schedule = $schedule->toArray();
     //1a. Validate Basic schedule Parameter
     $parameter = $schedule;
     unset($parameter['calendar']);
     $total = \App\Models\Work::calendarid($cal_id)->count();
     $queue = new \App\Models\Queue();
     $queue->fill(['process_name' => 'hr:schedules', 'process_option' => 'delete', 'parameter' => json_encode($parameter), 'total_process' => $total, 'task_per_process' => 1, 'process_number' => 0, 'total_task' => $total, 'message' => 'Initial Commit']);
     if (!$queue->save()) {
         $errors->add('Schedule', $queue->getError());
     }
     //End of validate schedule
     //2. store schedule of calendars to queue
     if (!$errors->count() && isset($schedule['calendar']['calendars']) && is_array($schedule['calendar']['calendars'])) {
         foreach ($schedule['calendar']['calendars'] as $key => $value) {
             $cals_data = \App\Models\Calendar::id($value['id'])->calendarid($cal_id)->first();
             if (!$cals_data) {
                 $errors->add('Calendar', 'Tidak ada kalender ' . $value['name']);
             }
             if (!$errors->count()) {
                 $total = \App\Models\Work::calendarid($value['id'])->count();
                 $parameter['calendar_id'] = $value['id'];
                 $queue = new \App\Models\Queue();
                 $queue->fill(['process_name' => 'hr:schedules', 'process_option' => 'delete', 'parameter' => json_encode($parameter), 'total_process' => $total, 'task_per_process' => 1, 'process_number' => 0, 'total_task' => $total, 'message' => 'Initial Commit']);
                 if (!$queue->save()) {
                     $errors->add('Schedule', $queue->getError());
                 }
             }
         }
     }
     //End of validate calendar schedule
     if ($errors->count()) {
         DB::rollback();
         return new JSend('error', (array) Input::all(), $errors);
     }
     DB::commit();
     return new JSend('success', (array) $schedule);
 }
예제 #16
0
 public function getEvent(Request $request)
 {
     $calendars = Calendar::where('start_date', '<=', date('Y-m-d', strtotime($request->date)))->where('end_date', '>=', date('Y-m-d', strtotime($request->date)))->get();
     return response()->json($calendars);
 }
예제 #17
0
 public static function getOtherCalendars()
 {
     $dataProvider = new ActiveDataProvider(['query' => \app\models\Calendar::find()->where(['sistem' => 1])]);
     return $dataProvider;
 }
 public function remove($id)
 {
     try {
         if ($id == 00) {
             $events = Calendar::truncate();
         } else {
             $event = Calendar::where('id', '=', $id)->first();
             $event->delete();
         }
         return Redirect::to('admin/calendar')->with(['events' => Calendar::all()]);
         //return View::make('admin.calendar.delete', ['status'=>'successful', 'event'=>$calendar, 'events'=>Calendar::all(), 'id'=>$id]);
     } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         return View::make('admin.calendar.delete', ['status' => 'unsuccessful', 'event' => 'ALL', 'events' => Calendar::all(), 'id' => $id, 'error' => 'Could not find this entry']);
     }
 }
예제 #19
0
파일: Clss.php 프로젝트: AtaBashir/ams
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getClssCal()
 {
     return $this->hasOne(Calendar::className(), ['cal_id' => 'clss_cal_id']);
 }
예제 #20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Calendar::create(['category' => 1, 'event' => 'Sample event', 'mont' => Carbon::now()->month, 'mont2' => Carbon::now()->month, 'da' => Carbon::now()->day, 'da2' => Carbon::now()->day + 1, 'hour' => Carbon::now()->hour, 'minute' => Carbon::now()->minute, 'state' => 'WA', 'phone' => '5556667777']);
 }
예제 #21
0
 public static function joinMemberToFamilyAndSave($model, $user_id, $family_id)
 {
     if (!$user_id || !$family_id) {
         return 'Não foi fornecido um parametro necessário.';
     }
     $user = \app\models\User::findIdentity($user_id);
     if (!$user) {
         return 'O utilizador ainda não tem registo no memoboard.';
     }
     //O utilizador não pode pertencer a nenhuma familia ou ser membro
     if ($user->family_id) {
         return 'Este utilizador já pertence a uma família.';
     }
     $family = \app\models\Family::find()->where(['id' => $family_id])->one();
     if (!$family) {
         return 'A familia não exste.';
     }
     if (!$family->accepts_members) {
         return 'A familia ' . $family->name . ' não está a aceitar novos membros.';
     }
     //Se já existir um user não pode associar outros
     if ($model->user_id) {
         return 'Não pode alterar membros da família por outros.';
     }
     //Cria membro
     $model->user_type = \app\enum\UserType::Utilizador_registado;
     $model->family_id = $family->id;
     $model->user_id = $user->id;
     if (!$model->validate()) {
         return 'Dados não válidos:<br>' . implode('<br>', $model->errors);
     }
     $transaction = Yii::$app->db->beginTransaction();
     if (!$model->save()) {
         $transaction->rollBack();
         return 'Não foi possível salvar os dados.';
     }
     //Cria um calendário para oo membro se não existir
     $my_cal = \app\models\Calendar::findOne(['member_id' => $model->id]);
     if (!$my_cal) {
         $my_cal = new \app\models\Calendar();
         $my_cal->member_id = $model->id;
         $my_cal->name = $model->name;
         if (!$my_cal->save()) {
             $transaction->rollBack();
             return 'Não foi possível salvar o calendário.';
         }
     }
     //Coloca valores no utilizador
     $user->family_id = $family->id;
     $user->family_member_id = $model->id;
     $user->calendar_id = $my_cal->id;
     if (!$user->save(['family_id', 'family_member_id', 'calendar_id'])) {
         $transaction->rollBack();
         return 'Não foi possível atualizar o utilizador.';
     }
     $transaction->commit();
     //Coloca nas prefeencias do utilizador o calendário
     //para mostrar imediatamente
     $user->setPreference('tasks_selected', $model->id);
     $user->setPreference('calendars_selected', $model->id);
     return true;
 }
예제 #22
0
 public function getSchedules()
 {
     return $this->hasMany(Calendar::className(), ['creator' => 'id']);
 }
예제 #23
0
 /**
  * Proprietário da tarefa
  * @return type FamilyMember
  */
 public function getOwner()
 {
     return $this->hasOne(FamilyMember::className(), ['id' => 'member_id'])->viaTable(Calendar::tableName(), ['id' => 'calendar_id']);
 }
예제 #24
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
     Calendar::observe(new CalendarObserver());
 }
예제 #25
0
 /** 
  * observe GivenWorkleave event saving
  * Case progressive workleave
  * 1. check workleave quota
  * 2. check start work
  * 3. check start work date
  * 4. check if progressive workleave is end of year and quota over 12
  * Case special workleave
  * 1. count quota
  * 
  * @param $model
  * @return bool
  */
 public function saving($model)
 {
     $errors = new MessageBag();
     //case a. if given workleave was progressive
     if ($model->work()->count() && $model->status == 'CN') {
         //1. check workleave quota
         if ($model->workleave()->count()) {
             $wleave_quota = $follow->workleave->quota;
         } else {
             $wleave_quota = 12;
         }
         //2. check start work
         $prev_work = Work::personid($model->person_id)->orderby('start', 'asc')->notid($model->work_id)->first();
         if ($prev_work) {
             $start_work = $prev_work->start;
         } else {
             $start_work = $model->work->start;
         }
         //2a. if work over a year ::
         //- end was end of start year + 3 months
         //- start could be taken now
         if ($start_work->diffInYears($model->start) >= 1) {
             $extendpolicy = \App\Models\Policy::organisationid($model->person->organisation_id)->type('extendsworkleave')->OnDate($model->start->format('Y-m-d H:i:s'))->orderby('started_at', 'desc')->first();
             if ($extendpolicy) {
                 $extends = $extendpolicy['value'];
             } else {
                 $extends = '+ 3 months';
             }
             $end = Carbon::create('end of December ' . $model->start->format('Y') . ' ' . $extends);
             $start = $model->start;
         } else {
             $extendpolicy = \App\Models\Policy::organisationid($model->person->organisation_id)->type('extendsmidworkleave')->OnDate($model->start->format('Y-m-d H:i:s'))->orderby('started_at', 'desc')->first();
             if ($extendpolicy) {
                 $extends = $extendpolicy['value'];
             } else {
                 $extends = '+ 1 year';
             }
             $end = Carbon::create('end of December ' . $model->start->format('Y') . ' ' . $extends);
             $start = $start_work->copy()->addYear();
         }
         //3. check start work date
         //3a. if start work date after 15
         if ($start_work->format('d') >= 15) {
             $next_start = $start->copy()->addMonth();
             //3a1. if next start workleave bigger than end ::
             //-quota set zero
             if (!is_null($model->work->end) && $next_start->format('Y-m-d H:i:s') > $model->work->end->format('Y-m-d H:i:s')) {
                 $quota = 0;
             } else {
                 $start = $next_start;
                 $quota = 1;
             }
         } else {
             $quota = 1;
         }
         //4. check if progressive workleave is end of year and quota over 12
         if ((int) $start->format('m') == 12 && $wleave_quota > 12) {
             $quota = $quota + ($wleave_quota - 12);
         }
         $model->start = $start->format('Y-m-d H:i:s');
         $model->end = $end->format('Y-m-d H:i:s');
         $model->quota = $quota;
     } elseif ($model->work()->count() && $model->status == 'CI') {
         $quota = 0;
         $from = Carbon::createFromFormat('Y-m-d', $model->start);
         $to = Carbon::createFromFormat('Y-m-d', $modenl->end);
         $days = $from->diffInDays($to);
         $interval = new DateInterval('P1D');
         $to->add($interval);
         $daterange = new DatePeriod($from, $interval, $to);
         foreach ($daterange as $date) {
             //1a. check person schedule
             $ps = \App\Models\PersonSchedule::ondate($date->format('Y-m-d'))->personid($model->person_id)->first();
             if (!$ps) {
                 //1b. check schedule
                 $s = \App\Models\Schedule::ondate($date->format('Y-m-d'))->calendarid($model->work->calendar_id)->first();
                 if (!$s) {
                     //1c. check calendar
                     $c = \App\Models\Calendar::id($model->work->calendar_id)->first();
                     if ($c) {
                         $harikerja = explode(',', $c['workdays']);
                         $day = ['senin' => 'monday', 'selasa' => 'tuesday', 'rabu' => 'wednesday', 'kamis' => 'thursday', 'jumat' => 'friday', 'sabtu' => 'saturday', 'minggu' => 'sunday', 'monday' => 'monday', 'tuesday' => 'tuesday', 'wednesday' => 'wednesday', 'thursday' => 'thursday', 'friday' => 'friday', 'saturday' => 'saturday', 'sunday' => 'sunday'];
                         $workdays = [];
                         //translate to ing
                         foreach ($harikerja as $key => $value) {
                             $workdays[] = $day[strtolower($value)];
                         }
                         if (!in_array(strtolower($date->format('l')), $workdays)) {
                             $quota = $quota + 1;
                         }
                     }
                 } elseif (in_array($s['status'], ['HB', 'DN'])) {
                     $quota = $quota + 1;
                 }
             } elseif (in_array($ps['status'], ['HB', 'DN'])) {
                 $quota = $quota + 1;
             }
         }
         $model->quota = $quota;
     }
     if ($errors->count()) {
         $model['errors'] = $errors;
         return false;
     }
     return true;
 }
예제 #26
0
파일: Access.php 프로젝트: picprofit/yii2
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCalendar()
 {
     return $this->hasMany(Calendar::className(), ['date' => 'date_event']);
 }