当前位置: 首页>>代码示例>>PHP>>正文


PHP Requests::model方法代码示例

本文整理汇总了PHP中Requests::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::model方法的具体用法?PHP Requests::model怎么用?PHP Requests::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Requests的用法示例。


在下文中一共展示了Requests::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: menuBadges

 public static function menuBadges()
 {
     $array = array();
     $inbox = $quotes['open'] = $quotes['closed'] = $bookings['provisional'] = $bookings['confirmed'] = $bookings['cancelled'] = 0;
     $today = new DateTime();
     $criteria = new CDbCriteria();
     $criteria->addCondition('mstRequestUsers.user_id = ' . Yii::app()->user->getInfo());
     $criteria->addCondition('mstRequestUsers.archived = 0');
     $criteria->with = array('mstRequestUsers');
     $modelArray = Requests::model()->findAll($criteria);
     foreach ($modelArray as $model) {
         switch ((int) $model->booking_type) {
             case 0:
                 if ($model->mstRequestUsers[0]->seen == 0) {
                     $inbox++;
                 }
                 break;
             case 1:
                 $eventDateObj = new DateTime($model->bookingDate);
                 if ($eventDateObj > $today) {
                     $quotes['closed']++;
                 } else {
                     $quotes['open']++;
                 }
                 break;
             case 2:
                 $bookings['provisional']++;
                 break;
             case 3:
                 $bookings['confirmed']++;
                 break;
             case 4:
                 $bookings['cancelled']++;
                 break;
         }
     }
     $array['inbox'] = $inbox;
     $array['quotes'] = $quotes;
     $array['bookings'] = $bookings;
     return $array;
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:41,代码来源:ComponentMenu.php

示例2: actionBooking

 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));
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:53,代码来源:RequestController.php

示例3: getMessageCreators

 public static function getMessageCreators($id)
 {
     $messageCreatorIds = [];
     $requestUsersArray = [];
     $messagesArray = array();
     $requestsModel = Requests::model()->findByPk($id);
     if ($requestsModel) {
         foreach ($requestsModel->mstRequestUsers as $user) {
             $requestUsersArray[] = (int) $user->user_id;
         }
     }
     if (!empty($requestUsersArray)) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('request.id = ' . $requestsModel->id);
         $criteria->addCondition('t.status = 1');
         $criteria->order = 't.created_on DESC';
         $criteria->with = array('request');
         $modelArray = Messages::model()->findAll($criteria);
         foreach ($modelArray as $model) {
             $messagesArray = array('creator' => $model->created_by);
         }
     }
     return $messagesArray;
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:24,代码来源:ActionClass.php

