#include <empresatpv.h>
Inheritance diagram for EmpresaTPV:

Public Member Functions | |
| EmpresaTPV (BulmaTPV *bges) | |
| virtual | ~EmpresaTPV () |
| El destructor de la clase EmpresaTPV borra toda la memoria almacenada. | |
| void | createMainWindows (Splash *) |
| void | guardaConf () |
| Guarda la configuracion de programa para poder recuperar algunas cosas de presentacion. | |
| void | cargaConf () |
| Guarda la configuracion de programa para poder recuperar algunas cosas de presentacion. | |
| Ticket * | newTicket () |
| void | cobrar () |
| void | z () |
| void | x () |
| Ticket * | ticketActual () |
| QList< Ticket * > * | listaTickets () |
| void | setTicketActual (Ticket *tick) |
Private Attributes | |
| BulmaTPV * | m_bulmaTPV |
| Puntero al mainWindow. | |
| QList< Ticket * > | m_listaTickets |
| Ticket * | m_ticketActual |
Clase principal del programa donde se almacenan y gestionan todos los datos de la empresa con la que se está trabajando. Deriva de postgresiface ya que tiene el tratamiento de la base de datos.
Definition at line 44 of file empresatpv.h.
| EmpresaTPV::EmpresaTPV | ( | BulmaTPV * | bges | ) |
| bges |
Definition at line 39 of file empresatpv.cpp.
References _depura(), bges, and m_bulmaTPV.
00039 : EmpresaBase(), Input(this) { 00040 _depura("EmpresaTPV::EmpresaTPV", 0); 00041 m_bulmaTPV = bges; 00042 _depura("END EmpresaTPV::EmpresaTPV", 0); 00043 }
| EmpresaTPV::~EmpresaTPV | ( | ) | [virtual] |
El destructor de la clase EmpresaTPV borra toda la memoria almacenada.
Guardamos la configuracion.
Definition at line 49 of file empresatpv.cpp.
References _depura(), guardaConf(), and m_listaTickets.
00049 { 00050 _depura("EmpresaTPV::~EmpresaTPV", 0); 00051 00052 while (!m_listaTickets.isEmpty()) 00053 delete m_listaTickets.takeFirst(); 00054 00056 guardaConf(); 00057 00058 _depura("END EmpresaTPV::~EmpresaTPV", 0); 00059 }
| void EmpresaTPV::createMainWindows | ( | Splash * | splash | ) |
| splash |
Establecemos el porcentaje del carga de información en las diferentes ventanas. pb = 0%
Creamos los nuevos tickets.
Disparamos los plugins.
Ponemos el titulo de la ventana
Definition at line 70 of file empresatpv.cpp.
References _depura(), cargaConf(), g_plugins, Plugins::lanza(), m_bulmaTPV, m_listaTickets, EmpresaBase::m_progressbar, m_ticketActual, Splash::mensaje(), postgresiface2::nameDB(), newTicket(), and Splash::setBarraProgreso().
Referenced by BulmaTPV::createMainWindows().
00070 { 00071 _depura("EmpresaTPV::createMainWindows", 0); 00074 splash->mensaje(QApplication::translate("EmpresaTPV", "Inicializando listado de articulos")); 00075 splash->setBarraProgreso(30); 00076 m_progressbar->setValue(30); 00077 00078 00080 m_ticketActual = newTicket(); 00081 if (!m_ticketActual) 00082 _depura("error en el sistema, reservando memoria.", 0); 00083 m_listaTickets.append(m_ticketActual); 00084 00085 00086 00088 int res = g_plugins->lanza("EmpresaTPV_createMainWindows_Post", this); 00089 if (res != 0) { 00090 return; 00091 } // end if 00092 00093 cargaConf(); 00094 00096 m_bulmaTPV->statusBar()->showMessage(nameDB(), 2000); 00097 m_bulmaTPV->setWindowTitle(QApplication::translate("EmpresaTPV", "Terminal Punto de Venta GPL") + " :: " + nameDB()); 00098 00099 _depura("END EmpresaTPV::createMainWindows", 0); 00100 }
| void EmpresaTPV::guardaConf | ( | ) |
Guarda la configuracion de programa para poder recuperar algunas cosas de presentacion.
Definition at line 308 of file empresatpv.cpp.
References _depura().
Referenced by ~EmpresaTPV().
00308 { 00309 _depura("EmpresaTPV::guardaConf", 0); 00310 /* 00311 QFile file(confpr->valor(CONF_DIR_USER) + "bulmafact_" + nameDB() + ".cfn"); 00313 if (file.open(QIODevice::WriteOnly)) { 00314 QTextStream stream(&file); 00315 stream << "<CONFIG>\n"; 00316 stream << "\t<PRINCIPAL>\n"; 00317 stream << "\t\t\t<X>" + QString::number(m_bulmafact->x()) + "</X>\n"; 00318 stream << "\t\t\t<Y>" + QString::number(m_bulmafact->y()) + "</Y>\n"; 00319 stream << "\t\t\t<WIDTH>" + QString::number(m_bulmafact->width()) + "</WIDTH>\n"; 00320 stream << "\t\t\t<HEIGHT>" + QString::number(m_bulmafact->height()) + "</HEIGHT>\n"; 00321 stream << "\t\t\t<INDEXADOR>" + (m_bulmafact->actionIndexador->isChecked() ? QString("TRUE") : QString("FALSE")) + "</INDEXADOR>\n"; 00322 stream << "\t</PRINCIPAL>\n"; 00323 00324 00325 for (int i = 0; i < m_listventanas->numVentanas(); i++) { 00326 QObject *obj = m_listventanas->ventana(i); 00327 QWidget *wid = (QWidget *) obj; 00328 stream << "\t<VENTANA>\n"; 00329 stream << "\t\t<VNAME>" + obj->objectName() + "</VNAME>\n"; 00330 stream << "\t\t<VX>" + QString::number(wid->parentWidget()->x()) + "</VX>\n"; 00331 stream << "\t\t<VY>" + QString::number(wid->parentWidget()->y()) + "</VY>\n"; 00332 stream << "\t\t<VWIDTH>" + QString::number(wid->width()) + "</VWIDTH>\n"; 00333 stream << "\t\t<VHEIGHT>" + QString::number(wid->height()) + "</VHEIGHT>\n"; 00334 stream << "\t\t<VVISIBLE>" + (wid->isVisible() ? QString("TRUE") : QString("FALSE")) + "</VVISIBLE>\n"; 00335 stream << "\t\t<VMAXIMIZED>" + (wid->isMaximized() ? QString("TRUE") : QString("FALSE")) + "</VMAXIMIZED>\n"; 00336 stream << "\t\t<VACTIVEWINDOW>" + (m_bulmafact->workspace()->activeWindow() == wid ? QString("TRUE") : QString("FALSE")) + "</VACTIVEWINDOW>"; 00337 stream << "\t</VENTANA>\n"; 00338 } // end for 00339 00340 stream << "</CONFIG>\n"; 00341 file.close(); 00342 } // end if 00343 */ 00344 _depura("END EmpresaTPV::guardaConf", 0); 00345 }
| void EmpresaTPV::cargaConf | ( | ) |
Guarda la configuracion de programa para poder recuperar algunas cosas de presentacion.
Definition at line 352 of file empresatpv.cpp.
References _depura().
Referenced by createMainWindows().
00352 { 00353 _depura("EmpresaTPV::cargaConf", 0); 00354 /* 00355 QFile file(confpr->valor(CONF_DIR_USER) + "bulmafact_" + nameDB() + ".cfn"); 00356 QDomDocument doc("mydocument"); 00357 if (!file.open(QIODevice::ReadOnly)) 00358 return; 00359 if (!doc.setContent(&file)) { 00360 file.close(); 00361 return; 00362 } 00363 file.close(); 00364 00365 // print out the element names of all elements that are direct children 00366 // of the outermost element. 00367 QDomElement docElem = doc.documentElement(); 00368 QDomElement principal = docElem.firstChildElement("PRINCIPAL"); 00370 QString nx = principal.firstChildElement("X").toElement().text(); 00371 00373 QString ny = principal.firstChildElement("Y").toElement().text(); 00374 00376 QString nwidth = principal.firstChildElement("WIDTH").toElement().text(); 00377 00379 QString nheight = principal.firstChildElement("HEIGHT").toElement().text(); 00380 00382 m_bulmafact->setGeometry(nx.toInt(), ny.toInt(), nwidth.toInt(), nheight.toInt()); 00383 00385 QString indexador = principal.firstChildElement("INDEXADOR").toElement().text(); 00386 if (indexador == "TRUE") { 00387 s_indexadorCambiaEstado(TRUE); 00388 m_bulmafact->actionIndexador->setChecked(TRUE); 00389 } else { 00390 s_indexadorCambiaEstado(FALSE); 00391 m_bulmafact->actionIndexador->setChecked(FALSE); 00392 } // end if 00393 00395 QWidget *activewindow = NULL; 00396 QDomNodeList nodos = docElem.elementsByTagName("VENTANA"); 00397 for (int i = 0; i < nodos.count(); i++) { 00398 QDomNode ventana = nodos.item(i); 00399 QDomElement e1 = ventana.toElement(); /// try to convert the node to an element. 00400 if( !e1.isNull() ) { /// the node was really an element. 00401 QString vname = e1.firstChildElement("VNAME").toElement().text(); 00402 for (int j = 0; j < m_listventanas->numVentanas(); j++) { 00403 QObject *obj = m_listventanas->ventana(j); 00404 QWidget *wid = (QWidget *) obj; 00405 if (obj->objectName() == vname) { 00406 QString vx = e1.firstChildElement("VX").toElement().text(); 00407 QString vy = e1.firstChildElement("VY").toElement().text(); 00408 QString vwidth = e1.firstChildElement("VWIDTH").toElement().text(); 00409 QString vheight = e1.firstChildElement("VHEIGHT").toElement().text(); 00410 QString vvisible = e1.firstChildElement("VVISIBLE").toElement().text(); 00411 QString vmaximized = e1.firstChildElement("VMAXIMIZED").toElement().text(); 00412 QString vactivewindow = e1.firstChildElement("VACTIVEWINDOW").toElement().text(); 00414 wid->resize(vwidth.toInt(), vheight.toInt()); 00415 wid->parentWidget()->move(vx.toInt(), vy.toInt()); 00416 if ( vvisible == "TRUE") { 00417 wid->showNormal(); 00418 } // end if 00419 if ( vmaximized == "TRUE") { 00420 wid->showMaximized(); 00421 } 00422 if ( vactivewindow == "TRUE") { 00423 activewindow = wid; 00424 } 00425 } // end if 00426 } // end for 00427 } // end if 00428 } // end for 00430 if (activewindow) 00431 m_bulmafact->workspace()->setActiveWindow(activewindow); 00432 */ 00433 _depura("END EmpresaTPV::cargaConf", 0); 00434 }
| Ticket * EmpresaTPV::newTicket | ( | ) |
Definition at line 438 of file empresatpv.cpp.
References _depura(), g_plugins, and Plugins::lanza().
Referenced by cobrar(), createMainWindows(), Abrevs::on_mui_aparcar_clicked(), and Trabajadores::trabajadorClicked().
00438 { 00439 _depura("EmpresaTPV::newTicket", 0); 00441 Ticket *bud; 00442 if (g_plugins->lanza("EmpresaTPV_newTicket", this, (void **)&bud)) 00443 return bud; 00444 bud = new Ticket(this, NULL); 00445 _depura("END EmpresaTPV::newTicket", 0); 00446 return bud; 00447 }
| void EmpresaTPV::cobrar | ( | ) |
Definition at line 449 of file empresatpv.cpp.
References DBRecord::DBvalue(), Ticket::guardar(), Ticket::imprimir(), m_listaTickets, m_ticketActual, newTicket(), Ticket::pintar(), DBRecord::setDBvalue(), and setTicketActual().
Referenced by Input::keyPressEvent().
00449 { 00450 QString idtrabajador = m_ticketActual->DBvalue("idtrabajador"); 00451 m_ticketActual->guardar(); 00452 m_ticketActual->imprimir(); 00453 m_listaTickets.removeAt(m_listaTickets.indexOf(m_ticketActual)); 00454 m_ticketActual = NULL; 00455 00456 00457 Ticket *ticket = NULL; 00458 Ticket *ticketv = NULL; 00459 00461 for (int i = 0; i < m_listaTickets.size(); ++i) { 00462 ticket = m_listaTickets.at(i); 00463 00464 if ( "" == ticket->DBvalue("nomticket") && idtrabajador == ticket->DBvalue("idtrabajador")) { 00465 setTicketActual(ticket); 00466 ticket->pintar(); 00467 ticketv = ticket; 00468 }// end if 00469 }// end for 00470 00472 if (!ticketv) { 00473 Ticket *tick = newTicket(); 00474 tick->setDBvalue("idtrabajador", idtrabajador); 00475 setTicketActual(tick); 00476 m_listaTickets.append(tick); 00477 tick->pintar(); 00478 }// end if 00479 00480 }
| void EmpresaTPV::z | ( | ) |
Definition at line 103 of file empresatpv.cpp.
References _depura(), postgresiface2::begin(), postgresiface2::cargacursor(), postgresiface2::commit(), CONF_IDALMACEN_DEFECTO, CONF_TICKET_PRINTER_FILE, confpr, postgresiface2::ejecuta(), cursor2::eof(), cursor2::valor(), and configuracion::valor().
00103 { 00104 begin(); 00105 QString query = "INSERT INTO z (idalmacen) VALUES(" +confpr->valor(CONF_IDALMACEN_DEFECTO)+ ")"; 00106 ejecuta(query); 00107 query = "SELECT max(idz) AS id FROM z"; 00108 cursor2 *cur = cargacursor(query); 00109 QString idz = cur->valor("id"); 00110 delete cur; 00111 query = "UPDATE albaran set idz = " + idz + " WHERE idz IS NULL AND ticketalbaran = TRUE"; 00112 ejecuta(query); 00113 query = "SELECT count(idz) AS numtickets, sum(totalalbaran) as total FROM albaran WHERE idz = " +idz; 00114 cur = cargacursor(query); 00115 QString numtickets = cur->valor("numtickets"); 00116 QString total = cur->valor("total"); 00117 if (total == "" ) total = "0"; 00118 query = "UPDATE z SET totalz = " + total + ", numtickets = " + numtickets + " WHERE idz =" + idz; 00119 ejecuta(query); 00120 commit(); 00121 delete cur; 00122 00123 00124 // ======================================== 00125 00126 QFile file( confpr->valor(CONF_TICKET_PRINTER_FILE) ); 00127 if ( !file.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) { 00128 _depura("Error en la Impresion de ticket", 2); 00129 } // end if 00130 file.write (QString("Informe Z\n").toAscii()); 00131 file.write (QString("=========\n").toAscii()); 00132 file.write (QString("Empresa S.L\n").toAscii()); 00133 file.write (QString("====================================\n").toAscii()); 00134 file.write(QString("Direccion\n").toAscii()); 00135 file.write(QString("CP: 07000 Palma de Mallorca\n").toAscii()); 00136 file.write(QString("Tel: 971 00 00 00\n").toAscii()); 00138 file.write ( "\n \n", 3); 00139 00140 00142 file.write( QString("Fecha: ").toAscii()); 00143 QDate fecha = QDate::currentDate(); 00144 QString sfecha = fecha.toString("d-M-yyyy"); 00145 file.write( sfecha.toAscii()); 00146 QTime hora = QTime::currentTime(); 00147 QString stime = " " + hora.toString("HH:mm"); 00148 file.write( stime.toAscii()); 00149 file.write ( "\n", 1); 00150 00152 cur = cargacursor("SELECT * FROM almacen WHERE idalmacen=" + confpr->valor(CONF_IDALMACEN_DEFECTO)); 00153 if (!cur->eof()) { 00154 file.write( QString("Almacen: ").toAscii()); 00155 file.write( cur->valor("nomalmacen").toAscii()); 00156 file.write ( "\n", 1); 00157 } // end if 00158 delete cur; 00159 00160 00161 file.write ( "\n", 1); 00162 file.write ( "\n", 1); 00163 00164 // ============================================ 00165 00166 00167 00168 file.write (QString("=======================\n").rightJustified(43,' ').toAscii()); 00169 00170 00171 QString str = "Num tickets " + numtickets.rightJustified(10,' '); 00172 file.write(str.rightJustified(42,' ').toAscii()); 00173 file.write ( "\n", 1); 00174 00175 str = "Total " + total.rightJustified(10,' '); 00176 file.write(str.rightJustified(42,' ').toAscii()); 00177 file.write ( "\n", 1); 00178 00179 00180 // ============================================ 00181 00182 00184 file.write ( "\n \n \n \n", 7); 00185 00188 file.write ("\x1Dh\x40",3); 00189 00191 file.write ( "\x1DH\x02",3); 00192 00194 file.write ( "\x1D",1); 00195 file.write ( "f\x01",2); 00196 00198 file.write ( "\x1D\x77\x01",3); 00200 file.write ( "\x1Dk\x04",3); 00201 file.write (QString("ZZZ").toAscii()); 00202 file.write (" ", 1); 00203 file.write (idz.toAscii()); 00204 file.write ("\x00", 1); 00205 00207 file.write ( "\n \n \n \n \n", 9); 00208 00209 00211 file.write ("\x1D\x56\x01", 3); 00212 file.close(); 00213 00214 // ======================================== 00215 }
| void EmpresaTPV::x | ( | ) |
Definition at line 219 of file empresatpv.cpp.
References _depura(), postgresiface2::cargacursor(), CONF_IDALMACEN_DEFECTO, CONF_TICKET_PRINTER_FILE, confpr, cursor2::eof(), configuracion::valor(), and cursor2::valor().
00219 { 00220 QString query = "SELECT count(idalbaran) AS numtickets, sum(totalalbaran) as total FROM albaran WHERE idz IS NULL AND ticketalbaran = TRUE"; 00221 cursor2 *cur = cargacursor(query); 00222 QString numtickets = cur->valor("numtickets"); 00223 QString total = cur->valor("total"); 00224 if (total == "" ) total = "0"; 00225 delete cur; 00226 00227 00228 // ======================================== 00229 00230 QFile file( confpr->valor(CONF_TICKET_PRINTER_FILE) ); 00231 if ( !file.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) { 00232 _depura("Error en la Impresion de ticket", 2); 00233 } // end if 00234 file.write (QString("Informe X\n").toAscii()); 00235 file.write (QString("=========\n").toAscii()); 00236 file.write (QString("Empresa S.L.\n").toAscii()); 00237 file.write (QString("====================================\n").toAscii()); 00238 file.write(QString("Direccion\n").toAscii()); 00239 file.write(QString("CP: 07000 Palma de Mallorca\n").toAscii()); 00240 file.write(QString("Tel: 971 00 00 00\n").toAscii()); 00242 file.write ( "\n \n", 3); 00243 00244 00246 file.write( QString("Fecha: ").toAscii()); 00247 QDate fecha = QDate::currentDate(); 00248 QString sfecha = fecha.toString("d-M-yyyy"); 00249 file.write( sfecha.toAscii()); 00250 QTime hora = QTime::currentTime(); 00251 QString stime = " " + hora.toString("HH:mm"); 00252 file.write( stime.toAscii()); 00253 file.write ( "\n", 1); 00254 00256 cur = cargacursor("SELECT * FROM almacen WHERE idalmacen=" + confpr->valor(CONF_IDALMACEN_DEFECTO)); 00257 if (!cur->eof()) { 00258 file.write( QString("Almacen: ").toAscii()); 00259 file.write( cur->valor("nomalmacen").toAscii()); 00260 file.write ( "\n", 1); 00261 } // end if 00262 delete cur; 00263 00264 00265 file.write ( "\n", 1); 00266 file.write ( "\n", 1); 00267 00268 // ============================================ 00269 00270 00271 00272 file.write (QString("=======================\n").rightJustified(43,' ').toAscii()); 00273 00274 00275 QString str = "Num tickets " + numtickets.rightJustified(10,' '); 00276 file.write(str.rightJustified(42,' ').toAscii()); 00277 file.write ( "\n", 1); 00278 00279 str = "Total " + total.rightJustified(10,' '); 00280 file.write(str.rightJustified(42,' ').toAscii()); 00281 file.write ( "\n", 1); 00282 00283 00284 // ============================================ 00285 00286 00288 file.write ( "\n \n \n \n", 7); 00289 00291 file.write ( "\n \n \n \n \n", 9); 00292 00293 00295 file.write ("\x1D\x56\x01", 3); 00296 file.close(); 00297 00298 // ======================================== 00299 }
| Ticket* EmpresaTPV::ticketActual | ( | ) | [inline] |
Definition at line 61 of file empresatpv.h.
References m_ticketActual.
Referenced by myplugin::elslot(), Input::keyPressEvent(), Abrevs::on_mui_aparcar_clicked(), Abrevs::on_mui_cliente_clicked(), Tickets::ticketClicked(), and Tickets::Tickets().
00061 {return m_ticketActual;};
| QList<Ticket *>* EmpresaTPV::listaTickets | ( | ) | [inline] |
Definition at line 62 of file empresatpv.h.
References m_listaTickets.
Referenced by Abrevs::on_mui_aparcar_clicked(), Tickets::ticketClicked(), Tickets::Tickets(), and Trabajadores::trabajadorClicked().
00062 {return &m_listaTickets;};
| void EmpresaTPV::setTicketActual | ( | Ticket * | tick | ) | [inline] |
Definition at line 63 of file empresatpv.h.
References m_ticketActual.
Referenced by cobrar(), Abrevs::on_mui_aparcar_clicked(), and Trabajadores::trabajadorClicked().
00063 {m_ticketActual = tick;};
BulmaTPV* EmpresaTPV::m_bulmaTPV [private] |
Puntero al mainWindow.
Definition at line 47 of file empresatpv.h.
Referenced by createMainWindows(), and EmpresaTPV().
QList<Ticket *> EmpresaTPV::m_listaTickets [private] |
Definition at line 48 of file empresatpv.h.
Referenced by cobrar(), createMainWindows(), listaTickets(), and ~EmpresaTPV().
Ticket* EmpresaTPV::m_ticketActual [private] |
Definition at line 49 of file empresatpv.h.
Referenced by cobrar(), createMainWindows(), setTicketActual(), and ticketActual().
1.5.1