public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'expediente_folio', 1 => 'expediente_fechainicio', 2 => 'expediente_tipo', 3 => 'expediente_consignatario', 4 => 'expediente_embarcador', 5 => 'expediente_estatus');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \ExpedienteQuery();
         $query->joinCliente()->withColumn('cliente_razonsocial');
         $query->joinProveedorcliente()->withColumn('proveedorcliente_nombre');
         //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->orderByIdexpediente(\Criteria::DESC);
         }
         if (!empty($post_data['search']['value'])) {
             $search = $post_data['search']['value'];
             $c = new \Criteria();
             $c1 = $c->getNewCriterion('expediente.expediente_folio', '%' . $search . '%', \Criteria::LIKE);
             //$c2= $c->getNewCriterion('expediente.expediente_fechainicio', '%'.$search.'%', \Criteria::LIKE);
             $c3 = $c->getNewCriterion('expediente.expediente_tipo', '%' . $search . '%', \Criteria::LIKE);
             $c4 = $c->getNewCriterion('expediente.expediente_estatus', '%' . $search . '%', \Criteria::LIKE);
             $c5 = $c->getNewCriterion('cliente.cliente_razonsocial', '%' . $search . '%', \Criteria::LIKE);
             $c6 = $c->getNewCriterion('proveedorcliente.proveedorcliente_nombre', '%' . $search . '%', \Criteria::LIKE);
             $c1->addOr($c3)->addOr($c4)->addOr($c5)->addOr($c6);
             $query->addAnd($c1);
         }
         //EL TOTAL DE LA BUSQUEDA
         $recordsFiltered = $query->count();
         //LIMIT
         $query->setOffset((int) $post_data['start']);
         $query->setLimit((int) $post_data['length']);
         //DAMOS EL FORMATO CORRECTO
         $data = array();
         $value = new \Expediente();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdexpediente();
             $tmp['expediente_folio'] = $value->getExpedienteFolio('d/m/Y');
             $tmp['expediente_fechainicio'] = $value->getExpedienteFechainicio('d/m/Y');
             $tmp['expediente_tipo'] = $value->getExpedienteTipo();
             $tmp['expediente_estatus'] = ucfirst($value->getExpedienteEstatus());
             if ($value->getExpedienteTipo() == 'importacion') {
                 $tmp['expediente_consignatario'] = $value->getCliente()->getClienteRazonsocial();
                 $tmp['expediente_embarcador'] = $value->getProveedorcliente()->getProveedorclienteNombre();
             } else {
                 $tmp['expediente_embarcador'] = $value->getCliente()->getClienteRazonsocial();
                 $tmp['expediente_consignatario'] = $value->getProveedorcliente()->getProveedorclienteNombre();
             }
             $tmp['expediente_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/clientes/ver/' . $value->getIdcliente() . '/expedientes/ver/' . $value->getIdexpediente() . '"><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));
     }
 }
 /**
  * Filter the query by a related Expediente object
  *
  * @param   Expediente|PropelObjectCollection $expediente The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ExpedienteanticipoQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByExpediente($expediente, $comparison = null)
 {
     if ($expediente instanceof Expediente) {
         return $this->addUsingAlias(ExpedienteanticipoPeer::IDEXPEDIENTE, $expediente->getIdexpediente(), $comparison);
     } elseif ($expediente instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ExpedienteanticipoPeer::IDEXPEDIENTE, $expediente->toKeyValue('PrimaryKey', 'Idexpediente'), $comparison);
     } else {
         throw new PropelException('filterByExpediente() only accepts arguments of type Expediente or PropelCollection');
     }
 }
示例#3
0
 /**
  * Exclude object from result
  *
  * @param   Expediente $expediente Object to remove from the list of results
  *
  * @return ExpedienteQuery The current query, for fluid interface
  */
 public function prune($expediente = null)
 {
     if ($expediente) {
         $this->addUsingAlias(ExpedientePeer::IDEXPEDIENTE, $expediente->getIdexpediente(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
示例#4
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 Expediente $obj A Expediente 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->getIdexpediente();
         }
         // if key === null
         ExpedientePeer::$instances[$key] = $obj;
     }
 }
 public function nuevoAction()
 {
     $request = $this->getRequest();
     $idcliente = $this->params()->fromRoute('id');
     $cliente = \ClienteQuery::create()->findPk($idcliente);
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $entity = new \Expediente();
         foreach ($post_data as $key => $value) {
             if (\ExpedientePeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'cliente_cumpleanios') {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //LA FECHA DE APERTURA
         $entity->setExpedienteFechainicio(new \DateTime());
         //EL ESTATUS
         $entity->setExpedienteEstatus('abierto');
         $date = new \DateTime();
         $entity->save();
         //CREAMOS EL FOLIO
         $folio = 'ITR' . $date->format('m') . $date->format('y');
         if ((int) $entity->getIdexpediente() < 10) {
             $folio .= '0';
         }
         $folio .= $entity->getIdexpediente();
         $entity->setExpedienteFolio($folio);
         $entity->save();
         $mailer = new \Shared\GeneralFunction\Itrademailer();
         if ($mailer->newExpedienteEmail($cliente, $folio)) {
             $this->flashMessenger()->addSuccessMessage('Correo electronico enviado exitosamente!');
         }
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toUrl('/clientes/ver/' . $idcliente . '/expedientes/ver/' . $entity->getIdexpediente());
     }
     $form = new \Admin\Clientes\Form\ExpedienteForm($idcliente);
     $view_model = new ViewModel();
     $view_model->setTemplate('admin/clientes/expedientes/nuevo');
     $view_model->setVariable('form', $form);
     $view_model->setVariable('cliente', $cliente);
     return $view_model;
 }
 /**
  * Declares an association between this object and a Expediente object.
  *
  * @param                  Expediente $v
  * @return Expedientearchivo The current object (for fluent API support)
  * @throws PropelException
  */
 public function setExpediente(Expediente $v = null)
 {
     if ($v === null) {
         $this->setIdexpediente(NULL);
     } else {
         $this->setIdexpediente($v->getIdexpediente());
     }
     $this->aExpediente = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Expediente object, it will not be re-added.
     if ($v !== null) {
         $v->addExpedientearchivo($this);
     }
     return $this;
 }