Exemplo n.º 1
0
 public function actionLoad($name)
 {
     // TODO: Look-up city name in database
     //   If city name exists:
     //     Get goodcitypic and state/country
     //     Format location string and display page
     //   If not: 404
     // We convert spaces to underscores in the links...
     //  convert them back.
     $name = str_replace("_", " ", $name);
     // Laval needs to be hardcoded (sigh)
     if ($name == "montreal") {
         $name = "laval";
     }
     // Check if the user has picked a city
     if (isset($_POST['one_time'])) {
         Yii::app()->user->setState('onetime', true);
         $goodcitykey = $_POST['city_selection'];
         $this->redirect(array("user/signup/city/{$goodcitykey}"));
     }
     if (isset($_POST['city_selection'])) {
         // Handle the case if the user backs out of a
         //  one-time sign-up...
         Yii::app()->user->clearStates();
         $goodcitykey = $_POST['city_selection'];
         $this->redirect(array("user/signup/city/{$goodcitykey}"));
     }
     // TODO: Make this distinct!
     $criteria = new CDbCriteria();
     //		$criteria->distinct  = true;
     //		$criteria->group     = 'goodcity';	     // Need this to prevent dups
     $criteria->order = 'goodcity ASC';
     $criteria->params = array(':location' => '%' . $name . '%');
     $criteria->condition = "goodcity LIKE :location AND goodcategory != 'X'";
     $model = Goodcity::model()->findAll($criteria);
     if (empty($model)) {
         $this->redirect(array('site/index', 'city' => $name));
     } else {
         $this->render('city', array('location' => $name, 'model' => $model));
     }
 }
Exemplo n.º 2
0
 public function actionPaypalPayment()
 {
     $customer_model = new Customer();
     $commande_model = new Commande();
     $customer_model->attributes = Yii::app()->user->getState('Customer');
     $commande_model->attributes = Yii::app()->user->getState('Commande');
     if (sizeof($customer_model->search()->getData()) == 0) {
         $customer_model->bilsignupip = CHttpRequest::getUserHostAddress();
         $customer_model->save();
         $commande_model->bilkey = $customer_model->bilkey;
         $commande_model->comdebut = date("Y-m-d");
         $commande_model->save();
     } else {
         $customerTemp = $customer_model->search()->getData();
         $customer_model->bilkey = $customerTemp[0]->attributes['bilkey'];
     }
     if (isset($_POST['payment_status'])) {
         if ($_POST['payment_status'] == "Completed" || $_POST['payment_status'] == "Pending") {
             $city = Goodcity::model()->findByPk($_POST['item_number']);
             $this->sendEmailConfirmation($customer_model, $city, $commande_model, $_POST['txn_id'], $this->getInvoiceTotals($customer_model, $commande_model));
             $this->render('application/2-orderform', array('goodcity' => $city, 'thanks' => true, 'payment_type' => "paypal", 'payment_method' => "email", 'order_totals' => $this->getInvoiceTotals($customer_model, $commande_model), 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'auth_code' => $_POST['txn_id']));
         } else {
             $this->redirect(array('user/order', 'transactionError' => true));
         }
     } else {
         $city = Goodcity::model()->findByPk($commande_model['comgoodcitykey']);
         $this->redirect(array('user/signup', 'city' => $commande_model['comgoodcitykey']));
     }
 }
 /**
  * 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 = Goodcity::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }