/**
  * 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 MapFloorPlanAnnotation the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = MapFloorPlanAnnotation::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * @return string the MapFloorPlanAnnotation id  display for the current MapFloorPlan
  */
 public function getMapFloorPlanAnnotationId()
 {
     $MapFloorPlanAnnotationRecord = MapFloorPlanAnnotation::model()->findByAttributes(array('floor_id' => $this->id));
     return $MapFloorPlanAnnotationRecord->id;
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     $model = $this->loadModel($id);
     if (file_exists(Yii::app()->basePath . '/../maps/' . $model->map_path)) {
         unlink(Yii::app()->basePath . '/../maps/' . $model->map_path);
     }
     $model->delete();
     MapFloorPlanAnnotation::model()->deleteAll("floor_id =" . $id);
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'mid' => $_GET["mid"]));
     }
 }