#include <informereferencia.h>
Public Member Functions | |
| InformeCliente (Company *) | |
| ~InformeCliente () | |
| void | setCliente (QString) |
| Establece el identificador del cliente a partir del cual generar el informe. | |
| void | generarInforme () |
Private Attributes | |
| QString | m_idcliente |
| Company * | companyact |
Definition at line 48 of file informereferencia.h.
| InformeCliente::InformeCliente | ( | Company * | comp | ) |
| comp |
Definition at line 299 of file informereferencia.cpp.
References _depura(), and companyact.
00299 { 00300 _depura("InformeCliente::InformeCliente", 0); 00301 companyact = comp; 00302 _depura("END InformeCliente::InformeCliente", 0); 00303 }
| InformeCliente::~InformeCliente | ( | ) |
Definition at line 309 of file informereferencia.cpp.
References _depura().
00309 { 00310 _depura("InformeCliente::~InformeCliente", 0); 00311 _depura("END InformeCliente::~InformeCliente", 0); 00312 }
| void InformeCliente::setCliente | ( | QString | val | ) |
Establece el identificador del cliente a partir del cual generar el informe.
| val | el valor del identificador de cliente. |
Definition at line 319 of file informereferencia.cpp.
References _depura(), and m_idcliente.
Referenced by ClienteView::on_mui_informe_clicked().
00319 { 00320 _depura("InformeCliente::setCliente", 0); 00321 m_idcliente = val; 00322 _depura("END InformeCliente::setCliente", 0); 00323 }
| void InformeCliente::generarInforme | ( | ) |
Definition at line 329 of file informereferencia.cpp.
References _depura(), postgresiface2::cargacursor(), coma, companyact, CONF_DIR_OPENREPORTS, CONF_DIR_USER, confpr, cursor2::eof(), invocaPDF(), m_idcliente, cursor2::siguienteregistro(), cursor2::valor(), and configuracion::valor().
Referenced by ClienteView::on_mui_informe_clicked().
00329 { 00330 _depura("InformeCliente::generarInforme", 0); 00331 QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) + "informecliente.rml"; 00332 QString archivod = confpr->valor(CONF_DIR_USER) + "informecliente.rml"; 00333 QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg"; 00335 #ifdef WINDOWS 00336 00337 archivo = "copy " + archivo + " " + archivod; 00338 #else 00339 00340 archivo = "cp " + archivo + " " + archivod; 00341 #endif 00342 00343 system(archivo.toAscii().constData()); 00345 #ifdef WINDOWS 00346 00347 archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg"; 00348 #else 00349 00350 archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg"; 00351 #endif 00352 00353 QFile file; 00354 file.setFileName(archivod); 00355 file.open(QIODevice::ReadOnly); 00356 QTextStream stream(&file); 00357 QString buff = stream.readAll(); 00358 file.close(); 00359 QString fitxersortidatxt = ""; 00360 00362 QString SQLQuery = "SELECT * FROM cliente WHERE idcliente = " + m_idcliente; 00363 cursor2 *cur = companyact->cargacursor(SQLQuery); 00364 while (!cur->eof() ) { 00365 buff.replace("[nomcliente]", cur->valor("nomcliente")); 00366 buff.replace("[telcliente]", cur->valor("telcliente")); 00367 buff.replace("[dircliente]", cur->valor("dircliente")); 00368 buff.replace("[poblcliente]", cur->valor("poblcliente")); 00369 cur->siguienteregistro(); 00370 } // end while 00371 delete cur; 00372 00374 QString referencias = "("; 00375 QString coma = ""; 00376 SQLQuery = "SELECT refpresupuesto AS referencia FROM presupuesto WHERE idcliente = " + m_idcliente; 00377 SQLQuery += " UNION SELECT refpedidocliente AS referencia FROM pedidocliente WHERE idcliente = " + m_idcliente; 00378 SQLQuery += " UNION SELECT refalbaran FROM albaran AS referencia WHERE idcliente = " + m_idcliente; 00379 SQLQuery += " UNION SELECT reffactura FROM factura AS referencia WHERE idcliente = " + m_idcliente; 00380 SQLQuery += " UNION SELECT refcobro FROM cobro AS referencia WHERE idcliente = " + m_idcliente; 00381 cur = companyact->cargacursor(SQLQuery); 00382 if (cur->eof()) { 00383 delete cur; 00384 return; 00385 } // end if 00386 while (!cur->eof() ) { 00387 referencias += coma + "'" + cur->valor("referencia") + "' "; 00388 coma = ","; 00389 cur->siguienteregistro(); 00390 } 00391 delete cur; 00392 referencias += ")"; 00393 00395 fitxersortidatxt = "<spacer length=\"15\"/>"; 00396 fitxersortidatxt += "<para>Resumen de ventas por articulo</para>\n"; 00397 fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"9cm, 2.5cm, 2.5cm, 2.5cm, 2.5cm\" repeatRows=\"1\">\n"; 00398 fitxersortidatxt += "<tr>\n"; 00399 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Articulo") + "</td>\n"; 00400 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pres.") + "</td>\n"; 00401 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pedido") + "</td>\n"; 00402 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Entregado") + "</td>\n"; 00403 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Facturado") + "</td>\n"; 00404 fitxersortidatxt += "</tr>\n"; 00405 00406 SQLQuery = " SELECT * FROM articulo "; 00407 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpresupuesto) AS cantlpresupuestot FROM lpresupuesto WHERE idpresupuesto IN (SELECT idpresupuesto FROM presupuesto WHERE refpresupuesto IN " + referencias + ") GROUP BY idarticulo) AS t1 ON t1.idarticulo = articulo.idarticulo "; 00408 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidocliente) AS cantlpedidoclientet FROM lpedidocliente WHERE idpedidocliente IN (SELECT idpedidocliente FROM pedidocliente WHERE refpedidocliente IN " + referencias + ") GROUP BY idarticulo) AS t2 ON t2.idarticulo = articulo.idarticulo "; 00409 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaran) AS cantlalbarant FROM lalbaran WHERE idalbaran IN (SELECT idalbaran FROM albaran WHERE refalbaran IN " + referencias + ") GROUP BY idarticulo) AS t3 ON t3.idarticulo = articulo.idarticulo "; 00410 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfactura) AS cantlfacturat FROM lfactura WHERE idfactura IN (SELECT idfactura FROM factura WHERE reffactura IN " + referencias + ") GROUP BY idarticulo) AS t4 ON t4.idarticulo = articulo.idarticulo "; 00411 SQLQuery += " WHERE (cantlpresupuestot <> 0 OR cantlpedidoclientet <> 0 OR cantlalbarant <> 0 OR cantlfacturat <> 0) "; 00412 cur = companyact->cargacursor(SQLQuery); 00413 while (!cur->eof() ) { 00414 fitxersortidatxt += "<tr>\n"; 00415 fitxersortidatxt += "<td>" + cur->valor("nomarticulo") + "</td>\n"; 00416 fitxersortidatxt += "<td>" + cur->valor("cantlpresupuestot") + "</td>\n"; 00417 fitxersortidatxt += "<td>" + cur->valor("cantlpedidoclientet") + "</td>\n"; 00418 fitxersortidatxt += "<td>" + cur->valor("cantlalbarant") + "</td>\n"; 00419 fitxersortidatxt += "<td>" + cur->valor("cantlfacturat") + "</td>\n"; 00420 fitxersortidatxt += "</tr>\n"; 00421 cur->siguienteregistro(); 00422 } // end while 00423 delete cur; 00424 00425 fitxersortidatxt += "</blockTable>\n"; 00426 00428 fitxersortidatxt += "<spacer length=\"15\"/>"; 00429 fitxersortidatxt += "<para>Resumen de compras por articulo</para>\n"; 00430 fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"10cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n"; 00431 fitxersortidatxt += "<tr>\n"; 00432 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Articulo") + "</td>\n"; 00433 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pedido") + "</td>\n"; 00434 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Entregado") + "</td>\n"; 00435 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Facturado") + "</td>\n"; 00436 fitxersortidatxt += "</tr>\n"; 00437 00438 SQLQuery = " SELECT * FROM articulo "; 00439 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidoproveedor) AS cantlpedidoproveedort FROM lpedidoproveedor WHERE idpedidoproveedor IN (SELECT idpedidoproveedor FROM pedidoproveedor WHERE refpedidoproveedor IN " + referencias + ") GROUP BY idarticulo) AS t2 ON t2.idarticulo = articulo.idarticulo "; 00440 00441 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaranp) AS cantlalbaranpt FROM lalbaranp WHERE idalbaranp IN (SELECT idalbaranp FROM albaranp WHERE refalbaranp IN " + referencias + ") GROUP BY idarticulo) AS t3 ON t3.idarticulo = articulo.idarticulo "; 00442 00443 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfacturap) AS cantlfacturapt FROM lfacturap WHERE idfacturap IN (SELECT idfacturap FROM facturap WHERE reffacturap IN " + referencias + ") GROUP BY idarticulo) AS t4 ON t4.idarticulo = articulo.idarticulo "; 00444 SQLQuery += " WHERE ( cantlpedidoproveedort <> 0 OR cantlalbaranpt <> 0 OR cantlfacturapt <> 0) "; 00445 00446 fprintf(stdout,"%s\n",SQLQuery.toAscii().constData()); 00447 00448 cur = companyact->cargacursor(SQLQuery); 00449 while (!cur->eof() ) { 00450 fitxersortidatxt += "<tr>\n"; 00451 fitxersortidatxt += " <td>" + cur->valor("nomarticulo") + "</td>\n"; 00452 fitxersortidatxt += " <td>" + cur->valor("cantlpedidoproveedort") + "</td>\n"; 00453 fitxersortidatxt += " <td>" + cur->valor("cantlalbaranpt") + "</td>\n"; 00454 fitxersortidatxt += " <td>" + cur->valor("cantlfacturapt") + "</td>\n"; 00455 fitxersortidatxt += "</tr>\n"; 00456 cur->siguienteregistro(); 00457 } // end while 00458 delete cur; 00459 00460 fitxersortidatxt += "</blockTable>\n"; 00461 00462 00463 buff.replace("[story]", fitxersortidatxt); 00464 00465 fitxersortidatxt = "<spacer length=\"15\"/>"; 00467 fitxersortidatxt += "<para>Totales ventas</para>\n"; 00468 fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\"3cm, 3cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n"; 00469 fitxersortidatxt += "<tr>\n"; 00470 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pres.") + "</td>\n"; 00471 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pedido") + "</td>\n"; 00472 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Entregado") + "</td>\n"; 00473 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Facturado") + "</td>\n"; 00474 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Cobrado") + "</td>\n"; 00475 fitxersortidatxt += "</tr>\n"; 00476 00478 fitxersortidatxt += "<tr>\n"; 00479 00481 SQLQuery = "SELECT SUM(totalpresupuesto) AS tpres FROM presupuesto WHERE refpresupuesto IN " + referencias; 00482 cur = companyact->cargacursor(SQLQuery); 00483 fitxersortidatxt += " <td>" + cur->valor("tpres") + "</td>\n"; 00484 delete cur; 00485 00487 SQLQuery = "SELECT SUM(totalpedidocliente) AS tpedcli FROM pedidocliente WHERE refpedidocliente IN " + referencias; 00488 cur = companyact->cargacursor(SQLQuery); 00489 fitxersortidatxt += " <td>" + cur->valor("tpedcli") + "</td>\n"; 00490 delete cur; 00491 00493 SQLQuery = "SELECT SUM(totalalbaran) AS talb FROM albaran WHERE refalbaran IN " + referencias; 00494 cur = companyact->cargacursor(SQLQuery); 00495 fitxersortidatxt += " <td>" + cur->valor("talb") + "</td>\n"; 00496 delete cur; 00497 00499 SQLQuery = "SELECT SUM(totalfactura) AS tfact FROM factura WHERE reffactura IN " + referencias; 00500 cur = companyact->cargacursor(SQLQuery); 00501 fitxersortidatxt += " <td>" + cur->valor("tfact") + "</td>\n"; 00502 delete cur; 00503 00505 SQLQuery = "SELECT SUM(cantcobro) AS tcobro FROM cobro WHERE refcobro IN " + referencias; 00506 cur = companyact->cargacursor(SQLQuery); 00507 fitxersortidatxt += " <td>" + cur->valor("tcobro") + "</td>\n"; 00508 delete cur; 00509 00510 fitxersortidatxt += "</tr>\n"; 00511 fitxersortidatxt += "</blockTable>\n"; 00512 00513 fitxersortidatxt += "<spacer length=\"15\"/>"; 00515 fitxersortidatxt += "<para>Totales compras</para>\n"; 00516 fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\" 4cm, 4cm, 4cm, 3cm\" repeatRows=\"1\">\n"; 00517 fitxersortidatxt += "<tr>\n"; 00518 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pedido") + "</td>\n"; 00519 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Entregado") + "</td>\n"; 00520 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Facturado") + "</td>\n"; 00521 fitxersortidatxt += " <td>" + QApplication::translate("InformeCliente", "Pagado") + "</td>\n"; 00522 fitxersortidatxt += "</tr>\n"; 00523 00525 fitxersortidatxt += "<tr>\n"; 00526 00528 SQLQuery = "SELECT SUM(totalpedidoproveedor) AS tpedpro FROM pedidoproveedor WHERE refpedidoproveedor IN " + referencias; 00529 cur = companyact->cargacursor(SQLQuery); 00530 fitxersortidatxt += " <td>" + cur->valor("tpedpro") + "</td>\n"; 00531 delete cur; 00532 00534 SQLQuery = "SELECT SUM(totalalbaranp) AS talbp FROM albaranp WHERE refalbaranp IN " + referencias; 00535 cur = companyact->cargacursor(SQLQuery); 00536 fitxersortidatxt += " <td>" + cur->valor("talbp") + "</td>\n"; 00537 delete cur; 00538 00540 SQLQuery = "SELECT SUM(totalfacturap) AS tfactp FROM facturap WHERE reffacturap IN " + referencias; 00541 cur = companyact->cargacursor(SQLQuery); 00542 fitxersortidatxt += " <td>" + cur->valor("tfactp") + "</td>\n"; 00543 delete cur; 00544 00546 SQLQuery = "SELECT SUM(cantpago) AS tpago FROM pago WHERE refpago IN " + referencias; 00547 cur = companyact->cargacursor(SQLQuery); 00548 fitxersortidatxt += " <td>" + cur->valor("tpago") + "</td>\n"; 00549 delete cur; 00550 00551 fitxersortidatxt += "</tr>\n"; 00552 fitxersortidatxt += "</blockTable>\n"; 00553 00554 00555 buff.replace("[totales]", fitxersortidatxt); 00556 00557 00558 if (file.open(QIODevice::WriteOnly)) { 00559 QTextStream stream(&file); 00560 stream << buff; 00561 file.close(); 00562 } // end if 00563 invocaPDF("informecliente"); 00564 _depura("END InformeCliente::generarInforme", 0); 00565 }
QString InformeCliente::m_idcliente [private] |
Definition at line 50 of file informereferencia.h.
Referenced by generarInforme(), and setCliente().
Company* InformeCliente::companyact [private] |
Definition at line 51 of file informereferencia.h.
Referenced by generarInforme(), and InformeCliente().
1.5.1