/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Gastofacturacion is new, it will return * an empty collection; or if this Gastofacturacion has previously * been saved, it will retrieve related Expedientegastos from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Gastofacturacion. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|Expedientegasto[] List of Expedientegasto objects */ public function getExpedientegastosJoinProveedoritrade($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = ExpedientegastoQuery::create(null, $criteria); $query->joinWith('Proveedoritrade', $join_behavior); return $this->getExpedientegastos($query, $con); }
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; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Proveedoritrade is new, it will return * an empty collection; or if this Proveedoritrade has previously * been saved, it will retrieve related Expedientegastos from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Proveedoritrade. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|Expedientegasto[] List of Expedientegasto objects */ public function getExpedientegastosJoinGastofacturacion($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = ExpedientegastoQuery::create(null, $criteria); $query->joinWith('Gastofacturacion', $join_behavior); return $this->getExpedientegastos($query, $con); }
/** * 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(ExpedientegastoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ExpedientegastoQuery::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; } }