impqtoolbutton.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 "impqtoolbutton.h"
00023 #include "funcaux.h"
00024 
00026 #include <QtXml/QDomDocument>
00027 #include <QtXml/QDomNodeList>
00028 #include <QtXml/QDomNode>
00029 #include <QString>
00030 #include <QFileDialog>
00031 #include <QMap>
00032 #include <QList>
00033 #include <QTextStream>
00034 #include "facturapview.h"
00035 #include "fixed.h"
00036 
00037 #include "presupuestolist.h"
00038 #include "presupuestoview.h"
00039 #include "pedidosclientelist.h"
00040 #include "pedidoclienteview.h"
00041 #include "albaranclienteview.h"
00042 #include "albaranclientelist.h"
00043 #include "facturaview.h"
00044 #include "cobroslist.h"
00045 #include "cobroview.h"
00046 #include "company.h"
00047 #include "dbrecord.h"
00048 
00049 
00051 
00060 ImpQToolButton::ImpQToolButton(PresupuestoList *pres, PedidosClienteList *ped, AlbaranClienteList *alb,  FacturasList *fac, CobrosList *cob , QWidget *parent) : QToolButton(parent) {
00061     _depura("ImpQToolButton::ImpQToolButton", 0);
00062     m_presupuestoList = pres;
00063     m_pedidosClienteList = ped;
00064     m_albaranClienteList = alb;
00065     m_facturasList = fac;
00066     m_cobrosList = cob;
00067 
00068     setBoton();
00069     _depura("END ImpQToolButton::ImpQToolButton", 0);
00070 }
00071 
00072 
00074 
00076 ImpQToolButton::~ImpQToolButton() {
00077     _depura("ImpQToolButton::~ImpQToolButton", 0);
00078     _depura("END ImpQToolButton::~ImpQToolButton", 0);
00079 }
00080 
00081 
00083 
00085 void ImpQToolButton::setBoton() {
00086     _depura("ImpQToolButton::setBoton", 0);
00087     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00088     setObjectName(QString::fromUtf8("exporta"));
00089     setStatusTip("Imprimir elementos seleccionados");
00090     setToolTip("Imprimir elementos seleccionados");
00091     setMinimumSize(QSize(32, 32));
00092     setIcon(QIcon(QString::fromUtf8(":/Genericos32x32/images/png/i_print1.png")));
00093     setIconSize(QSize(22, 22));
00094     _depura("END ImpQToolButton::setBoton", 0);
00095 }
00096 
00097 
00099 
00102 void ImpQToolButton::click() {
00103     _depura("ImpQToolButton::click", 0);
00104 
00105     cursor2 *cur1 = NULL;
00106     cursor2 *cur = NULL;
00107 
00108     try {
00109 
00110     QString res = "";
00111 
00112     if (m_presupuestoList != NULL) {
00113         m_companyact = (Company *)m_presupuestoList->empresaBase();
00114         SubForm3 *sub = m_presupuestoList->mui_list;
00115 
00117         for (int i = 0; i < sub->rowCount(); i++) {
00118             SDBRecord *rec = sub->lineaat(i);
00119             rec->refresh();
00120             QString val = rec->DBvalue("selector");
00121             if (val == "TRUE") {
00122                 QString id = rec->DBvalue("idpresupuesto");
00123 
00124                 PresupuestoView *pres = m_companyact->nuevoPresupuestoView();
00125                 pres->cargar(id);
00126 
00127                 pres->generaRML();
00128                 pres->close();
00129 
00130                 generaPDF("presupuesto");
00131 
00132                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"presupuesto.pdf "+confpr->valor(CONF_DIR_USER)+"presupuesto"+id+".pdf";
00133                 system(cad.toAscii().data());
00134                 res += confpr->valor(CONF_DIR_USER)+"presupuesto"+id+".pdf ";
00135             } // end if
00136         } // end for
00137     }
00138 
00139     if (m_facturasList != NULL) {
00140         m_companyact = (Company *)m_facturasList->empresaBase();
00141         SubForm3 *sub = m_facturasList->mui_list;
00142 
00144         for (int i = 0; i < sub->rowCount(); i++) {
00145             SDBRecord *rec = sub->lineaat(i);
00146             rec->refresh();
00147             QString val = rec->DBvalue("selector");
00148             if (val == "TRUE") {
00149                 QString id = rec->DBvalue("idfactura");
00150 
00151                 FacturaView *pres = m_companyact->newFacturaView();
00152                 pres->cargar(id);
00153 
00154                 pres->generaRML();
00155                 pres->close();
00156 
00157                 generaPDF("factura");
00158 
00159                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"factura.pdf "+confpr->valor(CONF_DIR_USER)+"factura"+id+".pdf";
00160                 system(cad.toAscii().data());
00161                 res += confpr->valor(CONF_DIR_USER)+"factura"+id+".pdf ";
00162             } // end if
00163         } // end for
00164     } // end if
00165 
00166     if (m_pedidosClienteList != NULL) {
00167         m_companyact = (Company *)m_pedidosClienteList->empresaBase();
00168         SubForm3 *sub = m_pedidosClienteList->mui_list;
00169 
00171         for (int i = 0; i < sub->rowCount(); i++) {
00172             SDBRecord *rec = sub->lineaat(i);
00173             rec->refresh();
00174             QString val = rec->DBvalue("selector");
00175             if (val == "TRUE") {
00176                 QString id = rec->DBvalue("idpedidocliente");
00177 
00178                 PedidoClienteView *pres = m_companyact->newPedidoClienteView();
00179                 pres->cargar(id);
00180 
00181                 pres->generaRML();
00182                 pres->close();
00183 
00184                 generaPDF("pedidocliente");
00185 
00186                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"pedidocliente.pdf "+confpr->valor(CONF_DIR_USER)+"pedidocliente"+id+".pdf";
00187                 system(cad.toAscii().data());
00188                 res += confpr->valor(CONF_DIR_USER)+"pedidocliente"+id+".pdf ";
00189             } // end if
00190         } // end for
00191     } // end if
00192 
00193 
00194     if (m_albaranClienteList != NULL) {
00195         m_companyact = (Company *)m_albaranClienteList->empresaBase();
00196         SubForm3 *sub = m_albaranClienteList->mui_list;
00197 
00199         for (int i = 0; i < sub->rowCount(); i++) {
00200             SDBRecord *rec = sub->lineaat(i);
00201             rec->refresh();
00202             QString val = rec->DBvalue("selector");
00203             if (val == "TRUE") {
00204                 QString id = rec->DBvalue("idalbaran");
00205 
00206                 AlbaranClienteView *pres = m_companyact->newAlbaranClienteView();
00207                 pres->cargar(id);
00208 
00209                 pres->generaRML();
00210                 pres->close();
00211 
00212                 generaPDF("albaran");
00213 
00214                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"albaran.pdf "+confpr->valor(CONF_DIR_USER)+"albaran"+id+".pdf";
00215                 system(cad.toAscii().data());
00216                 res += confpr->valor(CONF_DIR_USER)+"albaran"+id+".pdf ";
00217             } // end if
00218         } // end for
00219     } // end if
00220 
00222     if (m_cobrosList != NULL) {
00223 
00224         m_companyact = (Company *)m_cobrosList->empresaBase();
00225         SubForm3 *sub = m_cobrosList->mui_list;
00226         QString txt = "";
00227 
00228 
00229         QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) +"recibos.rml";
00230         QString archivod = confpr->valor(CONF_DIR_USER) + "recibos.rml";
00231         QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg";
00232 
00233 
00235 #ifdef WINDOWS
00236 
00237         archivo = "copy " + archivo + " " + archivod;
00238 #else
00239 
00240         archivo = "cp " + archivo + " " + archivod;
00241 #endif
00242 
00243         system (archivo.toAscii().constData());
00245 #ifdef WINDOWS
00246 
00247         archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00248 #else
00249 
00250         archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00251 #endif
00252 
00253         system(archivologo.toAscii().constData());
00254         QFile file;
00255         file.setFileName(archivod);
00256         file.open(QIODevice::ReadOnly);
00257         QTextStream stream(&file);
00258         QString buff = stream.readAll();
00259         file.close();
00260 
00261 
00262 
00264         int j = 0;
00265         for (int i = 0; i < sub->rowCount(); i++) {
00266             SDBRecord *rec = sub->lineaat(i);
00267             rec->refresh();
00268             QString val = rec->DBvalue("selector");
00269             if (val == "TRUE") {
00270                 QString id = rec->DBvalue("idcobro");
00271 
00272                 CobroView *pres = new CobroView(m_companyact, 0);
00273                 pres->cargar(id);
00274 
00275                 int col1 = j % 3;
00276                 double col = 0;
00277                 if (col1 == 2) col = 1.00;
00278                 if (col1 == 1) col = 10;
00279                 if (col1 == 0) col = 19.5;
00280 
00281                 txt += " <storyPlace x=\"0cm\" y=\"0cm\" width=\"15cm\" height=\"1cm\">\n";
00282                 txt += " <setFont name=\"Courier\" size=\"8\"/>\n";
00283                 txt += " <drawString x=\"4.7cm\" y=\""+ QString::number(col+7.6) +"cm\">"+pres->DBvalue("idcobro")+"</drawString>\n";
00284                 txt += " <drawString x=\"7.2cm\" y=\""+ QString::number(col+7.6) +"cm\">PALMA DE MALLORCA</drawString>\n";
00285                 txt += " <drawString x=\"14.2cm\" y=\""+ QString::number(col+7.6) +"cm\">EUROS "+pres->DBvalue("cantcobro")+"</drawString>\n";
00286 
00287                 txt += " <drawString x=\"5.7cm\" y=\""+ QString::number(col+6.8) +"cm\">"+pres->DBvalue("fechacobro")+"</drawString>\n";
00288                 txt += " <drawString x=\"12.4cm\" y=\""+ QString::number(col+6.8) +"cm\">"+pres->DBvalue("fechavenccobro")+"</drawString>\n";
00289 
00290                 if (pres->DBvalue("idbanco") != "") {
00291                         QString query = "SELECT * FROM banco WHERE idbanco ="+pres->DBvalue("idbanco");
00292                         cur1 = m_companyact->cargacursor(query);
00293                         if (!cur1->eof()){
00294                                 txt += " <drawString x=\"9.4cm\" y=\""+ QString::number(col+4.4) +"cm\">"+cur1->valor("nombanco")+"</drawString>\n";
00295                                 txt += " <drawString x=\"9.4cm\" y=\""+ QString::number(col+4) +"cm\">"+cur1->valor("pobbanco")+"</drawString>\n";
00296                                 txt += " <drawString x=\"12.4cm\" y=\""+ QString::number(col+3.5) +"cm\">"+cur1->valor("codentidadbanco")+" "+cur1->valor("codagenciabanco")+" "+cur1->valor("dcbanco")+" "+cur1->valor("numcuentabanco")+"</drawString>\n";
00297                         } // end if
00298                         delete cur1;
00299                 } // end if
00300 
00301 
00302                 if (pres->DBvalue("idcliente") != "") {
00303                         QString query = "SELECT * FROM cliente WHERE idcliente ="+pres->DBvalue("idcliente");
00304                         cur = m_companyact->cargacursor(query);
00305                         if (!cur->eof()){
00306                                 txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+2.3) +"cm\">"+cur->valor("nomcliente")+"</drawString>\n";
00307 //                              txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+1.9) +"cm\">"+cur->valor("nomaltcliente")+"</drawString>\n";
00308                                 txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+1.5) +"cm\">"+cur->valor("dircliente")+"</drawString>\n";
00309                                 txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+1.1) +"cm\">"+cur->valor("cpcliente")+" "+cur->valor("provcliente")+"</drawString>\n";
00310                         } // end if
00311                         delete cur;
00312                 } // end if
00313 
00314                 txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+5.6) +"cm\">a</drawString>\n";
00315                 txt += " <drawString x=\"4.8cm\" y=\""+ QString::number(col+5.2) +"cm\">"+num2texto(pres->DBvalue("cantcobro"))+"</drawString>\n";
00316 
00317                 txt += " </storyPlace>\n";
00318 
00319                 if (col1 == 2)
00320                     txt += "<nextPage/><nextFrame/>\n";
00321                 j++;
00322                 delete pres;
00323 
00324             } // end if
00325 
00326         } // end for
00327 
00328 
00329         buff.replace("[story]", txt);
00330 
00331         res = confpr->valor(CONF_DIR_USER)+"recibos.pdf ";
00332 
00333 
00336 #ifndef WINDOWS
00337         //   buff.replace("[detallearticulos]", detalleArticulos());
00338 #endif
00339 
00340         if (file.open(QIODevice::WriteOnly)) {
00341             QTextStream stream(&file);
00342             stream << buff;
00343             file.close();
00344         } // end if
00345 
00346 
00347         invocaPDF("recibos");
00348 
00349         return;
00350     } // end if
00351 
00352 
00353 
00354 
00355 
00356     QString comando = "kprinter "+res;
00357     system(comando.toAscii().data());
00358     comando = "rm "+res;
00359     system(comando.toAscii().data());
00360     _depura("END ImpQToolButton::click", 0);
00361 
00362    } catch(...) {
00363         mensajeInfo("Error en los calculos");
00365         if (cur1) delete cur1;
00366         if (cur) delete cur;
00367    } // end try
00368 }
00369 
00370 // ==================================================================================
00371 
00372 
00374 
00382 SelQToolButton::SelQToolButton(PresupuestoList *pres, PedidosClienteList *ped, AlbaranClienteList *alb,  FacturasList *fac , CobrosList *cob, QWidget *parent) : QToolButton(parent) {
00383     _depura("SelQToolButton::SelQToolButton", 0);
00384     m_presupuestoList = pres;
00385     m_pedidosClienteList = ped;
00386     m_albaranClienteList = alb;
00387     m_facturasList = fac;
00388     m_cobrosList = cob;
00389     setBoton();
00390     _depura("END SelQToolButton::SelQToolButton", 0);
00391 }
00392 
00393 
00395 
00397 SelQToolButton::~SelQToolButton() {
00398     _depura("SelQToolButton::~SelQToolButton", 0);
00399     _depura("END SelQToolButton::~SelQToolButton", 0);
00400 }
00401 
00402 
00404 
00406 void SelQToolButton::setBoton() {
00407     _depura("SelQToolButton::setBoton", 0);
00408     setObjectName(QString::fromUtf8("exporta"));
00409     setStatusTip("Invertir seleccion de elementos");
00410     setToolTip("Invertir seleccion de elementos");
00411     setMinimumSize(QSize(32, 32));
00412     setIcon(QIcon(QString::fromUtf8(":/Genericos32x32/images/png/i_invert.png")));
00413     setIconSize(QSize(22, 22));
00414 
00415     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00416     _depura("END SelQToolButton::setBoton", 0);
00417 }
00418 
00420 
00422 void SelQToolButton::click() {
00423     _depura("ImpQToolButton::click", 0);
00424 
00425     // Es posible que esto se haya cargado antes de cargar el company por eso
00426     // No me fio de que la asignacion en el constructor haya ido bien y reasigno aqui
00427 
00428     QString res = "";
00429 
00430     if (m_presupuestoList != NULL) {
00431         m_companyact = (Company *)m_presupuestoList->empresaBase();
00432         SubForm3 *sub = m_presupuestoList->mui_list;
00433 
00435         for (int i = 0; i < sub->rowCount(); i++) {
00436             SDBRecord *rec = sub->lineaat(i);
00437             rec->refresh();
00438             if (rec->DBvalue( "selector") == "TRUE") {
00439                 rec->setDBvalue("selector", "FALSE");
00440             } else {
00441                 rec->setDBvalue("selector", "TRUE");
00442             } // end if
00443         } // end for
00444     }
00445 
00446     if (m_pedidosClienteList != NULL) {
00447         m_companyact = (Company *)m_pedidosClienteList->empresaBase();
00448         SubForm3 *sub = m_pedidosClienteList->mui_list;
00449 
00451         for (int i = 0; i < sub->rowCount(); i++) {
00452             SDBRecord *rec = sub->lineaat(i);
00453             rec->refresh();
00454             if (rec->DBvalue( "selector") == "TRUE") {
00455                 rec->setDBvalue("selector", "FALSE");
00456             } else {
00457                 rec->setDBvalue("selector", "TRUE");
00458             } // end if
00459         } // end for
00460     }
00461 
00462 
00463     if (m_albaranClienteList != NULL) {
00464         m_companyact = (Company *)m_albaranClienteList->empresaBase();
00465         SubForm3 *sub = m_albaranClienteList->mui_list;
00466 
00468         for (int i = 0; i < sub->rowCount(); i++) {
00469             SDBRecord *rec = sub->lineaat(i);
00470             rec->refresh();
00471             if (rec->DBvalue( "selector") == "TRUE") {
00472                 rec->setDBvalue("selector", "FALSE");
00473             } else {
00474                 rec->setDBvalue("selector", "TRUE");
00475             } // end if
00476         } // end for
00477     }
00478 
00479 
00480     if (m_facturasList != NULL) {
00481         m_companyact = (Company *)m_facturasList->empresaBase();
00482         SubForm3 *sub = m_facturasList->mui_list;
00484         for (int i = 0; i < sub->rowCount(); i++) {
00485             SDBRecord *rec = sub->lineaat(i);
00486             rec->refresh();
00487             if (rec->DBvalue( "selector") == "TRUE") {
00488                 rec->setDBvalue("selector", "FALSE");
00489             } else {
00490                 rec->setDBvalue("selector", "TRUE");
00491             } // end if
00492         } // end for
00493     }
00494 
00495     if (m_cobrosList != NULL) {
00496         m_companyact = (Company *)m_cobrosList->empresaBase();
00497         SubForm3 *sub = m_cobrosList->mui_list;
00499         for (int i = 0; i < sub->rowCount(); i++) {
00500             SDBRecord *rec = sub->lineaat(i);
00501             rec->refresh();
00502             if (rec->DBvalue( "selector") == "TRUE") {
00503                 rec->setDBvalue("selector", "FALSE");
00504             } else {
00505                 rec->setDBvalue("selector", "TRUE");
00506             } // end if
00507         } // end for
00508     }
00509 
00510     _depura("END ImpQToolButton::click", 0);
00511 }
00512 
00513 // ==================================================================================
00514 
00515 
00517 
00525 EmailQToolButton::EmailQToolButton(PresupuestoList *pres, PedidosClienteList *ped, AlbaranClienteList *alb,  FacturasList *fac, CobrosList *cob , QWidget *parent) : QToolButton(parent) {
00526     _depura("EmailQToolButton::EmailQToolButton", 0);
00527     m_presupuestoList = pres;
00528     m_pedidosClienteList = ped;
00529     m_albaranClienteList = alb;
00530     m_facturasList = fac;
00531     m_cobrosList = cob;
00532     setBoton();
00533     _depura("END EmailQToolButton::EmailQToolButton", 0);
00534 }
00535 
00536 
00538 
00540 EmailQToolButton::~EmailQToolButton() {
00541     _depura("EmailQToolButton::~EmailQToolButton", 0);
00542     _depura("END EmailQToolButton::~EmailQToolButton", 0);
00543 }
00544 
00545 
00547 
00549 void EmailQToolButton::setBoton() {
00550     _depura("EmailQToolButton::setBoton", 0);
00551     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00552     setObjectName(QString::fromUtf8("exporta"));
00553     setStatusTip("Enviar elementos seleccionados por e-mail");
00554     setToolTip("Enviar elementos seleccionados por e-mail");
00555     setMinimumSize(QSize(32, 32));
00556     setIcon(QIcon(QString::fromUtf8(":/Genericos32x32/images/png/i_mail.png")));
00557     setIconSize(QSize(22, 22));
00558     _depura("END EmailQToolButton::setBoton", 0);
00559 }
00560 
00561 
00563 
00565 void EmailQToolButton::click() {
00566     _depura("ImpQToolButton::click", 0);
00567 
00568     // Es posible que esto se haya cargado antes de cargar el company por eso
00569     // No me fio de que la asignacion en el constructor haya ido bien y reasigno aqui
00570 
00571 
00572     QString res = "";
00573 
00574 
00575     if (m_presupuestoList != NULL) {
00576         m_companyact = (Company *)m_presupuestoList->empresaBase();
00577         SubForm3 *sub = m_presupuestoList->mui_list;
00578 
00580         for (int i = 0; i < sub->rowCount(); i++) {
00581             SDBRecord *rec = sub->lineaat(i);
00582             rec->refresh();
00583             QString val = rec->DBvalue("selector");
00584             if (val == "TRUE") {
00585                 QString id = rec->DBvalue("idpresupuesto");
00586                 QString idcliente = rec->DBvalue("idcliente");
00587                 QString query = "SELECT mailcliente from cliente WHERE idcliente="+idcliente;
00588                 cursor2 *curs = m_companyact->cargacursor( query);
00589                 QString email = curs->valor("mailcliente");
00590 
00591                 PresupuestoView *pres = m_companyact->nuevoPresupuestoView();
00592                 pres->cargar(id);
00593 
00594                 pres->generaRML();
00595                 pres->close();
00596 
00597                 generaPDF("presupuesto");
00598 
00599                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"presupuesto.pdf "+confpr->valor(CONF_DIR_USER)+"presupuesto"+id+".pdf";
00600                 system(cad.toAscii().data());
00601 
00602                 cad = "kmail -s \"Presupuesto "+id+"\" --body \" Adjunto remito presupuesto numero "+id+"\n Atentamente\n\" --attach "+confpr->valor(CONF_DIR_USER)+"presupuesto"+id+".pdf "+ email;
00603                 system(cad.toAscii().data());
00604                 res += confpr->valor(CONF_DIR_USER)+"presupuesto"+id+".pdf ";
00605             } // end if
00606         } // end for
00607     } // end if
00608 
00609 
00610 
00611     if (m_pedidosClienteList != NULL) {
00612         m_companyact = (Company *)m_pedidosClienteList->empresaBase();
00613         SubForm3 *sub = m_pedidosClienteList->mui_list;
00614 
00616         for (int i = 0; i < sub->rowCount(); i++) {
00617             SDBRecord *rec = sub->lineaat(i);
00618             rec->refresh();
00619             QString val = rec->DBvalue("selector");
00620             if (val == "TRUE") {
00621                 QString id = rec->DBvalue("idpedidocliente");
00622                 QString idcliente = rec->DBvalue("idcliente");
00623                 QString query = "SELECT mailcliente from cliente WHERE idcliente="+idcliente;
00624                 cursor2 *curs = m_companyact->cargacursor( query);
00625                 QString email = curs->valor("mailcliente");
00626 
00627                 PedidoClienteView *pres = m_companyact->newPedidoClienteView();
00628                 pres->cargar(id);
00629 
00630                 pres->generaRML();
00631                 pres->close();
00632 
00633                 generaPDF("pedidocliente");
00634 
00635                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"pedidocliente.pdf "+confpr->valor(CONF_DIR_USER)+"pedidocliente"+id+".pdf";
00636                 system(cad.toAscii().data());
00637 
00638                 cad = "kmail -s \"Pedido Cliente "+id+"\" --body \" Adjunto remito pedido numero "+id+"\n Atentamente\n\" --attach "+confpr->valor(CONF_DIR_USER)+"pedidocliente"+id+".pdf "+ email;
00639                 system(cad.toAscii().data());
00640                 res += confpr->valor(CONF_DIR_USER)+"pedidocliente"+id+".pdf ";
00641             } // end if
00642         } // end for
00643     } // end if
00644 
00645 
00646 
00647 
00648     if (m_albaranClienteList != NULL) {
00649         m_companyact = (Company *)m_albaranClienteList->empresaBase();
00650         SubForm3 *sub = m_albaranClienteList->mui_list;
00651 
00653         for (int i = 0; i < sub->rowCount(); i++) {
00654             SDBRecord *rec = sub->lineaat(i);
00655             rec->refresh();
00656             QString val = rec->DBvalue("selector");
00657             if (val == "TRUE") {
00658                 QString id = rec->DBvalue("idalbaran");
00659                 QString idcliente = rec->DBvalue("idcliente");
00660                 QString query = "SELECT mailcliente from cliente WHERE idcliente="+idcliente;
00661                 cursor2 *curs = m_companyact->cargacursor( query);
00662                 QString email = curs->valor("mailcliente");
00663 
00664                 PedidoClienteView *pres = m_companyact->newPedidoClienteView();
00665                 pres->cargar(id);
00666 
00667                 pres->generaRML();
00668                 pres->close();
00669 
00670                 generaPDF("albaran");
00671 
00672                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"albaran.pdf "+confpr->valor(CONF_DIR_USER)+"albaran"+id+".pdf";
00673                 system(cad.toAscii().data());
00674 
00675                 cad = "kmail -s \"Albaran Cliente "+id+"\" --body \" Adjunto remito albaran numero "+id+"\n Atentamente\n\" --attach "+confpr->valor(CONF_DIR_USER)+"albaran"+id+".pdf "+ email;
00676                 system(cad.toAscii().data());
00677                 res += confpr->valor(CONF_DIR_USER)+"albaran"+id+".pdf ";
00678             } // end if
00679         } // end for
00680     } // end if
00681 
00682 
00683 
00684 
00685     if (m_facturasList != NULL) {
00686         m_companyact = (Company *)m_facturasList->empresaBase();
00687         SubForm3 *sub = m_facturasList->mui_list;
00688 
00690         for (int i = 0; i < sub->rowCount(); i++) {
00691             SDBRecord *rec = sub->lineaat(i);
00692             rec->refresh();
00693             QString val = rec->DBvalue("selector");
00694             if (val == "TRUE") {
00695                 QString id = rec->DBvalue("idfactura");
00696                 QString idcliente = rec->DBvalue("idcliente");
00697                 QString num = rec->DBvalue("numfactura");
00698                 QString serie = rec->DBvalue("codigoserie_factura");
00699                 QString ref = rec->DBvalue("reffactura");
00700                 QString fecha = rec->DBvalue("ffactura");
00701 
00702                 QString query = "SELECT mailcliente from cliente WHERE idcliente="+idcliente;
00703                 cursor2 *curs = m_companyact->cargacursor( query);
00704                 QString email = curs->valor("mailcliente");
00705 
00706                 FacturaView *pres = m_companyact->newFacturaView();
00707                 pres->cargar(id);
00708 
00709                 pres->generaRML();
00710                 pres->close();
00711 
00712                 generaPDF("factura");
00713 
00714                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"factura.pdf "+confpr->valor(CONF_DIR_USER)+"factura"+serie+num+".pdf";
00715                 system(cad.toAscii().data());
00716 
00717 
00718                 cad = "kmail -s \"Factura "+num+"\" --body \"Estimado cliente,\n\n";
00719                 cad += "Adjunto le enviamos la factura número "+serie+num+" con fecha "+fecha+"\n";
00720                 cad += "Sin otro particular, reciba un cordial saludo:\n\n\n";
00721                 cad += "Departamento de Administración.\n\n";
00722                 cad += "Conetxia Soluciones Informáticas S.L.\n";
00723                 cad += "Tel. 971.29.06.29\n\"";
00724                 cad += " --attach "+confpr->valor(CONF_DIR_USER)+"factura"+serie+num+".pdf "+ email;
00725                 system(cad.toAscii().data());
00726 
00727                 res += confpr->valor(CONF_DIR_USER)+"factura"+serie+num+".pdf ";
00728             } // end if
00729         } // end for
00730     } // end if
00731 
00732     if (m_cobrosList != NULL) {
00733         m_companyact = (Company *)m_cobrosList->empresaBase();
00734         SubForm3 *sub = m_cobrosList->mui_list;
00735 
00737         for (int i = 0; i < sub->rowCount(); i++) {
00738             SDBRecord *rec = sub->lineaat(i);
00739             rec->refresh();
00740             QString val = rec->DBvalue("selector");
00741             if (val == "TRUE") {
00742                 QString id = rec->DBvalue("idcobro");
00743                 QString idcliente = rec->DBvalue("idcliente");
00744                 QString ref = rec->DBvalue("refcobro");
00745                 QString fecha = rec->DBvalue("fcobro");
00746 
00747                 QString query = "SELECT mailcliente from cliente WHERE idcliente="+idcliente;
00748                 cursor2 *curs = m_companyact->cargacursor( query);
00749                 QString email = curs->valor("mailcliente");
00750 
00751                 CobroView *pres = new CobroView(m_companyact, 0);
00752                 pres->cargar(id);
00753 
00754                 generaPDF("recibo");
00755 
00756                 QString cad = "mv "+confpr->valor(CONF_DIR_USER)+"recibo.pdf "+confpr->valor(CONF_DIR_USER)+"recibo"+fecha+ref+".pdf";
00757                 system(cad.toAscii().data());
00758 
00759 
00760                 cad = "kmail -s \"Recibo "+fecha+ref+"\" --body \"Estimado cliente,\n\n";
00761                 cad += "Adjunto le enviamos el recibo número "+fecha+ref+" con fecha "+fecha+"\n";
00762                 cad += "Sin otro particular, reciba un cordial saludo:\n\n\n";
00763                 cad += " --attach "+confpr->valor(CONF_DIR_USER)+"recibo"+fecha+ref+".pdf "+ email;
00764                 system(cad.toAscii().data());
00765 
00766                 res += confpr->valor(CONF_DIR_USER)+"recibo"+fecha+ref+".pdf ";
00767                 delete pres;
00768             } // end if
00769         } // end for
00770     } // end if
00771 
00772 
00773     _depura("END ImpQToolButton::click", 0);
00774 }
00775 
00776 

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