Esempio n. 1
0
 public function actionBooking()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/request-date.css");
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/request-date-resp.css");
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/plugins/responsive-calendar/responsive-calendar.js", CClientScript::POS_END);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/request-booking.js", CClientScript::POS_END);
     if (Yii::app()->request->isPostRequest) {
         $getDate = Yii::app()->request->getParam('changeDate', false);
         $dateObj = DateTime::createFromFormat('j-n-Y', $getDate);
         if ($dateObj) {
             $dateObj = new DateTime($getDate);
             $this->_model->bookingDate = $dateObj->format('Y-m-d');
             $this->_model->save();
         }
     }
     $today = ComponentTime::todayStart();
     $events = array();
     //        $bookingDate = new DateTime(date('Y-m-d', strtotime($this->_model->bookingDate)));
     //        while ($bookingDate >= $today) {
     //            $events[$bookingDate->format('Y-m-d')] = array(
     //                'number' => 1,
     //            );
     //            $bookingDate->modify('-1 day');
     //        }
     $options = array('time' => date('Y-m', strtotime($this->_model->bookingDate)), 'events' => $events);
     $criteria = new CDbCriteria();
     $criteria->addCondition('mstRequestUsers.user_id = ' . Yii::app()->user->getInfo());
     $criteria->addCondition('mstRequestUsers.archived = 0');
     $criteria->addCondition('booking_type > 0');
     $criteria->with = array('mstRequestUsers');
     $modelArray = Requests::model()->findAll($criteria);
     $requests = array();
     foreach ($modelArray as $model) {
         $requests[] = array('color' => ComponentType::booking($model->booking_type), 'day' => date('j', strtotime($model->eventDate)), 'month' => date('n', strtotime($model->eventDate)), 'year' => date('Y', strtotime($model->eventDate)));
     }
     $passedDays = array();
     $created_on = new DateTime(date('Y-m-d', strtotime($this->_model->created_on)));
     while ($created_on < $today) {
         $passedDays[] = array('day' => $created_on->format('j'), 'month' => $created_on->format('n'), 'year' => $created_on->format('Y'));
         $created_on->modify('+1 day');
     }
     $today = array('day' => $today->format('j'), 'month' => $today->format('n'), 'year' => $today->format('Y'));
     $bookingDate = new DateTime(date('Y-m-d', strtotime($this->_model->bookingDate)));
     //        $bookingDate = array(
     //            'day' => $bookingDate->format('j'),
     //            'month' => $bookingDate->format('n'),
     //            'year' => $bookingDate->format('Y'),
     //        );
     $array = array('options' => $options, 'color' => ComponentType::booking($this->_model->booking_type), 'today' => $today, 'requests' => $requests, 'passedDays' => $passedDays, 'bookingDate' => $bookingDate->format('m-d-Y'));
     $json = json_encode($array);
     Yii::app()->clientScript->registerScript('mapvar10', "var json='" . $json . "';", CClientScript::POS_HEAD);
     $this->render('booking', array('model' => $this->_model));
 }
Esempio n. 2
0
<?php

$cnt = 0;
$continuePoints = '';
$this->searchBar = false;
$request = isset($model) ? $model : false;
$currentPage = Yii::app()->controller->action->id;
if ($request) {
    $paidTotal = 0;
    foreach ($request->payments as $paid) {
        $paidTotal += $paid->amount;
    }
    $today = ComponentTime::todayStart();
    $daysLeft = ComponentTime::objToText(new DateTime($request->bookingDate));
}
$creator = $request ? $request->createdBy->firstName . ' ' . $request->createdBy->lastName : '';
$creatorFirstName = $request ? $request->createdBy->firstName : 'Empty';
$creator_phone = $request ? $request->createdBy->mobileNumber : '';
$creatorPhoto = $request ? ComponentImage::profile($request->createdBy->id, 'imgCircle makeCenter ', $creator) : '';
$creatorBG = $request ? Yii::app()->theme->baseUrl . '/img/bg.jpg' : '';
$creatorRole = $request ? $request->createdBy->role0->name : '';
$creatorId = $request ? $request->createdBy->id : 0;
$iconNumber = $request ? count($request->mstRequestUsers) : '';
$icon_requestID = $request ? $request->id : '';
$date = $request ? date('l, dS F, Y', strtotime($request->eventDate)) : 'Event Date';
$map = $request ? $request->map->name : 'Event Location';
$event = $request ? $request->eventType->name : 'Event Type';
$title = $request ? 'The Pearls Band' : 'Band && DJ';
$payment = $request ? '<span style="color: #2979FF;font-weight: bold;">&#8364;' . number_format($paidTotal) . '</span> - &#8364;' . number_format($request->amount) : 'Payment';
$booking = $request ? $daysLeft . ' Left' : 'Time Slot';
$notes = $request ? 'Note Goes here' : 'Notes';