コード例 #1
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 $id the ID of the model to be loaded
  * @return SubscriptionPackage the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SubscriptionPackage::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     // if user is already logged in
     // redirect to dash board
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('project/index'));
     }
     $model = new Account();
     //$companyModel = new Company();
     //$companyContactModel = new CompanyContact();
     $accountSubscriptionModel = new AccountSubscription();
     $accountProfile = new AccountProfile();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     /**
      * Process form's submission
      * param's name must be in this format, e.g. "Account[account_email]"
      */
     if (isset($_POST['Account'])) {
         $model->attributes = $_POST['Account'];
         $model->account_id = null;
         //$companyModel->attributes = $_POST['Company'];
         //$companyContactModel->attributes = $_POST['CompanyContact'];
         $accountSubscriptionModel->attributes = $_POST['AccountSubscription'];
         $accountProfile->attributes = $_POST['AccountProfile'];
         /**
         			$model->account_company_name = $companyModel->company_name;
         			$model->account_contact_surname = $companyContactModel->contact_surname;
         			$model->account_contact_given_name = $companyContactModel->contact_given_name;
         			$model->account_subscription_package_id = $accountSubscriptionModel->account_subscription_package_id;
         			**/
         // SAVE ACCOUNT
         //$model->account_password = $model->hashPassword($model->account_password);
         $model->account_status = ACCOUNT_STATUS_ACTIVATED;
         // ACCOUNT_STATUS_NOT_ACTIVATED;
         $save_result = '';
         // save user account record to database
         $save_result = $model->save();
         if ($save_result) {
             // create/update subscription record
             $accountSubscriptionModel->account_id = $model->account_id;
             $accountSubscriptionModel->account_subscription_start_date = date('Y-m-d H:i');
             $accountSubscriptionModel->account_subscription_status_id = 1;
             $accountSubscriptionModel->save();
             // create account profile
             $accountProfile->account_id = $model->account_id;
             $accountProfile->account_profile_preferred_display_name = $accountProfile->account_profile_given_name . ' ' . $accountProfile->account_profile_surname;
             $accountProfile->save();
             /**
             				// create company record
             				$companyModel->company_master_account_id = $model->account_id;
             				$companyModel->company_is_master = COMPANY_IS_MASTER;
             			
             				// save company record to database,
             				// if successful, create contact record
             				if ($companyModel->save()) {
             					// create contact record
             					$companyContactModel->contact_email1 = $model->account_email;
             					$companyContactModel->company_id = $companyModel->company_id;
             					$companyContactModel->account_id = $model->account_id;
             					// save contact record to database
             					$companyContactModel->save();
             				}**/
             // notify user through email
             $model->sendSuccessfulSignupEmailNotification();
         }
         // redirect to view
         if ($save_result) {
             //$this->redirect(array('view','id'=>$model->account_id));
             $this->redirect(Yii::app()->baseUrl . '/product/signup-success.php');
         }
     }
     /** 
      * otherwise just show creation form
      */
     $active_subscription_packages = SubscriptionPackage::getActivePackages();
     $active_subscription_package_names = array();
     foreach ($active_subscription_packages as $item) {
         $active_subscription_package_names[$item->subscription_package_id] = $item->subscription_package_name;
     }
     $data = array('model' => $model, 'accountProfileModel' => $accountProfile, 'accountSubscriptionModel' => $accountSubscriptionModel, 'active_subscription_packages' => $active_subscription_package_names);
     LBApplication::render($this, 'create', $data);
     //$this->render('create',);
 }
コード例 #3
0
 public static function getActivePackages()
 {
     $condition = 'subscription_package_status = :status_id';
     return SubscriptionPackage::model()->findAll($condition, array(':status_id' => 1));
 }