/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return APriceTime the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = APriceTime::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public static function getAllowedAPriceTimeObjForGivenTiffinAndQuantity($tiffinId, $quantity)
 {
     $response = array();
     $currDateTime = new DateTime();
     $currDateTime = $currDateTime->format('Y-m-d H:i:s');
     $selectedRecords = null;
     if (isset($tiffinId) && isset($quantity)) {
         $selectedRecords = APriceTime::model()->findAll(array('order' => 't.order_delivery_time, t.id', 'condition' => 't.is_deleted = "no" AND t.verified_by != "not verified"  AND t.price_time2tiffin = ' . $tiffinId . ' AND  t.quantity_currently_available >= ' . $quantity . ' AND t.order_start_time <= ' . '"' . $currDateTime . '"' . ' AND t.order_end_time >= ' . '"' . $currDateTime . '"' . ' AND t.order_delivery_time >= ' . '"' . $currDateTime . '" '));
     }
     if (isset($selectedRecords)) {
         $response = $selectedRecords;
     }
     return $response;
 }