public function editarAction() { $idcliente = $this->params()->fromRoute('id'); $id = $this->params()->fromRoute('idclientecliente'); $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); $entity = \ProveedorclienteQuery::create()->findPk($id); foreach ($post_data as $key => $value) { if (\ProveedorclientePeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'cliente_cumpleanios') { $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME); } } $entity->save(); $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!'); //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR return $this->redirect()->toUrl('/clientes/ver/' . $idcliente . '?active=clientes'); } $exist = \ProveedorclienteQuery::create()->filterByIdproveedorcliente($id)->exists(); if ($exist) { $entity = \ProveedorclienteQuery::create()->findPk($id); $cliente = \ClienteQuery::create()->findPk($idcliente); $form = new \Admin\Clientes\Form\ProveedorForm($idcliente); $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME)); $view_model = new ViewModel(); $view_model->setTemplate('admin/clientes/clientesclientes/editar'); $view_model->setVariables(array('entity' => $entity, 'successMessages' => json_encode($this->flashMessenger()->getSuccessMessages()), 'form' => $form, 'cliente' => $cliente)); return $view_model; } else { return $this->redirect()->toUrl('/clientes/ver/' . $idcliente . '?active=clientes'); } }
public function proveedoreliminarAction() { $request = $this->getRequest(); $id = $this->params()->fromRoute('idproveedor'); $idcliente = $this->params()->fromRoute('id'); if ($request->isPost()) { $entity = \ProveedorclienteQuery::create()->findPk($id); $entity->delete(); $this->flashMessenger()->addSuccessMessage('Registro eliminado exitosamente!'); return $this->getResponse()->setContent(json_encode(true)); } $viewModel = new ViewModel(); $viewModel->setTerminal(true); $viewModel->setTemplate('admin/clientes/proveedor/eliminar'); return $viewModel; }
/** * Returns a new ProveedorclienteQuery object. * * @param string $modelAlias The alias of a model in the query * @param ProveedorclienteQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProveedorclienteQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ProveedorclienteQuery) { return $criteria; } $query = new ProveedorclienteQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
public function getproveedoresAction() { $type = $this->params()->fromQuery('type'); $idcliente = $this->params()->fromQuery('idcliente'); $result = array(); if ($type == 'importacion') { $result = \ProveedorclienteQuery::create()->filterByIdcliente($idcliente)->filterByproveedorclienteTipo('proveedor')->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); } elseif ($type == 'exportacion') { $result = \ProveedorclienteQuery::create()->filterByIdcliente($idcliente)->filterByproveedorclienteTipo('cliente')->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); } return $this->getResponse()->setContent(json_encode($result)); }
/** * Returns the number of related Proveedorcliente objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Proveedorcliente objects. * @throws PropelException */ public function countProveedorclientes(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collProveedorclientesPartial && !$this->isNew(); if (null === $this->collProveedorclientes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProveedorclientes) { return 0; } if ($partial && !$criteria) { return count($this->getProveedorclientes()); } $query = ProveedorclienteQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByCliente($this)->count($con); } return count($this->collProveedorclientes); }
/** * Get the associated Proveedorcliente object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Proveedorcliente The associated Proveedorcliente object. * @throws PropelException */ public function getProveedorcliente(PropelPDO $con = null, $doQuery = true) { if ($this->aProveedorcliente === null && $this->idconsignatarioembarcador !== null && $doQuery) { $this->aProveedorcliente = ProveedorclienteQuery::create()->findPk($this->idconsignatarioembarcador, $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->aProveedorcliente->addExpedientes($this); */ } return $this->aProveedorcliente; }
/** * 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(ProveedorclientePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ProveedorclienteQuery::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; } }