Exemplo n.º 1
0
 public function inAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $empleado_email = $post_data['empleado_email'];
         $empleado_password = $post_data['empleado_password'] = md5($post_data['empleado_password']);
         //Verificamos si los datos de acceso son correctos y se encuentra activo
         $is_valid = \EmpleadoQuery::create()->filterByEmpleadoEmail($empleado_email)->filterByEmpleadoPassword($empleado_password)->filterByEmpleadoEstatus('activo')->exists();
         if ($is_valid) {
             //CREAMOS LA SESION DE NUESTRO USUARIO
             $empleado = \EmpleadoQuery::create()->filterByEmpleadoEmail($empleado_email)->filterByEmpleadoPassword($empleado_password)->findOne();
             //Nuesta session
             $session = new \Shared\Session\AouthSession();
             //Creamos nuestra session
             $session->Create(array('idempleado' => $empleado->getIdempleado(), 'empleado_nombre' => $empleado->getEmpleadoNombre(), 'empleado_apellidopaterno' => $empleado->getEmpleadoApellidopaterno(), 'empleado_apallidomaterno' => $empleado->getEmpleadoApallidomaterno(), 'empleado_email' => $empleado->getEmpleadoEmail(), 'empleado_estatus' => $empleado->getEmpleadoEstatus(), 'empleado_rol' => $empleado->getEmpleadoRol(), 'empleado_foto' => $empleado->getEmpleadoFoto()));
             return $this->redirect()->toRoute('admin');
         } else {
             return $this->redirect()->toRoute('admin/login');
         }
     } else {
         return $this->redirect()->toRoute('admin/login');
     }
 }
Exemplo n.º 2
0
 public function editarAction()
 {
     $id = $this->params()->fromRoute('id');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         //INSTANCIAMOS NUESTRA ENTIDAD
         $entity = \ClienteQuery::create()->findPk($id);
         //SETIAMOS NUESTROS DATOS CON EXCEPCIONES
         foreach ($post_data as $key => $value) {
             if (\ClientePeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'cliente_cumpleanios') {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         if (!empty($post_data['cliente_cumpleanios'])) {
             $cliente_cumpleanios = date_create_from_format('d/m/Y', $post_data['cliente_cumpleanios']);
             $entity->setClienteCumpleanios($cliente_cumpleanios);
         }
         $entity->save();
         //Agregamos un mensaje
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toRoute('admin/clientes/editar', array('id' => $entity->getIdcliente()));
     }
     $exist = \ClienteQuery::create()->filterByIdcliente($id)->exists();
     if ($exist) {
         $entity = \ClienteQuery::create()->findPk($id);
         $empleados = \EmpleadoQuery::create()->filterByIdempleado(1, \Criteria::NOT_EQUAL)->find();
         $empleados_array = array();
         $empleado = new \Empleado();
         foreach ($empleados as $empleado) {
             $id = $empleado->getIdempleado();
             $empleados_array[$id] = $empleado->getEmpleadoNombre() . ' ' . $empleado->getEmpleadoApellidopaterno() . ' ' . $empleado->getEmpleadoApallidomaterno();
         }
         $form = new \Admin\Clientes\Form\ClientesForm($empleados_array);
         $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME));
         //LOS ARCHIVOS
         $files = \ClientearchivoQuery::create()->filterByIdcliente($entity->getIdcliente())->find();
         $files_array = array();
         $file = new \Clientearchivo();
         foreach ($files as $file) {
             $file_path = $file->getClientearchivoArchivo();
             $file_name = explode('files/clientes/' . $entity->getIdcliente() . '/', $file->getClientearchivoArchivo());
             $tmp['id'] = $file->getIdclientearchivo();
             $tmp['name'] = $file_name[1];
             $tmp['size'] = $file->getClientearchivoSize();
             $tmp['type'] = mime_content_type($_SERVER['DOCUMENT_ROOT'] . '/' . $file->getClientearchivoArchivo());
             $files_array[] = $tmp;
         }
         //RETORNAMOS A NUESTRA VISTA
         $view_model = new ViewModel();
         $view_model->setTemplate('admin/clientes/clientes/editar');
         $view_model->setVariables(array('entity' => json_encode($entity->toArray(\BasePeer::TYPE_FIELDNAME)), 'successMessages' => json_encode($this->flashMessenger()->getSuccessMessages()), 'form' => $form, 'files' => json_encode($files_array)));
         return $view_model;
     } else {
         return $this->redirect()->toRoute('admin/clientes', array('action' => 'index'));
     }
 }