示例4: isReal

 private function isReal($id)
 {
     $return = false;
     if ($id > 0) {
         $model = Requests::model()->findByPk($id);
         if ($model != null) {
             $requestUsersArray = array();
             foreach ($model->mstRequestUsers as $user) {
                 $requestUsersArray[] = (int) $user->user_id;
             }
             if (in_array(Yii::app()->user->getInfo(), $requestUsersArray)) {
                 $return = array('model' => $model, 'requestUsers' => $requestUsersArray);
             }
         }
     }
     return $return;
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:17,代码来源:ApiController.php

示例5: loadModelDoc

 public function loadModelDoc($id)
 {
     $criteria = new CDbCriteria();
     $criteria->with = array('doc');
     $criteria->compare('t.id', $id);
     $model = Requests::model()->find($criteria);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:seekermain,项目名称:forms,代码行数:11,代码来源:RequestsController.php

示例6: actionRequest

 public function actionRequest()
 {
     if (!isset($_POST['doc_id'])) {
         $res['note'] = 'Не выбран номер запроса';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     if (!isset($_POST['comment']) || empty($_POST['comment'])) {
         $res['note'] = 'Необходимо прокомментировать заявку';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', array($_POST['doc_id']));
     $check = Documents::model()->findAll($criteria);
     if (empty($check)) {
         $res['note'] = 'Заявка с таим номером не существует';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     if ($check[0]->user_id != Yii::app()->user->id) {
         $res['note'] = 'Этот заявка был создан не Вами';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     $criteria_req = new CDbCriteria();
     $criteria_req->addInCondition('doc_id', array($check[0]->id));
     $criteria_req->addInCondition('user_id', array($check[0]->user_id));
     $criteria_req->addInCondition('state', array('WAIT'));
     $check_req = Requests::model()->count($criteria_req);
     if ($check_req != 0) {
         $res['note'] = 'Запрос уже был отправлен, дождитесь решения администрации';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     if ($this->documentUpdate($check[0]->id, array('state' => 'Inquiry'))) {
         if ($this->createRequest(Yii::app()->user->id, $_POST['doc_id'], $_POST['comment'])) {
             $res['note'] = 'Запрос успешно отправлен';
             $res['type'] = 'success';
             echo json_encode($res);
             Yii::app()->end();
         } else {
             $this->documentUpdate($check[0]->id, array('state' => 'Save'));
             $res['note'] = 'Ошибка Базы Данных, обратитесь к администрации';
             $res['type'] = 'error';
             echo json_encode($res);
             Yii::app()->end();
         }
     } else {
         $res['note'] = 'Ошибка Базы Данных, обратитесь к администрации';
         $res['type'] = 'error';
         echo json_encode($res);
         Yii::app()->end();
     }
     Yii::app()->end();
 }
开发者ID:seekermain,项目名称:forms,代码行数:61,代码来源:AjaxController.php

示例7: actionCalendar

 public function actionCalendar()
 {
     //        $this->layout = "//layouts/calendar";
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/my-calendar.css");
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/my-calendar-resp.css");
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/plugins/jQuery/jquery-ui.min.js", CClientScript::POS_HEAD);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/plugins/fullcalendar/fullcalendar.js", CClientScript::POS_END);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/plugins/spin/spin.js", CClientScript::POS_END);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/main.js", CClientScript::POS_END);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/my-calendar.js", CClientScript::POS_END);
     $returnArray = array();
     $day = 60 * 60 * 24;
     $time = time();
     $from = Yii::app()->request->getParam('from', '');
     $to = Yii::app()->request->getParam('to', '');
     $criteria = new CDbCriteria();
     $criteria->addCondition('mstRequestUsers.user_id = ' . Yii::app()->user->getInfo());
     $criteria->addCondition('mstRequestUsers.archived = 0');
     //        $criteria->addCondition('booking_type > 0');
     if (!empty($from)) {
         $criteria->addCondition('bookingDate >= ' . $from);
     }
     if (!empty($to)) {
         $criteria->addCondition('bookingDate < ' . $to);
     }
     $criteria->with = array('mstRequestUsers');
     $modelArray = Requests::model()->findAll($criteria);
     $eventsArray = array();
     $requestsTempArray = array();
     foreach ($modelArray as $model) {
         if ($model->booking_type > 0) {
             $criteria = new CDbCriteria();
             $criteria->select = 'sum(amount) as amount';
             $criteria->addCondition('request_id = ' . $model->id);
             $criteria->addCondition('status = 1');
             $modelSum = Payments::model()->find($criteria);
             $moneyPaid = (int) $modelSum->amount;
             $eventsArray[] = array('id' => $model->id, 'creator' => $model->createdBy->firstName . ' ' . $model->createdBy->lastName, 'title' => ComponentString::showPart($model->map->name, 14), 'map' => ComponentString::showPart($model->map->name, 28), 'event_type' => $model->eventType->name, 'start_time' => date('H:i A', strtotime($model->start_time)), 'end_time' => date('H:i A', strtotime($model->end_time)), 'start' => $model->eventDate, 'dateName' => date('l, F d, Y', strtotime($model->eventDate)), 'allDay' => true, 'type' => $model->booking_type, 'daysTotal' => ceil((strtotime($model->eventDate) - strtotime($model->created_on)) / $day), 'daysLeft' => ceil((strtotime($model->eventDate) - $time) / $day), 'moneyPaid' => $moneyPaid, 'moneyTotal' => $model->amount);
         } else {
             $requestsTempArray[date('d-m-Y', strtotime($model->eventDate))][] = 1;
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition('
         (LOWER(calendarType.name) = "flag" AND t.created_by = ' . Yii::app()->user->getInfo() . ') OR
         (LOWER(calendarType.name) = "unavailable" AND t.created_by = ' . Yii::app()->user->getInfo() . ') OR
         (LOWER(calendarType.name) = "holiday")
     ');
     $criteria->addCondition('calendarType.status = 1');
     $criteria->addCondition('t.status = 1');
     $criteria->with = array('calendarType');
     $modelArray = Calendar::model()->findAll($criteria);
     $flagsArray = array();
     $holidaysArray = array();
     $unavailableArray = array();
     foreach ($modelArray as $model) {
         switch (strtolower($model->calendarType->name)) {
             case 'flag':
                 $flagsArray[] = array('id' => $model->id, 'title' => ComponentString::showPart($model->message, 30), 'start' => $model->calendar_date);
                 break;
             case 'holiday':
                 $holidaysArray[] = array('id' => $model->id, 'title' => $model->message, 'start' => $model->calendar_date);
                 break;
             case 'unavailable':
                 $unavailableArray[] = array('id' => $model->id, 'title' => $model->message, 'start' => $model->calendar_date);
                 break;
         }
     }
     $requestsArray = array();
     foreach ($requestsTempArray as $key => $request) {
         $requestsArray[$key] = count($request);
     }
     $returnArray['events'] = $eventsArray;
     $returnArray['flags'] = $flagsArray;
     $returnArray['requests'] = $requestsArray;
     $returnArray['holidays'] = $holidaysArray;
     $returnArray['unavailable'] = $unavailableArray;
     $json = json_encode($returnArray);
     Yii::app()->clientScript->registerScript('mapvar10', "var json='" . $json . "';", CClientScript::POS_HEAD);
     $this->render('calendar');
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:81,代码来源:MyController.php


注:本文中的Requests::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。