00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <QWidget>
00022 #include "ticketqtoolbutton.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 #include "facturapview.h"
00038 #include "presupuestoview.h"
00039 #include "fixed.h"
00040
00041
00042 #include "facturaview.h"
00043 #include "company.h"
00044 #include "dbrecord.h"
00045
00046
00048
00055 TicketQToolButton::TicketQToolButton(PresupuestoView *pres, PedidoClienteView *ped, AlbaranClienteView *alb, FacturaView *fac , QWidget *parent) : QToolButton(parent) {
00056 _depura("TicketQToolButton::TicketQToolButton", 0);
00057 m_presupuestoView = pres;
00058 m_pedidoClienteView = ped;
00059 m_albaranClienteView = alb;
00060 m_facturaView = fac;
00061 setBoton();
00062 _depura("END TicketQToolButton::TicketQToolButton", 0);
00063 }
00064
00065
00067
00069 TicketQToolButton::~TicketQToolButton() {
00070 _depura("TicketQToolButton::~TicketQToolButton", 0);
00071 _depura("END TicketQToolButton::~TicketQToolButton", 0);
00072 }
00073
00074
00076
00078 void TicketQToolButton::setBoton() {
00079 _depura("TicketQToolButton::setBoton", 0);
00080 connect(this, SIGNAL(clicked()), this, SLOT(click()));
00081 setObjectName(QString::fromUtf8("exporta"));
00082 setStatusTip("Imprimir Ticket");
00083 setToolTip("Imprimir Ticket");
00084 setMinimumSize(QSize(32, 32));
00085 setIcon(QIcon(QString::fromUtf8("/usr/share/bulmages/icons/ticket.png")));
00086 setIconSize(QSize(22, 22));
00087 _depura("END TicketQToolButton::setBoton", 0);
00088 }
00089
00090
00092
00094 void TicketQToolButton::click() {
00095 _depura("ImpQToolButton::click", 0);
00096
00097
00098
00099 if (m_albaranClienteView != NULL) {
00100
00101 m_companyact = m_albaranClienteView->empresaBase();
00102
00103
00104 QFile file( "/dev/usblp0" );
00105 if ( !file.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) {
00106 _depura("Error en la Impresion de ticket", 2);
00107 }
00108
00109
00110 file.write (QString("Conetxia Soluciones Informaticas S.L\n").toAscii());
00111 file.write (QString("====================================\n").toAscii());
00112 file.write(QString("Joaquin Turina, 1 Local 4\n").toAscii());
00113 file.write(QString("CP: 07004 Palma de Mallorca\n").toAscii());
00114 file.write(QString("Tel: 971 29 06 29\n").toAscii());
00116 file.write ( "\n \n", 3);
00118 file.write( QString("Fecha: ").toAscii());
00119 QDate fecha = QDate::currentDate();
00120 QString sfecha = fecha.toString("d-M-yyyy");
00121 file.write( sfecha.toAscii());
00122 file.write ( "\n", 1);
00123
00124 file.write( QString("Trabajador: ").toAscii());
00125 file.write( m_albaranClienteView->mui_idtrabajador->currentText().toAscii());
00126 file.write ( "\n", 1);
00127
00128 file.write( QString("Cliente: ").toAscii());
00129 file.write( m_albaranClienteView->mui_idcliente->cifcliente().toAscii());
00130 file.write ( " ", 1);
00131 file.write( m_albaranClienteView->mui_idcliente->nomcliente().toAscii());
00132 file.write ( "\n", 1);
00133
00134
00135
00136 file.write( QString("Descripcion: ").toAscii());
00137 file.write( m_albaranClienteView->DBvalue("descalbaran").toAscii());
00138 file.write ( "\n", 1);
00139
00141 file.write ( "\n \n", 3);
00142
00143 QString l;
00144 SDBRecord *linea;
00145 for (int i = 0; i < m_albaranClienteView->getlistalineas()->rowCount(); ++i) {
00146 linea = m_albaranClienteView->getlistalineas()->lineaat(i);
00147 if (linea->DBvalue( "idarticulo") != "") {
00148 QString str = linea->DBvalue("cantlalbaran").rightJustified(5,' ')+QString(" ")+linea->DBvalue("desclalbaran").leftJustified(23,' ', TRUE)+linea->DBvalue("pvplalbaran").rightJustified(10, ' ');
00149 file.write(str.toAscii());
00150 file.write ( "\n", 1);
00151 }
00152 }
00153
00155 file.write ( "\n \n", 3);
00156
00158 QString stotalbases = QString("Base Imp").rightJustified(30,' ');
00159 stotalbases = stotalbases + m_albaranClienteView->m_totalBases->text().rightJustified(10,' ');
00160 file.write(stotalbases.toAscii());
00161 file.write ( "\n", 1);
00162
00164 QString stotaltases = QString("I.V.A.").rightJustified(30,' ');
00165 stotaltases = stotaltases + m_albaranClienteView->m_totalTaxes->text().rightJustified(10,' ');
00166 file.write(stotaltases.toAscii());
00167 file.write ( "\n", 1);
00168
00170 file.write (QString("____________________\n").rightJustified(42,' ').toAscii());
00171
00172 QString stotal = QString("TOTAL").rightJustified(30,' ');
00173 stotal = stotal + m_albaranClienteView->m_totalalbaran->text().rightJustified(10,' ');
00174 file.write(stotal.toAscii());
00175 file.write ( "\n", 1);
00176
00177
00179 file.write ( "\n \n \n \n", 7);
00180
00183 file.write ("\x1Dh\x40",3);
00185 file.write ( "\x1DH\x02",3);
00187 file.write ( "\x1D",1);
00188 file.write ( "f\x01",2);
00189 ;
00191 file.write ( "\x1D\x77\x01",3);
00193 file.write ( "\x1Dk\x04",3);
00194 file.write (QString("ALB").toAscii());
00195 file.write (" ", 1);
00196 file.write (m_albaranClienteView->DBvalue("idalbaran").toAscii());
00197 file.write (" ", 1);
00198 file.write (m_albaranClienteView->DBvalue("numalbaran").toAscii());
00199 file.write (" ", 1);
00200 file.write (m_albaranClienteView->DBvalue("refalbaran").toAscii());
00201 file.write ("\x00", 1);
00202
00204
00205
00206
00207
00208
00209
00210
00212 file.write ( "\n \n \n \n \n", 9);
00213
00214
00216 file.write ("\x1D\x56\x01", 3);
00217 file.close();
00218 }
00219
00220 if (m_facturaView != NULL) {
00221 m_companyact = m_facturaView->empresaBase();
00222
00223
00224
00225 QFile file( confpr->valor(CONF_TICKET_PRINTER_FILE) );
00226 if ( !file.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) {
00227 _depura("Error en la Impresion de ticket", 2);
00228 }
00229
00230
00231 file.write (QString("Conetxia Soluciones Informaticas S.L\n").toAscii());
00232 file.write (QString("====================================\n").toAscii());
00233 file.write(QString("Joaquin Turina, 1 Local 4\n").toAscii());
00234 file.write(QString("CP: 07004 Palma de Mallorca\n").toAscii());
00235 file.write(QString("Tel: 971 29 06 29\n").toAscii());
00237 file.write ( "\n \n", 3);
00239 file.write( QString("Fecha: ").toAscii());
00240 QDate fecha = QDate::currentDate();
00241 QString sfecha = fecha.toString("d-M-yyyy");
00242 file.write( sfecha.toAscii());
00243 file.write ( "\n", 1);
00244
00245 file.write( QString("Cliente: ").toAscii());
00246 file.write( m_facturaView->mui_idcliente->cifcliente().toAscii());
00247 file.write ( " ", 1);
00248 file.write( m_facturaView->mui_idcliente->nomcliente().toAscii());
00249 file.write ( "\n", 1);
00250
00251
00252
00253 file.write( QString("Descripcion: ").toAscii());
00254 file.write( m_facturaView->DBvalue("descfactura").toAscii());
00255 file.write ( "\n", 1);
00256
00258 file.write ( "\n \n", 3);
00259
00260 QString l;
00261 SDBRecord *linea;
00262 for (int i = 0; i < m_facturaView->getlistalineas()->rowCount(); ++i) {
00263 linea = m_facturaView->getlistalineas()->lineaat(i);
00264 if (linea->DBvalue( "idarticulo") != "") {
00265 QString str = linea->DBvalue("cantlfactura").rightJustified(5,' ')+QString(" ")+linea->DBvalue("desclfactura").leftJustified(23,' ', TRUE)+linea->DBvalue("pvplfactura").rightJustified(10, ' ');
00266 file.write(str.toAscii());
00267 file.write ( "\n", 1);
00268 }
00269 }
00270
00272 file.write ( "\n \n", 3);
00273
00275 QString stotalbases = QString("Base Imp").rightJustified(30,' ');
00276 stotalbases = stotalbases + m_facturaView->m_totalBases->text().rightJustified(10,' ');
00277 file.write(stotalbases.toAscii());
00278 file.write ( "\n", 1);
00279
00281 QString stotaltases = QString("I.V.A.").rightJustified(30,' ');
00282 stotaltases = stotaltases + m_facturaView->m_totalTaxes->text().rightJustified(10,' ');
00283 file.write(stotaltases.toAscii());
00284 file.write ( "\n", 1);
00285
00287 file.write (QString("____________________\n").rightJustified(42,' ').toAscii());
00288
00289 QString stotal = QString("TOTAL").rightJustified(30,' ');
00290 stotal = stotal + m_facturaView->m_totalfactura->text().rightJustified(10,' ');
00291 file.write(stotal.toAscii());
00292 file.write ( "\n", 1);
00293
00294
00296 file.write ( "\n \n \n \n", 7);
00297
00300 file.write ("\x1Dh\x40",3);
00302 file.write ( "\x1DH\x02",3);
00304 file.write ( "\x1D",1);
00305 file.write ( "f\x01",2);
00306 ;
00308 file.write ( "\x1D\x77\x01",3);
00310 file.write ( "\x1Dk\x04",3);
00311 file.write (QString("FAC").toAscii());
00312 file.write (" ", 1);
00313 file.write (m_facturaView->DBvalue("idfactura").toAscii());
00314 file.write (" ", 1);
00315 file.write (m_facturaView->DBvalue("numfactura").toAscii());
00316 file.write (" ", 1);
00317 file.write (m_facturaView->DBvalue("reffactura").toAscii());
00318 file.write ("\x00", 1);
00319
00321
00322
00323
00324
00325
00326
00327
00329 file.write ( "\n \n \n \n \n", 9);
00330
00331
00333 file.write ("\x1D\x56\x01", 3);
00334 file.close();
00335 }
00336
00337 _depura("END ImpQToolButton::click", 0);
00338 }
00339
00340