Exemplo n.º 3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @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(EmpleadoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = EmpleadoQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseEmpleado:delete:pre') as $callable) {
             if (call_user_func($callable, $this, $con)) {
                 $con->commit();
                 return;
             }
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             // symfony_behaviors behavior
             foreach (sfMixer::getCallables('BaseEmpleado:delete:post') as $callable) {
                 call_user_func($callable, $this, $con);
             }
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Privilegios is new, it will return
  * an empty collection; or if this Privilegios has previously
  * been saved, it will retrieve related Empleados 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 Privilegios.
  *
  * @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     PropelCollection|array Empleado[] List of Empleado objects
  */
 public function getEmpleadosJoinCiudadRelatedByIdProv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = EmpleadoQuery::create(null, $criteria);
     $query->joinWith('CiudadRelatedByIdProv', $join_behavior);
     return $this->getEmpleados($query, $con);
 }
Exemplo n.º 5
0
 /**
  * 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(EmpleadoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = EmpleadoQuery::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;
     }
 }
Exemplo n.º 6
0
 /**
  * Get the associated Empleado object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Empleado The associated Empleado object.
  * @throws PropelException
  */
 public function getEmpleado(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aEmpleado === null && $this->idempleado !== null && $doQuery) {
         $this->aEmpleado = EmpleadoQuery::create()->findPk($this->idempleado, $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->aEmpleado->addEmpleadofacturacions($this);
            */
     }
     return $this->aEmpleado;
 }
Exemplo n.º 7
0
 /**
  * Returns the number of related Empleado objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related Empleado objects.
  * @throws PropelException
  */
 public function countEmpleados(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collEmpleadosPartial && !$this->isNew();
     if (null === $this->collEmpleados || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collEmpleados) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getEmpleados());
         }
         $query = EmpleadoQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByRol($this)->count($con);
     }
     return count($this->collEmpleados);
 }
Exemplo n.º 8
0
 public function eliminarAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $id = $request->getPost('id');
         $entity = \EmpleadoQuery::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');
     /*
      * VALIDACIONES
      */
     //VALIDAMOS QUE EL EMPLEADO QUE SE QUIERE ELIMINAR NO TENGA ASIGNADO UN CLIENTE/EXPEDIENTE ASIGNADO
     $valid = true;
     if (\ClienteQuery::create()->filterByIdempleadocomercial($id)->exists()) {
         $valid = false;
     } elseif (\ClienteQuery::create()->filterByIdempleadooperaciones($id)->exists()) {
         $valid = false;
     }
     $viewModel = new ViewModel();
     $viewModel->setTerminal(true);
     $viewModel->setTemplate('admin/catalogo/empleado/eliminar');
     if (!$valid) {
         $viewModel->setTemplate('admin/catalogo/empleado/eliminar_error');
     }
     return $viewModel;
 }
Exemplo n.º 9
0
 public function eliminarAction()
 {
     $request = $this->getRequest();
     //Cachamos el valor desde nuestro params
     $id = (int) $this->params()->fromRoute('id');
     //Verificamos que el Id lugar que se quiere modificar exista
     if (!\EmpleadoQuery::create()->filterByIdempleado($id)->exists()) {
         $id = 0;
     }
     //Si es incorrecto redireccionavos al action nuevo
     if (!$id) {
         return $this->redirect()->toRoute('empleados', array('action' => 'nuevo'));
     }
     //Instanciamos nuestro lugar
     $entity = \EmpleadoQuery::create()->findPk($id);
     $entity->delete();
     //Agregamos un mensaje
     $this->flashMessenger()->addMessage('Empleado eliminado exitosamente!');
     //Redireccionamos a nuestro list
     return $this->redirect()->toRoute('empleados');
 }