#include <informereferencia.h>
Public Member Functions | |
| InformeReferencia (Company *) | |
| ~InformeReferencia () | |
| void | setreferencia (QString val) |
| Establece la referencia a partir de la cual generar el informe. | |
| void | generarinforme () |
Private Attributes | |
| QString | m_referencia |
| Company * | companyact |
Definition at line 33 of file informereferencia.h.
| InformeReferencia::InformeReferencia | ( | Company * | comp | ) |
| comp |
Definition at line 35 of file informereferencia.cpp.
References _depura(), and companyact.
00035 { 00036 _depura("InformeReferencia::InformeReferencia", 0); 00037 companyact = comp; 00038 _depura("END InformeReferencia::InformeReferencia", 0); 00039 }
| InformeReferencia::~InformeReferencia | ( | ) |
Definition at line 45 of file informereferencia.cpp.
References _depura().
00045 { 00046 _depura("InformeReferencia::~InformeReferencia", 0); 00047 _depura("END InformeReferencia::~InformeReferencia", 0); 00048 }
| void InformeReferencia::setreferencia | ( | QString | val | ) |
Establece la referencia a partir de la cual generar el informe.
| val | indica la referencia a ser establecida para realizar el informe |
Definition at line 55 of file informereferencia.cpp.
References _depura(), and m_referencia.
Referenced by BusquedaReferencia::on_mui_informe_clicked().
00055 { 00056 _depura("InformeReferencia::setreferencia", 0, val); 00057 m_referencia = val; 00058 _depura("END InformeReferencia::setreferencia", 0, val); 00059 }
| void InformeReferencia::generarinforme | ( | ) |
Definition at line 64 of file informereferencia.cpp.
References _depura(), postgresiface2::cargacursor(), companyact, CONF_DIR_OPENREPORTS, CONF_DIR_USER, confpr, cursor2::eof(), invocaPDF(), m_referencia, cursor2::siguienteregistro(), cursor2::valor(), and configuracion::valor().
Referenced by BusquedaReferencia::on_mui_informe_clicked().
00064 { 00065 _depura("InformeReferencia::generarinforme", 0); 00066 QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) + "informereferencia.rml"; 00067 QString archivod = confpr->valor(CONF_DIR_USER) + "informereferencia.rml"; 00068 QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg"; 00070 #ifdef WINDOWS 00071 00072 archivo = "copy " + archivo + " " + archivod; 00073 #else 00074 00075 archivo = "cp " + archivo + " " + archivod; 00076 #endif 00077 00078 system(archivo.toAscii().constData()); 00080 #ifdef WINDOWS 00081 00082 archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg"; 00083 #else 00084 00085 archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg"; 00086 #endif 00087 00088 QFile file; 00089 file.setFileName(archivod); 00090 file.open(QIODevice::ReadOnly); 00091 QTextStream stream(&file); 00092 QString buff = stream.readAll(); 00093 file.close(); 00094 QString fitxersortidatxt = ""; 00095 00096 buff.replace("[referencia]", m_referencia); 00097 00098 QString SQLQuery = "SELECT * FROM cliente WHERE idcliente IN ("; 00099 SQLQuery += "SELECT idcliente FROM presupuesto WHERE refpresupuesto = '" + m_referencia + "'"; 00100 SQLQuery += "UNION SELECT idcliente FROM pedidocliente WHERE refpedidocliente = '" + m_referencia + "'"; 00101 SQLQuery += "UNION SELECT idcliente FROM albaran WHERE refalbaran = '" + m_referencia + "'"; 00102 SQLQuery += "UNION SELECT idcliente FROM factura WHERE reffactura = '" + m_referencia + "'"; 00103 SQLQuery += "UNION SELECT idcliente FROM pedidoproveedor WHERE refpedidoproveedor = '" + m_referencia + "'"; 00104 SQLQuery += "UNION SELECT idcliente FROM albaranp WHERE refalbaranp = '" + m_referencia + "'"; 00105 SQLQuery += "UNION SELECT idcliente FROM facturap WHERE reffacturap = '" + m_referencia + "'"; 00106 SQLQuery += "UNION SELECT idcliente FROM cobro WHERE refcobro = '" + m_referencia + "'"; 00107 SQLQuery += "UNION SELECT idcliente FROM pago WHERE refpago = '" + m_referencia + "'"; 00108 SQLQuery += ")"; 00109 cursor2 *cur = companyact->cargacursor(SQLQuery); 00110 while (!cur->eof() ) { 00111 buff.replace("[nomcliente]", cur->valor("nomcliente")); 00112 buff.replace("[telcliente]", cur->valor("telcliente")); 00113 buff.replace("[dircliente]", cur->valor("dircliente")); 00114 buff.replace("[poblcliente]", cur->valor("poblcliente")); 00115 cur->siguienteregistro(); 00116 } // end while 00117 delete cur; 00118 00120 fitxersortidatxt = "<spacer length=\"15\"/>"; 00121 fitxersortidatxt += "<para>Resumen de ventas por articulo</para>\n"; 00122 fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"7cm, 3cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n"; 00123 fitxersortidatxt += "<tr>\n"; 00124 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Articulo") + "</td>\n"; 00125 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pres.") + "</td>\n"; 00126 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pedido") + "</td>\n"; 00127 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Entregado") + "</td>\n"; 00128 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Facturado") + "</td>\n"; 00129 fitxersortidatxt += "</tr>\n"; 00130 00131 SQLQuery = " SELECT * FROM articulo "; 00132 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpresupuesto) AS cantlpresupuestot FROM lpresupuesto WHERE idpresupuesto IN (SELECT idpresupuesto FROM presupuesto WHERE refpresupuesto = '" + m_referencia + "') GROUP BY idarticulo) AS t1 ON t1.idarticulo = articulo.idarticulo "; 00133 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidocliente) AS cantlpedidoclientet FROM lpedidocliente WHERE idpedidocliente IN (SELECT idpedidocliente FROM pedidocliente WHERE refpedidocliente = '" + m_referencia + "') GROUP BY idarticulo) AS t2 ON t2.idarticulo = articulo.idarticulo "; 00134 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaran) AS cantlalbarant FROM lalbaran WHERE idalbaran IN (SELECT idalbaran FROM albaran WHERE refalbaran = '" + m_referencia + "') GROUP BY idarticulo) AS t3 ON t3.idarticulo = articulo.idarticulo "; 00135 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfactura) AS cantlfacturat FROM lfactura WHERE idfactura IN (SELECT idfactura FROM factura WHERE reffactura = '" + m_referencia + "') GROUP BY idarticulo) AS t4 ON t4.idarticulo = articulo.idarticulo "; 00136 SQLQuery += " WHERE (cantlpresupuestot <>0 OR cantlpedidoclientet <> 0 OR cantlalbarant <> 0 OR cantlfacturat <> 0) "; 00137 00138 cur = companyact->cargacursor(SQLQuery); 00139 while (!cur->eof() ) { 00140 fitxersortidatxt += "<tr>\n"; 00141 fitxersortidatxt += " <td>" + cur->valor("nomarticulo") + "</td>\n"; 00142 fitxersortidatxt += " <td>" + cur->valor("cantlpresupuestot") + "</td>\n"; 00143 fitxersortidatxt += " <td>" + cur->valor("cantlpedidoclientet") + "</td>\n"; 00144 fitxersortidatxt += " <td>" + cur->valor("cantlalbarant") + "</td>\n"; 00145 fitxersortidatxt += " <td>" + cur->valor("cantlfacturat") + "</td>\n"; 00146 fitxersortidatxt += "</tr>\n"; 00147 cur->siguienteregistro(); 00148 } // end while 00149 delete cur; 00150 00151 fitxersortidatxt += "</blockTable>\n"; 00152 00153 buff.replace("[referencia]", m_referencia); 00154 00155 fitxersortidatxt += "<spacer length=\"15\"/>"; 00156 fitxersortidatxt += "<para>Resumen de compras por articulo</para>\n"; 00158 fitxersortidatxt += "<blockTable style=\"tablaresumen\" colWidths=\"10cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n"; 00159 fitxersortidatxt += "<tr>\n"; 00160 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Articulo") + "</td>\n"; 00161 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pedido") + "</td>\n"; 00162 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Entregado") + "</td>\n"; 00163 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Facturado") + "</td>\n"; 00164 fitxersortidatxt += "</tr>\n"; 00165 00166 SQLQuery = " SELECT * FROM articulo "; 00167 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlpedidoproveedor) AS cantlpedidoproveedort FROM lpedidoproveedor WHERE idpedidoproveedor IN (SELECT idpedidoproveedor FROM pedidoproveedor WHERE refpedidoproveedor = '" + m_referencia + "') GROUP BY idarticulo) AS t2 ON t2.idarticulo = articulo.idarticulo "; 00168 00169 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlalbaranp) AS cantlalbaranpt FROM lalbaranp WHERE idalbaranp IN (SELECT idalbaranp FROM albaranp WHERE refalbaranp = '" + m_referencia + "') GROUP BY idarticulo) AS t3 ON t3.idarticulo = articulo.idarticulo "; 00170 00171 SQLQuery += " LEFT JOIN (SELECT idarticulo, SUM(cantlfacturap) AS cantlfacturapt FROM lfacturap WHERE idfacturap IN (SELECT idfacturap FROM facturap WHERE reffacturap = '" + m_referencia + "') GROUP BY idarticulo) AS t4 ON t4.idarticulo = articulo.idarticulo "; 00172 SQLQuery += " WHERE ( cantlpedidoproveedort <> 0 OR cantlalbaranpt <> 0 OR cantlfacturapt <> 0) "; 00173 00174 fprintf(stdout,"%s\n",SQLQuery.toAscii().constData()); 00175 00176 cur = companyact->cargacursor(SQLQuery); 00177 while (!cur->eof() ) { 00178 fitxersortidatxt += "<tr>\n"; 00179 fitxersortidatxt += "<td>" + cur->valor("nomarticulo") + "</td>\n"; 00180 fitxersortidatxt += "<td>" + cur->valor("cantlpedidoproveedort") + "</td>\n"; 00181 fitxersortidatxt += "<td>" + cur->valor("cantlalbaranpt") + "</td>\n"; 00182 fitxersortidatxt += "<td>" + cur->valor("cantlfacturapt") + "</td>\n"; 00183 fitxersortidatxt += "</tr>\n"; 00184 cur->siguienteregistro(); 00185 } // end while 00186 delete cur; 00187 00188 fitxersortidatxt += "</blockTable>\n"; 00189 00190 buff.replace("[story]", fitxersortidatxt); 00191 00192 fitxersortidatxt = "<spacer length=\"15\"/>"; 00194 fitxersortidatxt += "<para>Totales ventas</para>\n"; 00195 fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\"3cm, 3cm, 3cm, 3cm, 3cm\" repeatRows=\"1\">\n"; 00196 fitxersortidatxt += "<tr>\n"; 00197 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pres.") + "</td>\n"; 00198 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pedido") + "</td>\n"; 00199 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Entregado") + "</td>\n"; 00200 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Facturado") + "</td>\n"; 00201 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Cobrado") + "</td>\n"; 00202 fitxersortidatxt += "</tr>\n"; 00203 00205 fitxersortidatxt += "<tr>\n"; 00206 00208 SQLQuery = "SELECT SUM(totalpresupuesto) AS tpres FROM presupuesto WHERE refpresupuesto='" + m_referencia + "' "; 00209 cur = companyact->cargacursor(SQLQuery); 00210 fitxersortidatxt += " <td>" + cur->valor("tpres") + "</td>\n"; 00211 delete cur; 00212 00214 SQLQuery = "SELECT SUM(totalpedidocliente) AS tpedcli FROM pedidocliente WHERE refpedidocliente='" + m_referencia + "' "; 00215 cur = companyact->cargacursor(SQLQuery); 00216 fitxersortidatxt += " <td>" + cur->valor("tpedcli") + "</td>\n"; 00217 delete cur; 00218 00220 SQLQuery = "SELECT SUM(totalalbaran) AS talb FROM albaran WHERE refalbaran='" + m_referencia + "' "; 00221 cur = companyact->cargacursor(SQLQuery); 00222 fitxersortidatxt += " <td>" + cur->valor("talb") + "</td>\n"; 00223 delete cur; 00224 00226 SQLQuery = "SELECT SUM(totalfactura) AS tfact FROM factura WHERE reffactura='" + m_referencia + "' "; 00227 cur = companyact->cargacursor(SQLQuery); 00228 fitxersortidatxt += " <td>" + cur->valor("tfact") + "</td>\n"; 00229 delete cur; 00230 00232 SQLQuery = "SELECT SUM(cantcobro) AS tcobro FROM cobro WHERE refcobro = '" + m_referencia + "'"; 00233 cur = companyact->cargacursor(SQLQuery); 00234 fitxersortidatxt += " <td>" + cur->valor("tcobro") + "</td>\n"; 00235 delete cur; 00236 00237 fitxersortidatxt += "</tr>\n"; 00238 fitxersortidatxt += "</blockTable>\n"; 00239 00240 fitxersortidatxt += "<spacer length=\"15\"/>"; 00242 fitxersortidatxt += "<para>Totales compras</para>\n"; 00243 fitxersortidatxt += "<blockTable style=\"tablatotales\" colWidths=\" 4cm, 4cm, 4cm, 3cm\" repeatRows=\"1\">\n"; 00244 fitxersortidatxt += "<tr>\n"; 00245 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pedido") + "</td>\n"; 00246 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Entregado") + "</td>\n"; 00247 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Facturado") + "</td>\n"; 00248 fitxersortidatxt += " <td>" + QApplication::translate("InformeReferencia", "Pagado") + "</td>\n"; 00249 fitxersortidatxt += "</tr>\n"; 00250 00252 fitxersortidatxt += "<tr>\n"; 00253 00255 SQLQuery = "SELECT SUM(totalpedidoproveedor) AS tpedpro FROM pedidoproveedor WHERE refpedidoproveedor='" + m_referencia + "' "; 00256 cur = companyact->cargacursor(SQLQuery); 00257 fitxersortidatxt += " <td>" + cur->valor("tpedpro") + "</td>\n"; 00258 delete cur; 00259 00261 SQLQuery = "SELECT SUM(totalalbaranp) AS talbp FROM albaranp WHERE refalbaranp='" + m_referencia + "' "; 00262 cur = companyact->cargacursor(SQLQuery); 00263 fitxersortidatxt += " <td>" + cur->valor("talbp") + "</td>\n"; 00264 delete cur; 00265 00267 SQLQuery = "SELECT SUM(totalfacturap) AS tfactp FROM facturap WHERE reffacturap = '" + m_referencia + "' "; 00268 cur = companyact->cargacursor(SQLQuery); 00269 fitxersortidatxt += " <td>" + cur->valor("tfactp") + "</td>\n"; 00270 delete cur; 00271 00273 SQLQuery = "SELECT SUM(cantpago) AS tpago FROM pago WHERE refpago = '" + m_referencia + "'"; 00274 cur = companyact->cargacursor(SQLQuery); 00275 fitxersortidatxt += " <td>" + cur->valor("tpago") + "</td>\n"; 00276 delete cur; 00277 00278 fitxersortidatxt += "</tr>\n"; 00279 fitxersortidatxt += "</blockTable>\n"; 00280 00281 buff.replace("[totales]", fitxersortidatxt); 00282 00283 if (file.open(QIODevice::WriteOnly)) { 00284 QTextStream stream(&file); 00285 stream << buff; 00286 file.close(); 00287 } // end if 00288 invocaPDF("informereferencia"); 00289 _depura("END InformeReferencia::generarinforme", 0); 00290 }
QString InformeReferencia::m_referencia [private] |
Definition at line 35 of file informereferencia.h.
Referenced by generarinforme(), and setreferencia().
Company* InformeReferencia::companyact [private] |
Definition at line 36 of file informereferencia.h.
Referenced by generarinforme(), and InformeReferencia().
1.5.1