コード例 #1
0
 public function actionStep1()
 {
     $model = new ServiceRegistrationForm('step1');
     $lastId = Yii::app()->session['last-service-id'];
     if ($lastId && !in_array($lastId, $model->services)) {
         $s = OurService::model()->findByPk($lastId);
         if ($s) {
             if ($s->childs) {
                 foreach ($s->childs as $c) {
                     $model->services[] = $c->id;
                 }
             } else {
                 $model->services[] = $s->id;
             }
         }
         unset(Yii::app()->session['last-service-id']);
     }
     $this->_setFormData($model);
     $this->_saveFormData($model);
     if (Yii::app()->request->isPostRequest && $model->validate()) {
         $this->redirect(array('step2'));
     }
     Yii::app()->theme = 'onehome';
     $this->layout = '/layouts/onehome/1-col';
     $this->pageTitle = 'Get Started - ' . Yii::app()->params['title'];
     $this->render('step1', array('model' => $model));
 }
コード例 #2
0
 public function save($runValidation = true, $attributes = null)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         if (!parent::save($runValidation, $attributes)) {
             throw new CHttpException(500, 'Registration could not be saved.');
         }
         // remove items that has child
         $serviceIds = array_combine($this->services, $this->services);
         foreach ($serviceIds as $sid) {
             $item = OurService::model()->findByPk($sid);
             if (!$item) {
                 throw new CHttpException(400, 'Request invalid.');
             }
             if ($item->parent_id) {
                 unset($serviceIds[$item->parent_id]);
             }
         }
         // save registered services
         foreach ($serviceIds as $sid) {
             $m = new ServiceRegistrationItem();
             $m->service_id = $sid;
             $m->registration_id = $this->id;
             if (!$m->save()) {
                 throw new CHttpException(500, 'Registration item could not be saved.');
             }
         }
         $transaction->commit();
     } catch (Exception $ex) {
         $transaction->rollBack();
         throw $ex;
     }
     return true;
 }
コード例 #3
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = OurService::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #4
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['ServiceCategory'])) {
         $model->attributes = $_POST['ServiceCategory'];
         $model->imageFile = CUploadedFile::getInstance($model, 'imageFile');
         if ($model->save()) {
             $model->saveImage();
             OurService::massUpdateDisplayOrder();
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess));
 }
コード例 #5
0
ファイル: our-services.php プロジェクト: jasonhai/onehome
</span>
		</div>
		<?php 
}
?>
	</div>
	<div class="service-tab">
		<div class="container"><div class="table-responsive"><!-- content added by js --></div></div>
	</div>
</div>

<div class="visible-xs-block" style="margin-top: 20px">
	<div class="collapse in navbar-collapse" id="bs-example-navbar-collapse-2">
		<ul class="nav navbar-nav service-nav">
			<?php 
foreach (OurService::getMainCategories() as $category) {
    ?>
			<li class="dropdown"> 
				<span><?php 
    echo $category->name;
    ?>
</span>

				<i class="fa fa-angle-right dropdown-toggle"
				   data-toggle="dropdown" 
				   role="button" aria-haspopup="true" 
				   aria-expanded="false"
				>&nbsp;</i>

				<ul class="dropdown-menu">
				<?php 
コード例 #6
0
ファイル: SiteController.php プロジェクト: jasonhai/onehome
     //        echo "<hr>$ClassName Data: ".count($aData)." - Exists: ".count($aExists)." - New: ".count($aNew)." - Detail: ".implode(",",$aNew);
 }
 /**
  * @Author: ANH DUNG Mar 04, 2015
  * @Todo: insert new record to db
  * @Param: $ClassName name of model
  * @Param: $field_name field in db
  * @Param: $aNew array data to insert new
  */
 public function InsertNewRecord($ClassName, $FieldName, $aNew)
 {
     $model_ = call_user_func(array($ClassName, 'model'));
     $tableName = $model_->tableName();
     Yii::app()->db->createCommand("truncate table {$tableName}")->query();
     //        sleep(1);
     $aRowInsert = array();
     foreach ($aNew as $key => $item) {
         $aRowInsert[] = "( '{$item}' )";
     }
     $sql = "insert into {$tableName} (\r\r                {$FieldName}\r\r            ) values " . implode(',', $aRowInsert);
     if (count($aRowInsert) > 0) {
         //            echo "<br> SQL: $sql <br>";
         Yii::app()->db->createCommand($sql)->execute();
     }
 }
 /**
コード例 #7
0
ファイル: ServiceCategory.php プロジェクト: jasonhai/onehome
 protected function beforeDelete()
 {
     $this->removeImage();
     return parent::beforeDelete();
 }
コード例 #8
0
 public function run()
 {
     $categories = OurService::getMainCategories();
     $this->render('our-service-link-widget', array('categories' => $categories));
 }