/**
  * Handles the first page of the application form
  * @param string $city
  */
 public function actionSignup($city)
 {
     $customer_model = new Customer();
     $commande_model = new Commande();
     $goodcity = Goodcity::model()->findByPk($city);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // Set the scenario to limit the attributes we suck in from
     //  the POST array.  This protects us against injection attacks.
     $commande_model->setScenario('user_create');
     $customer_model->setScenario('user_create');
     if (isset($_POST['Customer'])) {
         // Populate our new models from the input arrays
         $customer_model->attributes = $_POST['Customer'];
         $commande_model->attributes = $_POST['Commande'];
         // If a model saves, we know it's valid
         if ($customer_model->validate()) {
             // Save the uploaded files
             $arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
             foreach ($arr_uploads as $upload) {
                 $commande_model->{'t' . $upload} = CUploadedFile::getInstance($commande_model, $upload);
             }
             // We have to insert a dummy id here to run validate()
             $commande_model->bilkey = 0;
             if ($commande_model->validate()) {
                 // Save the uploaded files
                 $arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
                 foreach ($arr_uploads as $upload) {
                     $commande_model->{$upload} = CUploadedFile::getInstance($commande_model, $upload);
                     if ($commande_model->{$upload} != null) {
                         $path = $this->getUploadPath($commande_model->{$upload});
                         $commande_model->{$upload}->saveAs($path);
                         $_POST['Commande'][$upload] = $path;
                     }
                 }
                 // We don't actually want to do the save just yet,
                 //  so store *everything* in the session.  (This is hack-y)
                 Yii::app()->user->setState('Customer', $_POST['Customer']);
                 Yii::app()->user->setState('Commande', $_POST['Commande']);
                 Yii::app()->user->setState('payment_type', $_POST['payment']);
                 //var_dump($this->emailValidation($customer_model));die();
                 if ($this->passwordUsernameVerification($customer_model) == false) {
                     $this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'username_used' => true));
                     die;
                 } elseif ($this->emailValidation($customer_model) == false) {
                     $this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'email_used' => true));
                     die;
                 }
                 $this->redirect(array('order'));
             }
         } else {
             // We have to insert a dummy id here to run validate()
             $commande_model->bilkey = 0;
             $commande_model->validate();
         }
     } elseif (isset(Yii::app()->user->Customer)) {
         $customer_model->attributes = Yii::app()->user->Customer;
         $commande_model->attributes = Yii::app()->user->Commande;
         //    		$payment_type               = Yii::app()->user->payment_type;
     }
     // Hack for one-time setup option
     $onetime = false;
     if (isset(Yii::app()->user->onetime)) {
         $onetime = true;
     } else {
         $onetime = false;
     }
     $this->render('application/1-signup', array('customer_model' => $customer_model, 'commande_model' => $commande_model, 'goodcity' => $goodcity, 'onetime' => $onetime));
 }