informeqtoolbutton.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Arturo Martin Llado                             *
00003  *   amartin@conetxia.com                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <QWidget>
00022 #include "informeqtoolbutton.h"
00023 #include "funcaux.h"
00024 
00025 
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 
00029 #include <QFile>
00030 #include <QTextStream>
00031 
00032 
00033 #include <QString>
00034 #include <QFileDialog>
00035 #include <QMap>
00036 #include <QList>
00037 
00038 #include "fixed.h"
00039 
00040 
00041 #include "company.h"
00042 #include "dbrecord.h"
00043 #include "articulolist.h"
00044 
00046 
00050 InformeQToolButton::InformeQToolButton(ClientsList *art , QWidget *parent) : QToolButton(parent), PEmpresaBase() {
00051     _depura("InformeQToolButton::InformeQToolButton", 0);
00052     m_clientsList = art;
00053     setBoton();
00054     _depura("END InformeQToolButton::InformeQToolButton", 0);
00055 }
00056 
00057 
00059 
00061 InformeQToolButton::~InformeQToolButton() {
00062     _depura("InformeQToolButton::~InformeQToolButton", 0);
00063     _depura("END InformeQToolButton::~InformeQToolButton", 0);
00064 }
00065 
00066 
00068 
00070 void InformeQToolButton::setBoton() {
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 }
00081 
00082 
00084 
00086 void InformeQToolButton::click() {
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 }
00150 
00151 
00153 
00157 QString InformeQToolButton::generarCliente(QString idcliente) {
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 }
00338 
00342 
00344 
00348 InformeArtQToolButton::InformeArtQToolButton(ArticuloList *art , QWidget *parent) : QToolButton(parent), PEmpresaBase() {
00349     _depura("InformeArtQToolButton::InformeQToolButton", 0);
00350     m_articuloList = art;
00351     setBoton();
00352     _depura("END InformeArtQToolButton::InformeQToolButton", 0);
00353 }
00354 
00355 
00357 
00359 InformeArtQToolButton::~InformeArtQToolButton() {
00360     _depura("InformeArtQToolButton::~InformeArtQToolButton", 0);
00361     _depura("END InformeQToolButton::~InformeQToolButton", 0);
00362 }
00363 
00364 
00366 
00368 void InformeArtQToolButton::setBoton() {
00369     _depura("InformeArtQToolButton::setBoton", 0);
00370     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00371     setObjectName(QString::fromUtf8("exporta"));
00372     setStatusTip("Imprimir Informe Resumen");
00373     setToolTip("Imprimir Informe Resumen");
00374     setMinimumSize(QSize(32, 32));
00375     setIcon(QIcon(QString::fromUtf8("/usr/share/bulmages/icons/catalogo.png")));
00376     setIconSize(QSize(22, 22));
00377     _depura("END InformeArtQToolButton::setBoton", 0);
00378 }
00379 
00380 
00382 
00384 void InformeArtQToolButton::click() {
00385     _depura("InformeArtQToolButton::click", 0);
00386     // Puede que no se haya actualizado bien el company
00387     setEmpresaBase(m_articuloList->empresaBase());
00388 
00389     QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) + "informearticulos.rml";
00390     QString archivod = confpr->valor(CONF_DIR_USER) + "informearticulos.rml";
00391     QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg";
00392 
00394 #ifdef WINDOWS
00395 
00396     archivo = "copy " + archivo + " " + archivod;
00397 #else
00398 
00399     archivo = "cp " + archivo + " " + archivod;
00400 #endif
00401 
00402     system (archivo.toAscii().constData());
00403 
00405 #ifdef WINDOWS
00406 
00407     archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00408 #else
00409 
00410     archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00411 #endif
00412 
00413     QFile file;
00414     file.setFileName(archivod);
00415     file.open(QIODevice::ReadOnly);
00416     QTextStream stream(&file);
00417     QString buff = stream.readAll();
00418     file.close();
00419     QString fitxersortidatxt = generarArticulos();
00420 
00421 
00422     buff.replace("[story]", fitxersortidatxt);
00423 
00424     if (file.open(QIODevice::WriteOnly)) {
00425         QTextStream stream(&file);
00426         stream << buff;
00427         file.close();
00428     } // end if
00429     invocaPDF("informearticulos");
00430 
00431     _depura("END InformeQToolButton::click", 0);
00432 }
00433 
00434 
00436 
00440 QString InformeArtQToolButton::generarArticulos() {
00441     _depura("InformeQToolButton::generarCliente", 0);
00442     QString fitxersortidatxt;
00443 
00444 
00446     fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"9cm, 1.5cm, 1.5cm, 1.5cm, 1.5cm, 1.5cm, 1.5cm, 1.5cm\" repeatRows=\"1\">\n";
00447     fitxersortidatxt += "<tr>\n";
00448     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "Articulo") + "</td>\n";
00449     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "C. Ped.") + "</td>\n";
00450     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "C. Entr.") + "</td>\n";
00451     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "C. Fact.") + "</td>\n";
00452     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "V. Pres.") + "</td>\n";
00453     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "V. Ped.") + "</td>\n";
00454     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "V. Entr.") + "</td>\n";
00455     fitxersortidatxt += "    <td>" + QApplication::translate("InformeClientes", "V. Fact.") + "</td>\n";
00456     fitxersortidatxt += "</tr>\n";
00457 
00458     QString SQLQuery = " SELECT * FROM articulo ";
00459     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpresupuesto) AS cantlpresupuestot  FROM lpresupuesto   GROUP BY idarticulo) AS t1 ON t1.idarticulo = articulo.idarticulo ";
00460     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidocliente) AS cantlpedidoclientet  FROM lpedidocliente GROUP BY idarticulo) AS t2 ON t2.idarticulo = articulo.idarticulo ";
00461     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaran) AS cantlalbarant  FROM lalbaran GROUP BY idarticulo) AS t3 ON t3.idarticulo = articulo.idarticulo ";
00462     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfactura) AS cantlfacturat  FROM lfactura GROUP BY idarticulo) AS t4 ON t4.idarticulo = articulo.idarticulo ";
00463     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidoproveedor) AS cantlpedidoproveedort  FROM lpedidoproveedor GROUP BY idarticulo) AS t7 ON t7.idarticulo = articulo.idarticulo ";
00464     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaranp) AS cantlalbaranpt  FROM lalbaranp GROUP BY idarticulo) AS t5 ON t5.idarticulo = articulo.idarticulo ";
00465     SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfacturap) AS cantlfacturapt  FROM lfacturap GROUP BY idarticulo) AS t6 ON t6.idarticulo = articulo.idarticulo ";
00466     SQLQuery += " WHERE  (cantlpresupuestot <>0 OR cantlpedidoclientet <> 0 OR cantlalbarant <> 0 OR cantlfacturat <> 0 OR cantlpedidoproveedort <> 0 OR cantlalbaranpt <> 0 OR cantlfacturapt <> 0) ";
00467     cursor2 *cur = empresaBase()->cargacursor(SQLQuery);
00468     while (!cur->eof() ) {
00469         fitxersortidatxt += "<tr>\n";
00470         fitxersortidatxt += "    <td>" + cur->valor("nomarticulo") + "</td>\n";
00471         fitxersortidatxt += "    <td>" + cur->valor("cantlpedidoproveedort") + "</td>\n";
00472         fitxersortidatxt += "    <td>" + cur->valor("cantlalbaranpt") + "</td>\n";
00473         fitxersortidatxt += "    <td>" + cur->valor("cantlfacturapt") + "</td>\n";
00474         fitxersortidatxt += "    <td>" + cur->valor("cantlpresupuestot") + "</td>\n";
00475         fitxersortidatxt += "    <td>" + cur->valor("cantlpedidoclientet") + "</td>\n";
00476         fitxersortidatxt += "    <td>" + cur->valor("cantlalbarant") + "</td>\n";
00477         fitxersortidatxt += "    <td>" + cur->valor("cantlfacturat") + "</td>\n";
00478         fitxersortidatxt += "</tr>\n";
00479         cur->siguienteregistro();
00480     } // end while
00481     delete cur;
00482 
00483     fitxersortidatxt += "</blockTable>\n";
00484 
00485     _depura("END InformeQToolButton::generarArticulos", 0);
00486     return fitxersortidatxt;
00487 }
00488 
00489 

Generated on Sat Dec 15 00:01:07 2007 for BulmaGes by  doxygen 1.5.1