/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Commande(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Commande'])) { $model->attributes = $_POST['Commande']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->comkey)); } } $this->render('create', array('model' => $model)); }
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'])); } }