efacturarecepcion.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Arturo Martin Llado                             *
00003  *   amartin@conetxia.com                                                  *
00004  *   Contribution by Tomeu Borras tborras@conetxia.com                     *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00020  ***************************************************************************/
00021 
00022 #include "QString"
00023 
00024 #include "efacturarecepcion.h"
00025 #include "funcaux.h"
00026 #include <QFileDialog>
00027 #include <QLineEdit>
00028 
00029 #define EMAIL "efactura@conetxia.com"
00030 #define DIREMAIL "/home/arturo/efacturamail"
00031 
00032 
00034 
00038 EFacturaRecepcion::EFacturaRecepcion(Company *emp, QWidget *parent) : FichaBf(emp, parent) {
00039         _depura("EFacturaRecepcion::EFacturaRecepcion", 0);
00040         QString query;
00041         
00042         setupUi(this);  // Para que el form se inicialice bien
00043         _depura("END EFacturaRecepcion::EFacturaRecepcion", 0);
00044 }
00045 
00046 
00048 
00050 EFacturaRecepcion::~EFacturaRecepcion() {
00051         _depura("EFacturaRecepcion::~EFacturaRecepcion", 0);
00052         _depura("EFacturaRecepcion::~EFacturaRecepcion", 0);
00053 }
00054 
00055 
00057 
00060 void EFacturaRecepcion::on_mui_recibir_clicked() {
00061         _depura("EFacturaRecepcion::on_mui_salir_clicked", 0);
00062         
00064         
00065         QString query = "SELECT valor FROM configuracion WHERE nombre = 'eFactura_dirEmail'";
00066         cursor2 *dirEmail = empresaBase()->cargacursor(query);
00067 
00068         query = "SELECT valor FROM configuracion WHERE nombre = 'eFactura_serverRec'";
00069         cursor2 *serverRec = empresaBase()->cargacursor(query);
00070         
00071         query = "SELECT valor FROM configuracion WHERE nombre = 'eFactura_Email'";
00072         cursor2 *Email = empresaBase()->cargacursor(query);
00073 
00074         query = "SELECT valor FROM configuracion WHERE nombre = 'eFactura_Password'";
00075         cursor2 *Password = empresaBase()->cargacursor(query);
00076 
00078         
00079         QDir *direfactura = new QDir(dirEmail->valor("valor"));
00080         
00081         if (!direfactura->exists()) {
00082                 _depura("El directorio especificado en la configuracion para la eFactura no existe. Por favor, creelo e intentelo de nuevo", 2);
00083                 
00084                 return;
00085         }
00086                 
00088         
00089         QString llamada_qstring = "cd " + dirEmail->valor("valor") + " ; python /home/arturo/bulmages/trunk/bulmages/installbulmages/efactura/recibemail.py " + serverRec->valor("valor") + " " + Email->valor("valor") + " " + Password->valor("valor");
00090         
00091         char llamada[512];
00092         
00093         strncpy(llamada, llamada_qstring.toLatin1(), sizeof(llamada)-1);
00094                 
00095         system(llamada);
00096         
00098         
00099         // Filtramos solo por directorios que no sean enlaces
00100         direfactura->setFilter(QDir::Dirs);
00101         // Ordenamos por fecha de modificacion
00102         direfactura->setSorting(QDir::Name);
00103         
00104         QFileInfoList *listadirs = new QFileInfoList(direfactura->entryInfoList());
00105         
00106         mui_facturasRecibidas->setColumnCount(2);
00107         
00108         int cont = 0;
00109         
00110         mui_facturasRecibidas->setRowCount(0);
00111         
00112         QFileInfo *fileInfo = NULL;
00113         QTableWidgetItem *item = NULL;
00114         QFileInfoList *archivos = NULL;
00115 
00116         for (int i = 0; i < listadirs->size(); i++) {
00117                 
00118                 fileInfo = new QFileInfo(listadirs->at(i));
00119                 
00121                 
00122                 if (!fileInfo->fileName().startsWith(".")) {
00123                         
00125                         
00126                         if (!direfactura->cd(fileInfo->fileName())) {
00127                                 _depura("Error intentando entrar en " + fileInfo->fileName(), 2);
00128                                 continue;
00129                         }
00130                         
00132                         
00133                         direfactura->setFilter(QDir::Files);
00134                         
00136                         
00137                         archivos = new QFileInfoList(direfactura->entryInfoList());
00138                         
00139                         if (archivos->size() > 1) {
00140                                 _depura("El directorio " + direfactura->absolutePath() + " contiene mas de un archivo. Por favor, arreglelo dejando solo el fichero XML que contenga la e-factura.", 2);
00141                                 direfactura->cdUp();
00142                                 continue;
00143                         }
00144                         
00146                         
00147                         fileInfo = new QFileInfo(archivos->at(0));
00148                         
00150                         
00151                         mui_facturasRecibidas->insertRow(cont);
00152                         
00154                         
00155                         item = new QTableWidgetItem(fileInfo->fileName());
00156                         mui_facturasRecibidas->setItem(cont, 0, item);
00157                         
00159                         
00160                         item = new QTableWidgetItem(direfactura->absolutePath());
00161                         mui_facturasRecibidas->setItem(cont, 1, item);
00162                         
00163                         cont++;
00164                         
00166                         
00167                         direfactura->cdUp();
00168                         
00169                 } // end if
00170         }
00171         
00174                 
00176         
00177 //      delete item;
00178         delete fileInfo;
00179         delete direfactura;
00180         delete dirEmail;
00181         delete serverRec;
00182         delete Email;
00183         delete Password;
00184 
00185         _depura("END EFacturaRecepcion::on_mui_salir_clicked", 0);
00186 }
00187 
00188 
00190 
00192 void EFacturaRecepcion::on_mui_abrir_clicked() {
00193         _depura("EFacturaRecepcion::on_mui_salir_clicked", 0);
00194 
00195         _depura("END EFacturaRecepcion::on_mui_salir_clicked", 0);
00196 }
00197 
00198 
00200 
00202 void EFacturaRecepcion::on_mui_salir_clicked() {
00203         _depura("EFacturaRecepcion::on_mui_salir_clicked", 0);
00204         
00205         close();
00206         
00207         _depura("END EFacturaRecepcion::on_mui_salir_clicked", 0);
00208 }

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