?? cal_fee.c
字號:
#include <string.h>
#include <stdlib.h>
#include <bio.inc>
#include <menu.inc>
#include <key.inc>
#include "feedef.h"
ACC_STRUCT Account = { 0,0,0, 0,0,0, 0,0,0, 0,
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
0, 0
};
/* function : calculate the total dialing fee for all the phone
* called by : statistics()
* date : 1993.10.9
*/
void cal_total_fee(void)
{
UI i, j=0;
UC flag, user[10];
FILE *fp;
PHONE_STRUCT *phone;
AUTHCD_STRUCT *authcd;
UI SpecLen[2];
load_phone_tbl();
flag = load_authcd_tbl(0);
if(flag == TRUE)
{
Authflg=ON;
ANewlen = authcd_tbl_len();
}
else
{
Authflg=OFF;
message(AUTHCD_FILE_ERR);
}
load_special_tbl(0); /* local call definition table */
load_special_tbl(1); /* information call definition table */
SpecLen[0] = special_tbl_len(0); /* local */
SpecLen[1] = special_tbl_len(1); /* information */
message_disp(8,"正在計算, 請稍候..."); /* calculating, please wait... */
Newlen = phone_tbl_len();
for(i=0; i<Newlen; i++)
{
(Phone_top+i)->intern_time = 0;
(Phone_top+i)->intern_charge = 0;
(Phone_top+i)->intern_count = 0;
(Phone_top+i)->nation_time = 0;
(Phone_top+i)->nation_charge = 0;
(Phone_top+i)->nation_count = 0;
(Phone_top+i)->local_time = 0;
(Phone_top+i)->local_charge = 0;
(Phone_top+i)->local_count = 0;
(Phone_top+i)->addfee[4] = 0;
}
if(Authflg == ON)
{
for(i=0; i<ANewlen; i++)
{
(Auth_cd_top+i)->intern_time = 0;
(Auth_cd_top+i)->intern_charge = 0;
(Auth_cd_top+i)->intern_count = 0;
(Auth_cd_top+i)->nation_time = 0;
(Auth_cd_top+i)->nation_charge = 0;
(Auth_cd_top+i)->nation_count = 0;
(Auth_cd_top+i)->local_time = 0;
(Auth_cd_top+i)->local_charge = 0;
(Auth_cd_top+i)->local_count = 0;
(Auth_cd_top+i)->addfee = 0;
}
}
for(i=0; i<2; i++)
{
if(i == 0)
fp = fopen("idd.dbf","rb");
else
fp = fopen("idd.hst","rb");
if(fp != NULL)
{
while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fp) == 1)
{
if(!is_in_range()) /* not in the sorting time range */
continue;
if(temp_list.auth_code == 0xaaaaaa)
{
ltoa(temp_list.caller2, user, 10); /* int to ASCII string */
phone = binary_search(user); /* locate the phone No */
if(phone == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
phone->intern_time += temp_list.time;
phone->intern_count += 1;
if(phone->feeflag[4]) { /* IDD fee */
phone->intern_charge += temp_list.charge-temp_list.add;
phone->addfee[4] += (UL)temp_list.add;
}
}
else if(Authflg == ON)
{
authcd = binary_authcd(temp_list.auth_code); /* locate the phone No */
if(authcd == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
authcd->intern_time += temp_list.time;
authcd->intern_charge += temp_list.charge-temp_list.add;
authcd->intern_count += 1;
authcd->addfee += (UL)temp_list.add;
}
}
fclose(fp);
}
}
for(i=0; i<2; i++)
{
if(i == 0)
fp = fopen("ddd.dbf","rb");
else
fp = fopen("ddd.hst","rb");
if(fp != NULL)
{
while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fp) == 1)
{
if(!is_in_range()) /* not in the sorting time range */
continue;
if(temp_list.auth_code == 0xaaaaaa)
{
ltoa(temp_list.caller2, user, 10); /* int to ASCII string */
phone = binary_search(user); /* locate the phone No */
if(phone == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
phone->nation_time += temp_list.time;
phone->nation_count += 1;
if(phone->feeflag[3]) { /* DDD fee */
phone->nation_charge += temp_list.charge-temp_list.add;
phone->addfee[4] += (UL)temp_list.add;
}
}
else if(Authflg == ON)
{
authcd = binary_authcd(temp_list.auth_code); /* locate the phone No */
if(authcd == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
authcd->nation_time += temp_list.time;
authcd->nation_count += 1;
authcd->nation_charge += temp_list.charge-temp_list.add;
authcd->addfee += (UL)temp_list.add;
}
}
fclose(fp);
}
}
for(i=0; i<2; i++)
{
if(i == 0)
fp = fopen("ldd.dbf","rb");
else
fp = fopen("ldd.hst","rb");
if(fp != NULL)
{
while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fp) == 1)
{
if(!is_in_range()) /* not in the sorting time range */
continue;
j++;
if(temp_list.auth_code == 0xaaaaaa)
{
ltoa(temp_list.caller2, user, 10); /* int to ASCII string */
phone = binary_search(user); /* locate the phone No */
if(phone == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
phone->local_time += temp_list.time;
phone->local_count += 1;
if( phone->feeflag[0] && phone->feeflag[1] && phone->feeflag[2])
{
phone->local_charge += temp_list.charge-temp_list.add;
phone->addfee[4] += (UL)temp_list.add;
}
else {
UC f1, f2;
f1 = IsSpecialCall(temp_list.callee,SpecLen[0],0);
f2 = IsSpecialCall(temp_list.callee,SpecLen[1],1);
if( (phone->feeflag[1] && f1)
||(phone->feeflag[2] && f2)
|| (phone->feeflag[0] && !(f1 && f2) ))
{
phone->local_charge += temp_list.charge-temp_list.add;
phone->addfee[4] += (UL)temp_list.add;
}
}
}
else if(Authflg == ON)
{
authcd = binary_authcd(temp_list.auth_code); /* locate the phone No */
if(authcd == NULL) /* can't find the No */
continue;
if(temp_list.time%60 != 0 )
temp_list.time = (temp_list.time/60 + 1)*60;
authcd->local_time += temp_list.time;
authcd->local_charge += temp_list.charge-temp_list.add;
authcd->local_count += 1;
authcd->addfee += (UL)temp_list.add;
}
}
fclose(fp);
}
}
unload_special_tbl(0);
unload_special_tbl(1);
save_phone_tbl(0, 0);
unload_phone_tbl();
if(Authflg == ON)
{
save_authcd_tbl(NOFRESH, 0);
unload_authcd_tbl();
}
fp = fopen(TotTimeFileName,"wb");
fwrite(&s_time, sizeof(TIME_STRUCT), 1, fp);
fwrite(&e_time, sizeof(TIME_STRUCT), 1, fp);
fclose(fp);
message_end();
return;
}
/* function : calculate the total dialing fee for all the phone
* called by : statistics()
* date : 1993.10.9
*/
UC cal_acc_fee(UC isacc)
{
UI i;
UC sflag=0;
TIME_STRUCT stime, etime;
ACC_STRUCT acc;
FILE *fp;
if(isacc == BAN_ACC)
fp = fopen("gfsdata\\feeacc.dat","rb");
else if(isacc == DAY_ACC)
fp = fopen("gfsdata\\banacc.dat","rb");
else if(isacc == MON_ACC)
fp = fopen("gfsdata\\dayacc.dat","rb");
else if(isacc == YEAR_ACC)
fp = fopen("gfsdata\\monacc.dat","rb");
else
return(FALSE);
if(fp != NULL)
{
message_disp(8,"正在計算, 請稍候..."); /* calculating, please wait... */
Account.intern_time = 0;
Account.intern_charge = 0;
Account.intern_count = 0;
Account.nation_time = 0;
Account.nation_charge = 0;
Account.nation_count = 0;
Account.local_time = 0;
Account.local_charge = 0;
Account.local_count = 0;
Account.month_lease = 0;
for(i=0; i<5; i++)
Account.addfee[i] = 0;
while(fread(&acc, sizeof(ACC_STRUCT), 1, fp) == 1)
{
Account.intern_time += acc.intern_time;
Account.intern_count += acc.intern_count;
Account.intern_charge+= acc.intern_charge;
Account.nation_time += acc.nation_time;
Account.nation_count += acc.nation_count;
Account.nation_charge+= acc.nation_charge;
Account.local_time += acc.local_time;
Account.local_count += acc.local_count;
Account.local_charge += acc.local_charge;
Account.month_lease += acc.month_lease;
for(i=0; i<5; i++)
Account.addfee[i]+= acc.addfee[i];
if(sflag == 0)
{
sflag = 1;
stime.year = acc.seral_no.year+1900;
stime.month = acc.seral_no.month;
stime.day = acc.seral_no.day;
stime.hour = acc.seral_no.hour;
}
etime.year = acc.seral_no.year+1900;
etime.month = acc.seral_no.month;
etime.day = acc.seral_no.day;
etime.hour = acc.seral_no.hour;
etime.hour++;
}
fclose(fp);
if(isacc == BAN_ACC)
fp = fopen("gfsdata\\bantime.dat","wb");
else if(isacc == DAY_ACC)
fp = fopen("gfsdata\\daytime.dat","wb");
else if(isacc == MON_ACC)
fp = fopen("gfsdata\\montime.dat","wb");
else if(isacc == YEAR_ACC)
fp = fopen("gfsdata\\yeartime.dat","wb");
else
{
message_end();
return(FALSE);
}
fwrite(&stime, sizeof(TIME_STRUCT), 1, fp);
fwrite(&etime, sizeof(TIME_STRUCT), 1, fp);
fclose(fp);
message_end();
}
else
return(FALSE);
return(TRUE);
}
/* function : calculate the total dialing fee for all the phone
* called by : statistics()
* date : 1993.10.9
*/
void clr_acc_rcd(UC isacc)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -