presupuestolist.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Tomeu Borras Riera                              *
00003  *   tborras@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 <QMessageBox>
00022 #include <QCheckBox>
00023 #include <QFile>
00024 #include <QCheckBox>
00025 #include <QTextStream>
00026 
00027 #include "presupuestolist.h"
00028 #include "company.h"
00029 #include "presupuestoview.h"
00030 #include "funcaux.h"
00031 #include "plugins.h"
00032 #include "configuracion.h"
00033 
00034 
00036 
00041 PresupuestoList::PresupuestoList(QWidget *parent, Qt::WFlags flag)
00042         : Listado(NULL, parent, flag) {
00043     _depura("PresupuestoList::PresupuestoList(1)", 0);
00044     setupUi(this);
00046     int res = g_plugins->lanza("PresupuestoList_PresupuestoList", this);
00047     if (res != 0)
00048         return;
00049     m_idpresupuesto = "";
00050     setSubForm(mui_list);
00051     hideBusqueda();
00052     iniciaForm();
00053     _depura("END PresupuestoList::PresupuestoList(1)", 0);
00054 }
00055 
00056 
00058 
00064 PresupuestoList::PresupuestoList(Company *comp, QWidget *parent, Qt::WFlags flag)
00065         : Listado(comp, parent, flag) {
00066     _depura("PresupuestoList::PresupuestoList(2)", 0);
00067     setupUi(this);
00069     int res = g_plugins->lanza("PresupuestoList_PresupuestoList", this);
00070     if (res != 0)
00071         return;
00072     m_cliente->setEmpresaBase(comp);
00073     m_articulo->setEmpresaBase(comp);
00074     mui_list->setEmpresaBase(comp);
00075     setSubForm(mui_list);
00076     presentar();
00077     m_idpresupuesto = "";
00078     empresaBase()->meteWindow(windowTitle(), this);
00079     hideBusqueda();
00080     iniciaForm();
00082     trataPermisos("presupuesto");
00083     _depura("END PresupuestoList::PresupuestoList(2)", 0);
00084 }
00085 
00086 
00088 
00091 void PresupuestoList::iniciaForm() {
00092     _depura("PresupuestoList::iniciaForm");
00094     int res = g_plugins->lanza("PresupuestoList_iniciaForm", this);
00095     if (res != 0)
00096         return;
00097     mui_procesada->insertItem(0, tr("Todos los presupuestos"));
00098     mui_procesada->insertItem(1, tr("Presupuestos procesados"));
00099     mui_procesada->insertItem(2, tr("Presupuestos no procesados"));
00100     _depura("END PresupuestoList::iniciaForm");
00101 }
00102 
00103 
00105 
00107 PresupuestoList::~PresupuestoList() {
00108     _depura("PresupuestoList::~PresupuestoList", 0);
00109     _depura("END PresupuestoList::~PresupuestoList", 0);
00110 }
00111 
00112 
00114 
00117 QString PresupuestoList::idpresupuesto() {
00118     _depura("PresupuestoList::idpresupuesto", 0);
00119     _depura("END PresupuestoList::idpresupuesto", 0);
00120     return m_idpresupuesto;
00121 }
00122 
00123 
00125 
00128 void PresupuestoList::setEmpresaBase(Company *comp) {
00129     _depura("PresupuestoList::setEmpresaBase", 0);
00130     PEmpresaBase::setEmpresaBase(comp);
00131     m_cliente->setEmpresaBase(comp);
00132     m_articulo->setEmpresaBase(comp);
00133     mui_list->setEmpresaBase(comp);
00134     _depura("END PresupuestoList::setEmpresaBase", 0);
00135 }
00136 
00137 
00139 
00142 void PresupuestoList::setidcliente(QString val) {
00143     _depura("PresupuestoList::setidcliente", 0);
00144     m_cliente->setidcliente(val);
00145     _depura("END PresupuestoList::setidcliente", 0);
00146 }
00147 
00148 
00150 
00153 void PresupuestoList::setidarticulo(QString val) {
00154     _depura("PresupuestoList::setidarticulo", 0);
00155     m_articulo->setidarticulo(val);
00156     _depura("END PresupuestoList::setidarticulo", 0);
00157 }
00158 
00159 
00161 
00163 void PresupuestoList::crear() {
00164     _depura("PresupuestoList::crear", 0);
00165     ((Company *)empresaBase())->s_newPresupuestoCli();
00166     _depura("END PresupuestoList::crear", 0);
00167 }
00168 
00169 
00171 
00173 void PresupuestoList::presentar() {
00174     _depura("PresupuestoList::presentar", 0);
00175 
00177     mui_list->cargar("SELECT *, totalpresupuesto AS total, bimppresupuesto AS base, imppresupuesto AS impuestos FROM presupuesto LEFT JOIN  cliente ON presupuesto.idcliente=cliente.idcliente LEFT JOIN almacen ON presupuesto.idalmacen=almacen.idalmacen WHERE 1=1 " + generaFiltro());
00178 
00180     cursor2 *cur = empresaBase()->cargacursor("SELECT SUM(totalpresupuesto) AS total FROM presupuesto LEFT JOIN cliente ON presupuesto.idcliente=cliente.idcliente LEFT JOIN almacen ON presupuesto.idalmacen=almacen.idalmacen WHERE 1=1 " + generaFiltro());
00182     if (cur) {
00183         m_total->setText(cur->valor("total"));
00184         delete cur;
00185     } // end if
00186 
00187     _depura("END PresupuestoList::presentar", 0);
00188 }
00189 
00190 
00192 
00195 QString PresupuestoList::generaFiltro() {
00196     _depura("PresupuestoList::generaFiltro", 0);
00198     QString filtro = "";
00199 
00200     if (m_filtro->text() != "") {
00201         filtro = " AND ( lower(descpresupuesto) LIKE lower('%" + m_filtro->text() + "%') ";
00202         filtro += " OR refpresupuesto LIKE '" + m_filtro->text() + "%' ";
00203         filtro += " OR lower(nomcliente) LIKE lower('%" + m_filtro->text() + "%')) ";
00204     } // end if
00205 
00206     if (m_cliente->idcliente() != "") {
00207         filtro += " AND presupuesto.idcliente = " + m_cliente->idcliente();
00208     } // end if
00209 
00211     if (mui_procesada->currentIndex() == 1) {
00213         filtro += " AND procesadopresupuesto";
00214     } else if (mui_procesada->currentIndex() == 2) {
00216         filtro += " AND NOT procesadopresupuesto ";
00217     } // end if
00218 
00219     if (m_articulo->idarticulo() != "") {
00220         filtro += " AND idpresupuesto IN (SELECT DISTINCT idpresupuesto FROM lpresupuesto WHERE idarticulo='" + m_articulo->idarticulo() + "')";
00221     }// end if
00222 
00223     if (m_fechain->text() != "")
00224         filtro += " AND fpresupuesto >= '" + m_fechain->text() + "' ";
00225     if (m_fechafin->text() != "")
00226         filtro += " AND fpresupuesto <= '" + m_fechafin->text() + "' ";
00227     return (filtro);
00228     _depura("END PresupuestoList::generaFiltro", 0);
00229 }
00230 
00231 
00233 
00237 void PresupuestoList::editar(int row) {
00238     _depura("PresupuestoList::editar", 0);
00239     try {
00240         m_idpresupuesto = mui_list->DBvalue(QString("idpresupuesto"), row);
00241         if (modoEdicion()) {
00242             PresupuestoView *prov = ((Company *)empresaBase())->nuevoPresupuestoView();
00243             if (prov->cargar(m_idpresupuesto)) {
00244                 delete prov;
00245                 return;
00246             }
00247             empresaBase()->m_pWorkspace->addWindow(prov);
00248             prov->show();
00249         } else {
00250             emit(selected(m_idpresupuesto));
00251         } // end if
00252         _depura("END PresupuestoList::editar", 0);
00253     } catch(...) {
00254         mensajeInfo(tr("Error al editar el presupuesto"));
00255     } // end try
00256 }
00257 
00258 
00260 
00263 void PresupuestoList::imprimir() {
00264     _depura("PresupuestoList::imprimir", 0);
00265     mui_list->imprimirPDF(tr("Presupuestos a clientes"));
00266     _depura("END PresupuestoList::imprimir", 0);
00267 }
00268 
00269 
00271 
00274 void PresupuestoList::borrar() {
00275     _depura("PresupuestoList::borrar", 0);
00276     int a = mui_list->currentRow();
00277     if (a < 0) {
00278         mensajeInfo(tr("Debe seleccionar una linea"));
00279         return;
00280     } // end if
00281     try {
00282         m_idpresupuesto = mui_list->DBvalue(QString("idpresupuesto"));
00283         if (modoEdicion()) {
00284             PresupuestoView *pv = ((Company *)empresaBase())->nuevoPresupuestoView();
00285             if (pv->cargar(m_idpresupuesto))
00286                 throw -1;
00287             pv->on_mui_borrar_clicked();
00288             pv->close();
00289         } // end if
00290         presentar();
00291     } catch (...) {
00292         mensajeInfo(tr("Error al borrar el presupuesto"));
00293     } // end try
00294     _depura("END PresupuestoList::borrar", 0);
00295 }
00296 
00297 
00302 
00306 PresupuestoListSubForm::PresupuestoListSubForm(QWidget *parent, const char *) : SubForm2Bf(parent) {
00307     _depura("PresupuestoListSubForm::PresupuestoListSubForm", 0);
00309     int res = g_plugins->lanza("PresupuestoListSubForm_PresupuestoListSubForm", this);
00310     if (res != 0)
00311         return;
00312     setDBTableName("presupuesto");
00313     setDBCampoId("idpresupuesto");
00314     addSHeader("idpresupuesto", DBCampo::DBint, DBCampo::DBNotNull | DBCampo::DBPrimaryKey, SHeader::DBNoView | SHeader::DBNoWrite, tr("ID presupuesto"));
00315     addSHeader("numpresupuesto", DBCampo::DBint, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Presupuesto"));
00316     addSHeader("fpresupuesto", DBCampo::DBdate, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Fecha"));
00317     addSHeader("nomcliente", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Cliente"));
00318     addSHeader("refpresupuesto", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Referencia"));
00319     addSHeader("base", DBCampo::DBnumeric, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Base Imponible"));
00320     addSHeader("impuestos", DBCampo::DBnumeric, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Impuestos"));
00321     addSHeader("total", DBCampo::DBnumeric, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Total"));
00322     addSHeader("descpresupuesto", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Descripcion"));
00323     addSHeader("contactpresupuesto", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Persona de contacto"));
00324     addSHeader("telpresupuesto", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Telefono"));
00325     addSHeader("comentpresupuesto", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Comentario"));
00326     addSHeader("codigoalmacen", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Almacen"));
00327     addSHeader("idtrabajador", DBCampo::DBint, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("ID trabajador"));
00328     addSHeader("idcliente", DBCampo::DBint, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("ID cliente"));
00329     addSHeader("idalmacen", DBCampo::DBint, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("ID almacen"));
00330     setinsercion(FALSE);
00331     setDelete(FALSE);
00332     setSortingEnabled(TRUE);
00334     res = g_plugins->lanza("PresupuestoListSubForm_PresupuestoListSubForm_Post", this);
00335     if (res != 0)
00336     _depura("PresupuestoListSubForm::PresupuestoListSubForm", 0);
00337         return;
00338 }
00339 
00340 
00342 
00344 void PresupuestoListSubForm::cargar() {
00345         _depura("PresupuestoListSubForm::cargar", 0);
00346         QString SQLQuery = "SELECT * FROM presupuesto";
00347         SubForm3::cargar(SQLQuery);
00348         _depura("END PresupuestoListSubForm::cargar", 0);
00349 }
00350 
00351 
00353 
00356 void PresupuestoListSubForm::cargar(QString query) {
00357         _depura("PresupuestoListSubForm::cargar", 0, query);
00358         SubForm3::cargar(query);
00359         _depura("PresupuestoListSubForm::cargar", 0);
00360 }

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