/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ProveedoritradePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ProveedoritradeQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function eliminarAction() { $request = $this->getRequest(); if ($request->isPost()) { $id = $request->getPost('id'); $entity = \ProveedoritradeQuery::create()->findPk($id); $entity->delete(); //Agregamos un mensaje $this->flashMessenger()->addSuccessMessage('Registro eliminado exitosamente!'); if ($entity->isDeleted()) { return $this->getResponse()->setContent(json_encode(true)); } } $id = $this->params()->fromQuery('id'); //RETORNAMOS A NUESTRA VISTA $view_model = new ViewModel(); $view_model->setTerminal(true); $view_model->setTemplate('admin/catalogo/proveedor/eliminar'); return $view_model; return $viewModel; }
/** * Get the associated Proveedoritrade object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Proveedoritrade The associated Proveedoritrade object. * @throws PropelException */ public function getProveedoritrade(PropelPDO $con = null, $doQuery = true) { if ($this->aProveedoritrade === null && $this->idproveedoritrade !== null && $doQuery) { $this->aProveedoritrade = ProveedoritradeQuery::create()->findPk($this->idproveedoritrade, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aProveedoritrade->addProveedoritradearchivos($this); */ } return $this->aProveedoritrade; }
public function editarcargoAction() { $request = $this->getRequest(); $idgasto = $this->params()->fromQuery('id'); $entity = \ExpedientegastoQuery::create()->findPk($idgasto); if ($request->isPost()) { $post_data = $request->getPost(); $post_files = $request->getFiles(); $auth = new \Shared\Session\AouthSession(); $auth = $auth->getData(); $entity = \ExpedientegastoQuery::create()->findPk($post_data['idexpedientegasto']); foreach ($post_data as $key => $value) { if (\ExpedientegastoPeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'expedientegasto_fecha') { $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME); } } //LA FECHA $expedientegasto_fecha = \DateTime::createFromFormat('d/m/Y', $post_data['expedientegasto_fecha']); $entity->setExpedientegastoFecha($expedientegasto_fecha); $entity->setIdempleado($auth['idempleado']); $entity->save(); //El comprobante if (!empty($post_files['expedientegasto_comprobante']['name'])) { $target_path = "/files/expedientesgastos/"; $target_path = $target_path . $entity->getIdexpedientegasto() . '_' . basename($post_files['expedientegasto_comprobante']['name']); if (move_uploaded_file($_FILES['expedientegasto_comprobante']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . $target_path)) { $entity->setExpedientegastoComprobante($target_path); $entity->save(); } } $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!'); //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR return $this->redirect()->toUrl('/clientes/ver/' . $entity->getExpediente()->getIdcliente() . '/expedientes/ver/' . $entity->getIdexpediente()); } //LAS CATEGORIAS DE NUESTROS GASTOS $categoriasgasto = \CategoriagastoQuery::create()->find(); $categoriasgasto_array = array(); foreach ($categoriasgasto as $categoriagastos) { $id = $categoriagastos->getIdcategoriagasto(); $categoriasgasto_array[$id] = $categoriagastos->getCategoriagastoNombre(); } //LOS PROVEEDORES $proveedores = \ProveedoritradeQuery::create()->filterByIdproveedoritrade(1, \Criteria::NOT_EQUAL)->find(); $proveedores_array = array(); foreach ($proveedores as $proveedor) { $id = $proveedor->getIdproveedoritrade(); $proveedores_array[$id] = $proveedor->getProveedoritradeNombre(); } //gastos de facturacion $gastos_facturacion = \GastofacturacionQuery::create()->filterByIdcategoriagasto($entity->getGastofacturacion()->getIdcategoriagasto())->find(); $gastos_facturacion_array = array(); foreach ($gastos_facturacion as $gasto_facturacion) { $id = $gasto_facturacion->getIdgastofacturacion(); $gastos_facturacion_array[$id] = $gasto_facturacion->getGastofacturacionNombre(); } //INSTANCIAMOS NUESTRO FORMULARIO $form = new \Admin\Clientes\Form\ExpedientegastoForm($entity->getIdexpediente(), $categoriasgasto_array, $proveedores_array, $entity->getExpedientegastoMoneda(), $gastos_facturacion_array); //Ponemos nuetros datos al formulario.... $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME)); $form->get('expedientegasto_fecha')->setValue($entity->getExpedientegastoFecha('d/m/Y')); $form->get('idcategoriagasto')->setValue($entity->getGastofacturacion()->getIdcategoriagasto()); $form->get('idgastofacturacion')->setValue($entity->getIdgastofacturacion()); $form->get('idgastofacturacion')->setAttribute('disabled', false); //Enviamos a la vista $view_model = new ViewModel(); $view_model->setTerminal(true)->setVariable('form', $form)->setVariable('entity', $entity)->setTemplate('/clientes/expedientes/modal/editarcargo'); return $view_model; }