📄 prn_pfe.c
字号:
#include <string.h>
#include <stdlib.h>
#include <bio.inc>
#include "feedef.h"
/* function: print the notified phone fee
* called by:
* caller:
* date:
*/
UC prt_phone_fee(PHONE_STRUCT *phone, UI num)
{
UL p_no;
double total_f;
struct date now;
if(check_prn() == FALSE) /* not ready */
return(FALSE);
if( num == 0 )
{
if(print_pfehd() == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
if(print_pfedtal() == FALSE)
return(FALSE);
}
else if( (num != 0) && ( (num)%Page_len == 0) )
{
getdate(&now);
if(print_pfetbl() == FALSE)
return(FALSE);
if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时 制表时间:%-4u年%2u月%2u日\n",\
Ps_time.year, Ps_time.month, Ps_time.day, Ps_time.hour,\
Pe_time.year, Pe_time.month, Pe_time.day, Pe_time.hour, \
now.da_year, now.da_mon, now.da_day )\
== FALSE)
return(FALSE);
/* new page */
if(new_page() == FALSE)
return(FALSE);
if(print_pfehd() == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
if(print_pfedtal() == FALSE)
return(FALSE);
}
p_no = atol(phone->phone_no);
total_f = (double)(phone->local_charge)/100+\
((double)(phone->nation_charge)+(double)(phone->intern_charge))/100+\
(double)(phone->addfee[4])/100+\
(double)(phone->month_lease)/100+\
(double)(phone->addfee[2])/100+\
((double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3]))/100;
if(prnf("%-4u %-7lu %7.2f %8.2f %4u %6.2f %6.2f %6.2f %7.2f %9.2f\n", \
num, p_no, (double)(phone->local_charge)/100,\
(double)(phone->nation_charge+phone->intern_charge)/100,\
(phone->nation_count +phone->intern_count),\
(double)(phone->addfee[4])/100,\
((double)phone->month_lease)/100,\
(double)(phone->addfee[2])/100,\
(double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3])/100,\
total_f) == FALSE)
return(FALSE);
return(TRUE);
}
UC print_pfehd(void)
{
UC *head = " 分 机 话 费 汇 总 表";
if(prnfd("\n%s\n\n", head) == FALSE)
return(FALSE);
return(TRUE);
}
UC print_pfetbl(void)
{
if(prnf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n") == FALSE)
return(FALSE);
return(TRUE);
}
UC print_pfedtal(void)
{
if(prnf("序 分机 市话 长话 长话 附加 月租 维修 费用\n") == FALSE)
return(FALSE);
if(prnf("号 号码 话费 话费 次数 费 费 费 杂费 合计\n") == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
return(TRUE);
}
/* function: print the notified user fee
* called by:
* caller:
* date:
*/
UC prt_usr_fee(PHONE_STRUCT *phone, USERS_STRUCT usr, UI num)
{
double total_f;
struct date now;
UI i;
UC usr_nam_buf[11];
if(check_prn() == FALSE) /* not ready */
return(FALSE);
if( num == 0 )
{
if(print_ufehd() == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
if(print_ufedtal() == FALSE)
return(FALSE);
}
else if( (num != 0) && ( (num)%Page_len == 0) )
{
getdate(&now);
if(print_pfetbl() == FALSE)
return(FALSE);
if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时 制表时间:%-4u年%2u月%2u日\n",\
Ps_time.year, Ps_time.month, Ps_time.day, Ps_time.hour,\
Pe_time.year, Pe_time.month, Pe_time.day, Pe_time.hour, \
now.da_year, now.da_mon, now.da_day )\
== FALSE)
return(FALSE);
/* new page */
if(new_page() == FALSE)
return(FALSE);
if(print_ufehd() == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
if(print_ufedtal() == FALSE)
return(FALSE);
}
for(i=0; i<8; i++)
usr_nam_buf[i] = usr.user_name[i];
usr_nam_buf[i] = '\0';
total_f = (double)(phone->local_charge)/100+\
((double)(phone->nation_charge)+(double)(phone->intern_charge))/100+\
(double)(phone->addfee[4])/100+\
(double)(phone->month_lease)/100+\
(double)(phone->addfee[2])/100+\
((double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3]))/100;
if(prnf("%-4u%-10s%2u %7.2f %8.2f %4u %7.2f %6.2f %6.2f %7.2f %9.2f\n", \
num, usr_nam_buf, usr.phones, (double)(phone->local_charge)/100,\
(double)(phone->nation_charge+phone->intern_charge)/100,\
(phone->nation_count +phone->intern_count),\
(double)(phone->addfee[4])/100,\
(double)(phone->month_lease)/100,\
(double)(phone->addfee[2])/100,\
(double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3])/100,\
total_f) == FALSE)
return(FALSE);
return(TRUE);
}
UC print_ufehd(void)
{
UC *head = " 分 户 话 费 汇 总 表";
if(prnfd("\n%s\n\n", head) == FALSE)
return(FALSE);
return(TRUE);
}
UC print_ufedtal(void)
{
if(prnf("序 分机 市话 长话 长话 附加 月租 维修 费用\n") == FALSE)
return(FALSE);
if(prnf("号 户头名 数量 话费 话费 次数 费 费 费 杂费 合计\n") == FALSE)
return(FALSE);
if(print_pfetbl() == FALSE)
return(FALSE);
return(TRUE);
}
/* function : print the detailed information for the phones from the input one
* to the end
* called by : statistic()
* date : 1993.12.11
*/
void prtfee_part(UC opflg)
{
UC flag, phoneno[10];
UL phone_no;
UI pnum=0, lenth, j, i, idx;
double total_f;
FILE *fp, *fpu;
PHONE_STRUCT phoneu = {"",0,0,0,{1,1,1,1,1},0,0,0,0,0,0,0,0,0,0,0,0,0,{0,0,0,0,0}};
USERS_STRUCT user;
PHONE_STRUCT *phone;
struct date now;
fp = fopen(TotTimeFileName,"rb");
if(fp == NULL)
{
message(TFEE_FILE_ERR);
return;
}
fread(&Ps_time, sizeof(TIME_STRUCT), 1, fp);
fread(&Pe_time, sizeof(TIME_STRUCT), 1, fp);
fclose(fp);
if(check_prn() == FALSE) /* not ready */
return;
if(opflg == PHONE_FEE)
flag = inp_phid_num(&phone_no, &lenth, PRINT, PHONE_NO);
else if(opflg == DEPT_FEE)
flag = inp_phid_num(&phone_no, &lenth, PRINT, DEPT_NO);
else
flag = inp_phid_num(&phone_no, &lenth, PRINT, AUTH_CD);
if(flag == 1)
return;
load_phone_tbl();
message_disp(8,"正在打印,请稍候..."); /* printing, please wait... */
if(opflg == PHONE_FEE)
{
Newlen = phone_tbl_len();
i = 0;
phone = Phone_top;
ltoa(phone_no, phoneno, 10);
while(strcmp(phone->phone_no, phoneno) != 0)
{
i++;
phone++;
}
idx = i;
if( (idx+lenth) >= Newlen )
idx = Newlen;
else
idx += lenth;
j=0;
total_f = 0;
for(; i<idx; i++)
{
if(prt_phone_fee(phone, j) == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
total_f += (double)(phone->local_charge)/100+\
(double)(phone->nation_charge+phone->intern_charge)/100+\
(double)(phone->addfee[4])/100+\
(double)(phone->month_lease)/100+\
(double)(phone->addfee[2])/100+\
(double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3])/100;
phone++;
j++;
}
}
else if( opflg == DEPT_FEE)
{
fpu = fopen("gfsdata\\dept.dat","rb");
if(fpu == NULL)
{
unload_phone_tbl();
message(USER_FILE_ERR);
message_end();
return;
}
pnum = 0;
while(fread(&user, sizeof(USERS_STRUCT), 1, fpu) == 1)
{
if(user.user_no != (UI)phone_no)
pnum += user.phones;
else
break;
}
j=0;
total_f = 0;
for(i = 0; i < lenth; i++)
{
clr_ufc(&phoneu, 0);
cal_usr_fee(pnum, &user, &phoneu);
if(prt_usr_fee(&phoneu, user, j) == FALSE)
{
fclose(fpu);
message_end();
unload_phone_tbl();
return;
}
j++;
total_f += (double)(phoneu.local_charge)/100+\
(double)(phoneu.nation_charge+phoneu.intern_charge)/100+\
(double)(phoneu.addfee[4])/100+\
(double)(phoneu.month_lease)/100+\
(double)(phoneu.addfee[2])/100+\
(double)(phoneu.addfee[0]+phoneu.addfee[1]+phoneu.addfee[3])/100;
pnum += user.phones;
if(fread(&user, sizeof(USERS_STRUCT), 1, fpu) != 1) break;
}
fclose(fpu);
}
if(print_total(total_f) == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
if(print_pfetbl() == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
getdate(&now);
if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时 制表时间:%-4u年%2u月%2u日\n",\
Ps_time.year, Ps_time.month, Ps_time.day, Ps_time.hour,\
Pe_time.year, Pe_time.month, Pe_time.day, Pe_time.hour, \
now.da_year, now.da_mon, now.da_day )\
== FALSE)
{
unload_phone_tbl();
message_end();
return;
}
/* new page */
if(new_page() == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
unload_phone_tbl();
message_end();
return;
}
/* function : print the detailed information for all phones
* called by : sta_rpt()
* date : 1993.12.11
*/
void prtfee_all(UC opflg)
{
UI i, j;
UI pnum=0;
double total_f;
FILE *fp, *fpu;
PHONE_STRUCT *phone;
PHONE_STRUCT phoneu = {"",0,0,0,{1,1,1,1,1},0,0,0,0,0,0,0,0,0,0,0,0,0,{0,0,0,0,0}};
USERS_STRUCT user;
struct date now;
if(check_prn() == FALSE) /* not ready */
return;
fp = fopen(TotTimeFileName,"rb");
if(fp == NULL)
{
message(TFEE_FILE_ERR);
return;
}
fread(&Ps_time, sizeof(TIME_STRUCT), 1, fp);
fread(&Pe_time, sizeof(TIME_STRUCT), 1, fp);
fclose(fp);
load_phone_tbl();
message_disp(8,"正在打印,请稍候..."); /* printing, please wait... */
if(opflg == PHONE_FEE)
{
Newlen = phone_tbl_len();
phone = Phone_top;
total_f = 0;
for(i=0; i<Newlen; i++)
{
if(prt_phone_fee(phone, i) == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
total_f += (double)(phone->local_charge)/100+\
(double)(phone->nation_charge+phone->intern_charge)/100+\
(double)(phone->addfee[4])/100+\
(double)(phone->month_lease)/100+\
(double)(phone->addfee[2])/100+\
(double)(phone->addfee[0]+phone->addfee[1]+phone->addfee[3])/100;
phone++;
}
}
else
{
fpu = fopen("gfsdata\\dept.dat","rb");
if(fpu == NULL)
{
unload_phone_tbl();
message(USER_FILE_ERR);
message_end();
return;
}
pnum = 0;
j=0;
total_f = 0;
while(fread(&user,sizeof(USERS_STRUCT),1,fpu) == 1)
{
clr_ufc(&phoneu, 0);
cal_usr_fee(pnum, &user, &phoneu);
if(prt_usr_fee(&phoneu, user, j) == FALSE)
{
message_end();
unload_phone_tbl();
return;
}
j++;
total_f += (double)(phoneu.local_charge)/100+\
(double)(phoneu.nation_charge+phoneu.intern_charge)/100+\
(double)(phoneu.addfee[4])/100+\
(double)(phoneu.month_lease)/100+\
(double)(phoneu.addfee[2])/100+\
(double)(phoneu.addfee[0]+phoneu.addfee[1]+phoneu.addfee[3])/100;
pnum += user.phones;
}
fclose(fpu);
}
if(print_total(total_f) == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
if(print_pfetbl() == FALSE)
{
unload_phone_tbl();
message_end();
return;
}
getdate(&now);
if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时 制表时间:%-4u年%2u月%2u日\n",\
Ps_time.year, Ps_time.month, Ps_time.day, Ps_time.hour,\
Pe_time.year, Pe_time.month, Pe_time.day, Pe_time.hour, \
now.da_year, now.da_mon, now.da_day )\
== FALSE)
{
unload_phone_tbl();
message_end();
return;
}
/* new page */
if(new_page() == FALSE)
{
unload_phone_tbl();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -