示例#1
0
 public function nuevoAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $entity = new \Gastofacturacion();
         foreach ($post_data as $key => $value) {
             if (\GastofacturacionPeer::getTableMap()->hasColumn($key) && !empty($value)) {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //SETIAMOS EL IVA
         $entity->setGastofacturacionIva($post_data['gastofacturacion_iva']);
         $entity->save();
         //Agregamos un mensaje
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toRoute('admin/catalogo/gastos', array('action' => 'editar', 'id' => $entity->getIdgastofacturacion()));
     }
     //LE DAMOS FORMATO A LAS CATEGORIAS DE GASTOS
     $categorias_gastos = \CategoriagastoQuery::create()->find();
     $categorias_gastos_array = array();
     foreach ($categorias_gastos as $categoria_gasto) {
         $idcategoriagasto = $categoria_gasto->getIdcategoriagasto();
         $categorias_gastos_array[$idcategoriagasto] = $categoria_gasto->getCategoriagastoNombre();
     }
     //INSTANCIAMOS NUESTRO FORMULARIO
     $form = new \Catalogo\Form\GastoForm($categorias_gastos_array);
     //RETORNAMOS A NUESTRA VISTA
     $view_model = new ViewModel();
     $view_model->setTemplate('admin/catalogo/gastos/nuevo');
     $view_model->setVariable('form', $form);
     return $view_model;
 }
示例#2
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEmpleado !== null) {
             if ($this->aEmpleado->isModified() || $this->aEmpleado->isNew()) {
                 $affectedRows += $this->aEmpleado->save($con);
             }
             $this->setEmpleado($this->aEmpleado);
         }
         if ($this->aExpediente !== null) {
             if ($this->aExpediente->isModified() || $this->aExpediente->isNew()) {
                 $affectedRows += $this->aExpediente->save($con);
             }
             $this->setExpediente($this->aExpediente);
         }
         if ($this->aGastofacturacion !== null) {
             if ($this->aGastofacturacion->isModified() || $this->aGastofacturacion->isNew()) {
                 $affectedRows += $this->aGastofacturacion->save($con);
             }
             $this->setGastofacturacion($this->aGastofacturacion);
         }
         if ($this->aProveedoritrade !== null) {
             if ($this->aProveedoritrade->isModified() || $this->aProveedoritrade->isNew()) {
                 $affectedRows += $this->aProveedoritrade->save($con);
             }
             $this->setProveedoritrade($this->aProveedoritrade);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }