/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ProveedoresObjetos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ProveedoresObjetos'])) {
         $model->attributes = $_POST['ProveedoresObjetos'];
         $usuario = Usuarios::model()->actual();
         $model->ente_organo_id = $usuario->ente_organo_id;
         if ($model->validate()) {
             $objPrin = new ProveedorDominio();
             $objPrin->objeto = $model->objeto_principal;
             $objPrin->proveedor_id = $model->proveedor_id;
             $objPrin->ente_organo_id = $model->ente_organo_id;
             $objPrin->save();
             $productos = $model->rama_producto_id;
             foreach ($productos as $key) {
                 $aux = new ProveedoresObjetos();
                 $aux->attributes = $_POST['ProveedoresObjetos'];
                 $aux->ente_organo_id = $model->ente_organo_id;
                 $aux->rama_producto_id = $key;
                 $aux->save();
             }
             Yii::app()->user->setFlash('success', "Guardado con éxito!");
             $model = new ProveedoresObjetos();
         }
     }
     $this->render('create', array('model' => $model));
 }