public function loadModel($id)
 {
     $m = CcbrBranch::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('D2companyModule.crud_static', 'The requested page does not exist.'));
     }
     return $model;
 }
 public function actionUpdateccbr($ccmp_id, $ccbr_id = FALSE)
 {
     //company
     $model = $this->loadModel($ccmp_id);
     $model->scenario = $this->scenario;
     if (isset($_POST['CcbrBranch'])) {
         $m = CcbrBranch::model();
         $model = $m->findByPk($ccbr_id);
         $model->attributes = $_POST['CcbrBranch'];
         try {
             if ($model->save()) {
                 if (isset($_GET['returnUrl'])) {
                     $this->redirect($_GET['returnUrl']);
                 } else {
                     $this->redirect(array('manageccbr', 'ccmp_id' => $ccmp_id, 'ccbr_id' => $model->ccbr_id));
                 }
             }
         } catch (Exception $e) {
             $model->addError('ccbr_id', $e->getMessage());
         }
     }
     //branch
     $m = CcbrBranch::model();
     $mCcbr = $m->findByPk($ccbr_id);
     $this->render('update_extended', array('model' => $model, 'ccbr_id' => $ccbr_id, 'active_tab' => 'updateccbr', 'mCcbr' => $mCcbr));
 }