public function postCreate()
 {
     $proveedores = new Proveedores();
     $proveedores->nombre = Input::get('nombre');
     $proveedores->empresa = Input::get('empresa');
     $proveedores->telefono = Input::get('telefono');
     $proveedores->direccion = Input::get('direccion');
     $proveedores->notas = Input::get('notas');
     if ($proveedores->save()) {
         return Redirect::to('dashboard/proveedores/index')->with('msg', 'Datos guardados con éxito.')->with('class', 'success');
     } else {
         return Redirect::back()->withInput()->with('msg', '¡Algo salió mal! Los datos no fueron guardados.')->with('class', 'error');
     }
 }
 public function actionCreate()
 {
     $model = new Proveedores();
     if (isset($_POST['Proveedores'])) {
         $model->setAttributes($_POST['Proveedores']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ProveedoresExtranjeros();
     $modelProveedor = new Proveedores('extranjero');
     $modelContacto = new PersonasContacto();
     if (isset($_POST['ProveedoresExtranjeros'])) {
         $model->attributes = $_POST['ProveedoresExtranjeros'];
         $modelProveedor->attributes = $_POST['Proveedores'];
         $modelContacto->attributes = $_POST['PersonasContacto'];
         $transaction = $model->dbConnection->beginTransaction();
         // Transaction begin //Yii::app()->db->beginTransaction
         try {
             $modelProveedor->nacional = false;
             if (!$modelProveedor->tiene_rif) {
                 $modelProveedor->rif = 'N/A';
             }
             //$modelProveedor->tiene_rif = $_POST['Proveedores']['tiene_rif'];
             $flag = $modelProveedor->save();
             if ($flag) {
                 $model->proveedor_id = $modelProveedor->id;
                 $modelContacto->proveedor_id = $modelProveedor->id;
                 $flag = $flag && $model->save();
                 $flag = $flag && $modelContacto->save();
             }
             if ($flag) {
                 $transaction->commit();
                 // committing
                 Yii::app()->user->setFlash('success', "Proveedor extranjero registrado con exito.");
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 throw new Exception("Error Processing Request", 1);
             }
         } catch (Exception $e) {
             $transaction->rollBack();
             Yii::app()->user->setFlash('error', "No se pudo registrar el proveedor extranjero.");
             //return false;
         }
     }
     $this->render('create', array('model' => $model, 'modelProveedor' => $modelProveedor, 'modelContacto' => $modelContacto));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Proveedores();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Proveedores'])) {
         $model->attributes = $_POST['Proveedores'];
         $usuario = Usuarios::model()->actual();
         $model->rif = strtoupper($model->rif);
         $model->razon_social = strtoupper($model->razon_social);
         $model->ente_organo_id = $usuario->ente_organo_id;
         if ($model->save()) {
             $this->renderPartial('_exito', array(), false, true);
             //echo '<script>$("#jobDialog").dialog("close");</script>';
         }
     }
     $this->renderPartial('_form', array('model' => $model), false, true);
 }