InformeQToolButton Class Reference

#include <informeqtoolbutton.h>

Inheritance diagram for InformeQToolButton:

QToolButton PEmpresaBase

Public Slots

virtual void click ()

Public Member Functions

 InformeQToolButton (ClientsList *, QWidget *parent=NULL)
 ~InformeQToolButton ()
void setBoton ()
QString generarCliente (QString idcliente)

Private Attributes

ClientsListm_clientsList

Detailed Description

Definition at line 37 of file informeqtoolbutton.h.


Constructor & Destructor Documentation

InformeQToolButton::InformeQToolButton ( ClientsList art,
QWidget parent = NULL 
)

Parameters:
art 
parent 

Definition at line 50 of file informeqtoolbutton.cpp.

References _depura(), m_clientsList, and setBoton().

00050                                                                          : QToolButton(parent), PEmpresaBase() {
00051     _depura("InformeQToolButton::InformeQToolButton", 0);
00052     m_clientsList = art;
00053     setBoton();
00054     _depura("END InformeQToolButton::InformeQToolButton", 0);
00055 }

InformeQToolButton::~InformeQToolButton (  ) 

Definition at line 61 of file informeqtoolbutton.cpp.

References _depura().

00061                                         {
00062     _depura("InformeQToolButton::~InformeQToolButton", 0);
00063     _depura("END InformeQToolButton::~InformeQToolButton", 0);
00064 }


Member Function Documentation

void InformeQToolButton::setBoton (  ) 

Definition at line 70 of file informeqtoolbutton.cpp.

References _depura(), and click().

Referenced by InformeQToolButton().

00070                                   {
00071     _depura("InformeQToolButton::setBoton", 0);
00072     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00073     setObjectName(QString::fromUtf8("exporta"));
00074     setStatusTip("Imprimir Catalogo");
00075     setToolTip("Imprimir Catalogo");
00076     setMinimumSize(QSize(32, 32));
00077     setIcon(QIcon(QString::fromUtf8("/usr/share/bulmages/icons/catalogo.png")));
00078     setIconSize(QSize(22, 22));
00079     _depura("END InformeQToolButton::setBoton", 0);
00080 }

QString InformeQToolButton::generarCliente ( QString  idcliente  ) 

Parameters:
idcliente 
Returns:

Sacamos todas las referencias de este cliente y las guardamos en el string referencias

Generacion del informe de ventas.

Generacion del informe de compras.

Generacion del informe de totales de ventas.

Calculo de las cantidades totales en moneda.

Total presupuestado.

Total pedido.

Total trabajado.

Total facturado.

Total cobrado.

Generacion del informe de totales de compras.

Calculo de las cantidades totales en moneda.

Total pedido.

Total trabajado.

Total facturado.

Total cobrado.

Definition at line 157 of file informeqtoolbutton.cpp.

References _depura(), postgresiface2::cargacursor(), coma, PEmpresaBase::empresaBase(), cursor2::eof(), cursor2::siguienteregistro(), and cursor2::valor().

Referenced by click().

