📄 sale.c
字号:
/*
* Module: SALE.C
* Modified by: X.C.Zheng WeiHua
* Modified on: Date: 03-8-11 14:03
* Copyright(c) WeiHua Tech Ltd.
*/
#include "ecrsys.h"
#include "ftype.h"
#include "sysdata.h"
#include "data.h"
#include "mathes.h"
#include "stdlib.h"
#include "disp.h"
#include "keydef.h"
#include <string.h>
#include "Tft_disp.h"
#include "font.h"
/*************************************************************/
void salemain(void)
{
int Idx; /* The index number of Get the DEPT no. */
Lcd_Init_Sys_ID(SYS_ID_SALE_MAIN);
#ifdef REST_PLU_FUNC
menu_length=0;
#endif
if(continue_sale_flag != 0xAA) /* The last transaction is end normally */
{
InitTrans();
if((sysflag->clerk_mode)&&(currclerk == NUL_VLU))
{
Comm_SetStatus(STATUS_SALE);
// clerkpass(); /* Call the clerk password validate function */
Comm_SetStatus(STATUS_IDLE);
}
if(MainMode == CurrMode) /* When MainMode not equal to the CurrMode, Do not display the time */
{
DisTime();
}
Lcm_Disp_Str(Disp_Mode_Reg, LCM_LINE_2, ALIGN_MID, FALSE);
Clr_Dsp_Data();
RightDisp(0L, sysflag->sysdots);
}
else /* The last transaction is not end for the power down */
{
//VFDDisplay(Disp_Sale_Pwr_Dwn,NOTCLEARD,LEFT);
Lcm_Disp_Str(Disp_Sale_Pwr_Dwn ,LCM_LINE_2,ALIGN_MID, FALSE);
Lcm_Disp_Str(Last_Trans_Not_End ,LCM_LINE_1 ,ALIGN_MID, FALSE);
}
if(sysflag->tax_shift_mode) /* When the tax shift function is stay-down, set the tax flag */
Do_Tax_Flag();
Clr_Staus_Flag(); /* Clear the all system status flag */
Open_Step = 0;
while (TRUE) /* do forever until control key is changed */
{
if (!NewTrans)
{
Comm_SetStatus(STATUS_IDLE);
}
else
{
Comm_SetStatus(STATUS_SALE);
}
if (GetIn() == NG) /* Get a item from keyboard */
{
Clr_Dsp_Data();
RightDisp(0, sysflag->sysdots);
continue;
}
GetMainMode();
if(MainMode != CurrMode)
{
#ifdef VER_RSNT /* Support the restaurant function */
if((CurrMode == TRAINING) && (work_mode == RSNT)) /* When in the training mode, clear the table buffer */
{
for(Idx = 0; Idx < Max_Table_No; Idx ++)
Clr_Table(Idx);
}
#endif /* End VER_RSNT */
#ifdef RCPT_REPRN /* Support the receipt reprint function */
if(CurrMode == TRAINING)
Rcpt_RePrn_Cnt = 0; /* Not to reprint the receipt again */
#endif /* End RCPT_REPRN */
if((ra_flag) || (po_flag))
{
ra_flag = 0;
po_flag = 0;
}
return;
}
sysflag->wgt_bar.reg_flag = 0; /* Clear this flag */
if((InCmd < KD_DPLU_ST) || (InCmd > KD_DPLU_END))
{
#ifdef SCANNER /* Support the scanner function */
if((InCmd != KD_PLU) && (InCmd != SPLU) && (InCmd != KD_CLEAR) && (InCmd != KD_VOID)
&&(pluenflag == 1))
#else /* Else SCANNER */
if((InCmd != KD_PLU) && (InCmd != KD_CLEAR) && (InCmd != KD_VOID)
&&(pluenflag == 1))
#endif /* End SCANNER */
/* When the last press is AMOUNT key, and if this press is not the PLU key, error */
{
errorType(ERR_KEY_SEQ);
continue;
}
}
if (Open_Step == 1)
{
if (InCmd >= KD_TABLE_SPLIT_ST && InCmd <= KD_TABLE_SPLIT_END)
{
Do_Table_Split();
Do_Waiter_Select();
Open_Step = 2;
}
else
{
Open_Step = 0;
Lcd_Init_Sys_ID(SYS_ID_SALE_MAIN);
}
continue;
}
else if (Open_Step == 2)
{
if (InCmd >= KD_WAITER_ST && InCmd <= KD_WAITER_END)
{
Table_Sale_Init();
}
else if (InCmd >= KD_PAGE_LEFT_WAITER || InCmd == KD_PAGE_RIGHT_WAITER)
{
Do_Page_Waiter();
}
else
{
Open_Step = 0;
Lcd_Init_Sys_ID(SYS_ID_SALE_MAIN);
}
continue;
}
Comm_SetStatus(STATUS_SALE);
switch(InCmd)
{
case KD_F1:
case KD_F2:
case KD_CALC:
DEBUG_TMP(
errorType(ERR_FUNC_RES);
)
break;
case KD_PCLINK:
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, CLR);
Comm_SetStatus(STATUS_COMM);
Communication();
Comm_SetStatus(STATUS_IDLE);
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, SET);
Clr_Dsp_Data();
RightDisp(0, sysflag->sysdots);
break;
case KD_CLEAR: /* Clear key */
Do_Clear();
break;
case KD_CASH: /* Cash Tender key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if(ra_flag)
{
Do_RA_Ex();
break;
}
else if(po_flag)
{
Do_PO_Ex();
break;
}
#ifdef RCPT_REPRN /* Support the receipt reprint function */
if((numcnt == 0) && (!NewTrans) && (Rcpt_RePrn_Cnt != 0))
{
if((Void_flag) || (RM_flag) || (Mul_flag))
{errorType(ERR_KEY_SEQ);break;}
RePrn_Rcpt(1);
DisTime();
break;
}
#endif /* End RCPT_REPRN */
Do_Cash();
break;
case KD_PCASH1: /* Preset cash key */
case KD_PCASH2:
case KD_PCASH3:
case KD_PCASH4:
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if((ra_flag) || (po_flag))
{
errorType(ERR_KEY_SEQ);
break;
}
if(numcnt)
{errorType(ERR_DIGIT_ILLEGAL);break;}
PCASH_Idx = get_PCASH();
numcnt = 1; /* Sign the equal function has input the money */
lnum = PCASH[PCASH_Idx].price; /* Get the price */
// InCmd = KD_CASH;
Do_Cash();
break;
case KD_CHECK: /* Check key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if(ra_flag)
{
Do_RA_Ex();
break;
}
else if(po_flag)
{
Do_PO_Ex();
break;
}
if(!numcnt)
Check_Idx = 0;
else /* Get the check index number */
{
if( lnum > MAX_CHECK_NUM || lnum < 1 )
{errorType(ERR_DIGIT_ILLEGAL);break;}
Check_Idx = lnum - 1;
}
Do_Cash();
break;
case KD_CHARGE: /* Charge key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if(ra_flag)
{
Do_RA_Ex();
break;
}
else if(po_flag)
{
Do_PO_Ex();
break;
}
if(!numcnt)
Charge_Idx = 0;
else /* Get the charge index number */
{
if( lnum > MAX_CHARGE_NUM || lnum < 1 )
{errorType(ERR_DIGIT_ILLEGAL);break;}
Charge_Idx = lnum - 1;
}
Do_Cash();
break;
case KD_MISC: /* Miscellaneous tender key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if(ra_flag)
{
Do_RA_Ex();
break;
}
else if(po_flag)
{
Do_PO_Ex();
break;
}
Do_Cash();
break;
case KD_NS : /* #NS key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
if((ra_flag) || (po_flag))
{
errorType(ERR_KEY_SEQ);
break;
}
Do_NS();
break;
case KD_RA : /* RA Key */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
Do_RA();
break;
case KD_PO : /* Paid out */
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
Do_PO();
break;
case KD_DEPT:
if((ra_flag) || (po_flag))
{
errorType(ERR_KEY_SEQ);
break;
}
if(numcnt == 0)
{
errorType(ERR_KEY_ILLEGAL);
break;
}
if((lnum > Max_Dept_No)||(lnum <= 0))
{
errorType(ERR_DEPT_OVER);
break;
}
Idx = lnum -1;
Do_Dept(Idx);
break;
case KD_PLU: /* PLU key */
#ifdef SCANNER /* Support the scanner function */
case SPLU: /* End SPLU */
if((ra_flag) || (po_flag))
{
errorType(ERR_KEY_SEQ);
break;
}
if((InCmd == SPLU) || (BarInFlag == 1))
{
if(Judge_Weight_PLU(BCDbuf) == OK)
{
if(Weight_PLU_Process() == NG) /* The process is no good */
break;
}
else
{
if ((Idx = SC_SearchIndex(BCDbuf)) < 0)
{errorType(ERR_BAR_EXIST);break;}
else
{
Idx = Sindex[Idx];
lnum = Idx + 1; /* The index number */
numcnt = 4; /* Set a not zero data */
}
}
}
#endif /* End SCANNER */
if(InCmd == KD_PLU)
{
if((lnum == 0) && (numcnt == 1))
{
Inquire_PLU_Price(); /* Inquire the PLU price */
break;
}
#ifdef STOCK
else if((lnum == 0) && (numcnt == 2))
{
Inquire_PLU_Stock(); /* Inquire the PLU stock */
break;
}
#endif
}
Do_PLU();
break;
#ifdef REST_PLU_FUNC
case KD_MENU01:
case KD_MENU02:
case KD_MENU03:
case KD_MENU04:
case KD_MENU05:
case KD_MENU06:
case KD_MENU07:
case KD_MENU08:
case KD_MENU09:
case KD_MENU10:
if((ra_flag) || (po_flag))
{
errorType(ERR_KEY_SEQ);
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -