コード例 #1
0
 /**
  * GENERA UN RECIBO BANCARIO POR CADA RECIBO DE CLIENTE    
  */
 static function RecibosIndividuales($filtro)
 {
     $recibos = new RecibosClientes();
     $clientes = new Clientes();
     $tablaRecibos = $recibos->getDataBaseName() . "." . $recibos->getTableName();
     $tablaClientes = $clientes->getDataBaseName() . "." . $clientes->getTableName();
     $em = new EntityManager($recibos->getConectionName());
     if ($em->getDbLink()) {
         $filtro .= " and (Remesar='1') and (CHAR_LENGTH(r.Iban)>23) and (r.Iban<>'ES8200000000000000000000') and (r.Importe>0)";
         $query = "select r.IDRecibo " . "from {$tablaRecibos} as r " . "left join {$tablaClientes} as c on r.IDCliente=c.IDCliente " . "where {$filtro} " . "order by c.RazonSocial,r.Vencimiento ASC";
         $em->query($query);
         $rows = $em->fetchResult();
     }
     unset($recibos);
     $total = 0;
     foreach ($rows as $row) {
         $recibo = new RecibosClientes($row['IDRecibo']);
         $cliente = $recibo->getIDCliente();
         $total += $recibo->getImporte();
         $recibos[] = array('numeroFactura' => $recibo->getIDFactura()->getNumeroFactura(), 'importe' => $recibo->getImporte(), 'idMandato' => $recibo->getMandato(), 'fechaMandato' => $recibo->getFechaMandato('aaaammdd'), 'bic' => $recibo->getBic() == '' ? "BBBBESPP" : $recibo->getBic(), 'iban' => $recibo->getIban(), 'razonSocial' => $cliente->getRazonSocial(), 'direccion1' => $cliente->getDireccion(), 'direccion2' => $cliente->getIDPoblacion()->getMunicipio() . " " . $cliente->getCodigoPostal() . " " . $cliente->getIDProvincia()->getProvincia(), 'pais' => $cliente->getIDPais()->getCodigo(), 'texto' => "Factura N. {$recibo->getIDFactura()->getNumeroFactura()} {$recibo->getIDFactura()->getFecha()} {$recibo->getImporte()}");
     }
     unset($cliente);
     unset($recibo);
     return array('nRecibos' => count($rows), 'importeTotal' => $total, 'recibos' => $recibos);
 }