00157                                                             {
00158     _depura("InformeQToolButton::generarCliente", 0);
00159     QString fitxersortidatxt;
00161     QString referencias = "(";
00162     QString coma = "";
00163     QString SQLQuery = "SELECT refpresupuesto AS referencia FROM presupuesto WHERE idcliente = " + idcliente;
00164     SQLQuery += " UNION SELECT refpedidocliente AS referencia FROM pedidocliente WHERE idcliente = " + idcliente;
00165     SQLQuery += " UNION SELECT refalbaran FROM albaran AS referencia WHERE idcliente = " + idcliente;
00166     SQLQuery += " UNION SELECT reffactura FROM factura AS referencia WHERE idcliente = " + idcliente;
00167     SQLQuery += " UNION SELECT refcobro FROM cobro AS referencia WHERE idcliente = " + idcliente;
00168     cursor2 *cur = empresaBase()->cargacursor(SQLQuery);
00169     if (cur->eof()) {
00170         delete cur;
00171         return "";
00172     } // end if
00173     while (!cur->eof() ) {
00174         referencias += coma + "'" + cur->valor("referencia") + "' ";
00175         coma = ",";
00176         cur->siguienteregistro();
00177     } 
00178     delete cur;
00179     referencias += ")";
00180 
00182     fitxersortidatxt = "<spacer length=\"15\"/>";
00183     fitxersortidatxt += "<para>Resumen de ventas por articulo</para>\n";
00184     fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"9cm, 2.5cm, 2.5cm, 2.5cm, 2.5cm\" repeatRows=\"1\">\n";
00185     fitxersortidatxt += "<tr>\n";
00186     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Articulo") + "</td>\n";
00187     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pres.") + "</td>\n";
00188     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pedido") + "</td>\n";
00189     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Entregado") + "</td>\n";
00190     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Facturado") + "</td>\n";
00191     fitxersortidatxt += "</tr>\n";
00192 
00193     SQLQuery = " SELECT * FROM articulo ";
00194     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 ";
00195     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 ";
00196     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 ";
00197     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 ";
00198     SQLQuery += " WHERE  (cantlpresupuestot <>0 OR cantlpedidoclientet <> 0 OR cantlalbarant <> 0 OR cantlfacturat <> 0) ";
00199     cur = empresaBase()->cargacursor(SQLQuery);
00200     while (!cur->eof() ) {
00201         fitxersortidatxt += "<tr>\n";
00202         fitxersortidatxt += "    <td>" + cur->valor("nomarticulo") + "</td>\n";
00203         fitxersortidatxt += "    <td>" + cur->valor("cantlpresupuestot") + "</td>\n";
00204         fitxersortidatxt += "    <td>" + cur->valor("cantlpedidoclientet") + "</td>\n";
00205         fitxersortidatxt += "    <td>" + cur->valor("cantlalbarant") + "</td>\n";
00206         fitxersortidatxt += "    <td>" + cur->valor("cantlfacturat") + "</td>\n";
00207         fitxersortidatxt += "</tr>\n";
00208         cur->siguienteregistro();
00209     } // end while
00210     delete cur;
00211 
00212     fitxersortidatxt += "</blockTable>\n";
00213 
00215     fitxersortidatxt += "<spacer length=\"15\"/>";
00216     fitxersortidatxt += "<para>Resumen de compras por articulo</para>\n";
00217     fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"10cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n";
00218     fitxersortidatxt += "<tr>\n";
00219     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Articulo") + "</td>\n";
00220     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pedido") + "</td>\n";
00221     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Entregado") + "</td>\n";
00222     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Facturado") + "</td>\n";
00223     fitxersortidatxt += "</tr>\n";
00224 
00225     SQLQuery = " SELECT * FROM articulo ";
00226     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 ";
00227 
00228     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 ";
00229 
00230     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 ";
00231     SQLQuery += " WHERE  ( cantlpedidoproveedort <> 0 OR cantlalbaranpt <> 0 OR cantlfacturapt <> 0) ";
00232 
00233     cur = empresaBase()->cargacursor(SQLQuery);
00234     while (!cur->eof() ) {
00235         fitxersortidatxt += "<tr>\n";
00236         fitxersortidatxt += "    <td>" + cur->valor("nomarticulo") + "</td>\n";
00237         fitxersortidatxt += "    <td>" + cur->valor("cantlpedidoproveedort") + "</td>\n";
00238         fitxersortidatxt += "    <td>" + cur->valor("cantlalbaranpt") + "</td>\n";
00239         fitxersortidatxt += "    <td>" + cur->valor("cantlfacturapt") + "</td>\n";
00240         fitxersortidatxt += "</tr>\n";
00241         cur->siguienteregistro();
00242     } // end while
00243     delete cur;
00244 
00245     fitxersortidatxt += "</blockTable>\n";
00246 
00247     fitxersortidatxt += "<spacer length=\"15\"/>";
00249     fitxersortidatxt += "<para>Totales ventas</para>\n";
00250     fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\"3cm, 3cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n";
00251     fitxersortidatxt += "<tr>\n";
00252     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pres.") + "</td>\n";
00253     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pedido") + "</td>\n";
00254     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Entregado") + "</td>\n";
00255     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Facturado") + "</td>\n";
00256     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Cobrado") + "</td>\n";
00257     fitxersortidatxt += "</tr>\n";
00258 
00260     fitxersortidatxt += "<tr>\n";
00261 
00263     SQLQuery = "SELECT SUM(totalpresupuesto) AS tpres FROM presupuesto WHERE refpresupuesto IN " + referencias;
00264     cur = empresaBase()->cargacursor(SQLQuery);
00265     fitxersortidatxt += "    <td>" + cur->valor("tpres") + "</td>\n";
00266     delete cur;
00267 
00269     SQLQuery = "SELECT SUM(totalpedidocliente) AS tpedcli FROM pedidocliente WHERE refpedidocliente IN " + referencias;
00270     cur = empresaBase()->cargacursor(SQLQuery);
00271     fitxersortidatxt += "    <td>" + cur->valor("tpedcli") + "</td>\n";
00272     delete cur;
00273 
00275     SQLQuery = "SELECT SUM(totalalbaran) AS talb FROM albaran WHERE refalbaran IN " + referencias;
00276     cur = empresaBase()->cargacursor(SQLQuery);
00277     fitxersortidatxt += "    <td>" + cur->valor("talb") + "</td>\n";
00278     delete cur;
00279 
00281     SQLQuery = "SELECT SUM(totalfactura) AS tfact FROM factura WHERE reffactura IN " + referencias;
00282     cur = empresaBase()->cargacursor(SQLQuery);
00283     fitxersortidatxt += "    <td>" + cur->valor("tfact") + "</td>\n";
00284     delete cur;
00285 
00287     SQLQuery = "SELECT SUM(cantcobro) AS tcobro FROM cobro WHERE refcobro IN " + referencias;
00288     cur = empresaBase()->cargacursor(SQLQuery);
00289     fitxersortidatxt += "     <td>" + cur->valor("tcobro") + "</td>\n";
00290     delete cur;
00291 
00292     fitxersortidatxt += "</tr>\n";
00293     fitxersortidatxt += "</blockTable>\n";
00294 
00295     fitxersortidatxt += "<spacer length=\"15\"/>";
00297     fitxersortidatxt += "<para>Totales compras</para>\n";
00298     fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\" 4cm, 4cm, 4cm, 3cm\" repeatRows=\"1\">\n";
00299     fitxersortidatxt += "<tr>\n";
00300     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pedido") + "</td>\n";
00301     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Entregado") + "</td>\n";
00302     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Facturado") + "</td>\n";
00303     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Pagado") + "</td>\n";
00304     fitxersortidatxt += "</tr>\n";
00305 
00307     fitxersortidatxt += "<tr>\n";
00308 
00310     SQLQuery = "SELECT SUM(totalpedidoproveedor) AS tpedpro FROM pedidoproveedor WHERE refpedidoproveedor IN " + referencias;
00311     cur = empresaBase()->cargacursor(SQLQuery);
00312     fitxersortidatxt += "    <td>" + cur->valor("tpedpro") + "</td>\n";
00313     delete cur;
00314 
00316     SQLQuery = "SELECT SUM(totalalbaranp) AS talbp FROM albaranp WHERE refalbaranp IN " + referencias;
00317     cur = empresaBase()->cargacursor(SQLQuery);
00318     fitxersortidatxt += "    <td>" + cur->valor("talbp") + "</td>\n";
00319     delete cur;
00320 
00322     SQLQuery = "SELECT SUM(totalfacturap) AS tfactp FROM facturap WHERE reffacturap IN " + referencias;
00323     cur = empresaBase()->cargacursor(SQLQuery);
00324     fitxersortidatxt += "    <td>" + cur->valor("tfactp") + "</td>\n";
00325     delete cur;
00326 
00328     SQLQuery = "SELECT SUM(cantpago) AS tpago FROM pago WHERE refpago IN " + referencias;
00329     cur = empresaBase()->cargacursor(SQLQuery);
00330     fitxersortidatxt += "     <td>" + cur->valor("tpago") + "</td>\n";
00331     delete cur;
00332 
00333     fitxersortidatxt += "</tr>\n";
00334     fitxersortidatxt += "</blockTable>\n";
00335     _depura("END InformeQToolButton::generarCliente", 0);
00336     return fitxersortidatxt;
00337 }

