/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Clientes();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Clientes'])) {
         $model->attributes = $_POST['Clientes'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->NumServicio));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function saveAction()
 {
     if (isset($_POST['id'])) {
         if ($_POST['id'] > 0) {
             $resul = Clientes::findFirstById($this->request->getPost('id'));
             $resul->razon_social = $this->request->getPost('razon_social');
             $resul->nit = $this->request->getPost('nit');
             $resul->telefono = $this->request->getPost('telefono');
             $resul->celular = $this->request->getPost('celular');
             $resul->correo = $this->request->getPost('correo');
             $resul->direccion = $this->request->getPost('direccion');
             // $resul->imagen = $this->request->getPost('imagen');
             $resul->representante_legal = $this->request->getPost('representante_legal');
             $resul->ci_representante_legal = $this->request->getPost('ci_representante_legal');
             $resul->celular_representante_legal = $this->request->getPost('celular_representante_legal');
             $resul->correo_representante_legal = $this->request->getPost('correo_representante_legal');
             $resul->nombre_ref = $this->request->getPost('nombre_ref');
             $resul->ci_ref = $this->request->getPost('ci_ref');
             $resul->celular_ref = $this->request->getPost('celular_ref');
             $resul->correo_ref = $this->request->getPost('correo_ref');
             // $resul->usuario_reg = $this->_user->id;
             // $resul->fecha_reg = date("Y-m-d H:i:s");
             // $resul->baja_logica = 1;
             if ($resul->save()) {
                 $msm = 'Exito: Se guardo correctamente';
             } else {
                 $msm = 'Error: No se guardo el registro';
             }
         } else {
             $resul = new Clientes();
             $resul->razon_social = $this->request->getPost('razon_social');
             $resul->nit = $this->request->getPost('nit');
             $resul->telefono = $this->request->getPost('telefono');
             $resul->celular = $this->request->getPost('celular');
             $resul->correo = $this->request->getPost('correo');
             $resul->direccion = $this->request->getPost('direccion');
             // $resul->imagen = $this->request->getPost('imagen');
             $resul->representante_legal = $this->request->getPost('representante_legal');
             $resul->ci_representante_legal = $this->request->getPost('ci_representante_legal');
             $resul->celular_representante_legal = $this->request->getPost('celular_representante_legal');
             $resul->correo_representante_legal = $this->request->getPost('correo_representante_legal');
             $resul->nombre_ref = $this->request->getPost('nombre_ref');
             $resul->ci_ref = $this->request->getPost('ci_ref');
             $resul->celular_ref = $this->request->getPost('celular_ref');
             $resul->correo_ref = $this->request->getPost('correo_ref');
             $resul->usuario_reg = $this->_user->id;
             $resul->fecha_reg = date("Y-m-d H:i:s");
             $resul->baja_logica = 1;
             if ($resul->save()) {
                 $msm = 'Exito: Se guardo correctamente';
             } else {
                 $msm = 'Error: No se guardo el registro';
             }
         }
     }
     $this->view->disable();
     echo $msm;
 }