Beispiel #1
0
 public function actionAjaxBillType()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     if (!empty($parents = Yii::$app->request->post('depdrop_parents'))) {
         /** @var Location $location */
         $location = Location::findOne($parents[0]);
         $output = [];
         foreach (Ticket::$BILL_TYPE_SELECT as $bill_type_id => $bill_type) {
             $option = ['id' => (string) $bill_type_id, 'name' => $bill_type];
             if ($bill_type_id == Ticket::BILL_PROACTIVE) {
                 $option['options'] = ['disabled' => !($location && $location->proactive)];
             }
             $output[] = $option;
         }
         return ['output' => $output, 'selected' => (string) ($location ? $location->proactive : Ticket::BILL_HOURLY)];
     }
     return ['output' => ''];
 }
 /**
  * Finds the Location model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Location the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Location::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }