int MTicketIVAInc_pintar ( MTicketIVAInc *mtick ) { BL_FUNC_DEBUG QString query; QString buscar; BtTicket *tick = ( ( BtCompany * ) mtick->mainCompany() )->ticketActual(); QString plainTextContent = ""; QString htmlContent = "<font size=\"4\", font-family:monospace>"; htmlContent += "Ticket: " + tick->dbValue ( "nomticket" ) + "<BR>"; plainTextContent += "Ticket: " + tick->dbValue ( "nomticket" ) + "\n"; query = "SELECT idtrabajador, nomtrabajador FROM trabajador WHERE idtrabajador = " + tick->dbValue ( "idtrabajador" ); BlDbRecordSet *rsTrabajador = mtick->mainCompany()->loadQuery ( query ); plainTextContent += "Trabajador: " + rsTrabajador->value( "nomtrabajador" ) + "\n"; htmlContent += "Trabajador: " + rsTrabajador->value( "nomtrabajador" ) + "<br>"; delete rsTrabajador; query = "SELECT idcliente, nomcliente FROM cliente WHERE idcliente = " + tick->dbValue ( "idcliente" ); BlDbRecordSet *rsCliente = mtick->mainCompany()->loadQuery ( query ); plainTextContent += "Cliente: " + rsCliente->value( "nomcliente" ) + "\n"; htmlContent += "Cliente: " + rsCliente->value( "nomcliente" ) + "<br>"; delete rsCliente; htmlContent += "<br>"; htmlContent += "<TABLE border=\"0\" width=\"100%\">"; htmlContent += "<tr><td>" + QString(_("CANT:")) + "</td><td width=\"30%\">" + QString(_("ARTI:")) + "</td><td>" + QString(_("TALLA:")) + "</td><td>" + QString(_("COLOR:")) + "</td><td>" + QString(_("PREC:")) + "</td></tr>"; htmlContent += "<tr><td colspan=\"5\" width=\"100%\" ><hr></td></tr>"; plainTextContent += "\n"; plainTextContent += " " + QString(_("CANT:").rightJustified( 7, ' ', true )) + " " + QString(_("ARTI:").leftJustified ( 15, ' ', true )) + " " + QString(_("TALLA:").leftJustified( 7, ' ', true ))+ " " + QString(_("COLOR:").leftJustified( 7, ' ', true ))+ " " + QString(_("PRECIO:").leftJustified( 9, ' ', true )) + "\n"; plainTextContent += "-----------------------------------------------------------\n"; // if (tick->dbValue("nomticket") != "") { // htmlContent += "<TR><TD colspan=\"5\" align=\"center\"><B>" + tick->dbValue ( "nomticket" ) + "</B></td></tr>"; // } // end if BlDbRecord *item; for ( int i = 0; i < tick->listaLineas()->size(); ++i ) { item = tick->listaLineas()->at ( i ); QString bgcolor = "#FFFFFF"; if ( item == tick->lineaActBtTicket() ) { buscar = item->dbValue ( "nomarticulo" ); bgcolor = "#CCCCFF"; plainTextContent += "> "; } else { plainTextContent += " "; } // end if htmlContent += "<TR>"; htmlContent += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + item->dbValue ( "cantlalbaran" ) + "</TD>"; htmlContent += "<TD bgcolor=\"" + bgcolor + "\" whidth>" + item->dbValue ( "nomarticulo" ) + "</TD>"; htmlContent += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_talla" ) + "</TD>"; htmlContent += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_color" ) + "</TD>"; BlFixed totalLinea ( "0.00" ); totalLinea = BlFixed ( item->dbValue ( "cantlalbaran" ) ) * BlFixed ( item->dbValue ( "pvpivainclalbaran" ) ); htmlContent += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + totalLinea.toQString() + "</TD>"; htmlContent += "</TR>"; plainTextContent += item->dbValue("cantlalbaran").rightJustified ( 7, ' ', true ) + " "; plainTextContent += item->dbValue("nomarticulo").leftJustified ( 20, ' ', true ) + " "; plainTextContent += item->dbValue("nomtc_talla").leftJustified ( 7, ' ', true ) + " "; plainTextContent += item->dbValue("nomtc_color").leftJustified ( 7, ' ', true ) + " "; plainTextContent += totalLinea.toQString().leftJustified ( 9, ' ', true ) + "\n"; } // end for htmlContent+= "</TABLE>"; htmlContent += "<HR>"; base basesimp; base basesimpreqeq; BlDbRecord *linea; QString l; BlFixed irpf ( "0" ); BlDbRecordSet *cur = mtick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" ); if ( cur ) { if ( !cur->eof() ) { irpf = BlFixed ( cur->value( "valor" ) ); } // end if delete cur; } // end if BlFixed descuentolinea ( "0.00" ); for ( int i = 0; i < tick->listaLineas()->size(); ++i ) { linea = tick->listaLineas()->at ( i ); BlFixed cant ( linea->dbValue ( "cantlalbaran" ) ); BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran" ) ); BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) ); BlFixed cantpvp = cant * pvpund; BlFixed iva ( linea->dbValue ( "ivalalbaran" ) ); BlFixed base = cantpvp - cantpvp * desc1 / 100; base = base / ( BlFixed ( "1" ) + ( iva / BlFixed ( "100" ) ) ); descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 ); basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base; basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base; } // end for BlFixed basei ( "0.00" ); base::Iterator it; for ( it = basesimp.begin(); it != basesimp.end(); ++it ) { basei = basei + it.value(); } // end for mtick->mui_browser->setText ( htmlContent ); mtick->mui_plainText->setPlainText ( plainTextContent ); mtick->mui_browser->find ( buscar ); QTextCursor cursor = mtick->mui_browser->textCursor(); cursor.clearSelection(); mtick->mui_browser->setTextCursor( cursor ); return -1; // BtTicket *tick = ( ( BtCompany * ) mtick->mainCompany() )->ticketActual(); // QString html = "<p style=\"font-family:monospace; font-size: 12pt;\">"; // QString html1 = "<font size=\"1\">"; // // html1 += "Ticket: " + tick->dbValue ( "nomticket" ) + "<BR>"; // // QString querytrab = "SELECT * FROM trabajador WHERE idtrabajador = " + tick->dbValue ( "idtrabajador" ); // BlDbRecordSet *curtrab = mtick->mainCompany()->loadQuery ( querytrab ); // html1 += "Trabajador: " + tick->dbValue ( "idtrabajador" ) + " " + curtrab->value( "nomtrabajador" ) + "<BR>"; // delete curtrab; // // QString query = "SELECT * FROM cliente WHERE idcliente = " + tick->dbValue ( "idcliente" ); // BlDbRecordSet *cur1 = mtick->mainCompany()->loadQuery ( query ); // html1 += "Cliente: " + tick->dbValue ( "idcliente" ) + " " + cur1->value( "nomcliente" ) + "<BR>"; // delete cur1; // // html += "<TABLE border=\"0\" width=\"100%\">"; // if (tick->dbValue("nomticket") != "") { // html += "<TR><TD colspan=\"5\" align=\"center\"><B>" + tick->dbValue ( "nomticket" ) + "</B></td></tr>"; // } // end if // // BlDbRecord *item; // for ( int i = 0; i < tick->listaLineas()->size(); ++i ) { // item = tick->listaLineas()->at ( i ); // QString bgcolor = "#FFFFFF"; // if ( item == tick->lineaActBtTicket() ) bgcolor = "#CCCCFF"; // html += "<TR>"; // html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + item->dbValue ( "cantlalbaran" ) + "</TD>"; // html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomarticulo" ) + "</TD>"; // html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_talla" ) + "</TD>"; // html += "<TD bgcolor=\"" + bgcolor + "\">" + item->dbValue ( "nomtc_color" ) + "</TD>"; // BlFixed totalLinea ( "0.00" ); // totalLinea = BlFixed ( item->dbValue ( "cantlalbaran" ) ) * BlFixed ( item->dbValue ( "pvpivainclalbaran" ) ); // html += "<TD bgcolor=\"" + bgcolor + "\" align=\"right\" width=\"50\">" + totalLinea.toQString() + "</TD>"; // html += "</TR>"; // } // end for // // html += "</TABLE>"; // html += "<BR><HR><BR>"; // base basesimp; // base basesimpreqeq; // BlDbRecord *linea; // // /// Impresion de los contenidos. // QString l; // BlFixed irpf ( "0" ); // // BlDbRecordSet *cur = mtick->mainCompany()->loadQuery ( "SELECT * FROM configuracion WHERE nombre = 'IRPF'" ); // // if ( cur ) { // if ( !cur->eof() ) { // irpf = BlFixed ( cur->value( "valor" ) ); // } // end if // delete cur; // } // end if // // BlFixed descuentolinea ( "0.00" ); // // for ( int i = 0; i < tick->listaLineas()->size(); ++i ) { // linea = tick->listaLineas()->at ( i ); // BlFixed cant ( linea->dbValue ( "cantlalbaran" ) ); // BlFixed pvpund ( linea->dbValue ( "pvpivainclalbaran" ) ); // BlFixed desc1 ( linea->dbValue ( "descuentolalbaran" ) ); // BlFixed cantpvp = cant * pvpund; // BlFixed iva ( linea->dbValue ( "ivalalbaran" ) ); // BlFixed base = cantpvp - cantpvp * desc1 / 100; // base = base / ( BlFixed ( "1" ) + ( iva / BlFixed ( "100" ) ) ); // descuentolinea = descuentolinea + ( cantpvp * desc1 / 100 ); // basesimp[linea->dbValue ( "ivalalbaran" ) ] = basesimp[linea->dbValue ( "ivalalbaran" ) ] + base; // basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] = basesimpreqeq[linea->dbValue ( "reqeqlalbaran" ) ] + base; // } // end for // // BlFixed basei ( "0.00" ); // base::Iterator it; // // for ( it = basesimp.begin(); it != basesimp.end(); ++it ) { // basei = basei + it.value(); // } // end for // // /// Calculamos el total de los descuentos. // /// De momento aqui no se usan descuentos generales en venta. // BlFixed porcentt ( "0.00" ); // // /// Calculamos el total de base imponible. // BlFixed totbaseimp ( "0.00" ); // BlFixed parbaseimp ( "0.00" ); // // for ( it = basesimp.begin(); it != basesimp.end(); ++it ) { // if ( porcentt > BlFixed ( "0.00" ) ) { // parbaseimp = it.value() - it.value() * porcentt / 100; // } else { // parbaseimp = it.value(); // } // end if // html1 += "Base Imp " + it.key() + "% " + parbaseimp.toQString() + "<BR>"; // totbaseimp = totbaseimp + parbaseimp; // } // end for // // /// Calculamos el total de IVA. // BlFixed totiva ( "0.00" ); // BlFixed pariva ( "0.00" ); // // for ( it = basesimp.begin(); it != basesimp.end(); ++it ) { // BlFixed piva ( it.key().toLatin1().constData() ); // if ( porcentt > BlFixed ( "0.00" ) ) { // pariva = ( it.value() - it.value() * porcentt / 100 ) * piva / 100; // } else { // pariva = it.value() * piva / 100; // } // end if // html1 += "IVA " + it.key() + "% " + pariva.toQString() + "<BR>"; // totiva = totiva + pariva; // } // end for // // /// Calculamos el total de recargo de equivalencia. // BlFixed totreqeq ( "0.00" ); // BlFixed parreqeq ( "0.00" ); // // for ( it = basesimpreqeq.begin(); it != basesimpreqeq.end(); ++it ) { // BlFixed preqeq ( it.key().toLatin1().constData() ); // if ( porcentt > BlFixed ( "0.00" ) ) { // parreqeq = ( it.value() - it.value() * porcentt / 100 ) * preqeq / 100; // } else { // parreqeq = it.value() * preqeq / 100; // } // end if // html1 += "R.Eq " + it.key() + "% " + parreqeq.toQString() + "<BR>"; // totreqeq = totreqeq + parreqeq; // } // end for // // BlFixed totirpf = totbaseimp * irpf / 100; // // html1 += "<B>Base Imp. " + totbaseimp.toQString() + "<BR>"; // html1 += "<B>IVA. " + totiva.toQString() + "<BR>"; // html1 += "<B>IRPF. " + totirpf.toQString() + "<BR>"; // // BlFixed total = totiva + totbaseimp + totreqeq - totirpf; // html1 += "<B>Total: " + total.toQString() + "<BR>"; // // html += "</p>"; // html1 += "</FONT>"; // // /// Pintamos el HTML en el textBrowser // mtick->mui_browser->setText ( html ); // // return -1; }
void Trabajadores::trabajadorClicked() { BtCompany *emp1 = ( BtCompany * ) mainCompany(); BtTicket *ticket = NULL; BtTicket *ticketv = NULL; bool encontrado = false; /// Buscamos cual ha sido el trabajador pulsado. BlDbRecordSet *cur = mainCompany() ->loadQuery ( "SELECT * FROM trabajador" ); while ( !encontrado && !cur->eof() ) { if ( ( ( QPushButton * ) sender() ) ->text() == cur->value( "nomtrabajador" ) + " " + cur->value( "apellidostrabajador" ) && ((cur->value("passwordtrabajador") == mui_password->text() || cur->value("passwordtrabajador") == "")) ) { encontrado = true; } else { cur->nextRecord(); } // end if } // end while if (encontrado) { /// Buscamos el ticket vacio de este trabajador y lo pintamos for ( int i = 0; i < emp1->listaTickets() ->size(); ++i ) { ticket = emp1->listaTickets() ->at ( i ); if ( ticket->nomTicketDefecto() == ticket->dbValue ( "nomticket" ) && cur->value( "idtrabajador" ) == ticket->dbValue ( "idtrabajador" ) ) { ( ( BtCompany * ) mainCompany() ) ->setTicketActual ( ticket ); ticket->pintar(); ticketv = ticket; }// end if }// end for /// Si el trabajador no tiene ticket vacio lo creamos y le ponemos el idtrabajador. if ( !ticketv ) { BtTicket * tick = emp1->newBtTicket(); tick->setDbValue ( "idtrabajador", cur->value( "idtrabajador" ) ); emp1->setTicketActual ( tick ); emp1->listaTickets() ->append ( tick ); tick->pintar(); }// end if /// Segun los privilegios que tenga el camarero le desabilitamos determinados objetos. if(cur->value("admintrabajador") == "t") { QToolButton *toolz = g_main->findChild<QToolButton *> ( "mui_z" ); if (toolz) { toolz->setEnabled(true); } // end if QToolButton *toolx = g_main->findChild<QToolButton *> ( "mui_x" ); if (toolx) { toolx->setEnabled(true); } // end if QToolButton *toolborraticket = g_main->findChild<QToolButton *> ( "mui_borrarticket" ); if (toolborraticket) { toolborraticket->setEnabled(true); } // end if } else { QToolButton *toolz = g_main->findChild<QToolButton *> ( "mui_z" ); if (toolz) { toolz->setEnabled(false); } // end if QToolButton *toolx = g_main->findChild<QToolButton *> ( "mui_x" ); if (toolx) { toolx->setEnabled(false); } // end if QToolButton *toolborraticket = g_main->findChild<QToolButton *> ( "mui_borrarticket" ); if (toolborraticket) { toolborraticket->setEnabled(false); } // end if } // end if delete cur; m_validUser = true; done ( 0 ); } // end if }
void Mesa::mouseReleaseEvent(QMouseEvent* event) { BtTicket *ticket; BtCompany * emp = ( BtCompany * ) mainCompany(); if (event -> button() == Qt::LeftButton) { if (!g_bloqueo) { event->accept(); // do not propagate if (m_escalando > 0) { m_escalando = 0; repaint(); } // end if } else { if (g_selectMode) { abrirMesa(); } else { /// Comprueba que la mesa no este seleccionada previamente. /// Si es el caso se deselecciona. int indexNombreMesa = g_selectedTables.indexOf(m_nombreMesa); if (indexNombreMesa == -1) { /// No esta en la lista. /// Comprueba que la mesa este abierta. Si no no se puede seleccionar. for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) { ticket = emp->listaTickets() ->at ( i ); if ( m_nombreMesa == ticket->dbValue ( "nomticket" )) { g_selectedTables.push_back(m_nombreMesa); break; } // end if } // end for } else { /// Esta en la lista. Se borra. g_selectedTables.removeAt(indexNombreMesa); } // end if update(); if ((g_selectedTables.count() == 2) && g_joinTables) { /// Se han seleccionado 2 mesas y esta activo el modo 'unir mesas'. /// Encuentra a que 2 tickets corresponden. BtTicket *ticket1; BtTicket *ticket2; for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) { ticket1 = emp->listaTickets() ->at ( i ); if ( g_selectedTables[0] == ticket1->dbValue ( "nomticket" ) ) { break; } // end if } // end for for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) { ticket2 = emp->listaTickets() ->at ( i ); if ( g_selectedTables[1] == ticket2->dbValue ( "nomticket" ) ) { break; } // end if } // end for emp->joinTickets(ticket1, ticket2); g_selectMode = TRUE; g_joinTables = FALSE; g_selectedTables.clear(); g_mesas->m_distro->mui_table_move -> setChecked (FALSE); update(); abrirMesa(); } // end if } // end if } // end if } // end if }
void Mesa::abrirMesa() { BtCompany * emp = ( BtCompany * ) mainCompany(); /// Miramos que no haya ningun ticket abierto con el nombre usado BtTicket *ticket; for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) { ticket = emp->listaTickets() ->at ( i ); if ( m_nombreMesa == ticket->dbValue ( "nomticket" )) { /// Quitamos el bloqueo emp->ticketActual() ->setDbValue( "bloqueadoticket", "FALSE"); /// Llamamos a plugins para poder hacer lo pertinente g_plugins->run("Abrevs_on_mui_aparcar_clicked", this); /// Ponemos al trabajador creado el trabajador del ticket actual. emp->setTicketActual ( ticket ); /// Borra el valor del Input. emp->pulsaTecla ( Qt::Key_F4, "" ); /// Llamamos a plugins para poder hacer lo pertinente g_plugins->run("Abrevs_on_mui_aparcar_clicked_Post", this); /// Ponemos el nuevo bloqueo ticket->setDbValue("bloqueadoticket", "TRUE"); ticket->pintar(); g_mesas->on_mui_mesas_clicked(); return; }// end if }// end for BtTicket *tick; tick = emp->newBtTicket(); tick->setDbValue ( "idtrabajador", emp->ticketActual() ->dbValue ( "idtrabajador" ) ); emp->setValorBtInput(m_nombreMesa); emp->listaTickets() ->insert ( 0, tick ); /// El nombre del ticket a aparcar lo coge del BtInput. tick ->setDbValue ( "nomticket", m_nombreMesa ); /// Quitamos el bloqueo emp->ticketActual() ->setDbValue( "bloqueadoticket", "FALSE"); /// Llamamos a plugins para poder hacer lo pertinente g_plugins->run("Abrevs_on_mui_aparcar_clicked", this); /// Ponemos al trabajador creado el trabajador del ticket actual. emp->setTicketActual ( tick ); /// Borra el valor del Input. emp->pulsaTecla ( Qt::Key_F4, "" ); /// Llamamos a plugins para poder hacer lo pertinente g_plugins->run("Abrevs_on_mui_aparcar_clicked_Post", this); /// Ponemos el nuevo bloqueo tick->setDbValue("bloqueadoticket", "TRUE"); tick->pintar(); g_mesas->on_mui_mesas_clicked(); }
void Mesa::paintEvent ( QPaintEvent * event ) { QPainter painter; painter.begin ( this ); // paint in picture painter.setPen(QColor(0, 0, 0, 255)); QFont sansFont("Helvetica [Cronyx]", 8); QFont normal("Helvetica [Cronyx]", 10); painter.setFont(normal); BtCompany * emp = ( BtCompany * ) mainCompany(); if (g_selectedTables.contains(m_nombreMesa) && (!g_selectMode)) { painter.fillRect(0,0,m_XScale,m_YScale, QColor(255,255,0)); } // end if /// Miramos que no haya ningun ticket abierto con el nombre usado BtTicket *ticket = NULL; for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) { ticket = emp->listaTickets() ->at ( i ); if ( m_nombreMesa == ticket->dbValue ( "nomticket" )) { if (ticket->dbValue("idalbaran") != "") { painter.setBrush(Qt::cyan); painter.drawRect(QRectF (0, 0, m_XScale, 30)); painter.setBrush(Qt::NoBrush); } // end if int min = ticket->elapsed() / 60000; int sec = (ticket->elapsed() % 60000) / 1000; QString tiempo; tiempo.sprintf( "%02i:%02i", min, sec ); painter.setFont(sansFont); painter.drawText(0,20, tiempo); painter.setFont(normal); painter.setPen(QColor(255, 0, 0, 127)); }// end if }// end for painter.drawText(0, 10, m_nombreMesa); if (m_escalando == 0) { QSvgRenderer arender(QString(m_filename), this); // arender.render(&painter, QRectF (0, 15, g_escala, g_escala)); arender.render(&painter, QRectF (0, 15, m_XScale, m_YScale)); } if (g_mesaAct == this) { if (!g_bloqueo) { painter.setPen(QColor(0, 0, 0, 127)); painter.setPen(Qt::DashDotLine); painter.drawRect(0,0,m_XScale,m_YScale); painter.setPen(QColor(0, 0, 0, 127)); painter.setPen(Qt::DashDotLine); painter.setBrush(Qt::green); painter.drawRect(0,0,5,5); painter.drawRect(0,m_YScale -5, 5, 5); painter.drawRect(m_XScale -5,0, 5, 5); painter.drawRect(m_XScale -5,m_YScale -5, 5, 5); painter.drawRect(m_XScale / 2 -3,m_YScale -5, 5, 5); painter.drawRect(m_XScale / 2 -3, 0, 5, 5); painter.drawRect(0,m_YScale / 2 -3, 5, 5); painter.drawRect(m_XScale - 5,m_YScale / 2 -3, 5, 5); } else { painter.setPen(Qt::DashDotLine); painter.drawRect(0,0,m_XScale,m_YScale); }// end if } //end if painter.end(); }