void InformeQToolButton::click (  )  [virtual, slot]

Definition at line 86 of file informeqtoolbutton.cpp.

References _depura(), postgresiface2::cargacursor(), CONF_DIR_OPENREPORTS, CONF_DIR_USER, confpr, PEmpresaBase::empresaBase(), cursor2::eof(), generarCliente(), invocaPDF(), m_clientsList, PEmpresaBase::setEmpresaBase(), cursor2::siguienteregistro(), cursor2::valor(), and configuracion::valor().

Referenced by setBoton().

00086                                {
00087     _depura("InformeQToolButton::click", 0);
00088     // Puede que no se haya actualizado bien el company
00089     setEmpresaBase(m_clientsList->empresaBase());
00090 
00091     QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) + "informeclientes.rml";
00092     QString archivod = confpr->valor(CONF_DIR_USER) + "informeclientes.rml";
00093     QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg";
00094 
00096 #ifdef WINDOWS
00097 
00098     archivo = "copy " + archivo + " " + archivod;
00099 #else
00100 
00101     archivo = "cp " + archivo + " " + archivod;
00102 #endif
00103 
00104     system (archivo.toAscii().constData());
00105 
00107 #ifdef WINDOWS
00108 
00109     archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00110 #else
00111 
00112     archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00113 #endif
00114 
00115     QFile file;
00116     file.setFileName(archivod);
00117     file.open(QIODevice::ReadOnly);
00118     QTextStream stream(&file);
00119     QString buff = stream.readAll();
00120     file.close();
00121     QString fitxersortidatxt = "";
00122 
00124     QString SQLQuery = "SELECT * FROM cliente ";
00125     cursor2 *cur = empresaBase()->cargacursor(SQLQuery);
00126     while (!cur->eof()) {
00127         QString gen = generarCliente(cur->valor("idcliente"));
00128         if (gen != "") {
00129                 fitxersortidatxt += "<para><H1>Cliente: " + cur->valor("nomcliente");
00130                 fitxersortidatxt += " -- " + cur->valor("cifcliente") + "</H1></para>\n";
00131                 fitxersortidatxt += gen;
00132                 fitxersortidatxt += "\n<nextPage/>\n";
00133                 fitxersortidatxt += "\n<nextFrame/>\n";
00134         } // end if
00135         cur->siguienteregistro();
00136     } // end while
00137     delete cur;
00138 
00139     buff.replace("[story]", fitxersortidatxt);
00140 
00141     if (file.open(QIODevice::WriteOnly)) {
00142         QTextStream stream(&file);
00143         stream << buff;
00144         file.close();
00145     } // end if
00146     invocaPDF("informeclientes");
00147 
00148     _depura("END InformeQToolButton::click", 0);
00149 }


Field Documentation

ClientsList* InformeQToolButton::m_clientsList [private]

Definition at line 41 of file informeqtoolbutton.h.

Referenced by click(), and InformeQToolButton().


The documentation for this class was generated from the following files:
Generated on Sat Dec 15 00:01:55 2007 for BulmaGes by  doxygen 1.5.1