Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

labcashbox.ui.h

00001 
00002 static QMap< QString, QString > pgBtns ;
00003 static QMap< QString, int > directActions ;
00004 static QMap< QString, int > payStrategies ;
00005 
00006 
00007 void LabCashbox::init()
00008 {
00009         ticketViewTable->setLeftMargin( 0 ) ;
00010         ticketViewTable->setColumnWidth( 0, 50 ) ;
00011         ticketViewTable->setColumnWidth( 1, 150 ) ;
00012         ticketViewTable->setColumnWidth( 2, 50 ) ;
00013         ticketViewTable->setColumnWidth( 3, 50 ) ;
00014         ticketViewTable->setColumnStretchable( 1, TRUE ) ;
00015         ticketViewTable->refresh( QDataTable::RefreshAll ) ;
00016         totalLCDNumber->display( tr( "hello" ) ) ;
00017 
00018         cdata = new QlabCashbox( this, "LabCashbox" ) ;
00019 
00020         cdata->setStatus( QlabCashbox::Opened ) ;  // Box opened
00021         cdata->setActionCode( QlabCashbox::Ready ) ;
00022         cdata->clearLine() ;
00023         cdata->setCountDone( FALSE ) ;
00024         stdGetterLineEdit->setFocus() ;
00025 
00026         setFreeButtons() ;
00027         inInit = TRUE ;
00028         newTicket() ;
00029         inInit = FALSE ;
00030 }
00031 
00032 void LabCashbox::CloseBox()
00033 {
00034         if ( !cdata->countDone() ) {
00035         countBox( "Closing" ) ;
00036         }
00037         cdata->setStatus( QlabCashbox::Closed ) ;
00038         close() ;
00039 }
00040 
00041 
00042 void LabCashbox::PauseBox()
00043 {
00044         cdata->setStatus( QlabCashbox::Paused ) ;
00045         LoginForm * dialog = new LoginForm( this, "Login Form", TRUE ) ;
00046         if ( dialog->exec() == QDialog::Accepted ) {
00047         cdata->setStatus( QlabCashbox::Opened ) ;
00048         } else {
00049         close() ;
00050         }
00051         delete dialog ;
00052 }
00053 
00054 
00055 void LabCashbox::countBox( const QString & mode)
00056 {
00057         CashboxCount * dialog = new CashboxCount( this, "Count Box", TRUE ) ;    
00058         dialog->setMode( mode ) ;
00059         dialog->exec() ;
00060 }
00061 
00062 
00063 void LabCashbox::withdrawalBox()
00064 {
00065         countBox( "Withdrawal" ) ;
00066 }
00067 
00068 
00069 void LabCashbox::optionsBox()
00070 {
00071         qDebug( "Specific options will be inserted here. Not yet implemented" ) ;
00072 }
00073 
00074 
00075 void LabCashbox::superviseMode()
00076 {
00077 
00078 }
00079 
00080 
00081 void LabCashbox::doAction()
00082 {
00083         QString line = stdGetterLineEdit->text().stripWhiteSpace() ;
00084         if ( line.isEmpty() ) return ;
00085         qDebug( "Entered doAction" ) ;
00086         switch ( cdata->actionCode() ) {
00087         case QlabCashbox::Ready : 
00088         qDebug( "Box is Ready" ) ;
00089         CurProd1TextLabel->setText( "" ) ;
00090         if ( cdata->findPart( line ) ) {
00091                 CurProd2TextLabel->setText( "" ) ;
00092                 ticketViewTable->refresh( QDataTable::RefreshData ) ;
00093                 PriceLCDNumber->display( cdata->getElement( QlabCashbox::TTotal ).toDouble() ) ;
00094                 currLineTextLabel->setText( cdata->getElement( QlabCashbox::TProdName ).toString() ) ;
00095                 totalLCDNumber->display( cdata->getElement( QlabCashbox::TGrandTotal ).toDouble() ) ;
00096                 objectsLCDNumber->display( cdata->getElement( QlabCashbox::TTotalItems ).toInt() ) ;
00097                 stdGetterLineEdit->setText( "" ) ;
00098                 cdata->clearLine() ;
00099         } else {
00100                 stdGetterLineEdit->setText( "" ) ;
00101                 CurProd2TextLabel->setText( QString( tr( "Part: %1 not found" ).arg( line ) ) ) ;
00102         }
00103         break ;
00104         case QlabCashbox::Searching : 
00105         break ;
00106         case QlabCashbox::Payment : 
00107         qDebug( "Box is in PayMode" ) ;
00108         if ( cdata->
00109         break ;
00110         case QlabCashbox::BegSubTotal : 
00111         break ;
00112         case QlabCashbox::BegTotal : 
00113         break ;
00114         case QlabCashbox::BegImmediateCancel : 
00115         if ( !cdata->cancelLast() ) {
00116                 CurProd1TextLabel->setText( tr( "Invalid action. Nothing to cancel now." ) ) ;  
00117         }
00118         cdata->setActionCode( QlabCashbox::Ready ) ;
00119         break ;
00120         case QlabCashbox::BegTicketCancel : 
00121         if ( !cdata->cancelLastTicket() ) {
00122                 CurProd1TextLabel->setText( tr( "Could not cancel last ticket." ) ) ;           
00123         }
00124         break ;
00125         case QlabCashbox::BegTransactionCancel :
00126         if ( cdata->getTicketList() ) {
00127                 TicketHistory * dialog = new TicketHistory( this, "TicketHistory", TRUE ) ;
00128                 dialog->setMessage( tr( "Select the ticket to cancel and click Apply" ) ) ;
00129                 dialog->setDateValues( QDate::currentDate() ) ;
00130                 if ( dialog->exec() == QDialog::Accepted ) {
00131 
00132                 }
00133                 delete dialog ;
00134         }
00135         break ;
00136 
00137         /*
00138                 case 9 : // We are in Payment Generration
00139         manageCashPayment() ;
00140         return ;
00141         break ;
00142         */
00143         }
00144 }
00145 
00146 
00147 void LabCashbox::doCount()
00148 {
00149         countBox( "Cash Counting" ) ;
00150 }
00151 
00152 
00153 
00154 void LabCashbox::evalGetLine( const QString & line )
00155 {
00156         if ( line.isEmpty() ) return ;
00157         qDebug( QString( "evalGetLine reports: %1" ).arg( line ) ) ;
00158         CurProd1TextLabel->setText( "" ) ;
00159         QString test = line.right( 1 ) ;
00160         if ( test == "*" ) {
00161                 cdata->setValue( "qty", "1" ) ;
00162         }
00163 }
00164 
00168 /*
00169 Inserts a subtotal line in the current data stream
00170 */
00171 
00172 
00178 void LabCashbox::evalPayStrategy()
00179 {
00180         QString mode = QObject::sender()->name() ;
00181         mode.replace( "Button", "" ) ;
00182         CurProd1TextLabel->setText( "" ) ;
00183         cdata->insertLine( QlabCashbox::Total ) ;
00184         ticketViewTable->refresh( QDataTable::RefreshData ) ;
00185         QlabCashbox::PayDialog act = cdata->setPayStrategy( mode ) ;
00186         switch ( act ) {
00187         case QlabCashbox::GetCashValue : 
00188         CurProd1TextLabel->setText( tr( "Please enter Money value" ) ) ;
00189         break ;
00190         case QlabCashbox::FullPartial :
00191         CurProd1TextLabel->setText( tr( "1 for Full, 2 for partial" ) ) ;
00192         break ;
00193         case QlabCashbox::GetVoucher :
00194         CurProd1TextLabel->setText( tr( "Enter or scan Voucher value" ) ) ;
00195         break ;
00196         case QlabCashbox::GetCustomer :
00197         CurProd1TextLabel->setText( tr( "Customer Code. ? for search" ) ) ;
00198         break ;
00199         case QlabCashbox::UnknownMode :
00200         CurProd1TextLabel->setText( tr( "Unknown Pay Mode. Correct it" ) ) ;
00201         break ;
00202         }
00203 }
00204 
00211 void LabCashbox::evalFreeBtns()
00212 {
00213         QString btn = QObject::sender()->name() ;
00214         stdGetterLineEdit->setText( pgBtns[btn] ) ;
00215         doAction() ;
00216 }
00217 
00221 void LabCashbox::newTicket()
00222 {
00223         currLineTextLabel->setText( "" ) ;
00224         CurProd1TextLabel->setText( tr( "Welcome" ) ) ;
00225         CurProd2TextLabel->setText( tr( "Next Customer" ) ) ;
00226 
00227         ticketInfoLabel->setText( cdata->createTicket() ) ;
00228         if ( !inInit ) {
00229         cdata->insertLine(  QlabCashbox::Header ) ;
00230         PriceLCDNumber->display( 0 ) ;
00231         objectsLCDNumber->display( 0 ) ;
00232         totalLCDNumber->display( 0 ) ;  
00233         }
00234         stdGetterLineEdit->setText( "" ) ;
00235         cdata->setActionCode( QlabCashbox::Ready ) ;
00236 }
00237 
00238 
00242 void LabCashbox::manageCashPayment()
00243 {
00244         double money = stdGetterLineEdit->text().stripWhiteSpace().toDouble() ;
00245         // Save the Cashin value
00246         cdata->setValue( "total", QString( "%1" ).arg( money ) ) ;
00247         cdata->insertLine( QlabCashbox::Cashin ) ;
00248 
00249         CurProd2TextLabel->setText( tr( "Cash Received" ) ) ;
00250         PriceLCDNumber->display( QString::number( money, 'f', 2 ) ) ;
00251         // Refresh View
00252         ticketViewTable->refresh( QDataTable::RefreshData ) ;
00253 
00254         double total = cdata->getGrandTotal() ;
00255         if ( money >= total ) {
00256                 totalLCDNumber->display( QString::number( money - total, 'f', 2 ) ) ;
00257                 CurProd1TextLabel->setText( tr( "Cash to refund" ) ) ;
00258         }
00259         // Save Refund value
00260         cdata->setValue( "total", QString( "%1" ).arg( money - total ) ) ;
00261         cdata->insertLine( QlabCashbox::Refund ) ;
00262         // Refresh View
00263         ticketViewTable->refresh( QDataTable::RefreshData ) ;
00264         // Is ticket closed?
00265         if ( money >= total ) {
00266                 cdata->informMaster( QlabCashbox::TicketEnd ) ;
00267         } else {
00268                 CurProd2TextLabel->setText( tr( "Incomplete. Select complementary pay mode" ) ) ;
00269         }
00270 }
00271 
00286 void LabCashbox::setFreeButtons()
00287 {
00288         // Initialize Free Buttons to some known state
00289         for ( int i = 0; i < 24; i++ ) {
00290         QPushButton * btn = (QPushButton *)this->child( QString( "free%1" ).arg( i + 1 ) );
00291         btn->setEnabled( FALSE ) ;
00292         btn->setText( "" ) ;
00293         connect( btn, SIGNAL( clicked() ), this, SLOT( evalFreeBtns() ) );
00294         }
00295         QStringList btns = cdata->getProgrammableButtons() ;
00296         for ( QStringList::Iterator it = btns.begin(); it != btns.end(); ++it ) {
00297         QString entry = *it ;
00298         QString name = entry.section( "=", 0, 0 ) ;
00299         QString value = entry.section( "{", 1, 1 ).replace( "}", "" ) ;
00300         QString lbl = value.section( ";", 0, 0 ) ;
00301         lbl = lbl.section( "=", 1, 1 ) ;
00302         QString lvalue = value.section( ";", 1, 1 ) ;
00303         lvalue = lvalue.section( "=", 1, 1 ) ;
00304         QPushButton * btn = (QPushButton * )this->child( name ) ;
00305         btn->setText( lbl ) ;
00306         btn->setEnabled( TRUE ) ;
00307         pgBtns.replace( name, lvalue ) ;
00308         }
00309 }
00310 
00314 void LabCashbox::evalDirectAction()
00315 {
00316         QString btn = QObject::sender()->name() ;
00317         btn.replace( "Button", "" ) ;
00318         if ( btn =="subTotal" ) {
00319 
00320         cdata->insertLine( QlabCashbox::Subtotal ) ;
00321         } else if ( btn == "total" ) {
00322         cdata->insertLine( QlabCashbox::Total ) ;
00323         } else if ( btn == "immCancel" ) {
00324         cdata->setActionCode( QlabCashbox::BegImmediateCancel ) ;
00325         doAction() ;
00326         } else if ( btn == "ticketCancel" ) {
00327         cdata->setActionCode( QlabCashbox::BegTicketCancel ) ;
00328         doAction() ;
00329         } else if ( btn == "transactionCancel" ) {
00330         cdata->setActionCode( QlabCashbox::BegTransactionCancel ) ;
00331         doAction() ;
00332         } else if ( btn == "qty" ) {
00333         QString line = stdGetterLineEdit->text() ;
00334         if ( line == "*" || line.isEmpty() ) {
00335                 cdata->setValue( "qty", "1" ) ;
00336                 cdata->setValue( "serial", cdata->prevSerial() ) ;
00337                 stdGetterLineEdit->setText( cdata->prevSerial() ) ;
00338                 doAction() ;
00339         } else {
00340                 cdata->setValue( "qty", stdGetterLineEdit->text().replace( "*", "" ) ) ;
00341         }
00342         CurProd2TextLabel->setText( QString( "%1 x " ).arg( stdGetterLineEdit->text().replace( "*", "" ) ) ) ;
00343         stdGetterLineEdit->setText( "" ) ;
00344         }
00345         ticketViewTable->refresh( QDataTable::RefreshData ) ;
00346 }

 

L.A.B. Project © 2001-2004 LAB Project & DJ Anubis