Ejemplo 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');
     }
 }
Ejemplo 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'));
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns a new EmpleadoQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   EmpleadoQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return EmpleadoQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof EmpleadoQuery) {
         return $criteria;
     }
     $query = new EmpleadoQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 6
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;
     }
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'empleado_nombre', 1 => 'empleado_email', 2 => 'empleado_celular', 3 => 'empleado_rol');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \EmpleadoQuery();
         $query->filterByIdempleado(1, \Criteria::NOT_EQUAL);
         //ORDER
         if (isset($post_data['order'])) {
             $order = $table_map[$post_data['order'][0]['column']];
             $dir = $post_data['order'][0]['dir'];
             $query->orderBy($order, $dir);
         } else {
             $query->orderByIdempleado(\Criteria::DESC);
         }
         if (!empty($post_data['search']['value'])) {
             $search = $post_data['search']['value'];
             $c = new \Criteria();
             $c1 = $c->getNewCriterion('empleado.empleado_nombre', '%' . $search . '%', \Criteria::LIKE);
             $c2 = $c->getNewCriterion('empleado.empleado_apallidomaterno', '%' . $search . '%', \Criteria::LIKE);
             $c3 = $c->getNewCriterion('empleado.empleado_apellidopaterno', '%' . $search . '%', \Criteria::LIKE);
             $c4 = $c->getNewCriterion('empleado.empleado_celular', '%' . $search . '%', \Criteria::LIKE);
             $c5 = $c->getNewCriterion('empleado.empleado_rol', '%' . $search . '%', \Criteria::LIKE);
             $c1->addOr($c2)->addOr($c3)->addOr($c4)->addOr($c5);
             $query->addAnd($c1);
         }
         //EL TOTAL DE LA BUSQUEDA
         $recordsFiltered = $query->count();
         //SUSTITUIMOS VARIABLES SI NOS LAS ENVIAN POR LA URL
         if (isset($post_data['url_params']['limit']) && isset($post_data['url_params']['page'])) {
             $post_data['length'] = (int) $post_data['url_params']['limit'];
             $post_data['start'] = 0;
             if ((int) $post_data['url_params']['page'] > 1) {
                 $post_data['start'] = $post_data['url_params']['limit'] * ((int) $post_data['url_params']['page'] - 1);
             }
         }
         //LIMIT
         $query->setOffset((int) $post_data['start']);
         $query->setLimit((int) $post_data['length']);
         //DAMOS EL FORMATO CORRECTO
         $data = array();
         $value = new \Empleado();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdempleado();
             $tmp['empleado_nombre'] = $value->getEmpleadoNombre() . ' ' . $value->getEmpleadoApellidopaterno() . ' ' . $value->getEmpleadoApallidomaterno();
             $tmp['empleado_email'] = $value->getEmpleadoEmail();
             $tmp['empleado_celular'] = $value->getEmpleadoCelular();
             $tmp['empleado_rol'] = ucfirst($value->getEmpleadoRol());
             $tmp['empleado_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/catalogo/empleados/editar/' . $value->getIdempleado() . '"><i class="fa fa-pencil"></i></a><a class="delete" data-toggle="tooltip" data-placement="left" title="Eliminar" href="javascript:void(0)"><i class="fa fa-trash-o"></i></a>';
             $data[] = $tmp;
         }
         //El arreglo que regresamos
         $json_data = array("draw" => (int) $post_data['draw'], "recordsFiltered" => $recordsFiltered, "data" => $data, "page" => $post_data['url_params']['page']);
         return $this->getResponse()->setContent(json_encode($json_data));
     }
 }
Ejemplo n.º 10
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');
 }