/**
  * Filter the query by a related Empleado object
  *
  * @param   Empleado|PropelObjectCollection $empleado The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ExpedientearchivoQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByEmpleado($empleado, $comparison = null)
 {
     if ($empleado instanceof Empleado) {
         return $this->addUsingAlias(ExpedientearchivoPeer::IDEMPLEADO, $empleado->getIdempleado(), $comparison);
     } elseif ($empleado instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ExpedientearchivoPeer::IDEMPLEADO, $empleado->toKeyValue('PrimaryKey', 'Idempleado'), $comparison);
     } else {
         throw new PropelException('filterByEmpleado() only accepts arguments of type Empleado or PropelCollection');
     }
 }
Пример #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'));
     }
 }
Пример #3
0
 /**
  * Exclude object from result
  *
  * @param   Empleado $empleado Object to remove from the list of results
  *
  * @return EmpleadoQuery The current query, for fluid interface
  */
 public function prune($empleado = null)
 {
     if ($empleado) {
         $this->addUsingAlias(EmpleadoPeer::IDEMPLEADO, $empleado->getIdempleado(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Пример #4
0
 /**
  * Declares an association between this object and a Empleado object.
  *
  * @param                  Empleado $v
  * @return Empleadofacturacion The current object (for fluent API support)
  * @throws PropelException
  */
 public function setEmpleado(Empleado $v = null)
 {
     if ($v === null) {
         $this->setIdempleado(NULL);
     } else {
         $this->setIdempleado($v->getIdempleado());
     }
     $this->aEmpleado = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Empleado object, it will not be re-added.
     if ($v !== null) {
         $v->addEmpleadofacturacion($this);
     }
     return $this;
 }
Пример #5
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Empleado $obj A Empleado object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getIdempleado();
         }
         // if key === null
         EmpleadoPeer::$instances[$key] = $obj;
     }
 }
Пример #6
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));
     }
 }