# tbsdata wb3.awk ###################################################### function fixdate(dt) { # change /'s to -'s in dd/mm/yyyy sub("/","-",dt) sub("/","-",dt) return dt } #----------------------------------------------------------- function trim(s) { sub(/^[ \t]*/,"",s) sub(/[ \t]*$/,"",s) return s } function clip(s) { sub(/[ \t]*$/,"",s) return s } #----------------------------------------------------------- ##################################################### function ld_t21dircsvfile(t21dircsvfile) { printf("ld_t21dircsvfile(%s)\n", t21dircsvfile) # test 3032,ZVARGULIS,MARIS,8685,MATHS RW # real RecordNo,Surname,Firstname,eXtension,Dept,Div,Title,Location,ServiceID,Email,TEC,Mobile,Fax_Number,Voicemail #real 52182,ZUZIC,EDDIE,57206,SERV DELIVERY,CGE,AREA CONT,TH LEVEL 5,5540THA,,T12R03S04,,57225, while ( (getline aline < t21dircsvfile) > 0 ) { split(aline, a_arr, ",") ##printf("aline=%s\n", aline) #printf("a_arr 1=%s 2=%s 3=%s 4=%s 5=%s\n", a_arr[1], a_arr[2], a_arr[3], a_arr[4], a_arr[5]) recordno = trim(a_arr[1]) t21surname = trim(a_arr[2]) t21firstname = trim(a_arr[3]) extn = trim(a_arr[4]) t21department = trim(a_arr[5]) t21section = t21department div = trim(a_arr[6]) t21title = trim(a_arr[7]) t21location = trim(a_arr[8]) extgroupunique = trim(a_arr[9]) email = trim(a_arr[10]) tec = trim(a_arr[11]) t21mobile = trim(a_arr[12]) fax = trim(a_arr[13]) voicemail = trim(a_arr[14]) if ( t21surname == "" ) t21surname = "Not Set" tmp_t21mobile = t21_mobile gsub(" ","",tmp_t21mobile) gsub("-","",tmp_t21mobile) if ( length(tmp_t21_mobile) == 10 ) t21mobile = substr(tmp_t21mobile,1,4) "-" substr(tmp_t21mobile,5,6) printf(" - t21surname = [%s] t21firstname = [%s] extgroupunique = [%s] extn = [%s]\n", t21surname, t21firstname, extgroupunique, extn) itag = extgroupunique "|" extn #printf(" itag = [%s]\n", itag) if ( egridextn_to_t21surname_arr[itag] == "" ) egridextn_to_t21surname_arr[itag] = t21surname else egridextn_to_t21surname_arr[itag] = "Multiple" if ( egridextn_to_t21firstname_arr[itag] == "" ) egridextn_to_t21firstname_arr[itag] = t21firstname else egridextn_to_t21firstname_arr[itag] = "Multiple" if ( egridextn_to_t21mobile_arr[itag] == "" ) egridextn_to_t21mobile_arr[itag] = t21mobile else egridextn_to_t21mobile_arr[itag] = "Multiple" if ( egridextn_to_t21location_arr[itag] == "" ) egridextn_to_t21location_arr[itag] = t21location else egridextn_to_t21location_arr[itag] = "Multiple" if ( egridextn_to_t21section_arr[itag] == "" ) egridextn_to_t21section_arr[itag] = t21section else egridextn_to_t21section_arr[itag] = "Multiple" if ( egridextn_to_t21title_arr[itag] == "" ) egridextn_to_t21title_arr[itag] = t21title else egridextn_to_t21title_arr[itag] = "Multiple" if ( t21mobile != "" ) { t21mobile_to_egridextn_arr[t21mobile] = itag print "save t21mobile_to_egridextn_arr[" t21mobile "] = [" t21mobile_to_egridextn_arr[t21mobile] "]" } # itag = extgroupunique if ( egrid_to_t21section_arr[itag] == "" ) egrid_to_t21section_arr[itag] = t21section else egrid_to_t21section_arr[itag] = "Multiple" } close(t21dircsvfile) } function ld_t21groups2(t21groups2file) { printf("ld_t21groups2(%s)\n", t21groups2file) while ( (getline aline < t21groups2file) > 0 ) { split(aline, a_arr, "|") ##printf("aline=%s\n", aline) #printf("a_arr 1=%s 2=%s 3=%s 4=%s\n", a_arr[1], a_arr[2], a_arr[3], a_arr[4]) parentgroupid = trim(a_arr[1]) grid = trim(a_arr[2]) grtype = trim(a_arr[3]) grname1 = trim(a_arr[4]) grname2 = trim(a_arr[5]) #printf(" - parentgroupid = [%s] grid = [%s] grtype = [%s] grname1 = [%s] grname2 = [%s]\n", parentgroupid, grid, grtype, grname1, grname2) grid_to_parentgroupid_arr[grid] = parentgroupid grid_to_grtype_arr[grid] = grtype grid_to_grname1_arr[grid] = grname1 grid_to_grname2_arr[grid] = grname2 if ( grtype == "G" ) { DIVID = grid DIVIDdesc1 = grname1 DIVIDdesc2 = grname2 DIVID_to_DIVIDdesc1_arr[DIVID] = DIVIDdesc1 DIVID_to_DIVIDdesc2_arr[DIVID] = DIVIDdesc2 } } close(t21groups2file) } #----------------------------------------------------------------- # load tbs database info #-------------------------- # old tbs database # # #==> tblCustomer.unl <== # #ALH||ALSTOM AUSTRALIA LTD|1|V7074100| # #==> tblServiceGroup.unl <== # #2|Network Services|Robyn Douglas|Level 4; 585 Collins St|1043| # #==> tblServiceElements.unl <== # #1030|2.1.2|Telco switchboard calls|2|1| 1.000000|10|0|| # #==> tblTASSEMap.unl <== # #SA|VICTRACK|CALL DIVERSION||||1050| # #function ld_customer(customerfile) { # printf("ld_customer(%s)\n", customerfile) # #ALH||ALSTOM MTL|1|V7074100| # while ( (getline aline < customerfile) > 0 ) { # split(aline, a_arr, "|") # ##printf("aline=%s\n", aline) # ShipTo = trim(a_arr[1]) # ShipToDesc = trim(a_arr[3]) # ShipToCode = trim(a_arr[5]) # # ShipTo = toupper(ShipTo) # # ShipTo_to_ShipToDesc_arr[ShipTo] = ShipToDesc # ShipTo_to_ShipToCode_arr[ShipTo] = ShipToCode # # #print "ld_customer(" customerfile ") ShipTo = " ShipTo # #print " ShipTo_to_ShipToDesc_arr[" ShipTo "] = " ShipTo_to_ShipToDesc_arr[ShipTo] # #print " ShipTo_to_ShipToCode_arr[" ShipTo "] = " ShipTo_to_ShipToCode_arr[ShipTo] # } # close(customerfile) #} # # #function ld_servicegroup(servicegroupfile) { # printf("ld_servicegroup(%s)\n", servicegroupfile) # while ( (getline aline < servicegroupfile) > 0 ) { # split(aline, a_arr, "|") # ##printf("aline=%s\n", aline) # #printf("a_arr 1=%s 2=%s 5=%s\n", a_arr[1], a_arr[2], a_arr[5]) # #SGID = trim(a_arr[1]) # #SGIDdesc = trim(a_arr[2]) # SGID = 0 # SGIDdesc = "All" # platinumSEID = trim(a_arr[5]) # SGID_to_SGIDdesc_arr[SGID] = SGIDdesc # } # close(servicegroupfile) #} # # #function ld_serviceelements(serviceelementsfile) { # printf("ld_serviceelements(%s)\n", serviceelementsfile) # while ( (getline aline < serviceelementsfile) > 0 ) { # split(aline, a_arr, "|") # ##printf("aline=%s\n", aline) # #printf("a_arr 1=%s 3=%s 4=%s\n", a_arr[1], a_arr[3], a_arr[4]) # SEID = trim(a_arr[1]) # SEIDdesc = trim(a_arr[3]) # #SGID = trim(a_arr[4]) # SGID = 0 # SEID_to_SEIDdesc_arr[SEID] = SEIDdesc # SEID_to_SGID_arr[SEID] = SGID # } # close(serviceelementsfile) #} # # #function ld_tassemap(tassemapfile) { # printf("ld_tassemapfile(%s)\n", tassemapfile) # while ( (getline aline < tassemapfile) > 0 ) { # split(aline, a_arr, "|") # ##printf("aline=%s\n", aline) # #printf("a_arr 1=%s 7=%s\n", a_arr[1], a_arr[7]) # tascode = trim(a_arr[1]) # tastype = trim(a_arr[2]) # SEID = trim(a_arr[7]) # tascode_to_SEID_arr[tascode] = SEID # # split(tastype, tastype_arr, " ") # supplier = toupper(tastype_arr[1]) # tascode_to_supplier_arr[tascode] = supplier # supplier_to_supplierdesc_arr[supplier] = tastype # # #print " tascode_to_supplier_arr[" tascode "] = " tascode_to_supplier_arr[tascode] # #print " supplier_to_supplierdesc_arr[" supplier "] = " supplier_to_supplierdesc_arr[supplier] # } # close(tassemapfile) #} #-------------------------- # new tbsdata database function ld_tbsdata_customer(customerfile) { printf("ld_tbsdata_customer(%s)\n", customerfile) #1|NXS|NEGA (SWANSTON TRAMS) PTY LTD|V6050884| # NATIONAL EXPRESS (SWANSTON) PTY LTD| # C/O MCGRATH NICOL - ATT: D PIENING|LEVEL 1; 161 COLLINS STREET| # MELBOURNE|VIC|3000||0|1|1|Dec 07 2004 12:00AM||robynd|1| while ( (getline aline < customerfile) > 0 ) { split(aline, a_arr, "|") ##printf("aline=%s\n", aline) CustomerID = trim(a_arr[1]) ShipTo = trim(a_arr[2]) ShipToDesc = trim(a_arr[3]) ShipToCode = trim(a_arr[4]) ShipTo = toupper(ShipTo) ShipTo_to_ShipToDesc_arr[ShipTo] = ShipToDesc ShipTo_to_ShipToCode_arr[ShipTo] = ShipToCode CustomerID_to_ShipTo_arr[CustomerID] = ShipTo print " ShipTo = " ShipTo print " ShipTo_to_ShipToDesc_arr[" ShipTo "] = " ShipTo_to_ShipToDesc_arr[ShipTo] print " ShipTo_to_ShipToCode_arr[" ShipTo "] = " ShipTo_to_ShipToCode_arr[ShipTo] print " CustomerID_to_ShipTo_arr[" CustomerID "] = " CustomerID_to_ShipTo_arr[CustomerID] } close(customerfile) } function ld_tbsdata_servicetype(servicetypefile) { printf("ld_tbsdata_servicetype(%s)\n", servicetypefile) #99|XA|SMS MESSAGES|194|140|140|0||0|1|Dec 07 2004 12:00AM| # |1|0|0|0.0000|0| while ( (getline aline < servicetypefile) > 0 ) { split(aline, a_arr, "|") ServiceTypeID = trim(a_arr[1]) ServiceTypeCode = trim(a_arr[2]) SupplierID = trim(a_arr[4]) RevenueElementID = trim(a_arr[5]) SystemID = trim(a_arr[8]) tascode = ServiceTypeCode tascode_to_SystemID_arr[tascode] = SystemID tascode_to_ElementID_arr[tascode] = RevenueElementID tascode_to_orgElementID_arr[tascode] = RevenueElementID tascode_to_SupplierID_arr[tascode] = SupplierID print " tascode = " tascode print " tascode_to_SystemID_arr[" tascode "] = " tascode_to_SystemID_arr[tascode] print " tascode_to_ElementID_arr[" tascode "] = " tascode_to_ElementID_arr[tascode] print " tascode_to_SupplierID_arr[" tascode "] = " tascode_to_SupplierID_arr[tascode] } close(servicetypefile) } function ld_tbsdata_element(elementfile) { printf("ld_tbsdata_element(%s)\n", elementfile) #1|1046|Telco Account Processing Fee||1|1|May 10 2005 12:00AM||499|10|0| while ( (getline aline < elementfile) > 0 ) { split(aline, a_arr, "|") ##printf("aline=%s\n", aline) #printf("a_arr 1=%s 3=%s 4=%s\n", a_arr[1], a_arr[3], a_arr[4]) ElementID = trim(a_arr[1]) ElementCode = trim(a_arr[2]) ElementCodeDesc = trim(a_arr[3]) CustomerID = trim(a_arr[9]) if ( CustomerID != "499" ) # only look at VRT entries continue SGID = 0 SGIDdesc = "All" SEID = ElementCode SEIDdesc = ElementCodeDesc SGID_to_SGIDdesc_arr[SGID] = SGIDdesc SEID_to_SEIDdesc_arr[SEID] = SEIDdesc SEID_to_SGID_arr[SEID] = SGID ElementID_to_SEID_arr[ElementID] = SEID SEID_to_orgElementID_arr[SEID] = ElementID print " SGID = " SGID " SEID = " SEID print " SEID_to_SGID_arr[" SEID "] = " SEID_to_SGID_arr[SEID] print " SGID_to_SGIDdesc_arr[" SGID "] = " SGID_to_SGIDdesc_arr[SGID] print " SEID_to_SEIDdesc_arr[" SEID "] = " SEID_to_SEIDdesc_arr[SEID] print " ElementID_to_SEID_arr[" ElementID "] = " ElementID_to_SEID_arr[ElementID] } close(elementfile) } function ld_tbsdata_supplier(supplierfile) { printf("ld_tbsdata_supplier(%s)\n", supplierfile) #1|OPTUS COMMUNICATIONS|1||robynd|OPT001|1|OPTUS COMMUNICATIONS| # LEVEL 6|50 MILLER STREET|NORTH SYDNEY|NSW|2060| while ( (getline aline < supplierfile) > 0 ) { split(aline, a_arr, "|") ##printf("aline=%s\n", aline) #printf("a_arr 1=%s 7=%s\n", a_arr[1], a_arr[7]) SupplierID = trim(a_arr[1]) SupplierName = trim(a_arr[2]) split(SupplierName, SupplierName_arr, " ") supplier = toupper(SupplierName_arr[1]) SupplierID_to_supplier_arr[SupplierID] = supplier print " SupplierID = " SupplierID print " SupplierName = " SupplierName print " supplier = " supplier print " SupplierID_to_supplier_arr[" SupplierID "] = " SupplierID_to_supplier_arr[SupplierID] } close(supplierfile) } #----------------------------------------------------------------- function ld_seidtranslate(seidtranslatefile) { printf("ld_seidtranslate(%s)\n", seidtranslatefile) while ( (getline aline < seidtranslatefile) > 0 ) { split(aline, a_arr, ",") ##printf("aline=%s\n", aline) #printf("a_arr 1=%s 7=%s\n", a_arr[1], a_arr[7]) systemid = trim(a_arr[1]) seid = trim(a_arr[2]) systemid_to_seid[systemid] = seid print "systemid_to_seid[" systemid "] = " systemid_to_seid[systemid] } close(seidtranslatefile) } #----------------------------------------------------------------- function ld_cde(cdefile) { printf("ld_cde(%s)\n", cdefile) while ( (getline aline < cdefile) > 0 ) { gsub("\r","",aline) i = split(aline, a_arr, "|") if ( i != 20 ) { print "WARNING: bad cde record in file " cdefile " [" aline "]" " i=" i continue } print cdefile ": " aline ##printf("aline=[%s]\n", aline) #printf("a_arr 1=%s\n", a_arr[1]) DIVID = trim(a_arr[1]) sundry = trim(a_arr[2]) rentcost = trim(a_arr[3]) callcost = trim(a_arr[4]) othercost = trim(a_arr[5]) totalcost = trim(a_arr[6]) tascode = trim(a_arr[7]) SID = trim(a_arr[8]) location = trim(a_arr[9]) user = trim(a_arr[10]) #costcentre = trim(a_arr[11]) " " trim(a_arr[13]) #costcentre = trim(a_arr[11]) #department = trim(a_arr[16]) #servicedesc = trim(a_arr[13]) #installdate = trim(a_arr[14]) #std = trim(a_arr[15]) # new from getcde3 centre = trim(a_arr[11]) activity = trim(a_arr[12]) element = trim(a_arr[13]) subledger = trim(a_arr[14]) paytype = trim(a_arr[15]) department = trim(a_arr[16]) servicedesc = trim(a_arr[17]) installdate = trim(a_arr[18]) std = trim(a_arr[19]) ############################ costcentre = sprintf("%-6.6s %-2.2s %-6.6s %-6.6s %-1.1s", centre, activity, element, subledger, paytype) ElementID = tascode_to_ElementID_arr[tascode] print "ld_cde: tascode_to_ElementID_arr[" tascode "] = [" tascode_to_ElementID_arr[tascode] "]" DIVID = toupper(DIVID) # cant have "/" in SID (re: filenames) gsub("/",".",SID) #itag = DIVID "|" sundry orgElementID = ElementID = tascode_to_orgElementID_arr[tascode] itag = DIVID "|" sundry "|" orgElementID platinv_batch = parent_sundry_to_platinv_batch_arr[itag] print "ld_cde: itag=" itag " platinv_batch = " platinv_batch if ( platinv_batch == "" ) { print "WARNING: Can't get Platinum Invoice batch for DIVID = " DIVID " sundry = " sundry } # if ShipTo code in tbs Customer is blank then set DIVID to VRT if ( ShipTo_to_ShipToCode_arr[DIVID] == "" ) { print "WARNING: blank ShiptoCode, setting DIVID to VRT" DIVID = "VRT" #itag = DIVID "|" sundry itag = DIVID "|" sundry "|" orgElementID platinv_batch = "VRTBATCHFILENAME" parent_sundry_to_platinv_batch_arr[itag] = platinv_batch invoiceno = "VRT999999" parent_sundry_to_platinv_invoicenumber_arr[itag] = invoiceno } # if ShipTo code in tbs Customer is VRT if ( ShipTo_to_ShipToCode_arr[DIVID] == "VRT" ) { print "ShiptoCode = VRT, setting dummy platinv_batch" DIVID = "VRT" #itag = DIVID "|" sundry itag = DIVID "|" sundry "|" orgElementID platinv_batch = "VRTBATCHFILENAME" parent_sundry_to_platinv_batch_arr[itag] = platinv_batch invoiceno = "VRT999999" parent_sundry_to_platinv_invoicenumber_arr[itag] = invoiceno } SupplierID = tascode_to_SupplierID_arr[tascode] #old tassemap supplier = tascode_to_supplier_arr[tascode] supplier = SupplierID_to_supplier_arr[SupplierID] #old tassemap SEID = tascode_to_SEID_arr[tascode] SEID = ElementID_to_SEID_arr[ElementID] print "ld_cde: ElementID_to_SEID_arr[" ElementID "] = [" ElementID_to_SEID_arr[ElementID] "]" # 05/12/2007 # all internal and external network services for VRT # are now set to seid 2399 in tbsdata seidchange = 0 actualSEID = SEID #if ( SEID == 2399 ) { # do for all (for VoiceMail in non VRT and future) # for mobile - translate seid using systemid systemid = tascode_to_SystemID_arr[tascode] newseid = systemid_to_seid[systemid] if ( newseid != "" ) { print " translate SEID=" SEID " translate newseid=" newseid " systemid=" systemid SEID = newseid seidchange = 1 } else { # use SID to determine Telmax21 data tmpsid = SID newseid = 101043 if ( grid_to_grtype_arr[tmpsid] == "E" ) { print " SEID=" SEID " newseid=" newseid " SID=" SID SEID = newseid seidchange = 1 } else { # test for Switchboard or Voicemail if ( substr(SID,1,2) == "SW" ) { tmpsid = substr(SID,3) newseid = 101030 } if ( substr(SID,1,2) == "VM" ) { tmpsid = substr(SID,3) newseid = 101047 } if (grid_to_grtype_arr[tmpsid] == "E") { print " SEID=" SEID " newseid=" newseid " SID=" SID " tmpsid=" tmpsid SEID = newseid seidchange = 1 } } } #} ## SEID is still 2399 so, ## this is to prevent hardcodes in reports from ## creating drill down to t21 call/rent for ## non drilldown services #if ( SEID == 2399 ) { # SEID = 102399 # SEID_to_SEIDdesc_arr[SEID] = SEID_to_SEIDdesc_arr[2399] # print " no translate for SEID=2399 setto=" SEID " systemid=" systemid # seidchange = 1 #} # set elementid to seid lookup for replaced VRT 2399 seid if ( seidchange == 1 ) { # use replaced SEID+100000 as elementid newelementid = SEID + 100000 tascode_to_ElementID_arr[tascode] = newelementid ElementID_to_SEID_arr[newelementid] = SEID SEID_to_orgElementID_arr[SEID] = ElementID print "new ElementID_to_SEID_arr[" newelementid "] = " ElementID_to_SEID_arr[newelementid] SEID_to_SGID_arr[SEID] = 0 # create seid desc for new seid's set here # preserve switchboard seid desc SEID_to_SEIDdesc_arr[101030] = SEID_to_SEIDdesc_arr[1030] # VOICEMAIL has no entry in tElement SEID_to_SEIDdesc_arr[101047] = "Telco VoiceMail" # preserve mobile seid desc SEID_to_SEIDdesc_arr[101044] = SEID_to_SEIDdesc_arr[1044] # preserve T21 Rent and Calls seid desc SEID_to_SEIDdesc_arr[101043] = SEID_to_SEIDdesc_arr[1043] } print "ld_cde(" cdefile ") use SEID = " SEID " tascode=" tascode " supplier=" supplier # store sundry for T21 calls #if (supplier == t21_supplier && SEID == 1043) { # seid now set here in ld_cde() if (supplier == t21_supplier && SEID == 101043) { if ( t21_sundry != "" ) { if ( t21_sundry != sundry ) { print "FATAL ERROR: multiple TIMS calls Sundrys t21_sundry = " t21_sundry " next sundry = " sundry exit 1 } } else { # save TIMS calls sundry t21_sundry = sundry t21_elementid = ElementID print "ld_cde(" cdefile ") t21_sundry = " t21_sundry } if ( platinv_batch != "VRTBATCHFILENAME" ) { # save TIMS calls platinv_batch t21_platinv_batch[platinv_batch] = 1 print "ld_cde: t21 platinv_batch = " platinv_batch } } sundrySID_to_tascode_arr[sundry "|" SID] = tascode # only doing thisDIVID if ( thisDIVID != "all" && thisDIVID != DIVID ) continue ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 1 Skipping platinv_batch = " platinv_batch # continue #} # only doing this platinumbatch if (platinumBATCH != "all" && platinumBATCH != platinv_batch) continue invoiceno = parent_sundry_to_platinv_invoicenumber_arr[itag] print "ld_cde: itag=" itag " invoiceno = " invoiceno if ( invoiceno == "" ) { print "WARNING: NO INVOICE for shipto = " DIVID " and sundry = " sundry " SID = " SID " tascode_to_orgElementID_arr[" tascode "] = " tascode_to_orgElementID_arr[tascode] #print "WARNING: NO INVOICE for shipto = " DIVID " and sundry = " sundry " SID = " SID #platinv_batch = DIVID monthtag "NOINV" #parent_sundry_to_platinv_batch_arr[itag] = platinv_batch #invoiceno = DIVID "_" "NOINV" #parent_sundry_to_platinv_invoicenumber_arr[itag] = invoiceno continue } # flag parent / sundry in cde cde_parent_sundry_arr[itag] = 1 print "cde_parent_sundry_arr[" itag "]=[" cde_parent_sundry_arr[itag] "]" ElementID = tascode_to_ElementID_arr[tascode] #old tassemap SEID = tascode_to_SEID_arr[tascode] SEID = ElementID_to_SEID_arr[ElementID] SGID = SEID_to_SGID_arr[SEID] # assign unique DEPTID DEPTID = department_to_DEPTID_arr[department] if ( DEPTID == 0 ) { department_to_DEPTID_arr[department] = ++MAXDEPTID DEPTID = MAXDEPTID DEPTID_to_department_arr[DEPTID] = department #printf("NEW DIVID = %s department = (%d)%s MAXDEPTID = %d\n", DIVID, DEPTID, department, MAXDEPTID) pipecmd = "sort >" logdir "/" "DEPTID_" batchtag ".lst" print DIVID "|" DEPTID "|" department | pipecmd } # deptid lookup (used to get deptid fronm t21 dir entries) itag = DIVID "|" SID # rjs. 22/11/2007 #if ( parentSID_to_DEPTID_arr[itag] != "" && parentSID_to_DEPTID_arr[itag] != DEPTID ) { # # rjs skip multiple # if ( SID == "INV 2253177" ) # continue # if ( SID == "INV 2257030" ) # continue # printf("FATAL ERROR: SID=[%s] has multile deptid's for parent = %s\n", SID, DIVID) # exit 1 #} parentSID_to_DEPTID_arr[itag] = DEPTID HIERID = DIVID "|" SGID "|" SEID "|" DEPTID "|" SID HIERID = HIERID "|" supplier "|" tascode "|" location "|" user "|" costcentre HIERID = HIERID "|" sundry HIERID = HIERID "|" invoiceno HIERIDxDUPcount = ++HIERIDxcount[HIERID] HIERID = HIERID "|" HIERIDxDUPcount HIERIDx = HIERID "|" if (DIVID == "" || SGID == "" || SEID == "" || DEPTID == "" || SID == "" || supplier == "" || tascode == "" || sundry == "" || invoiceno == "") { print "FATAL ERROR: BAD HIERIDx = " HIERIDx print " DIVID = " DIVID print " SGID = " SGID print " SEID = " SEID " (ElementID = " ElementID ")" print " DEPTID = " DEPTID print " SID = " SID print " supplier = " supplier print " tascode = " tascode print " location = " location print " user = " user print " costcentre = " costcentre print " sundry = " sundry print " invoiceno = " invoiceno exit 1 } got_cde_data = 1 #print "HIERIDx = " HIERIDx #HIERIDx_to_sundry_arr[HIERIDx] = sundry # #HIERIDx_to_supplier_arr[HIERIDx] = supplier #HIERIDx_to_tascode_arr[HIERIDx] = tascode #HIERIDx_to_location_arr[HIERIDx] = location #HIERIDx_to_user_arr[HIERIDx] = user #HIERIDx_to_costcentre_arr[HIERIDx] = costcentre HIERIDx_to_rentcost_arr[HIERIDx] = rentcost HIERIDx_to_callcost_arr[HIERIDx] = callcost HIERIDx_to_othercost_arr[HIERIDx] = othercost HIERIDx_to_totalcost_arr[HIERIDx] = totalcost # for getting processing order pipecmd = "sort >" logdir "/" "HIERIDx_" batchtag ".lst" print HIERIDx | pipecmd pipecmd = "sort -u >" logdir "/" "sundrys_" batchtag ".uniq" print sundry " " supplier | pipecmd pipecmd = "sort | uniq -d >" logdir "/" "SID_" batchtag ".dup" print SID | pipecmd } close(cdefile) } function is_t21_platinv_batch(platinvbatchfilename) { for ( t21batchfilename in t21_platinv_batch ) { if ( platinvbatchfilename == t21batchfilename ) return 1 } return 0 } #---------------------------------------------------------- # convert MMYYYY MMM_YYYY function MMYYYY_to_billperiod(MMYYYY,sep) { mnthstr[1] = "January" mnthstr[2] = "February" mnthstr[3] = "March" mnthstr[4] = "April" mnthstr[5] = "May" mnthstr[6] = "June" mnthstr[7] = "July" mnthstr[8] = "August" mnthstr[9] = "September" mnthstr[10] = "October" mnthstr[11] = "November" mnthstr[12] = "December" billmm = 0 + substr(MMYYYY,1,2) billyyyy = 0 + substr(MMYYYY,3,4) if ( sep != "" ) sepchar = substr(sep,1,1) else sepchar = " " # create monthtag/billperiod billperiod = substr(mnthstr[billmm],1,3) sepchar billyyyy monthtag = substr(mnthstr[billmm],1,3) "_" billyyyy #for ( billmm = 1; billmm < 12; ++billmm ) { # if ( substr(mnthstr[billmm],1,3) == substr(billperiod,1,3) ) # break #} if ( billmm > 12 ) { printf("FATAL ERROR: BAD billperiod [%s]\n", billperiod) exit 1 } #billyyyy = 0 + substr(billperiod,5,4) #monthtag = sprintf("%s_%d", substr(mnthstr[billmm],1,3), billyyyy) print "MMYYYY = " MMYYYY " billperiod = " billperiod # expanded bill period exbillperiod = sprintf("%s %d", mnthstr[billmm], billyyyy) printf("exbillperiod = %s\n", exbillperiod) } #---------------------------------------------------------- function getcdefiles(cdedir) { cmd = "ls indata/" monthtag "/" cdedir "/*.cde" #print "cmd = " cmd #cmd | getline cdefile_arr[cdedir] cnt_cde = 0 while ( (cmd | getline aline) > 0 ) { ++cnt_cde cstr = cdedir "|" cnt_cde cdefile_arr[cstr] = aline print "getcdefile(" cdedir ") cnt=" cnt_cde " - cdefile_arr[" cstr "] = " cdefile_arr[cstr] } } #---------------------------------------------------------- function get_HIERIDx_info(HIERIDx,printflag) { rentcost = HIERIDx_to_rentcost_arr[HIERIDx] callcost = HIERIDx_to_callcost_arr[HIERIDx] othercost = HIERIDx_to_othercost_arr[HIERIDx] totalcost = HIERIDx_to_totalcost_arr[HIERIDx] split(HIERIDx, HIERIDx_arr, "|") DIVID = HIERIDx_arr[1]; DIVIDdesc1 = DIVID_to_DIVIDdesc1_arr[DIVID] DIVIDdesc2 = DIVID_to_DIVIDdesc2_arr[DIVID] ShipToDesc = ShipTo_to_ShipToDesc_arr[DIVID] SGID = HIERIDx_arr[2]; SGIDdesc = SGID_to_SGIDdesc_arr[SGID] SEID = HIERIDx_arr[3]; SEIDdesc = SEID_to_SEIDdesc_arr[SEID] DEPTID = HIERIDx_arr[4]; department = DEPTID_to_department_arr[DEPTID] SID = HIERIDx_arr[5] # supplier = HIERIDx_arr[6] tascode = HIERIDx_arr[7] location = HIERIDx_arr[8] user = HIERIDx_arr[9] costcentre = HIERIDx_arr[10] # sundry = HIERIDx_arr[11] # invoiceno = HIERIDx_arr[12]; # HIERIDxDUPcount = HIERIDx_arr[13] ORGELEMENTID = SEID_to_orgElementID_arr[SEID] #itag = DIVID "|" sundry itag = DIVID "|" sundry "|" ORGELEMENTID platinv_batch = parent_sundry_to_platinv_batch_arr[itag] print "GHID: parent_sundry_to_platinv_batch_arr[" itag "]=[" parent_sundry_to_platinv_batch_arr[itag] "]" # if run on single Platinum Batch filename ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 3 Skipping platinv_batch = " platinv_batch # continue #} if ( platinumBATCH != "all" ) { # use customer invoice number for service group desc # (instead of All) SGIDdesc = invoiceno } SIDdesc = user #sundry = HIERIDx_to_sundry_arr[HIERIDx] # #supplier = HIERIDx_to_supplier_arr[HIERIDx] #tascode = HIERIDx_to_tascode_arr[HIERIDx] #location = HIERIDx_to_location_arr[HIERIDx] #user = HIERIDx_to_user_arr[HIERIDx] #costcentre = HIERIDx_to_costcentre_arr[HIERIDx] idtag = sprintf("%s_%s", DIVID, monthtag); if ( printflag > 1 ) { printf("idtag = %s\n", idtag); } #pardir = idtag; this_divgroup = exwebconf_parent_to_cdgroup_arr[DIVID] #rs 1 if ( this_divgroup == "" ) # single div this_divgroup = DIVID # (force single to a divgroup) #rs 1 if ( this_divgroup != "" ) # belongs to a cdgroup pardir = monthtag "/" platinumBATCH "_" thisDIVID "/" this_divgroup "/" DIVID else pardir = monthtag "/" platinumBATCH "_" thisDIVID "/" DIVID #printf("pardir = %s\n", pardir); if ( printflag > 1 ) { printf("\n") printf("HIERIDxDUPcount = %d\n", HIERIDxDUPcount) printf("HIERIDx = %s\n", HIERIDx) printf("platinv_batch = [%s]\n", platinv_batch) printf("SID = [%s]\n", SID) printf("invoiceno = [%s]\n", invoiceno) printf("sundry = [%s]\n", sundry) printf("supplier = [%s]\n", supplier) printf("location = [%s]\n", location) printf("user = [%s]\n", user) printf("costcentre = [%s]\n", costcentre) printf("rentcost = [%s]\n", rentcost) printf("callcost = [%s]\n", callcost) printf("othercost = [%s]\n", othercost) printf("totalcost = [%s]\n", totalcost) printf("department = [(%d)%s]\n", DEPTID, department) printf("tascode = [%s]\n", tascode) printf("ELEMENTID = [%s]\n", ELEMENTID) printf("SEID = [(%s)%s]\n", SEID, SEIDdesc) printf("SGID = [(%d)%s]\n", SGID, SGIDdesc) printf("DIVID = [(%s)%s|%s]\n", DIVID, DIVIDdesc1, ShipToDesc) } if ( printflag ) { printf("%d|%s|%s|%s|%s|%s|%s|%f|%f|%f|TOTAL = %f|>DEPT(%d)%s >%s >SEID(%d)%s >SGID(%d)%s >DIV:(%s)%s|%s\n", HIERIDxDUPcount, SID, sundry, supplier, location, user, costcentre, rentcost, callcost, othercost, totalcost, DEPTID, department, tascode, SEID, SEIDdesc, SGID, SGIDdesc, DIVID, DIVIDdesc1, ShipToDesc) } } #---------------------------------------------------------- #---------------------------------------------------------- ############################################################## function gen_top_csv() { # generate top csv file top_fname = sprintf("topdat/%s/data/top.csv", pardir); printf("%s,%s,%s,%s,%s,%s\n", "Monthly Service Reports", exbillperiod, "SDATE", "EDATE", ShipToDesc, DIVID) >top_fname; close(top_fname); } function cpy_img(x) { # test if image already done imgmarkerfile = sprintf("topdat/%s/index.html", pardir) printf("cpy_img(%d): testing for %s\n", x, imgmarkerfile) if ( (getline xs < imgmarkerfile) < 0 ) { printf("%d: Copy image files for %s\n", x, pardir) # copy image folder dirs and files cmd = sprintf("cpyimg topdat/%s 2>&1", pardir); system(cmd); } else { printf("%d: Image ALREADY exists for %s\n", x, pardir) } close(imgmarkerfile) } function mk_idfile(x) { # test if idfile already done idfile_fname = sprintf("topdat/%s/%s.txt", pardir, idtag); printf("mk_idfile(%d): testing for %s\n", x, idfile_fname) if ( (getline xs < idfile_fname) < 0 ) { # generate ID file printf("%d: Generate idfile (%s) for %s\n", x, idfile_fname, pardir) printf("\r\n") >idfile_fname; printf("%s - %s\r\n", ShipTo_to_ShipToDesc_arr[DIVID], DIVID) >>idfile_fname; printf("Service Reports and Directory\r\n") >>idfile_fname; printf("For %s\r\n", exbillperiod) >>idfile_fname; # running in single platinum invoice ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 4 Skipping platinv_batch = " platinv_batch # continue #} if ( platinumBATCH != "all" ) { printf("InvoiceNo: %s\r\n", invoiceno) >>idfile_fname; } else { printf("InvoiceNo: %s\r\n", "ALL") >>idfile_fname; } printf("\r\n") >>idfile_fname; } else { printf("%d: idfile (%s) exists for %s\n", x, idfile_fname, pardir) } close(idfile_fname); } #---------------------------------------------------------- #ZZZZZ function init_totals(Xtotid) { for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") # 0 all sundry totals for Xtotid if ( Xtotid != cstr_arr[1] ) { #print "SKIP - init_totals(" Xtotid ") - " cstr continue } print "DO - init_totals(" Xtotid ") - " cstr #rentcost_arr[cstr] = 0.00 #callcost_arr[cstr] = 0.00 #othercost_arr[cstr] = 0.00 #totalcost_arr[cstr] = 0.00 # must delete to stop 0 totals on inappropriate sundrys delete rentcost_arr[cstr] delete callcost_arr[cstr] delete othercost_arr[cstr] delete totalcost_arr[cstr] } } function add_totals(Xtotid, p1, p2, Xinvoiceno, Xsundry, Xsupplier, rentcost, callcost, othercost, totalcost) { #--------------- XXXX = Xtotid "|" Xinvoiceno "|" Xsundry "|" Xsupplier "|" p1 "|" p2 print "1 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," Xsundry "," Xsupplier ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost XXXX = Xtotid "|" "All" "|" Xsundry "|" Xsupplier "|" p1 "|" p2 print "1 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," Xsundry "," Xsupplier ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost #--------------- XXXX = Xtotid "|" Xinvoiceno "|" "All" "|" Xsupplier "|" p1 "|" p2 print "2 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," "All" "," Xsupplier ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost XXXX = Xtotid "|" "All" "|" "All" "|" Xsupplier "|" p1 "|" p2 print "2 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," "All" "," Xsupplier ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost #--------------- XXXX = Xtotid "|" Xinvoiceno "|" Xsundry "|" "All" "|" p1 "|" p2 print "3 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," Xsundry "," "All" ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost XXXX = Xtotid "|" "All" "|" Xsundry "|" "All" "|" p1 "|" p2 print "3 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," Xsundry "," "All" ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost #--------------- XXXX = Xtotid "|" Xinvoiceno "|" "All" "|" "All" "|" p1 "|" p2 print "4 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," "All" "," "All" ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost XXXX = Xtotid "|" "All" "|" "All" "|" "All" "|" p1 "|" p2 print "4 add_totals(" Xtotid "," p1 "," p2 "," Xinvoiceno "," "All" "," "All" ") - " XXXX rentcost_arr[XXXX] += rentcost callcost_arr[XXXX] += callcost othercost_arr[XXXX] += othercost totalcost_arr[XXXX] += totalcost } #---------------------------------------------------------- function handle_DIVID_change() { # new DIVID if ( DIVID != last_DIVID ) { printf("DIVID change...\n"); if ( DIVID_fname != "" ) { # close previous file #spit_DIVIDtotals_to_TOTALSfile(); gen_cde_DIVID_totals_rep(); init_totals("DIVID"); close(DIVID_fname); DIVID_fname = ""; } if ( DIVID_fname == "" ) { # new file gen_top_csv(); cpy_img(0); mk_idfile(0); DIVID_fname = sprintf("topdat/%s/data/divid/divid_%s.csv", pardir, DIVID); printf(">>> DIVID_fname = %s\n", DIVID_fname); if ( (getline x < DIVID_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/divid", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir); system(cmd); spit_header_to_DIVIDfile(); divid_file_exists = 0 } else { printf("WARNING %d: DIVID_fname = %s exists.\n", NR, DIVID_fname); divid_file_exists = 1 } } } } function handle_SGID_change() { # new SGID if ( DIVID != last_DIVID || SGID != last_SGID ) { printf("SGID change...\n"); if ( SGID_fname != "" ) { # close previous file # do SEID / DEPTATMENT spit_SEIDDEPTIDtotals_to_SGIDfile(); init_totals("DIVID.SGID.SEIDDEPTID") spit_SGIDtotals_to_DIVIDfile(); init_totals("DIVID.SGID") close(SGID_fname); SGID_fname = ""; } if ( SGID_fname == "" ) { # new file SGID_fname = sprintf("topdat/%s/data/sgid/sgid_%s_%s.csv", pardir, DIVID, SGID); printf(">>> SGID_fname = %s\n", SGID_fname); if ( (getline x < SGID_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/sgid", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir); system(cmd); spit_header_to_SGIDfile(); sgid_file_exists = 0 } else { printf("WARNING %d: SGID_fname = %s exists.\n", NR, SGID_fname); sgid_file_exists = 1 } } } } function handle_SEID_change() { # new SEID if ( DIVID != last_DIVID || SGID != last_SGID || SEID != last_SEID ) { printf("SEID change...\n"); if ( SEID_fname != "" ) { # close previous file spit_cde_SEIDDEPTID_totals_data(); #spit_SEIDtotals_to_SGIDfile(); init_totals("DIVID.SGID.SEID") #close(SEID_fname); SEID_fname = ""; } if ( SEID_fname == "" ) { # new file SEID_fname = sprintf("topdat/%s/data/seid/seid_%s_%s_%s.csv", pardir, DIVID, SGID, SEID); # printf(">>> SEID_fname = %s\n", SEID_fname); # if ( (getline x < SEID_fname) < 0 ) { # # create file and csv header # newdir = sprintf("topdat/%s/data/seid", pardir); # cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir); # system(cmd); # spit_header_to_SEIDfile(); # seid_file_exists = 0 # } # else { # printf("WARNING %d: SEID_fname = %s exists.\n", NR, SEID_fname); # seid_file_exists = 1 # } } } } function handle_DEPTID_change() { # new DEPTID if ( DIVID != last_DIVID || SGID != last_SGID || SEID != last_SEID || DEPTID != last_DEPTID ) { printf("DEPTID change...\n"); if ( DEPTID_fname != "" ) { # close previous file #spit_DEPTIDtotals_to_SEIDfile(); #init_totals("DIVID.SGID.SEID.DEPTID") close(DEPTID_fname); DEPTID_fname = ""; } if ( DEPTID_fname == "" ) { # new file DEPTID_fname = sprintf("topdat/%s/data/deptid/deptid_%s_%s_%s_%s.csv", pardir, DIVID, SGID, SEID, DEPTID); printf(">>> DEPTID_fname = %s\n", DEPTID_fname); if ( (getline x < DEPTID_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/deptid", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir); system(cmd); spit_header_to_DEPTIDfile(); deptid_file_exists = 0 } else { printf("WARNING %d: DEPTID_fname = %s exists.\n", NR, DEPTID_fname); deptid_file_exists = 1 } } } } function handle_SID_change() { # new SID # DONT ADD up cde SID records if ( HIERIDx != last_HIERIDx ) { #if ( DIVID != last_DIVID || SGID != last_SGID || SEID != last_SEID || DEPTID != last_DEPTID || SID != last_SID ) { printf("SID change...\n"); if ( last_SID != "" ) { # do customer import CSV spit_SIDtotals_to_CUSTOMERIMPORTfile(); spit_SIDtotals_to_DEPTIDfile(); # process detail data for SID process_SID_detail_data() init_totals("DIVID.SGID.SEID.DEPTID.SID") } } } ################################################ ################################################ function spit_cde_SEIDDEPTID_totals_data() { print "spit_cde_SEIDDEPTID_totals_data() - " tmptotalsrepfile " - for " last_DIVID " " last_SEID " " SEID_to_SEIDdesc_arr[last_SEID] forXtotid = "DIVID.SGID.SEIDDEPTID" print "spit_cde: forXtotid=[" forXtotid "]" # loop to spit actual sundry,invoice,supplier seid_cnt = 0 for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] p1 = cstr_arr[5] # (SEID) p2 = cstr_arr[6] # (DEPTID) if ( forXtotid == Xtotid ) { print "spit_cde:cstr=[" cstr "]" print " Xtotid=[" Xtotid "]" print " Xinvoiceno=[" Xinvoiceno "]" print " Xsundry=[" Xsundry "]" print " Xsupplier=[" Xsupplier "]" # only look actual SEID if ( p1 != last_SEID ) continue # only look for DEPTID totals if ( p2 != "ALL" ) continue # skip any All entries if ( Xsundry == "All" || Xinvoiceno == "All" || Xsupplier == "All" ) continue sstr = sprintf(" %-11.11s %-6.6s %-25.25s %-5.5s %-15.15s $%9.2f\r\n", Xinvoiceno, last_SEID, SEID_to_SEIDdesc_arr[last_SEID], Xsundry, Xsupplier, totalcost_arr[cstr]) printf("spit_cde: %s", sstr) #printf("%s", sstr) >>tmptotalsrepfile sortcmd = "sort >>" tmptotalsrepfile printf("%s", sstr) | sortcmd ++seid_cnt } } close(sortcmd) # if more than one seid show total if ( seid_cnt > 1 ) { # Show SEID DEPTID Sundry Invoiceno Supplier # Total X ALL All, All, All Xsundry = "All" Xinvoiceno = "All" Xsupplier = "All" p1 = last_SEID # (SEID) p2 = "ALL" # (DEPTID) cstr = forXtotid "|" Xinvoiceno "|" Xsundry "|" Xsupplier "|" p1 "|" p2 sstr = sprintf(" %-11.11s %-6.6s %-25.25s %-5.5s %-15.15s $%9.2f\r\n", Xinvoiceno, last_SEID, SEID_to_SEIDdesc_arr[last_SEID], Xsundry, Xsupplier, totalcost_arr[cstr]) printf("spit_cde: %s", sstr) printf("%s", sstr) >>tmptotalsrepfile } printf("\r\n") >>tmptotalsrepfile } function gen_cde_DIVID_totals_rep() { print "gen_cde_DIVID_totals_rep() - " totalsrepfile # create directory csv for div mk_dircsvfile(t21dircsvfile, last_pardir, last_DIVID) # link to div directiory index html ln_div_dir_html_index(last_pardir, last_DIVID) printf("%-8.8s - %-25.25s %-5.5s %-15.15s $%9.2f\r\n", last_DIVID, ShipTo_to_ShipToDesc_arr[last_DIVID], "", "Total Cost", totalcost_arr["DIVID|All|All|All||"]) >>totalsrepfile; printf("\r\n") >>totalsrepfile; close(totalsrepfile); close(tmptotalsrepfile); print "---------- tmptotalsrepfile = " tmptotalsrepfile " ----------" cmd=sprintf("cat %s", tmptotalsrepfile) print "---------------------------" system(cmd); cmd=sprintf("cat %s >>%s; rm -f %s", tmptotalsrepfile, totalsrepfile, tmptotalsrepfile); system(cmd); cmd=sprintf("> %s", tmptotalsrepfile) system(cmd) printf("\r\n\r\n") >>totalsrepfile; close(totalsrepfile); } ################################################ function spit_dircsv(frm,div) { ostr = sprintf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", pd1_out_recordno, pd1_out_name, pd1_out_extn, pd1_out_div, pd1_out_divdesc, pd1_out_deptid, pd1_out_deptdesc, pd1_out_seid, pd1_out_seiddesc, pd1_out_sid, pd1_out_mobile, pd1_out_sundry, pd1_out_supplier, pd1_out_invoiceno, pd1_out_location, pd1_t21title, pd1_email, pd1_tec, pd1_fax, pd1_voicemail, pd1_out_replinkflag) print "spit_dircsv(" frm "," div ") - " ostr print ostr >>pd1_dircsvfile_fname } function mk_dircsvfile(pd1_t21dircsvfile, pd1_pardir, pd1_divid) { printf("mk_dircsvfile(%s,%s,%s)\n", pd1_t21dircsvfile,pd1_pardir,pd1_divid) # get this div group pd1_this_divgroup = exwebconf_parent_to_cdgroup_arr[pd1_divid] if ( pd1_this_divgroup == "" ) # single div (no cdgroup) pd1_this_divgroup = pd1_divid pd1_dircsvfile_fname = sprintf("topdat/%s/direnq/T21Eptc.csv", pd1_pardir) newdir = sprintf("topdat/%s/direnq", pd1_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir) system(cmd) # add all t21 directory entries pd1_maxrecordno = 1 pd1_dirreccount = 0 while ( (getline pd1_aline < pd1_t21dircsvfile) > 0 ) { split(pd1_aline, pd1_a_arr, ",") ##printf("pd1_aline=%s\n", pd1_aline) # create dir rec from sid info pd1_recordno = trim(pd1_a_arr[1]) pd1_t21surname = trim(pd1_a_arr[2]) pd1_t21firstname = trim(pd1_a_arr[3]) pd1_extn = trim(pd1_a_arr[4]) pd1_t21department = trim(pd1_a_arr[5]) pd1_t21section = pd1_t21department pd1_t21div = trim(pd1_a_arr[6]) pd1_t21title = trim(pd1_a_arr[7]) pd1_t21location = trim(pd1_a_arr[8]) pd1_extgroupunique = trim(pd1_a_arr[9]) pd1_email = trim(pd1_a_arr[10]) pd1_tec = trim(pd1_a_arr[11]) pd1_t21mobile = trim(pd1_a_arr[12]) pd1_fax = trim(pd1_a_arr[13]) pd1_voicemail = trim(pd1_a_arr[14]) pd1_out_recordno = pd1_recordno if ( (0 + pd1_recordno) > pd1_maxrecordno ) pd1_maxrecordno = pd1_recordno if ( ++pd1_dirreccount == 1 ) { # header pd1_out_name = "Name/User/Description____" pd1_out_extn = "#}eXtension" pd1_out_div = "}Div" pd1_out_divdesc = "}Customer_Name____________" pd1_out_deptid = "#DeptID" pd1_out_deptdesc = "}Section/Department__" pd1_out_seid = "#SEID" pd1_out_seiddesc = "}ServiceType_____________" pd1_out_sid = "}ServiceID______" pd1_out_mobile = "}Mobile______" pd1_out_sundry = "Sundry" pd1_out_supplier = "Supplier_______" pd1_out_invoiceno = "InvoiceNo_" pd1_out_location = "Location____________" pd1_out_replinkflag = "#RepLinkFlag" } else { pd1_out_name = pd1_t21firstname pd1_out_extn = pd1_extn if ( pd1_out_name != "" && pd1_t21surname != "" ) pd1_out_name = pd1_out_name " " pd1_out_name = pd1_out_name pd1_t21surname pd1_out_div = pd1_t21div pd1_out_divdesc = ShipTo_to_ShipToDesc_arr[pd1_out_div] #pd1_out_deptid = -1 # t21 dir doesn't have dept pd1_out_deptid = parentSID_to_DEPTID_arr[pd1_out_div "|" pd1_extgroupunique] pd1_out_deptdesc = pd1_t21section #if ( pd1_out_div == "VRT" ) # pd1_out_seid = 2399 #else # pd1_out_seid = 1043 # seid now set here in ld_cde() if ( pd1_out_div == "VRT" ) pd1_out_seid = 101043 pd1_out_seiddesc = SEID_to_SEIDdesc_arr[pd1_out_seid] pd1_out_sid = pd1_extgroupunique tmp_pd1_mobile = pd1_t21mobile gsub(" ","",tmp_pd1_mobile) gsub("-","",tmp_pd1_mobile) if ( length(tmp_pd1_mobile) == 10 ) pd1_out_mobile = substr(tmp_pd1_mobile,1,4) "-" substr(tmp_pd1_mobile,5,6) else pd1_out_mobile = tmp_pd1_mobile pd1_out_sundry = t21_sundry pd1_out_supplier = t21_supplier pd1_out_elementid = t21_elementid pd1_out_invoiceno = parent_sundry_to_platinv_invoicenumber_arr[pd1_out_div "|" pd1_out_sundry "|" pd1_out_elementid] pd1_out_location = pd1_t21location # if not doing TLM - skip TLM dir entries if ( pd1_this_divgroup != "TLM" && pd1_t21div == "TLM" ) continue # test if belongs to a grid in parent cdgroup # (to set rep link flag) divgroup = exwebconf_parent_to_cdgroup_arr[pd1_t21div] if ( divgroup == "" ) # single div (no cdgroup) divgroup = pd1_t21div if ( divgroup == pd1_this_divgroup || pd1_divid == "VRT" ) { pd1_out_replinkflag = 1 } else { pd1_out_replinkflag = 0 } # if not real extn then clear these if ( pd1_out_extn == 0 ) { pd1_out_sundry = "" pd1_out_supplier = "" pd1_out_invoiceno = "" pd1_out_replinkflag = 0 } } spit_dircsv("spitdirt21",pd1_divid) } close(pd1_t21dircsvfile) # add cde data for this parent group for ( pd1_Hxo = 1; pd1_Hxo <= HIERIDxmaxorder; ++pd1_Hxo ) { pd1_HIERIDx = HIERIDxorder_to_HIERIDx_arr[pd1_Hxo] print "pd1_HIERIDx = " pd1_HIERIDx #cant call this as globals used in outer loop!!! #get_HIERIDx_info(HIERIDx, 2) split(pd1_HIERIDx, pd1_HIERIDx_arr, "|") pd1_DIVID = pd1_HIERIDx_arr[1]; pd1_SGID = pd1_HIERIDx_arr[2]; pd1_SGIDdesc = SGID_to_SGIDdesc_arr[pd1_SGID] pd1_SEID = pd1_HIERIDx_arr[3]; pd1_SEIDdesc = SEID_to_SEIDdesc_arr[pd1_SEID] pd1_DEPTID = pd1_HIERIDx_arr[4]; pd1_department = DEPTID_to_department_arr[pd1_DEPTID] pd1_SID = pd1_HIERIDx_arr[5] pd1_supplier = pd1_HIERIDx_arr[6] pd1_tascode = pd1_HIERIDx_arr[7] pd1_location = pd1_HIERIDx_arr[8] pd1_user = pd1_HIERIDx_arr[9] pd1_costcentre = pd1_HIERIDx_arr[10] pd1_sundry = pd1_HIERIDx_arr[11] pd1_invoiceno = pd1_HIERIDx_arr[12] pd1_HIERIDxDUPcount = pd1_HIERIDx_arr[13] print "pd1_SID = " pd1_SID " pd1_sundry = " pd1_sundry " pd1_supplier = " pd1_supplier # test if belongs to a grid in parent cdgroup divgroup = exwebconf_parent_to_cdgroup_arr[pd1_DIVID] if ( divgroup == "" ) # single div (no cdgroup) divgroup = pd1_DIVID if ( divgroup == pd1_this_divgroup || pd1_divid == "VRT" ) { pd1_out_recordno = ++pd1_maxrecordno pd1_out_name = pd1_user pd1_out_extn = "Service:" pd1_out_div = pd1_DIVID pd1_out_divdesc = ShipTo_to_ShipToDesc_arr[pd1_out_div] pd1_out_deptid = pd1_DEPTID pd1_out_deptdesc = pd1_department pd1_out_seid = pd1_SEID pd1_out_seiddesc = pd1_SEIDdesc pd1_out_replinkflag = 1 # skip (already got this from the t21 directory) ## t21 calls and rent rest VRT #if ( pd1_out_seid == 1043 || pd1_out_seid == 2399 ) { # seid now set here in ld_cde() if ( pd1_out_seid == 101043 ) { print "skipping t21 eggrid SID = [" pd1_SID "]" pd1_out_extn = "Service:-" #continue } ## mobile rest VRT #if ( pd1_out_seid == 1044 || pd1_out_seid == 2405 ) { # seid now set here in ld_cde() if ( pd1_out_seid == 101044 ) { # skip cde if mobile in t21 directory tmp_pd1_mobile = pd1_SID gsub(" ","",tmp_pd1_mobile) gsub("-","",tmp_pd1_mobile) print "test t21mobile_to_egridextn_arr[" tmp_pd1_mobile "] = [" t21mobile_to_egridextn_arr[tmp_pd1_mobile] "]" if (t21mobile_to_egridextn_arr[tmp_pd1_mobile] != "") { print "skipping mobile = [" pd1_SID "]" pd1_out_extn = "Service:--" #continue } pd1_out_mobile = pd1_SID pd1_out_sid = pd1_SID } else { pd1_out_mobile = "" pd1_out_sid = pd1_SID } pd1_out_sundry = pd1_sundry pd1_out_supplier = pd1_supplier pd1_out_invoiceno = pd1_invoiceno pd1_out_location = pd1_location pd1_t21title = "" pd1_email = "" pd1_tec = "" pd1_fax = "" if ( pd1_SEID == 101047 ) pd1_voicemail = "VOICEMAIL" else pd1_voicemail = "" spit_dircsv("spitdircde",pd1_divid) } } close(pd1_dircsvfile_fname) } function ln_div_dir_html_index(pd1_pardir, pd1_divid) { pd1_this_divgroup = exwebconf_parent_to_cdgroup_arr[pd1_divid] # cdgroup master divid if ( pd1_this_divgroup != "" && pd1_this_divgroup == pd1_divid ) { # create dir index file div_dir_html_path = "topdat" "/" monthtag "/" platinumBATCH "_" thisDIVID "/" pd1_this_divgroup div_dir_html_index_fname = sprintf("%s - Click here to start the Victrack Directory.html", pd1_this_divgroup) cmd = "rm -f " "\"" div_dir_html_path "/" div_dir_html_index_fname "\"" "; ln -s ../../../../img/direnq/divdir.html " "\"" div_dir_html_path "/" div_dir_html_index_fname "\"" print "ln_div_dir_html_index() cmd=[" cmd "]" system(cmd) } } ################################################ ################################################ #---------------------------------------------------------- function spit_header_to_CUSTOMERIMPORTfile() { print "spit_header_to_CUSTOMERIMPORTfile() - " CUSTOMERIMPORT_fname printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Billing_Period", "CustomerName", "ShipTo", "SE_Description", "department", "ServiceID", "invoiceno", "sundry", "supplier", "location", "user", "centre", "activity", "element", "subledger", "paytype", "rentcost:Float", "callcost:Float", "othercost:Float", "totalcost:Float") >CUSTOMERIMPORT_fname } function spit_SIDtotals_to_CUSTOMERIMPORTfile() { print "spit_SIDtotals_to_CUSTOMERIMPORTfile() - " CUSTOMERIMPORT_fname print " last_costcentre = [" last_costcentre "]" tmp_costcentre = last_costcentre #gsub(/[ \t]+/, "|", tmp_costcentre) #print " tmp_costcentre = [" tmp_costcentre "]" #split(tmp_costcentre, tmp_costcentre_arr, "|") #Xcentre = tmp_costcentre_arr[1] #Xactivity = tmp_costcentre_arr[2] #Xelement = tmp_costcentre_arr[3] #Xsubledger = tmp_costcentre_arr[4] #Xpaytype = "W" # CCCCCC AA EEEEEE SSSSSS P # 123456789012345678901234567 # 1 2 Xcentre = trim(substr(tmp_costcentre,1,6)) Xactivity = trim(substr(tmp_costcentre,8,2)) Xelement = trim(substr(tmp_costcentre,11,6)) Xsubledger = trim(substr(tmp_costcentre,18,6)) Xpaytype = trim(substr(tmp_costcentre,25,1)) forXtotid = "DIVID.SGID.SEID.DEPTID.SID"; for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] # skip All totals if ( Xinvoiceno == "All" ) continue if ( Xsundry == "All" || Xsupplier == "All" ) continue if ( forXtotid == Xtotid ) { CUSTOMERIMPORT_fname = sprintf("topdat/%s/import_%s_%s_%s.csv", last_pardir, last_DIVID, monthtag, Xinvoiceno) #printf(">>> CUSTOMERIMPORT_fname = %s\n", CUSTOMERIMPORT_fname); if ( (getline x < CUSTOMERIMPORT_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p \"%s\"", newdir, newdir); system(cmd); spit_header_to_CUSTOMERIMPORTfile(); } htag = last_DIVID "|" Xinvoiceno "|" Xsundry tbsbillperiod = parent_invoicenumber_sundry_to_period_arr[htag] yyyy = 0 + substr(tbsbillperiod,1,4) mm = 0 + substr(tbsbillperiod,6,2) # expanded bill tbsbillperiod extbsbillperiod = sprintf("%s %d", mnthstr[mm], yyyy) print " htag=[" htag "]" " tbsbillperiod=[" tbsbillperiod "]" " yyyy=[" yyyy "]" " mm=[" mm "]" " extbsbillperiod=[" extbsbillperiod "]" csvstr = sprintf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%0.2f\n", extbsbillperiod, ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SEID_to_SEIDdesc_arr[last_SEID], DEPTID_to_department_arr[last_DEPTID], last_SID, Xinvoiceno, Xsundry, Xsupplier, last_location, last_user, Xcentre, Xactivity, Xelement, Xsubledger, Xpaytype, rentcost_arr[cstr], callcost_arr[cstr], othercost_arr[cstr], totalcost_arr[cstr]) printf("%s", csvstr) printf("%s", csvstr) >>CUSTOMERIMPORT_fname close(CUSTOMERIMPORT_fname) } } } #---------------------------------------------------------- function spit_DIVIDtotals_to_TOTALSfile() { print "spit_DIVIDtotals_to_TOTALSfile() - " totalsrepfile forXtotid = "DIVID" for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] if ( Xinvoiceno == "All" ) continue if ( Xsundry == "All" || Xsupplier == "All" ) continue # do totals reports if ( forXtotid == Xtotid ) { totstr = sprintf("CDE %-8.8s - %-25.25s %-5.5s %-15.15s $%9.2f\r\n", last_DIVID, ShipTo_to_ShipToDesc_arr[last_DIVID], Xsundry, Xsupplier, totalcost_arr[cstr]) printf("%s", totstr) printf("%s", totstr) >>totalsrepfile } } } #------- function spit_header_to_DIVIDfile() { print "spit_header_to_DIVIDfile() - " DIVID_fname printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Service Group Summary", exbillperiod, "SDATE", "EDATE", ShipToDesc, DIVID, "SGIDdesc", "SGID", "invoiceno", "sundry", "supplier", "rentcost:Float", "callcost:Float", "othercost:Float", "totalcost:Float") >DIVID_fname } function spit_SGIDtotals_to_DIVIDfile() { print "spit_SGIDtotals_to_DIVIDfile() - " DIVID_fname forXtotid = "DIVID.SGID"; for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] #if ( Xinvoiceno == "All" ) # continue if ( forXtotid == Xtotid ) { csvstr = sprintf(",,,,,,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%0.2f\n", SGID_to_SGIDdesc_arr[last_SGID], last_SGID, Xinvoiceno, Xsundry, Xsupplier, rentcost_arr[cstr], callcost_arr[cstr], othercost_arr[cstr], totalcost_arr[cstr]) printf("%s", csvstr) printf("%s", csvstr) >>DIVID_fname } } } #------- function spit_header_to_SGIDfile() { print "spit_header_to_SGIDfile() - " SGID_fname printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Service Summary", exbillperiod, "SDATE", "EDATE", ShipToDesc, DIVID, SGIDdesc, SGID, "SEIDdesc", "SEID", "department", "DEPTID", "invoiceno", "sundry", "supplier", "rentcost:Float", "callcost:Float", "othercost:Float", "totalcost:Float") >SGID_fname } function spit_SEIDDEPTIDtotals_to_SGIDfile() { print "spit_SEIDDEPTIDtotals_to_SGIDfile() - " SGID_fname forXtotid = "DIVID.SGID.SEIDDEPTID"; for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] Xseid = cstr_arr[5] Xdeptid = cstr_arr[6] if ( forXtotid == Xtotid ) { csvstr = sprintf(",,,,,,,,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%0.2f\n", SEID_to_SEIDdesc_arr[Xseid], Xseid, DEPTID_to_department_arr[Xdeptid], Xdeptid, Xinvoiceno, Xsundry, Xsupplier, rentcost_arr[cstr], callcost_arr[cstr], othercost_arr[cstr], totalcost_arr[cstr]) printf("%s", csvstr) printf("%s", csvstr) >>SGID_fname } } } #------- function spit_header_to_DEPTIDfile() { print "spit_header_to_DEPTIDfile() - " DEPTID_fname printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "ServiceID Summary", exbillperiod, "SDATE", "EDATE", ShipToDesc, DIVID, SGIDdesc, SGID, SEIDdesc, SEID, department, DEPTID, "SID", "invoiceno", "sundry", "supplier", "DUPcount", "location", "user", "costcentre", "rentcost:Float", "callcost:Float", "othercost:Float", "totalcost:Float") >DEPTID_fname } function spit_SIDtotals_to_DEPTIDfile() { print "spit_SIDtotals_to_DEPTIDfile() - " DEPTID_fname forXtotid = "DIVID.SGID.SEID.DEPTID.SID"; for ( cstr in totalcost_arr ) { split(cstr, cstr_arr, "|") Xtotid = cstr_arr[1] Xinvoiceno = cstr_arr[2] Xsundry = cstr_arr[3] Xsupplier = cstr_arr[4] #False!! # NO All in DEPTID file - each SID has one sundry/supplier entry # if ( Xsundry == "All" || Xsupplier == "All" ) # continue if ( forXtotid == Xtotid ) { csvstr = sprintf(",,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%0.2f\n", last_SID, Xinvoiceno, Xsundry, Xsupplier, last_HIERIDxDUPcount, last_location, last_user, last_costcentre, rentcost_arr[cstr], callcost_arr[cstr], othercost_arr[cstr], totalcost_arr[cstr]) printf("%s", csvstr) printf("%s", csvstr) >>DEPTID_fname store_t21calls_eggrid_cde_info() } } } #---------------------------------------------------------- #---------------------------------------------------------- # T21 function store_t21calls_gggrid_cde_info() { printf("store_t21calls_gggrid_cde_info() callcost_arr[%s] = %0.2f Xsundry=%s Xsupplier=%s last_DIVID=%s last_SEID=%s\n", cstr, callcost_arr[cstr], Xsundry, Xsupplier, last_DIVID, last_SEID) if ( Xinvoiceno == "All" ) # skip all for invoice numbers return if ( Xsundry == "All" ) # skip alls return # store info for later processing of T21 calls #if (last_SEID != "" && Xsupplier == t21_supplier && Xsundry == t21_sundry && last_SEID == 1043) { # seid now set here in ld_cde() if (last_SEID != "" && Xsupplier == t21_supplier && Xsundry == t21_sundry && last_SEID == 101043) { # store cost info for DIVID Xtag = last_DIVID t21gggrid_to_rentcost_arr[Xtag] = rentcost_arr[cstr] t21gggrid_to_callcost_arr[Xtag] = callcost_arr[cstr] t21gggrid_to_othercost_arr[Xtag] = othercost_arr[cstr] printf("store_t21calls_gggrid_cde_info() t21gggrid_to_callcost_arr[%s] = %0.2f\n", Xtag, t21gggrid_to_callcost_arr[Xtag]) } } function store_t21calls_eggrid_cde_info() { printf("store_t21calls_eggrid_cde_info() callcost_arr[%s] = %0.2f Xsundry=%s Xsupplier=%s last_SID=%s last_SEID=%s\n", cstr, callcost_arr[cstr], Xsundry, Xsupplier, last_SID, last_SEID) if ( Xinvoiceno == "All" ) # skip alls for invoicenumber return if ( Xsundry == "All" ) # skip alls return # store info for later processing of T21 calls #if (last_SID != "" && last_SEID != "" && Xsupplier == t21_supplier && Xsundry == t21_sundry && last_SEID == 1043) { # seid now set here in ld_cde() if (last_SID != "" && last_SEID != "" && Xsupplier == t21_supplier && Xsundry == t21_sundry && last_SEID == 101043) { Xtag = last_DIVID "|" last_SID # create cde DIVID lookup for T21 calls processing # handle dups if ( t21eggrid_to_cdeDIVID[last_SID] != "" ) { # if stored t21 - cdeDIV has 0 callcost # then replace it with current one # if current rentcost is 0 if ( t21gggrid_eggrid_to_callcost_arr[Xtag] == 0 && rentcost_arr[cstr] == 0 ) t21eggrid_to_cdeDIVID[last_SID] = last_DIVID } else { t21eggrid_to_cdeDIVID[last_SID] = last_DIVID } print "store t21eggrid_to_cdeDIVID[" last_SID "] = " t21eggrid_to_cdeDIVID[last_SID] # store cost info for DIVID, SID t21gggrid_eggrid_to_rentcost_arr[Xtag] = rentcost_arr[cstr] t21gggrid_eggrid_to_callcost_arr[Xtag] = callcost_arr[cstr] t21gggrid_eggrid_to_othercost_arr[Xtag] = othercost_arr[cstr] printf("store_t21calls_eggrid_cde_info() t21gggrid_eggrid_to_callcost_arr[%s] = %0.2f\n", Xtag, t21gggrid_eggrid_to_callcost_arr[Xtag]) } } #---------------------------------------------------------- #---------------------------------------------------------- # Process Detail data bellow ServiceID Summary function process_SID_detail_data() { print "process_SID_detail_data() last_SEID = " last_SEID XRENT = HIERIDx_to_rentcost_arr[last_HIERIDx] XCALL = HIERIDx_to_callcost_arr[last_HIERIDx] XOTHER = HIERIDx_to_othercost_arr[last_HIERIDx] XTOTAL = HIERIDx_to_totalcost_arr[last_HIERIDx] print "XRENT = " XRENT " XCALL = " XCALL " XOTHER = " XOTHER # SEID for... rest VRT # mobile SEID and only if cde has call cost #if ( (last_SEID == 1044 || last_SEID == 2405) && XCALL > 0 ) { # seid now set here in ld_cde() # t21 cdr if ( last_SEID == 101043 ) { printf("skipping T21 CDR detail for %s\n", last_HIERIDx) } else # mobile SEID if ( last_SEID == 101044 && XCALL > 0 ) { procgsmcalldetails(gsmcallsfile) } else # voicemail SEID if ( last_SEID == 101047 ) { procvmlcalldetails(t21vmcallsfile) } else # switchboard SEID if ( last_SEID == 101030 ) { procswbcalldetails(t21swcallsfile) } #else { #printf("skipping detail for %s\n", last_HIERIDx) # look SQL detail dir #indetdir = "detail_" YYYYMM "_" "all" indetdir = detailodir indetfile = "detail_" YYYYMM "_" last_sundry "_" last_SID process_indetail_file(indetdir "/" indetfile ".unl") #} } function process_indetail_file(indetailfile) { #sqldetail #30074|2009/01|4|Telstra Mobile 208 4550 371|TELSTRA CORPORATION LTD| # 0407-326077|0407326077|TYH|NSA MOBILE PHONE 2084550371| # Feb 20 2009 12:06PM|Dec 22 2008 11:26AM|Network Services| # TBSFEB2009011194|VRT042703|VNE|V/LINE PASSENGER PTY LTD| # 72130||1044|Telco Voice Wireless 3rd|||1044| # Telco Voice Wireless 3rd|34572|KYNETON|KYNETON|NEWLYN TODD| # DIVERTED TO||CALL FORWARDING CHARGES| # Mobile Call Forwarding|CALL| # 101|30|0.0400| # |||||||||||||||||||||||||||||| create_siddetail_detail_file() print "process_indetail_file(" indetailfile ")" if ( (getline aline < indetailfile) < 0 ) { print " - INDETNOTFOUND [" indetailfile "]" close(indetailfile) close(siddetail_fname) return } afound = 1 while ( afound ) { #print "indetail aline = " aline split(aline, a_arr, "|") f = 0 siddet_tBatch_ID = a_arr[++f] siddet_tBatch_BillingPeriod = a_arr[++f] siddet_tBatchType_SupplierID = a_arr[++f] siddet_tBatchType_Description = a_arr[++f] siddet_tSupplier_SupplierName = a_arr[++f] siddet_tServiceID_ServiceID = a_arr[++f] siddet_tServiceID_Service = a_arr[++f] siddet_tServiceType_Code = a_arr[++f] siddet_tServiceType_Description = a_arr[++f] siddet_tInvoice_InvoiceDate = a_arr[++f] siddet_tFinalisedTransaction_TxnDate = a_arr[++f] siddet_tReportGroup_GroupDesc = a_arr[++f] siddet_tInvoice_PlatinumFileName = a_arr[++f] siddet_tInvoice_PlatinumInvoiceNo = a_arr[++f] siddet_tCustomer_ShipTo = a_arr[++f] siddet_tCustomer_FullName = a_arr[++f] siddet_tCentre_Description = a_arr[++f] siddet_tActivity_Description = a_arr[++f] siddet_tElement_ElementCode = a_arr[++f] siddet_tElement_Description = a_arr[++f] siddet_tElement_CustEleCode = a_arr[++f] siddet_tElement_CustEleDesc = a_arr[++f] siddet_tElement_EleAdmCode = a_arr[++f] siddet_tElement_EleAdmDesc = a_arr[++f] siddet_tSubledger_CustSubLedger = a_arr[++f] siddet_tDepartment_CustDept = a_arr[++f] siddet_tLocation_Description = a_arr[++f] siddet_tPerson_Person = a_arr[++f] siddet_tOrigin_Description = a_arr[++f] siddet_tDestination_Description = a_arr[++f] siddet_tRateDescription_Description = a_arr[++f] siddet_tTransactionType_Description = a_arr[++f] siddet_tTransactionGroup_Description = a_arr[++f] siddet_tDialledNumber_Description = a_arr[++f] siddet_tFinalisedTransaction_Duration = a_arr[++f] siddet_tFinalisedTransaction_AmountExGST = a_arr[++f] siddet_tBatchType_Var01Description = a_arr[++f] siddet_tFinalisedTransaction_Var01 = a_arr[++f] siddet_tBatchType_Var02Description = a_arr[++f] siddet_tFinalisedTransaction_Var02 = a_arr[++f] siddet_tBatchType_Var03Description = a_arr[++f] siddet_tFinalisedTransaction_Var03 = a_arr[++f] siddet_tBatchType_Var04Description = a_arr[++f] siddet_tFinalisedTransaction_Var04 = a_arr[++f] siddet_tBatchType_Var05Description = a_arr[++f] siddet_tFinalisedTransaction_Var05 = a_arr[++f] siddet_tBatchType_Var06Description = a_arr[++f] siddet_tFinalisedTransaction_Var06 = a_arr[++f] siddet_tBatchType_Var07Description = a_arr[++f] siddet_tFinalisedTransaction_Var07 = a_arr[++f] siddet_tBatchType_Var08Description = a_arr[++f] siddet_tFinalisedTransaction_Var08 = a_arr[++f] siddet_tBatchType_Var09Description = a_arr[++f] siddet_tFinalisedTransaction_Var09 = a_arr[++f] siddet_tBatchType_Var10Description = a_arr[++f] siddet_tFinalisedTransaction_Var10 = a_arr[++f] siddet_tBatchType_Var11Description = a_arr[++f] siddet_tFinalisedTransaction_Var11 = a_arr[++f] siddet_tBatchType_Var12Description = a_arr[++f] siddet_tFinalisedTransaction_Var12 = a_arr[++f] siddet_tBatchType_Var13Description = a_arr[++f] siddet_tFinalisedTransaction_Var13 = a_arr[++f] siddet_tBatchType_Var14Description = a_arr[++f] siddet_tFinalisedTransaction_Var14 = a_arr[++f] siddet_tBatchType_Var15Description = a_arr[++f] siddet_tFinalisedTransaction_Var15 = a_arr[++f] spit_siddetail_todetailfile() if ( (getline aline < indetailfile) <= 0 ) afound = 0 } close(indetailfile) # close detail file close(siddetail_fname) siddetail_fname = "" } function create_siddetail_detail_file() { siddetail_fname = sprintf("topdat/%s/data/siddetail/detail_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, last_sundry); printf(">>> siddetail_fname = %s\n", siddetail_fname); if ( (getline x < siddetail_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/siddetail", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "ServiceID Detail", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, last_invoiceno, last_sundry, last_supplier, last_user, XRENT, XCALL, XOTHER, "Date","Time","Origin","Dialled Number","Description","Duration","Cost:Float") >siddetail_fname siddetail_file_exists = 0 } else { printf("WARNING %d: siddetail_fname = %s exists.\n", NR, siddetail_fname) siddetail_file_exists = 1 } } function spit_siddetail_todetailfile() { # mobile m10 input file... # 30143|0434187604|OPTUS| M|Jan 2009|12/01/2009|134900|FRANKSTON|MELBOURNE|0397815031|P|27|0.09| # append record if ( siddetail_file_exists ) { # skip deatils if already exists if ( siddetail_file_exists == 1 ) print "siddetail file exists - skipping gen detail for " last_SID siddetail_file_exists = 2 return } #Jan 05 2009 04:23PM dt = siddet_tFinalisedTransaction_TxnDate # cnv dt to "dd/mm/yyyy" and 24hr "hhmmss" MM = MMM_to_MM(substr(dt,1,3)) DD = 0 + substr(dt,5,2) YYYY = 0 + substr(dt,8,4) siddet_cdate = sprintf("%02d/%02d/%04d", DD, MM, YYYY) hh = 0 + substr(dt,13,2) if ( hh == 12 && toupper(substr(dt,18,2)) == "AM" ) hh = 0 if ( hh < 12 && toupper(substr(dt,18,2)) == "PM" ) hh += 12 mm = 0 + substr(dt,16,2) ss = 0 siddet_ctime = sprintf("%02s%02d%02d", hh, mm, ss) date = fixdate(siddet_cdate) durhh = int(siddet_tFinalisedTransaction_Duration / 3600) remd = siddet_tFinalisedTransaction_Duration - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd siddet_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) hh = substr(siddet_ctime,1,2) mm = substr(siddet_ctime,3,2) ss = substr(siddet_ctime,5,2) ctimestr = sprintf("%2s:%2s:%2s",hh, mm, ss) siddet_origin = siddet_tOrigin_Description ## if blank use Location Desciption #if ( siddet_origin == "" ) # siddet_origin = siddet_tLocation_Description # if blank use ServiceType Desciption if ( siddet_origin == "" ) siddet_origin = siddet_tServiceType_Description # set dialled no siddet_dialled = siddet_tDialledNumber_Description # set destination/description info siddet_destination = siddet_tDestination_Description # User TransactionType Description (Rent/Calltype Desc) ## if still blank #if ( siddet_destination == "" ) if ( siddet_destination != "" ) siddet_destination = siddet_destination " " siddet_destination = siddet_destination siddet_tTransactionType_Description # Rate Desc ## if still blank #if ( siddet_destination == "" ) if ( siddet_destination != "" ) siddet_destination = siddet_destination " " siddet_destination = siddet_destination siddet_tRateDescription_Description ## use var05 if still blank #if ( siddet_destination == "" ) # getdet_destination = siddet_tFinalisedTransaction_Var05 ## add call class description to destination #if ( siddet_callclass != "" ) # siddet_destination = siddet_destination " " siddet_callclass # if still blank use TransactionGroup Desc if ( siddet_destination == "" ) getdet_destination = siddet_tTransactionGroup_Description if (siddet_tTransactionGroup_Description == "CALL") { # RENT/CALL/OTHER siddet_callclass = siddet_tRateDescription_Description } else { date = "CHARGE_DESC" ctimestr = "00:00:00" siddet_origin = siddet_tTransactionGroup_Description siddet_callclass = siddet_tTransactionType_Description } # remove dialled number from start of destination #if ( siddet_dialled == siddet_destination ) # siddet_destination = "" if ( siddet_dialled != "" ) { #sub(siddet_dialled,"",siddet_destination) if ( substr(siddet_destination,1,length(siddet_dialled)) == siddet_dialled ) siddet_destination = substr(siddet_destination,length(siddet_dialled)+1) } # dialno_desc = sprintf("%s", siddet_dialled) # if ( siddet_destination != "" ) # dialno_desc = sprintf("%s %s", dialno_desc, siddet_destination) #ZZZZZ dialledno = siddet_dialled #printf("noddsuparr[%s] = %d\n", gggrid, noddsuparr[gggrid]); gggrid = siddet_tServiceID_ServiceID if ( 1 || noddsuparr[gggrid] == 1 ) { # group has NO digit suppression expdialledno = dialledno; } else { # xx for last 2 digits in dialledno if length >= 0 ## supress for these callcategories only #if ( index("JALMESIOF", callcat) ) { dnl = length(dialledno); dnpreflen = dnl - 2; if ( dnpreflen < 0 ) dnpreflen = 0; if ( dnl >= 0 ) { dnpref = substr(dialledno, 1, dnpreflen); expdialledno = sprintf("%sxx", dnpref); } #} #else { # expdialledno = dialledno; #} } siddet_cost = siddet_tFinalisedTransaction_AmountExGST csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s\n", date, ctimestr, siddet_origin, expdialledno, siddet_destination "~" aline, siddet_durstr, siddet_cost) #printf("%s", csvstr) printf("%s", csvstr) >>siddetail_fname } function MMM_to_MM(MMM) { mmmstr["Jan"] = 1 mmmstr["Feb"] = 2 mmmstr["Mar"] = 3 mmmstr["Apr"] = 4 mmmstr["May"] = 5 mmmstr["Jun"] = 6 mmmstr["Jul"] = 7 mmmstr["Aug"] = 8 mmmstr["Sep"] = 9 mmmstr["Oct"] = 10 mmmstr["Nov"] = 11 mmmstr["Dec"] = 12 return 0 + mmmstr[MMM] } #---------------------------------------------------------- #---------------------------------------------------------- # Voicemail Call Details function create_vmlextnsum_file() { vmlextnsum_fname = sprintf("topdat/%s/data/vmlextnsum/vmlextnsum_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, last_sundry); printf(">>> vmlextnsum_fname = %s\n", vmlextnsum_fname); if ( (getline x < vmlextnsum_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/vmlextnsum", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Extension Voicemail Breakdown", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, last_invoiceno, last_sundry, last_supplier, last_user, XRENT, XCALL, XOTHER, "Extension","Surname","FirstName","Section","Title","InQuantity","InDuration","InCost","OutQuantity","OutDuration","OutCost","RentCost","TotalCost:Float") >vmlextnsum_fname vmlextnsum_file_exists = 0 } else { printf("WARNING %d: vmlextnsum_fname = %s exists.\n", NR, vmlextnsum_fname) vmlextnsum_file_exists = 1 } } function spit_vmlextnsum_tovmlextnsumfile() { # append vmlextnsum call record data to vmlextnsum file if ( vmlextnsum_file_exists ) { # skip deatils if already exists if ( vmlextnsum_file_exists == 1 ) print "vmlextnsum file exists - skipping vml extnsumail for " last_SID vmlextnsum_file_exists = 2 return } durhh = int(vmlextntot_duration["in"] / 3600) remd = vmlextntot_duration["in"] - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd vml_in_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) durhh = int(vmlextntot_duration["out"] / 3600) remd = vmlextntot_duration["out"] - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd vml_out_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) vmlitag = last_vml_eggrid "|" last_vml_extn vml_t21surname = egridextn_to_t21surname_arr[vmlitag] vml_t21firstname = egridextn_to_t21firstname_arr[vmlitag] vml_t21section = egridextn_to_t21section_arr[vmlitag] vml_t21title = egridextn_to_t21title_arr[vmlitag] csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", last_vml_extn, vml_t21surname, vml_t21firstname, vml_t21section, vml_t21title, vmlextntot_count["in"], vml_in_durstr, vmlextntot_cost["in"], vmlextntot_count["out"], vml_out_durstr, vmlextntot_cost["out"], VMLEXTN_XRENT, vmlextntot_cost["in"] + vmlextntot_cost["out"] + VMLEXTN_XRENT) printf("VMLextnsum %s", csvstr) printf("%s", csvstr) >>vmlextnsum_fname } function create_vmldet_detail_file() { vmldet_fname = sprintf("topdat/%s/data/vmldet/vmldet_%s_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, vml_extn, last_sundry); printf(">>> vmldet_fname = %s\n", vmldet_fname); if ( (getline x < vmldet_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/vmldet", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Voicemail Call Detail", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, vml_extn, vml_name, last_invoiceno, last_sundry, last_supplier, last_user, VMLEXTN_XRENT, 0, 0, "Date","Time", "Dialled Number","Description","Duration","Cost:Float") >vmldet_fname vmldet_file_exists = 0 } else { printf("WARNING %d: vmldet_fname = %s exists.\n", NR, vmldet_fname) vmldet_file_exists = 1 } } function spit_sdrrec_tovmldetfile() { # append vmldet call record data to vmldet file if ( vmldet_file_exists ) { # skip deatils if already exists if ( vmldet_file_exists == 1 ) print "vmldet file exists - skipping vml detail for " last_SID vmldet_file_exists = 2 return } date = fixdate(vml_cdate) durhh = int(vml_duration / 3600) remd = vml_duration - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd vml_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) hh = substr(vml_ctime,1,2) mm = substr(vml_ctime,3,2) ss = substr(vml_ctime,5,2) ctimestr = sprintf("%2s:%2s:%2s",hh, mm, ss) dialledno = vml_dialled csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s\n", date, ctimestr, dialledno, vml_dirdesc, vml_durstr, vml_cost) printf("VMLdet %s", csvstr) printf("%s", csvstr) >>vmldet_fname } function procvmlcalldetails(vmlcallsfile) { printf("\n") printf("procvmlcalldetails(%s) %s %s %s %s)\n", vmlcallsfile, last_SID, last_HIERIDxDUPcount, last_supplier, last_sundry) vmlextnsum_fname = "" vmldet_fname = "" vmlextntot_count["in"] = 0 vmlextntot_duration["in"] = 0 vmlextntot_cost["in"] = 0 vmlextntot_count["out"] = 0 vmlextntot_duration["out"] = 0 vmlextntot_cost["out"] = 0 create_vmlextnsum_file() vml_eggrid = substr(last_SID,3) #tmpvmlcallsfile = sprintf("%s.tmp", vmlcallsfile) cmd = "basename " vmlcallsfile cmd | getline basevmlcallsfile tmpvmlcallsfile = sprintf("%s/%s.tmp", logdir, basevmlcallsfile) print "tmpvmlcallsfile = " tmpvmlcallsfile system("rm -f " tmpvmlcallsfile) cmdstr = sprintf("grep -iF \"%s,%s,\" %s >%s", last_DIVID, vml_eggrid, vmlcallsfile, tmpvmlcallsfile) print "RUN: " cmdstr system(cmdstr) #system("cat " tmpvmlcallsfile) # count extensions last_vml_extn = "" vml_extncount = 0 while ( (getline aline < tmpvmlcallsfile) > 0 ) { #print "VMLEXTNCOUNT aline = " aline " split(aline, a_arr, ",") vml_extn = a_arr[3] if ( vml_extn != last_vml_extn) ++vml_extncount last_vml_extn = vml_extn #print "VMLEXTNCOUNT vml_extn = " vml_extn " vml_extncount = " vml_extncount } close(tmpvmlcallsfile) if ( vml_extncount != 0 ) VMLEXTN_XRENT = sprintf("%0.2f", XRENT / vml_extncount) else VMLEXTN_XRENT = 0 print "SID = " last_SID " " "XRENT = " XRENT " " "vml_extncount = " vml_extncount " " "VMLEXTN_XRENT = " VMLEXTN_XRENT #ALA,ALA01PWS,18171,09/02/2004,104508,39,60033,out,19000,O,Outgoing Internal Network,396,0.0, #gggrid, eggrid, inletno, calldate, endtime, $cdrtable.siteid, inoutno, "out", dialledno, callcategory, calltypedesc, $cdrtable.duration, $cdrtable.callcost last_vml_eggrid = "" last_vml_extn = "" while ( (getline aline < tmpvmlcallsfile) > 0 ) { #print "VMLDET aline = " aline split(aline, a_arr, ",") f = 0 vml_divid = a_arr[++f] vml_eggrid = a_arr[++f] vml_extn = a_arr[++f] vml_cdate = a_arr[++f] vml_ctime = a_arr[++f] vml_siteid = a_arr[++f] vml_inoutno = a_arr[++f] vml_direction = a_arr[++f] vml_dialled = a_arr[++f] vml_category = a_arr[++f] vml_calltypedesc = a_arr[++f] vml_duration = a_arr[++f] vml_cost = a_arr[++f] vml_cost = 0 + voicemailcallcost itag = vml_eggrid "|" vml_extn vml_name = egridextn_to_t21surname_arr[itag] vml_operator = "" vml_dirdesc = "" if ( vml_direction == "in" ) { vml_dirdesc = "Incomming Voicemail Call" } if ( vml_direction == "out" ) { vml_dirdesc = "Voicemail Facility" } #printf("VMLDET: %s %s %s %s %s %s %s %s %d %0.2f\n", vml_divid, vml_eggrid, vml_extn, vml_name, vml_cdate, vml_ctime, vml_direction, vml_dialled, vml_duration, vml_cost) if ( vml_extn != last_vml_extn ) { if ( last_vml_extn != "" ) { if ( vmlextnsum_fname != "" ) { spit_vmlextnsum_tovmlextnsumfile() } } if ( vmldet_fname != "" ) { print "close(" vmldet_fname ")" # close vml detail file close(vmldet_fname) vmldet_fname == "" print " incount=" vmlextntot_count["in"] " outcount=" vmlextntot_count["out"] if ( (vmlextntot_count["in"] + vmlextntot_count["out"]) == 0 ) { #no calls so delete detail file # (only X dummies) print "remove empty vmldet_fname=" vmldet_fname system("rm -f " vmldet_fname) } } vmlextntot_count["in"] = 0 vmlextntot_duration["in"] = 0 vmlextntot_cost["in"] = 0 vmlextntot_count["out"] = 0 vmlextntot_duration["out"] = 0 vmlextntot_cost["out"] = 0 create_vmldet_detail_file() } # add call and spit if NOT dummy from directory if ( vml_category != "X" ) { vmlextntot_count[vml_direction] += 1 vmlextntot_duration[vml_direction] += vml_duration vmlextntot_cost[vml_direction] += voicemailcallcost #print "vml_extn = " vml_extn " vmlextntot_cost[" vml_direction "] = " vmlextntot_cost[vml_direction] spit_sdrrec_tovmldetfile() } last_vml_eggrid = vml_eggrid last_vml_extn = vml_extn } close(tmpvmlcallsfile) system("rm -f " tmpvmlcallsfile) if ( last_vml_extn != "" ) { if ( vmlextnsum_fname != "" ) { spit_vmlextnsum_tovmlextnsumfile() } } if ( vmldet_fname != "" ) { # close vml detail file close(vmldet_fname) vmldet_fname == "" print " incount=" vmlextntot_count["in"] " outcount=" vmlextntot_count["out"] if ( (vmlextntot_count["in"] + vmlextntot_count["out"]) == 0 ) { #no calls so delete detail file # (only X dummies) print "remove empty vmldet_fname=" vmldet_fname system("rm -f " vmldet_fname) } } # close vmlextnsum file close(vmlextnsum_fname) vmlextnsum_fname == "" } #---------------------------------------------------------- #---------------------------------------------------------- # Switchboard Call Details function create_swbextnsum_file() { swbextnsum_fname = sprintf("topdat/%s/data/swbextnsum/swbextnsum_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, last_sundry); printf(">>> swbextnsum_fname = %s\n", swbextnsum_fname); if ( (getline x < swbextnsum_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/swbextnsum", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Extension Switchboard Breakdown", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, last_invoiceno, last_sundry, last_supplier, last_user, XRENT, XCALL, XOTHER, "Extension","InQuantity","InDuration","InCost","OutQuantity","OutDuration","OutCost","TotalCost:Float") >swbextnsum_fname swbextnsum_file_exists = 0 } else { printf("WARNING %d: swbextnsum_fname = %s exists.\n", NR, swbextnsum_fname) swbextnsum_file_exists = 1 } } function spit_swbextnsum_toswbextnsumfile() { # append swbextnsum call record data to swbextnsum file if ( swbextnsum_file_exists ) { # skip deatils if already exists if ( swbextnsum_file_exists == 1 ) print "swbextnsum file exists - skipping swb extnsumail for " last_SID swbextnsum_file_exists = 2 return } durhh = int(swbextntot_duration["in"] / 3600) remd = swbextntot_duration["in"] - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd swb_in_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) durhh = int(swbextntot_duration["out"] / 3600) remd = swbextntot_duration["out"] - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd swb_out_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s,%s\n", last_swb_extn, swbextntot_count["in"], swb_in_durstr, swbextntot_cost["in"], swbextntot_count["out"], swb_out_durstr, swbextntot_cost["out"], swbextntot_cost["in"] + swbextntot_cost["out"]) printf("SWBextnsum %s", csvstr) printf("%s", csvstr) >>swbextnsum_fname } function create_swbdet_detail_file() { swbdet_fname = sprintf("topdat/%s/data/swbdet/swbdet_%s_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, swb_extn, last_sundry); printf(">>> swbdet_fname = %s\n", swbdet_fname); if ( (getline x < swbdet_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/swbdet", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "Switchboard Call Detail", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, swb_extn, swb_name, last_invoiceno, last_sundry, last_supplier, last_user, 0, 0, 0, "Date","Time","Operator", "Dialled Number","Description","Duration","Cost:Float") >swbdet_fname swbdet_file_exists = 0 } else { printf("WARNING %d: swbdet_fname = %s exists.\n", NR, swbdet_fname) swbdet_file_exists = 1 } } function spit_sdrrec_toswbdetfile() { # append swbdet call record data to swbdet file if ( swbdet_file_exists ) { # skip deatils if already exists if ( swbdet_file_exists == 1 ) print "swbdet file exists - skipping swb detail for " last_SID swbdet_file_exists = 2 return } date = fixdate(swb_cdate) durhh = int(swb_duration / 3600) remd = swb_duration - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd swb_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) hh = substr(swb_ctime,1,2) mm = substr(swb_ctime,3,2) ss = substr(swb_ctime,5,2) ctimestr = sprintf("%2s:%2s:%2s",hh, mm, ss) dialledno = swb_dialled csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s\n", date, ctimestr, swb_operator, dialledno, swb_dirdesc, swb_durstr, swb_cost) printf("SWBdet %s", csvstr) printf("%s", csvstr) >>swbdet_fname } function procswbcalldetails(swbcallsfile) { printf("\n") printf("procswbcalldetails(%s) %s %s %s %s)\n", swbcallsfile, last_SID, last_HIERIDxDUPcount, last_supplier, last_sundry) swbextnsum_fname = "" swbdet_fname = "" swbextntot_count["in"] = 0 swbextntot_duration["in"] = 0 swbextntot_cost["in"] = 0 swbextntot_count["out"] = 0 swbextntot_duration["out"] = 0 swbextntot_cost["out"] = 0 create_swbextnsum_file() last_swb_extn = "" last_swb_name = "" swb_eggrid = substr(last_SID,3) #tmpswbcallsfile = sprintf("%s.tmp", swbcallsfile) cmd = "basename " swbcallsfile cmd | getline baseswbcallsfile tmpswbcallsfile = sprintf("%s/%s.tmp", logdir, baseswbcallsfile) print "tmpswbcallsfile = " tmpswbcallsfile system("rm -f " tmpswbcallsfile) cmdstr = sprintf("grep -iF \"%s,%s,\" %s >%s", last_DIVID, swb_eggrid, swbcallsfile, tmpswbcallsfile) print "RUN: " cmdstr system(cmdstr) #system("cat " tmpswbcallsfile) #ALA,ALA01PWS,18171,09/02/2004,104508,39,60033,out,19000,O,Outgoing Internal Network,396,0.0, #gggrid, eggrid, inletno, calldate, endtime, $cdrtable.siteid, inoutno, "out", dialledno, callcategory, calltypedesc, $cdrtable.duration, $cdrtable.callcost while ( (getline aline < tmpswbcallsfile) > 0 ) { #print "SWBDET aline = " aline split(aline, a_arr, ",") f = 0 swb_divid = a_arr[++f] swb_eggrid = a_arr[++f] swb_extn = a_arr[++f] swb_cdate = a_arr[++f] swb_ctime = a_arr[++f] swb_siteid = a_arr[++f] swb_inoutno = a_arr[++f] swb_direction = a_arr[++f] swb_dialled = a_arr[++f] swb_category = a_arr[++f] swb_calltypedesc = a_arr[++f] swb_duration = a_arr[++f] swb_cost = a_arr[++f] swb_cost = 0 + switchboardcallcost itag = swb_eggrid "|" swb_extn swb_name = egridextn_to_t21surname_arr[itag] swb_operator = "" swb_dirdesc = "" if ( swb_direction == "in" ) { swb_operator = swb_inoutno swb_dirdesc = "Incomming Enquiry Call" } if ( swb_direction == "out" ) { swb_operator = "" # not available in cdr swb_dirdesc = "Operator Assisted Call" } #printf("SWBDET: %s %s %s %s %s %s %s %s %d %0.2f\n", swb_divid, swb_eggrid, swb_extn, swb_name, swb_cdate, swb_ctime, swb_direction, swb_dialled, swb_duration, swb_cost) if ( swb_extn != last_swb_extn ) { if ( last_swb_extn != "" ) { if ( swbextnsum_fname != "" ) { spit_swbextnsum_toswbextnsumfile() } } if ( swbdet_fname != "" ) { print "close(" swbdet_fname ")" # close swb detail file close(swbdet_fname) swbdet_fname == "" print " incount=" swbextntot_count["in"] " outcount=" swbextntot_count["out"] if ( (swbextntot_count["in"] + swbextntot_count["out"]) == 0 ) { #no calls so delete detail file # (only X dummies) print "remove empty swbdet_fname=" swbdet_fname system("rm -f " swbdet_fname) } } swbextntot_count["in"] = 0 swbextntot_duration["in"] = 0 swbextntot_cost["in"] = 0 swbextntot_count["out"] = 0 swbextntot_duration["out"] = 0 swbextntot_cost["out"] = 0 create_swbdet_detail_file() } # add call and spit if NOT dummy from directory if ( swb_category != "X" ) { swbextntot_count[swb_direction] += 1 swbextntot_duration[swb_direction] += swb_duration swbextntot_cost[swb_direction] += switchboardcallcost #print "swb_extn = " swb_extn " swbextntot_cost[" swb_direction "] = " swbextntot_cost[swb_direction] spit_sdrrec_toswbdetfile() } last_swb_extn = swb_extn last_swb_name = swb_name } close(tmpswbcallsfile) system("rm -f " tmpswbcallsfile) if ( last_swb_extn != "" ) { if ( swbextnsum_fname != "" ) { spit_swbextnsum_toswbextnsumfile() } } if ( swbdet_fname != "" ) { # close swb detail file close(swbdet_fname) swbdet_fname == "" print " incount=" swbextntot_count["in"] " outcount=" swbextntot_count["out"] if ( (swbextntot_count["in"] + swbextntot_count["out"]) == 0 ) { #no calls so delete detail file # (only X dummies) print "remove empty swbdet_fname=" swbdet_fname system("rm -f " swbdet_fname) } } # close swbextnsum file close(swbextnsum_fname) swbextnsum_fname == "" } #---------------------------------------------------------- #---------------------------------------------------------- # GSM Mobile Call Details function create_mobile_detail_file() { mobile_fname = sprintf("topdat/%s/data/mobile/mobile_%s_%s_%s_%s_%s_%s.csv", last_pardir, last_DIVID, last_SGID, last_SEID, last_DEPTID, last_SID, last_sundry); printf(">>> mobile_fname = %s\n", mobile_fname); if ( (getline x < mobile_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/mobile", last_pardir) cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir) print "system 3 [" cmd "]" system(cmd) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", "ServiceID Detail", exbillperiod, "SDATE", "EDATE", ShipTo_to_ShipToDesc_arr[last_DIVID], last_DIVID, SGID_to_SGIDdesc_arr[last_SGID], last_SGID, SEID_to_SEIDdesc_arr[last_SEID], last_SEID, DEPTID_to_department_arr[last_DEPTID], last_DEPTID, last_SID, last_invoiceno, last_sundry, last_supplier, last_user, XRENT, XCALL, XOTHER, "Date","Time","Origin","Dialled Number","Description","Duration","Cost:Float") >mobile_fname mobile_file_exists = 0 } else { printf("WARNING %d: mobile_fname = %s exists.\n", NR, mobile_fname) mobile_file_exists = 1 } } function spit_mdrrec_tomobilefile() { # append mobile call record data to mobile file if ( mobile_file_exists ) { # skip deatils if already exists if ( mobile_file_exists == 1 ) print "mobile file exists - skipping gsm detail for " last_SID mobile_file_exists = 2 return } #c sdate = fixdate(sdate) #c edate = fixdate(edate) date = fixdate(gsm_cdate) durhh = int(gsm_duration / 3600) remd = gsm_duration - (durhh * 3600) durmm = int(remd / 60) remd = remd - (durmm * 60) durss = remd gsm_durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss) hh = substr(gsm_ctime,1,2) mm = substr(gsm_ctime,3,2) ss = substr(gsm_ctime,5,2) ctimestr = sprintf("%2s:%2s:%2s",hh, mm, ss) # set dialled/description info if ( gsm_dialled == gsm_destination ) gsm_destination = "" # remove dialled number from start of destination if ( gsm_dialled != "" ) { #sub(gsm_dialled,"",gsm_destination) if ( substr(gsm_destination,1,length(gsm_dialled)) == gsm_dialled ) gsm_destination = substr(gsm_destination,length(gsm_dialled)+1) } # dialno_desc = sprintf("%s", gsm_dialled) # if ( gsm_destination != "" ) # dialno_desc = sprintf("%s %s", dialno_desc, gsm_destination) # add call class description to destination if ( gsm_callclass != "" ) gsm_destination = gsm_destination " " gsm_callclass dialledno = gsm_dialled #printf("noddsuparr[%s] = %d\n", gggrid, noddsuparr[gggrid]); if ( 1 || noddsuparr[gggrid] == 1 ) { # group has NO digit suppression expdialledno = dialledno; } else { # xx for last 2 digits in dialledno if length >= 0 ## supress for these callcategories only #if ( index("JALMESIOF", callcat) ) { dnl = length(dialledno); dnpreflen = dnl - 2; if ( dnpreflen < 0 ) dnpreflen = 0; if ( dnl >= 0 ) { dnpref = substr(dialledno, 1, dnpreflen); expdialledno = sprintf("%sxx", dnpref); } #} #else { # expdialledno = dialledno; #} } csvstr = sprintf(",,,,,,,,,,,,,,,,,,,,%s,%s,%s,%s,%s,%s,%s\n", date, ctimestr, gsm_origin, expdialledno, gsm_destination, gsm_durstr, gsm_cost) #printf("%s", csvstr) printf("%s", csvstr) >>mobile_fname } function procgsmcalldetails(gsmcallsfile) { mobile = "" printf("\n") printf("procgsmcalldetails(%s) %s %s %s %s)\n", gsmcallsfile, last_SID, last_HIERIDxDUPcount, last_supplier, last_sundry) create_mobile_detail_file() if ( substr(last_SID,5,1) == "-" ) last_mobile = substr(last_SID,1,4) substr(last_SID,6) else last_mobile = last_SID printf(" last_mobile=[%s]\n", last_mobile) tmpgsmcallsfile = sprintf("%s.tmp", gsmcallsfile) system("rm -f " tmpgsmcallsfile) cmdstr = sprintf("grep -iF \"%s|%s|%s|\" %s >%s", last_sundry, last_mobile, last_supplier, gsmcallsfile, tmpgsmcallsfile) print "RUN: " cmdstr system(cmdstr) while ( (getline aline < tmpgsmcallsfile) > 0 ) { #print "GSMDET aline = " aline split(aline, a_arr, "|") gsm_sundry = a_arr[1] gsm_mobile = a_arr[2] gsm_carrier = a_arr[3] gsm_callclass = a_arr[4] gsm_billperiod = a_arr[5] gsm_cdate = a_arr[6] gsm_ctime = a_arr[7] gsm_origin = a_arr[8] gsm_destination = a_arr[9] gsm_dialled = a_arr[10] gsm_rate = a_arr[11] gsm_duration = a_arr[12] gsm_cost = a_arr[13] # force uppercase gsm_carrier = toupper(gsm_carrier) #printf("GSMDET: %s|%s|%s\n", gsm_mobile,gsm_sundry,gsm_carrier) #if ( last_mobile != gsm_mobile || last_supplier != gsm_carrier || last_sundry != gsm_sundry ) # continue if ( last_sundry != gsm_sundry ) continue #print "GSMDETaline = " aline #printf("GSMDET: %s %s %s %s %s %d %0.2f\n", gsm_sundry, gsm_mobile, gsm_carrier, gsm_cdate, gsm_ctime, gsm_duration, gsm_cost) spit_mdrrec_tomobilefile() } close(tmpgsmcallsfile) system("rm -f " tmpgsmcallsfile) # close mobile detail file close(mobile_fname) mobile_fname = "" } # ------ function procgsmdet(gsmcallsfile) { mobile = "" printf("\n") printf("procgsmdet(%s)\n", gsmcallsfile) while ( (getline aline < gsmcallsfile) > 0 ) { #print "GSMDET aline = " aline split(aline, a_arr, "|") gsm_sundry = a_arr[1] gsm_mobile = a_arr[2] gsm_carrier = a_arr[3] gsm_callclass = a_arr[4] gsm_billperiod = a_arr[5] gsm_cdate = a_arr[6] gsm_ctime = a_arr[7] gsm_origin = a_arr[8] gsm_destination = a_arr[9] gsm_dialled = a_arr[10] gsm_rate = a_arr[11] gsm_duration = a_arr[12] gsm_cost = a_arr[13] # force uppercase gsm_carrier = toupper(gsm_carrier) gsm_SID = substr(gsm_mobile,1,4) "-" substr(gsm_mobile,5) gsm_tascode = sundrySID_to_tascode_arr[gsm_sundry "|" gsm_SID] gsm_ElementID = tascode_to_ElementID_arr[gsm_tascode] #old tassemap gsm_SEID = tascode_to_SEID_arr[gsm_tascode] gsm_SEID = ElementID_to_SEID_arr[gsm_ElementID] gsm_SEIDdesc = SEID_to_SEIDdesc_arr[gsm_SEID] gsm_SGID = SEID_to_SGID_arr[gsm_SEID] gsm_SGIDdesc = SGID_to_SGIDdesc_arr[gsm_SGID] #gsm_DIVID = XXX # ??? SGID_to_DIVID_arr[gsm_SGID] #gsm_DIVIDdesc1 = DIVID_to_DIVIDdesc1_arr[gsm_DIVID] #gsm_DIVIDdesc2 = DIVID_to_DIVIDdesc2_arr[gsm_DIVID] #gsm_ShipToDesc = ShipTo_to_ShipToDesc_arr[gsm_DIVID] print "GSMDETaline = " aline printf("GSMDET: %s|%s|%s|%s|%s|%s|%s|%s|%d|%0.2f\n", gsm_SGID, gsm_SEID, gsm_tascode, gsm_sundry, gsm_SID, gsm_carrier, gsm_cdate, gsm_ctime, gsm_duration, gsm_cost) } close(gsmcallsfile) } #---------------------------------------------------------- #---------------------------------------------------------- function ld_exwebconf(exwebconffile) { printf("ld_exwebconf(%s)\n", exwebconffile) #noddsupfile = "noddsup.txt"; #while ( (getline custline < noddsupfile) > 0 ) { # split(custline, noddsupgggrid, " "); # noddsuparr[noddsupgggrid[1]] = 1; #} #close(noddsupfile); while ( (getline exwebconfline < exwebconffile) > 0 ) { split(exwebconfline, exwebconfarr, ","); #printf("exwebconfline=%s\n", exwebconfline); #printf("exwebconfarr 1=%s 2=%s 3=%s 4=%s\n", exwebconfarr[1], exwebconfarr[2], exwebconfarr[3], exwebconfarr[4]); exwebconf_parent = trim(exwebconfarr[1]) exwebconf_dialxx = trim(exwebconfarr[2]) exwebconf_email = trim(exwebconfarr[3]) exwebconf_emailyn = trim(exwebconfarr[4]) exwebconf_status1 = trim(exwebconfarr[5]) exwebconf_lastemailed = trim(exwebconfarr[6]) exwebconf_lastemaileddate = trim(exwebconfarr[7]) exwebconf_print = trim(exwebconfarr[8]) exwebconf_cdgroup = trim(exwebconfarr[9]) # skip retired entries if ( exwebconf_status1 == "R" ) continue # flag parent in exwebconf exwebconf_parent_arr[exwebconf_parent] = 1 if ( platinv_parent_arr[exwebconf_parent] != 1 ) { print "WARNING: parent = " exwebconf_parent " found in exwebconf, but is not in platinum invoice data" } #printf("noddsuparr[%s] = %d\n", exwebconf_parent, noddsuparr[exwebconf_parent]); if ( toupper(exwebconf_dialxx) == "N" ) noddsuparr[exwebconf_parent] = 1; else noddsuparr[exwebconf_parent] = 0; #tmpgggrid = exwebconf_parent; #if ( noddsuparr[tmpgggrid] == 1 ) # printf(" NO DD SUPPRESS\n"); #else # printf(" DO DD SUPPRESS\n"); # store parent grouping exwebconf_parent_to_cdgroup_arr[exwebconf_parent] = exwebconf_cdgroup } close(exwebconffile); } #---------------------------------------------------------- #---------------------------------------------------------- function ld_platinv(platinvfile) { printf("ld_platinv(%s)\n", platinvfile) while ( (getline platinvline < platinvfile) > 0 ) { split(platinvline, platinvarr, "|"); #printf("platinvline=%s\n", platinvline); f = 0 tblInvoice_ShipToCode = trim(platinvarr[++f]) tblInvoice_PlatinumFileName = trim(platinvarr[++f]) tblInvoice_PlatinumInvoiceNo = trim(platinvarr[++f]) tblInvoicedTransaction_Var1 = trim(platinvarr[++f]) tblTASSEMap_TASType = trim(platinvarr[++f]) tblServiceGroup_ServiceGroupID = trim(platinvarr[++f]) tblServiceGroup_ServiceGroupDesc = trim(platinvarr[++f]) tblInvoiceDetail_ServiceElementID = trim(platinvarr[++f]) tblServiceElements_ServiceElementDesc = trim(platinvarr[++f]) tblInvoiceDetail_Period = trim(platinvarr[++f]) tblInvoicedTransaction_ImportedFileID = trim(platinvarr[++f]) tblInvoicedTransaction_InvoiceDetailID = trim(platinvarr[++f]) tblInvoice_InvoiceDate = trim(platinvarr[++f]) tblInvoiceDetail_Amount = trim(platinvarr[++f]) tblInvoice_ShipToCode = toupper(tblInvoice_ShipToCode) platinv_parent = tblInvoice_ShipToCode platinv_batch = tblInvoice_PlatinumFileName platinv_invoicenumber = tblInvoice_PlatinumInvoiceNo platinv_sundry = tblInvoicedTransaction_Var1 platinv_supplier = tblTASSEMap_TASType platinv_elementid = tblInvoiceDetail_ServiceElementID if ( platinv_parent == "" ) { print "FATAL ERROR: Blank parent (ShipTo) in platinum invoice data" exit 1 } if ( platinv_batch == "" ) { print "FATAL ERROR: Blank PlatinumFileName in platinum invoice data" exit 1 } if ( platinv_invoicenumber == "" ) { print "FATAL ERROR: Blank InvoiceNumber in platinum invoice data" exit 1 } if ( platinv_sundry == "" ) { print "FATAL ERROR: Blank Sundry (var1) in platinum invoice data" exit 1 } print "" print " platinv_batch = " platinv_batch print "platinv_invoicenumber = " platinv_invoicenumber print " platinv_sundry = " platinv_sundry print " platinv_elementid = " platinv_elementid print " platinv_supplier = " platinv_supplier print " platinv_parent = " platinv_parent #if (length(inp_platinumBATCH) > 0 ) { # if (length(inp_platinumBATCH) >= 7 && length(inp_platinumBATCH) <= 10) { # if ( inp_platinumBATCH != platinv_invoicenumber ) { # print " skipping invoicenumber" # continue # } # } # if (length(inp_platinumBATCH) > 10) { # if ( inp_platinumBATCH != platinv_batch ) { # print " skipping batch" # continue # } # } #} # rjs 25/01/2005 hack = 0 if ( platinv_batch == "TBSJAN2005001288" && platinv_invoicenumber == "VRT025261" && platinv_sundry == "15321" && platinv_parent == "NAD" ) { platinv_batch = "TBSJAN2005001291" platinv_invoicenumber = "VRT025334" hack = 11 } if ( platinv_batch == "TBSJAN2005001288" && platinv_invoicenumber == "VRT025261" && platinv_sundry == "15322" && platinv_parent == "NAD" ) { platinv_batch = "TBSJAN2005001291" platinv_invoicenumber = "VRT025334" hack = 12 } if ( platinv_batch == "TBSJAN2005001288" && platinv_invoicenumber == "VRT025268" && platinv_sundry == "15321" && platinv_parent == "RBD" ) { platinv_batch = "TBSJAN2005001291" platinv_invoicenumber = "VRT025335" hack = 21 } if ( platinv_batch == "TBSJAN2005001288" && platinv_invoicenumber == "VRT025268" && platinv_sundry == "15322" && platinv_parent == "RBD" ) { platinv_batch = "TBSJAN2005001291" platinv_invoicenumber = "VRT025335" hack = 22 } if ( platinv_batch == "TBSJAN2005001288" && platinv_invoicenumber == "VRT025275" && platinv_sundry == "15322" && platinv_parent == "SDM" ) { platinv_batch = "TBSJAN2005001291" platinv_invoicenumber = "VRT025336" hack = 3 } if ( platinv_batch == "TBSJAN2005001300" && platinv_invoicenumber == "VRT025348" && platinv_sundry == "15374" && platinv_parent == "ART" ) { platinv_batch = "TBSJAN2005001302" platinv_invoicenumber = "VRT025403" hack = 4 } if ( hack ) { print " XXXXXXXXXXXXXXXXXXX" print " XX hack = " hack print " XX platinv_batch = " platinv_batch print " XXplatinv_invoicenumber = " platinv_invoicenumber print " XX platinv_sundry = " platinv_sundry print " XX platinv_supplier = " platinv_supplier print " XX platinv_parent = " platinv_parent } htag = platinv_parent "|" platinv_invoicenumber "|" platinv_sundry printf(" htag = [%s]\n", htag) #itag = platinv_parent "|" platinv_sundry itag = platinv_parent "|" platinv_sundry "|" platinv_elementid printf(" itag = [%s]\n", itag) jtag = platinv_parent "|" platinv_invoicenumber printf(" jtag = [%s]\n", jtag) ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 0 Skipping platinv_batch = " platinv_batch # continue #} billingPeriod = tblInvoiceDetail_Period parent_invoicenumber_sundry_to_period_arr[htag] = billingPeriod print " parent_invoicenumber_sundry_to_period_arr[" htag "] = " parent_invoicenumber_sundry_to_period_arr[htag] ## rjs 18/8/2008 if ( parent_sundry_to_platinv_batch_arr[itag] != "" && parent_sundry_to_platinv_batch_arr[itag] != platinv_batch ) { print "FATAL ERROR: conflicting platinum invoice batch / sundry" print " platinv_parent = " platinv_parent print " platinv_batch = " platinv_batch print "platinv_invoicenumber = " platinv_invoicenumber print " platinv_sundry = " platinv_sundry print " itag = " itag print " parent_sundry_to_platinv_batch_arr[" itag "] = " parent_sundry_to_platinv_batch_arr[itag] exit 1 } if ( parent_sundry_to_platinv_batch_arr[itag] == "" ) parent_sundry_to_platinv_batch_arr[itag] = platinv_batch print " parent_sundry_to_platinv_batch_arr[" itag "] = " parent_sundry_to_platinv_batch_arr[itag] ## rjs 18/8/2008 if ( parent_sundry_to_platinv_invoicenumber_arr[itag] != "" && parent_sundry_to_platinv_invoicenumber_arr[itag] != platinv_invoicenumber ) { print "FATAL ERROR: conflicting platinum invoice number / sundry" print " platinv_parent = " platinv_parent print " platinv_batch = " platinv_batch print "platinv_invoicenumber = " platinv_invoicenumber print " platinv_sundry = " platinv_sundry print " itag = " itag print " parent_sundry_to_platinv_invoicenumber_arr[" itag "] = " parent_sundry_to_platinvinvoicenumber_arr[itag] exit 1 } if ( parent_sundry_to_platinv_invoicenumber_arr[itag] == "" ) parent_sundry_to_platinv_invoicenumber_arr[itag] = platinv_invoicenumber print " parent_sundry_to_platinv_invoicenumber_arr[" itag "] = " parent_sundry_to_platinv_invoicenumber_arr[itag] if ( parent_invoicenumber_to_platinv_batch_arr[jtag] != "" && parent_invoicenumber_to_platinv_batch_arr[jtag] != platinv_batch ) { print "FATAL ERROR: conflicting platinum invoice batch / invoicenumber" print " platinv_parent = " platinv_parent print " platinv_batch = " platinv_batch print "platinv_invoicenumber = " platinv_invoicenumber print " platinv_sundry = " platinv_sundry print " jtag = " jtag print " parent_invoicenumber_to_platinv_batch_arr[" jtag "] = " parent_invoicenumber_to_platinv_batch_arr[jtag] exit 1 } parent_invoicenumber_to_platinv_batch_arr[jtag] = platinv_batch print " parent_invoicenumber_to_platinv_batch_arr[" jtag "] = " parent_invoicenumber_to_platinv_batch_arr[jtag] # flag parent / sundry in platinv platinv_parent_sundry_arr[itag] = 1 print "platinv_parent_sundry_arr[" itag "]=[" platinv_parent_sundry_arr[itag] "]" # flag parent in platinv platinv_parent_arr[platinv_parent] = 1 } close(platinvfile); } # T21CALLS ##################################################### ##################################################### ##################################################### ##################################################### function get_ggname(gggrid) { # get group name ggname = grid_to_grname2_arr[gggrid] printf("get_ggname(): gggrid = %s ggname = %s\n", gggrid, ggname); return } function get_egname(eggrid) { # get group name egname = grid_to_grname2_arr[eggrid] printf("get_egname(): eggrid = %s egname = %s\n", eggrid, egname); return } function get_dirname(siteid,eggrid,extn) { # get name from directory itag = eggrid "|" extn t21surname = egridextn_to_t21surname_arr[itag] t21firstname = egridextn_to_t21firstname_arr[itag] printf("get_dirname(): eggrid=%s extn=%s t21surname = %s t21firstname = %s\n", eggrid, extn, t21surname, t21firstname) t21name = t21surname if ( t21surname != "Multiple" ) { if ( t21firstname != "" ) t21name = sprintf("%s %s", t21firstname, t21name); } printf("get_dirname(): siteid = %d eggrid= %s extn = %d t21name = %s\n", siteid, eggrid, extn, t21name); return t21name } function get_t21_upper_info(gggrid, eggrid) { t21_DIVID = gggrid t21_SID = eggrid #t21_tascode = "TQ" t21_tascode = sundrySID_to_tascode_arr[t21_sundry "|" t21_SID] t21_ElementID = tascode_to_ElementID_arr[t21_tascode] #old tassemap t21_SEID = tascode_to_SEID_arr[t21_tascode] t21_SEID = ElementID_to_SEID_arr[t21_ElementID] t21_SEIDdesc = SEID_to_SEIDdesc_arr[t21_SEID] t21_SGID = SEID_to_SGID_arr[t21_SEID] t21_SGIDdesc = SGID_to_SGIDdesc_arr[t21_SGID] t21_DIVIDdesc1 = DIVID_to_DIVIDdesc1_arr[t21_DIVID] t21_DIVIDdesc2 = DIVID_to_DIVIDdesc2_arr[t21_DIVID] t21_ShipToDesc = ShipTo_to_ShipToDesc_arr[t21_DIVID] itag = t21_DIVID "|" t21_sundry "|" t21_elementid t21_invoiceno = parent_sundry_to_platinv_invoicenumber_arr[itag] printf("get_t21_upper_info(%s,%s): %s|%s|%s|%s|%s|(%d)%s|(%d)%s|(%s) %s,%s\n", gggrid, eggrid, t21_SID, t21_sundry, t21_supplier, t21_invoiceno, t21_tascode, t21_SEID, t21_SEIDdesc, t21_SGID, t21_SGIDdesc, t21_DIVID, t21_DIVIDdesc1, t21_ShipToDesc) } ############################################################## function spit_cdrrec_toextnfile() { # append call record data to extn file printf(",,,,,,,,,,,,,,,,,,,,,") >>extn_fname printf("%s,%s,%s,%s,%s,%s\n", date, endtimestr, expdialledno, calldesc, durstr, callcost) >> extn_fname; } function spit_extnrec_toegfile() { print "spit_extnrec_toegfile() - " eggrid_fname get_dirname(last_siteid, last_eggrid,last_extn); printf("T21 spit_extnrec_toegfile(): eggrid=%s extn=%s t21surname=%s t21firstname=%s t21name=%s\n", last_eggrid, last_extn, t21surname, t21firstname, t21name) printf(",,,,,,,,,,,,,,,,,,") >>eggrid_fname printf("%s,,", t21name) >>eggrid_fname printf("%s,%d,%d,%d,%d,%d,%d,%d,%d,%0.2f,%0.2f,%0.2f,%0.2f,%0.2f\n", last_extn, extn_callcount["P"], extn_callcount["A"] + extn_callcount["N"], extn_callcount["F"], extn_callcount["L"], extn_callcount["S"] + extn_callcount["E"], extn_callcount["M"], extn_callcount["I"], extn_callcount["J"] + extn_callcount["O"], extn_callcost["L"], # + extn_callcost["F"], extn_callcost["S"] + extn_callcost["E"], extn_callcost["M"], extn_callcost["I"], extn_totalcosts) >>eggrid_fname; } function spit_egrec_toggfile() { print "spit_egrec_toggfile() - " gggrid_fname t21section = egrid_to_t21section_arr[last_eggrid] printf("T21 spit_egrec_toggfile(): eggrid=%s t21section = %s\n", last_eggrid, t21section) printf(",,,,,,,,,,,,,,,,") >>gggrid_fname printf("%s,,,,", t21section) >>gggrid_fname printf("%s,%d,%d,%d,%d,%d,%d,%d,%d,%0.2f,%0.2f,%0.2f,%0.2f,%0.2f\n", last_eggrid, eggrp_callcount["P"], eggrp_callcount["A"] + eggrp_callcount["N"], eggrp_callcount["F"], eggrp_callcount["L"], eggrp_callcount["S"] + eggrp_callcount["E"], eggrp_callcount["M"], eggrp_callcount["I"], eggrp_callcount["J"] + eggrp_callcount["O"], eggrp_callcost["L"], # + eggrp_callcost["F"], eggrp_callcost["S"] + eggrp_callcost["E"], eggrp_callcost["M"], eggrp_callcost["I"], eggrp_totalcosts) >>gggrid_fname; } ################################################ ################################################ function spit_t21_totals_data() { print "spit_t21_totals_data() - " tmptotalsrepfile " ans " totalscsvfile " - for " last_gggrid " " last_eggrid " " last_egname " " eggrp_totalcosts #printf(" %-8.8s - %-25.25s $%9.2f\r\n", last_eggrid, last_egname, eggrp_totalcosts) >>tmptotalsrepfile; printf(" %-8.8s - %-25.25s %-5.5s %-15.15s $%9.2f\r\n", last_eggrid, last_egname, "", "", eggrp_totalcosts) >>tmptotalsrepfile; printf("%s,%s,%s,%0.2f\r\n", last_gggrid, last_eggrid, last_egname, eggrp_totalcosts) >>totalscsvfile; } function gen_t21_totals_rep() { print "gen_t21_totals_rep() - " totalsrepfile #while ( (getline egline < gggrid_fname) > 0 ) { # split(egline, egarr, ","); #} #close(gggrid_fname); printf("%-8.8s - %-25.25s %-5.5s %-15.15s $%9.2f\r\n", last_gggrid, last_ggname, "", "Total Cost", gggrp_totalcosts) >>totalsrepfile; printf("\r\n") >>totalsrepfile; close(totalsrepfile); close(tmptotalsrepfile); cmd=sprintf("cat %s >>%s; rm -f %s", tmptotalsrepfile, totalsrepfile, tmptotalsrepfile); system(cmd); printf("\r\n\r\n") >>totalsrepfile; close(totalsrepfile); } ################################################ ################################################ function handle_extn_change() { # start new extn if ( extn != last_extn || eggrid != last_eggrid || gggrid != last_gggrid ) { if ( extn_fname != "" ) { # close previous extn file if ( !dot21verify ) { spit_extnrec_toegfile(); close(extn_fname); } init_extntotals(); extn_fname = ""; } extn_fname = sprintf("topdat/%s/data/extn/extn_%s_%s_%d.csv", pardir, gggrid, eggrid, extn); get_ggname(gggrid); get_egname(eggrid); get_dirname(siteid,eggrid,extn); t21section = egrid_to_t21section_arr[eggrid] itag = eggrid "|" extn t21location = egridextn_to_t21location_arr[itag] if ( dot21verify ) return printf(" >>> extn_fname = %s\n", extn_fname); if ( (getline x < extn_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/extn", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir); system(cmd); # T21 # store extra info from cde/t21dir/t21hier printf("T21 extn_change(): t21_sundry=%s t21_supplier=%s\n", t21_sundry, t21_supplier) # don't know rent down to extn yet!!! #Xtag = gggrid "|" eggrid "|" extn XRENT = 0 XCALL = 0 XOTHER = 0 #printf("T21 extn_change(): Xtag=%s XRENT = %0.2f\n", Xtag, XRENT) #printf("T21 extn_change(): Xtag=%s XCALL = %0.2f\n", Xtag, XCALL) #printf("T21 extn_change(): Xtag=%s XOTHER = %0.2f\n", Xtag, XOTHER) printf("T21 extn_change(): eggrid=%s t21section = %s\n", eggrid, t21section) printf("T21 extn_change(): itag=%s t21location=%s\n", itag, t21location) get_t21_upper_info(gggrid, eggrid) printf("T21 extn_change(): eggrid=%s extn=%s t21surname=%s t21firstname=%s t21name=%s\n", eggrid, extn, t21surname, t21firstname, t21name) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%s,%s,%s,%s,%s,", "Call Details", exbillperiod, sdate, edate, t21_ShipToDesc, t21_DIVID, t21_SGIDdesc, t21_SGID, t21_SEIDdesc, t21_SEID, t21_invoiceno, t21_sundry, t21_supplier, XRENT, XCALL, XOTHER, t21section, t21_SID, extn, t21name, t21location) >extn_fname printf("Date,End Time,Dialled Number,Description,Duration,Total:Float\n") >>extn_fname extn_file_exists = 0 } else { printf("WARNING %d: extn_fname = %s exists.\n", NR, extn_fname); extn_file_exists = 1 } } } function handle_egrp_change() { # start new extgroup if ( eggrid != last_eggrid || gggrid != last_gggrid ) { if ( eggrid_fname != "" ) { # close previous eggrid file if ( !dot21verify ) { spit_egrec_toggfile(); close(eggrid_fname); } spit_t21_totals_data(); init_egtotals(); eggrid_fname = ""; } eggrid_fname = sprintf("topdat/%s/data/egrp/egrp_%s_%s.csv", pardir, gggrid, eggrid); if ( dot21verify ) return printf(" >>> eggrid_fname = %s\n", eggrid_fname); if ( (getline x < eggrid_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/egrp", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir); system(cmd); # T21 # store extra info from cde/t21dir/t21hier printf("T21 egrp_change(): t21_sundry=%s t21_supplier=%s\n", t21_sundry, t21_supplier) Xtag = gggrid "|" eggrid XRENT = t21gggrid_eggrid_to_rentcost_arr[Xtag] XCALL = t21gggrid_eggrid_to_callcost_arr[Xtag] XOTHER = t21gggrid_eggrid_to_othercost_arr[Xtag] printf("T21 egrp_change(): Xtag=%s XRENT = %0.2f\n", Xtag, XRENT) printf("T21 egrp_change(): Xtag=%s XCALL = %0.2f\n", Xtag, XCALL) printf("T21 egrp_change(): Xtag=%s XOTHER = %0.2f\n", Xtag, XOTHER) t21section = egrid_to_t21section_arr[eggrid] printf("T21 egrp_change(): eggrid=%s t21section = %s\n", eggrid, t21section) get_t21_upper_info(gggrid, eggrid) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,%s,%s,", "Extension Call Breakdown", exbillperiod, sdate, edate, t21_ShipToDesc, t21_DIVID, t21_SGIDdesc, t21_SGID, t21_SEIDdesc, t21_SEID, t21_invoiceno, t21_sundry, t21_supplier, XRENT, XCALL, XOTHER, t21section, t21_SID) >eggrid_fname printf("Name,d1,") >>eggrid_fname printf("Extension,Incoming Calls Ext:Int,Incoming Calls Int:Int,Outgoing Calls Free:Int,Outgoing Calls Local:Int,Outgoing Calls STD:Int,Outgoing Calls Mobile:Int,Outgoing Calls IDD:Int,Outgoing Calls Int:Int,Outgoing Call Costs Local:Float,Outgoing Call Costs STD:Float,Outgoing Call Costs Mobile:Float,Outgoing Call Costs IDD:Float,Total Costs:Float\n") >>eggrid_fname eggrid_file_exists = 0 } else { printf("WARNING %d: eggrid_fname = %s exists.\n", NR, eggrid_fname); eggrid_file_exists = 1 } } } function handle_ggrp_change() { # start new gengroup if ( gggrid != last_gggrid ) { if ( gggrid_fname != "" ) { # close previous gggrid file if ( !dot21verify ) close(gggrid_fname); gen_t21_totals_rep(); init_ggtotals(); gggrid_fname = ""; } gggrid_fname = sprintf("topdat/%s/data/ggrp/ggrp_%s.csv", pardir, gggrid); if ( dot21verify ) return printf("noddsuparr[%s] = %d\n", gggrid, noddsuparr[gggrid]); # set DIVID etc. for gen_top_csv(), cpy_img(), mk_idfile() DIVID = gggrid DIVIDdesc2 = DIVID_to_DIVIDdesc2_arr[DIVID] ShipToDesc = ShipTo_to_ShipToDesc_arr[DIVID] gen_top_csv(); cpy_img(1); mk_idfile(1); printf(" >>> gggrid_fname = %s\n", gggrid_fname); if ( (getline x < gggrid_fname) < 0 ) { # create file and csv header newdir = sprintf("topdat/%s/data/ggrp", pardir); cmd = sprintf("[ ! -d \"%s\" ] && mkdir -p %s", newdir, newdir); system(cmd); # T21 # store extra info from cde/t21dir/t21hier printf("T21 ggrp_change(): t21_sundry=%s t21_supplier=%s\n", t21_sundry, t21_supplier) Xtag = gggrid XRENT = t21gggrid_to_rentcost_arr[Xtag] XCALL = t21gggrid_to_callcost_arr[Xtag] XOTHER = t21gggrid_to_othercost_arr[Xtag] printf("T21 ggrp_change(): Xtag=%s XRENT = %0.2f\n", Xtag, XRENT) printf("T21 ggrp_change(): Xtag=%s XCALL = %0.2f\n", Xtag, XCALL) printf("T21 ggrp_change(): Xtag=%s XOTHER = %0.2f\n", Xtag, XOTHER) get_t21_upper_info(gggrid, eggrid) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%0.2f,%0.2f,%0.2f,", "ServiceID Call Breakdown", exbillperiod, sdate, edate, t21_ShipToDesc, t21_DIVID, t21_SGIDdesc, t21_SGID, t21_SEIDdesc, t21_SEID, t21_invoiceno, t21_sundry, t21_supplier, XRENT, XCALL, XOTHER) >gggrid_fname printf("Section,d1,d2,d3,") >>gggrid_fname printf("Service ID,Incoming Calls Ext:Int,Incoming Calls Int:Int,Outgoing Calls Free:Int,Outgoing Calls Local:Int,Outgoing Calls STD:Int,Outgoing Calls Mobile:Int,Outgoing Calls IDD:Int,Outgoing Calls Int:Int,Outgoing Call Costs Local:Float,Outgoing Call Costs STD:Float,Outgoing Call Costs Mobile:Float,Outgoing Call Costs IDD:Float,Total Costs:Float\n") >>gggrid_fname gggrid_file_exists = 0 } else { printf("WARNING %d: gggrid_fname = %s exists.\n", NR, gggrid_fname); gggrid_file_exists = 1 } } } ################################################################# function init_extntotals() { #print "init_extntotals()" extn_callcount["J"] = 0; # ORIGINATING INTERNAL extn_callcount["A"] = 0; # ANSWERING INTERNAL extn_callcount["L"] = 0; # LOCAL extn_callcount["M"] = 0; # MOBILE extn_callcount["E"] = 0; # INFO extn_callcount["S"] = 0; # STD extn_callcount["I"] = 0; # IDD| extn_callcount["N"] = 0; # INCOMING NETWORK extn_callcount["P"] = 0; # INCOMING PUBLIC extn_callcount["O"] = 0; # OUTGOING NETWORK extn_callcount["F"] = 0; # FREE # extn_callcost["J"] = 0.00; # ORIGINATING INTERNAL extn_callcost["A"] = 0.00; # ANSWERING INTERNAL extn_callcost["L"] = 0.00; # LOCAL extn_callcost["M"] = 0.00; # MOBILE extn_callcost["E"] = 0.00; # INFO extn_callcost["S"] = 0.00; # STD extn_callcost["I"] = 0.00; # IDD| extn_callcost["N"] = 0.00; # INCOMING NETWORK extn_callcost["P"] = 0.00; # INCOMING PUBLIC extn_callcost["O"] = 0.00; # OUTGOING NETWORK extn_callcost["F"] = 0.00; # FREE extn_totalcosts = 0.00; } function init_egtotals() { #print "init_egtotals()" eggrp_callcount["J"] = 0; # ORIGINATING INTERNAL eggrp_callcount["A"] = 0; # ANSWERING INTERNAL eggrp_callcount["L"] = 0; # LOCAL eggrp_callcount["M"] = 0; # MOBILE eggrp_callcount["E"] = 0; # INFO eggrp_callcount["S"] = 0; # STD eggrp_callcount["I"] = 0; # IDD| eggrp_callcount["N"] = 0; # INCOMING NETWORK eggrp_callcount["P"] = 0; # INCOMING PUBLIC eggrp_callcount["O"] = 0; # OUTGOING NETWORK eggrp_callcount["F"] = 0; # FREE # eggrp_callcost["J"] = 0.00; # ORIGINATING INTERNAL eggrp_callcost["A"] = 0.00; # ANSWERING INTERNAL eggrp_callcost["L"] = 0.00; # LOCAL eggrp_callcost["M"] = 0.00; # MOBILE eggrp_callcost["E"] = 0.00; # INFO eggrp_callcost["S"] = 0.00; # STD eggrp_callcost["I"] = 0.00; # IDD| eggrp_callcost["N"] = 0.00; # INCOMING NETWORK eggrp_callcost["P"] = 0.00; # INCOMING PUBLIC eggrp_callcost["O"] = 0.00; # OUTGOING NETWORK eggrp_callcost["F"] = 0.00; # FREE eggrp_totalcosts = 0.00; } function init_ggtotals() { #print "init_ggtotals()" gggrp_callcount["J"] = 0; # ORIGINATING INTERNAL gggrp_callcount["A"] = 0; # ANSWERING INTERNAL gggrp_callcount["L"] = 0; # LOCAL gggrp_callcount["M"] = 0; # MOBILE gggrp_callcount["E"] = 0; # INFO gggrp_callcount["S"] = 0; # STD gggrp_callcount["I"] = 0; # IDD| gggrp_callcount["N"] = 0; # INCOMING NETWORK gggrp_callcount["P"] = 0; # INCOMING PUBLIC gggrp_callcount["O"] = 0; # OUTGOING NETWORK gggrp_callcount["F"] = 0; # FREE # gggrp_callcost["J"] = 0.00; # ORIGINATING INTERNAL gggrp_callcost["A"] = 0.00; # ANSWERING INTERNAL gggrp_callcost["L"] = 0.00; # LOCAL gggrp_callcost["M"] = 0.00; # MOBILE gggrp_callcost["E"] = 0.00; # INFO gggrp_callcost["S"] = 0.00; # STD gggrp_callcost["I"] = 0.00; # IDD| gggrp_callcost["N"] = 0.00; # INCOMING NETWORK gggrp_callcost["P"] = 0.00; # INCOMING PUBLIC gggrp_callcost["O"] = 0.00; # OUTGOING NETWORK gggrp_callcost["F"] = 0.00; # FREE gggrp_totalcosts = 0.00; } ################################################################ # process T21 detail calls file function dot21callsfile(t21callsfile) { printf("dot21callsfile(%s)\n", t21callsfile) printf(" t21_sundry=%s t21_supplier=%s\n", t21_sundry, t21_supplier) if ( !dot21verify ) { printf("\r\n") >>totalsrepfile printf("T21 Calls\r\n") >>totalsrepfile printf("\r\n") >>totalsrepfile } if ( !dot21verify ) { #tmpt21callsfile = t21callsfile ".tmp" #cmd = "basename " t21callsfile #cmd | getline baset21callsfile baset21callsfile = "c9_" batchtag tmpt21callsfile = logdir "/" baset21callsfile ".tmp" # phase 2 # create tmp file with replaced t21 parent with cde parent # tmp file name to include parent if single all if all sub("c9_", "c9_" thisDIVID "_", tmpt21callsfile) print "tmpt21callsfile = " tmpt21callsfile } else { tmpt21callsfile = t21callsfile } ggname = "" egname = "" t21name = ""; pardir = ""; last_gggrid = "First Time"; last_eggrid = "First Time"; last_extn = -1; last_siteid = -1; last_ggname = ""; last_egname = ""; last_t21surname = ""; last_t21firstname = ""; last_t21name = ""; last_pardir = ""; last_t21section = ""; last_t21location = ""; gggrid_fname = ""; eggrid_fname = ""; extn_fname = ""; gggrid_file_exists = 0 eggrid_file_exists = 0 extn_file_exists = 0 init_extntotals(); init_egtotals(); init_ggtotals(); ############################################### if ( !dot21verify ) replace_t21gggrp_with_cdeDIVDID(tmpt21callsfile, t21callsfile) ############################################### # process each T21 call t21_donesome = 0 while ( (getline c9line < tmpt21callsfile) > 0 ) { split(c9line, c9_arr, ",") ##printf("c9line=%s\n", c9line) #NEG,2672SSA,1,12124,02/06/1996,124820, ,indial,536,0.0 sdate = fixdate(sdate); edate = fixdate(edate); gggrid = c9_arr[1]; eggrid = c9_arr[2]; extn = c9_arr[3]; date = c9_arr[4]; endtime = c9_arr[5]; siteid = c9_arr[6]; otherno = c9_arr[7]; direction = c9_arr[8]; dialledno = c9_arr[9]; callcat = c9_arr[10]; calldesc = c9_arr[11]; dur = c9_arr[12]; callcost = c9_arr[13]; if ( gggrid == "" ) gggrid="XXX"; if ( eggrid == "" ) eggrid = "YYY" ###################################### # only doing this platinumbatch itag = gggrid "|" t21_sundry "|" t21_elementid platinv_batch = parent_sundry_to_platinv_batch_arr[itag] ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 5 Skipping platinv_batch = " platinv_batch # continue #} if ( platinumBATCH != "all" && platinumBATCH != platinv_batch ) continue ###################################### # only doing thisDIVID if ( thisDIVID != "all" && gggrid != thisDIVID ) continue # # if doing all check if parent is in exwebconf # # and only do it if in exwebconf # if ( thisDIVID == "all" && !exwebconf_parent_arr[gggrid] ) { # print "T21 SKIPPING parent = " gggrid " (NOT in exwebconf)" # continue # } ## Testing all #if ( gggrid != "SPA" && gggrid != "VRT" && gggrid != "ALH" && gggrid != "FRT" && gggrid != "CGE" ) { # if ( gggrid != last_skip ) # print "Testing - T21 Skipping " gggrid # last_skip = gggrid # continue #} ###################################### #printf("c9line=[%s]\n", c9line) idtag = sprintf("%s_%s", gggrid, monthtag); #printf("idtag = %s\n", idtag); #pardir = idtag; this_divgroup = exwebconf_parent_to_cdgroup_arr[gggrid] #rs 1 if ( this_divgroup == "" ) # single div this_divgroup = gggrid # (force single to a divgroup) #rs 1 if ( this_divgroup != "" ) # belongs to a cdgroup pardir = monthtag "/" platinumBATCH "_" thisDIVID "/" this_divgroup "/" gggrid else pardir = monthtag "/" platinumBATCH "_" thisDIVID "/" gggrid #printf("pardir = %s\n", pardir); # set correct call category for internal call if ( direction == "in" && callcat == "J" ) { callcat = "A"; calldesc = "Incoming Internal"; } # force dialledno to other extn for Answering Internal KB if ( callcat == "A" ) dialledno = otherno; # force dialledno to other extn for originating Internal KB if ( callcat == "J" ) dialledno = otherno; #if ( callcat == "O" ) { # Outgoing N/W (Tie not shown) # continue; #} date = fixdate(date); durhh = int(dur / 3600); remd = dur - (durhh * 3600); durmm = int(remd / 60); remd = remd - (durmm * 60); durss = remd; durstr = sprintf("%03d:%02d:%02d", durhh, durmm, durss); hh = substr(endtime,1,2); mm = substr(endtime,3,2); ss = substr(endtime,5,2); endtimestr = sprintf("%2s:%2s:%2s",hh, mm, ss); #printf("noddsuparr[%s] = %d\n", gggrid, noddsuparr[gggrid]); if ( dot21verify || noddsuparr[gggrid] == 1 ) { # group has no digit suppression expdialledno = dialledno; } else { # xx for last 2 digits in dialledno if length >= 0 # supress for these callcategories only if ( index("JALMESIOF", callcat) ) { dnl = length(dialledno); dnpreflen = dnl - 2; if ( dnpreflen < 0 ) dnpreflen = 0; if ( dnl >= 0 ) { dnpref = substr(dialledno, 1, dnpreflen); expdialledno = sprintf("%sxx", dnpref); } } else { expdialledno = dialledno; } } t21_donesome = 1 handle_extn_change(); # skip dummy records (allows for 0 totals in summary data) if ( callcat != "X" && !dot21verify ) spit_cdrrec_toextnfile(); handle_egrp_change(); handle_ggrp_change(); #if ( callcat != "O" ) { # Outgoing Network not shown #if ( callcat != "F" ) { # FREE not shown # add to extn total extn_callcount[callcat] += 1; extn_callcost[callcat] += callcost; extn_totalcosts += callcost; # add to extgroup total eggrp_callcount[callcat] += 1; eggrp_callcost[callcat] += callcost; eggrp_totalcosts += callcost; # add to gen group total gggrp_callcount[callcat] += 1; gggrp_callcost[callcat] += callcost; gggrp_totalcosts += callcost; #} #### last_pardir = pardir; last_gggrid = gggrid; last_eggrid = eggrid; last_extn = extn; last_siteid = siteid; last_ggname = ggname; last_egname = egname; last_t21surname = t21surname; last_t21firstname = t21firstname; last_t21name = t21name; last_t21section = t21section; last_t21location = t21location; } close(tmpt21callsfile) if ( !dot21verify ) { system("rm -f " tmpt21callsfile) } ############################################### # finish up if ( t21_donesome ) { if ( !dot21verify ) { spit_extnrec_toegfile(); close(eggrid_fname); spit_egrec_toggfile(); close(gggrid_fname); } spit_t21_totals_data(); gen_t21_totals_rep(); #gen_top_csv(); #cpy_img(1); #mk_idfile(1); } print "" print "finished dot21callsfile() - " tmpt21callsfile } function replace_t21gggrp_with_cdeDIVDID(tmpt21callsfile, t21callsfile) { printf("replace_t21gggrp_with_cdeDIVID(%s,%s)\n", tmpt21callsfile, t21callsfile) if ( platinumBATCH != "all" && !is_t21_platinv_batch(platinumBATCH) ) { print "INFO: Not doing Tims Calls because single platinumBATCH =" platinumBATCH # not doing t21 calls, so create empty file printf("") > tmpt21callsfile close(tmpt21callsfile) return } if ( (getline xs < tmpt21callsfile) >= 0 ) { printf("tmpt21callsfile %s ALREADY exists so use it!\n", tmpt21callsfile) close(tmpt21callsfile) return } #unsorttmpt21callsfile = tmpt21callsfile ".unsorted" #print "unsorttmpt21callsfile = " unsorttmpt21callsfile system("rm -f " tmpt21callsfile) #system("rm -f " unsorttmpt21callsfile) ############################################### # process each T21 replaceing T21 gggrp with cdeDIVID sortcmd = "sort > " tmpt21callsfile replast_gggrid = "" while ( (getline c9line < t21callsfile) > 0 ) { split(c9line, c9_arr, ",") #printf("c9line=%s\n", c9line) #NEG,2672SSA,1,12124,02/06/1996,124820, ,indial,536,0.0 gggrid = c9_arr[1]; eggrid = c9_arr[2]; extn = c9_arr[3]; date = c9_arr[4]; endtime = c9_arr[5]; siteid = c9_arr[6]; otherno = c9_arr[7]; direction = c9_arr[8]; dialledno = c9_arr[9]; callcat = c9_arr[10]; calldesc = c9_arr[11]; dur = c9_arr[12]; callcost = c9_arr[13]; if ( gggrid == "" ) gggrid="XXX"; if ( eggrid == "" ) eggrid = "YYY" # r3 # ignore gggrid from Telmax21 # use that from the cde for eggrid t21_SID = eggrid cdeDIVID = t21eggrid_to_cdeDIVID[t21_SID] if ( cdeDIVID != gggrid && gggrid != replast_gggrid ) { printf("WARNING: T21 gggrid (%s) != cdeDIVID (%s) for eegrid = (%s)\n", gggrid, cdeDIVID, eggrid) } # use cdeDIVID if found if ( cdeDIVID != "" ) gggrid = cdeDIVID # if ShipTo code in tbs Customer is blank then set gggrid to VRT if ( ShipTo_to_ShipToCode_arr[gggrid] == "" ) gggrid = "VRT" ###################################### # only doing thisDIVID if ( thisDIVID != "all" && gggrid != thisDIVID ) { replast_gggrid = gggrid continue } ###################################### # only doing this platinumbatch itag = gggrid "|" t21_sundry "|" t21_elementid platinv_batch = parent_sundry_to_platinv_batch_arr[itag] ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 6 Skipping platinv_batch = " platinv_batch # continue #} if ( platinumBATCH != "all" && platinumBATCH != platinv_batch ) continue ## Testing all #if ( gggrid != "SPA" && gggrid != "VRT" && gggrid != "ALH" && gggrid != "FRT" && gggrid != "CGE" ) { # if ( gggrid != last_skip ) # print "Testing - T21 VERIFY Skipping " gggrid # last_skip = gggrid # continue #} ###################################### #printf("c9line=[%s]\n", c9line) #printf("OUT TO [%s] %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", sortcmd, gggrid, eggrid, extn, date, endtime, siteid, otherno, direction, dialledno, callcat, calldesc, dur, callcost) printf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", gggrid, eggrid, extn, date, endtime, siteid, otherno, direction, dialledno, callcat, calldesc, dur, callcost) | sortcmd replast_gggrid = gggrid } close(t21callsfile) #close(unsorttmpt21callsfile) #system("sort " unsorttmpt21callsfile " > " tmpt21callsfile) #system("rm -f " unsorttmpt21callsfile) close(sortcmd) } # END T21CALLS ##################################################### ##################################################### ##################################################### ##################################################### #---------------------------------------------------------- #---------------------------------------------------------- # main BEGIN { MMYYYY_to_billperiod(MMYYYY,"_") YYYYMM = substr(MMYYYY,3,4) substr(MMYYYY,1,2) print "Begin wb3 - dot21verify = " dot21verify print " - thisDIVID = " thisDIVID print " - RESTcde = " RESTcde print " - platinumBATCH = " platinumBATCH print " - switchboardcallcost = " switchboardcallcost print " - voicemailcallcost = " voicemailcallcost print " - MMYYYY = " MMYYYY print " - billperiod = " billperiod print " - YYYYMM = " YYYYMM if ( platinumBATCH == "" ) { platinumBATCH = "all" } inp_platinumBATCH = platinumBATCH batchtag = billperiod "_" inp_platinumBATCH "_" thisDIVID #------------------------ t21_supplier = "VICTRACK" t21_sundry = "" t21_elementid = "" if ( ! dot21verify ) { #------------------------ # load platinv file ld_platinv(platinvfile) print "platinumBATCH = " platinumBATCH if ( platinumBATCH != "all" ) { # Division and/or sundry specified if (thisDIVID == "all" && length(platinumBATCH) <= 6) { # get platinum BATCH for this sundry sundryBATCH = platinumBATCH platinumBATCH = "" print " Get Platinum Batch for Specified Sundry = " sundryBATCH for (cstr in parent_sundry_to_platinv_batch_arr) { split(cstr, cstr_arr, "|") parent = cstr_arr[1] sundry = cstr_arr[2] elementid = cstr_arr[3] if ( sundry != sundryBATCH ) continue # Division (ShipTo) & sundry specified if ( thisDIVID != "all" && thisDIVID != parent ) continue foundpB = parent_sundry_to_platinv_batch_arr[parent "|" sundry "|" elementid] print " found ... parent_sundry_to_platinv_batch_arr[" parent "|" sundry "|" elementid "] = " parent_sundry_to_platinv_batch_arr[parent "|" sundry "|" elementid] if ( platinumBATCH != "" && platinumBATCH != foundpB ) { print "FATAL ERROR: Non Unique Platinum BATCH for Specified Sundry = " sundryBATCH exit 1 } platinumBATCH = foundpB } if ( platinumBATCH == "" ) { print "FATAL ERROR: Can't get Platinum BATCH for Specified Sundry = " sundryBATCH exit 1 } } # invoicenumber specified if (length(platinumBATCH) >= 7 && length(platinumBATCH) <= 10) { # get platinum BATCH for this invoicenumber invoicenumberBATCH = platinumBATCH platinumBATCH = "" print " Get Platinum Batch for Specified Invoicenumber = " invoicenumberBATCH for (cstr in parent_invoicenumber_to_platinv_batch_arr) { split(cstr, cstr_arr, "|") parent = cstr_arr[1] invoiceno = cstr_arr[2] if ( invoiceno != invoicenumberBATCH ) continue foundpB = parent_invoicenumber_to_platinv_batch_arr[parent "|" invoiceno] print " found ... parent_invoicenumber_to_platinv_batch_arr[" parent "|" invoiceno "] = " parent_invoicenumber_to_platinv_batch_arr[parent "|" invoiceno] if ( platinumBATCH != "" && platinumBATCH != foundpB ) { print "FATAL ERROR: Non Unique Platinum BATCH for Specified Invoicenumber = " invoicenumberBATCH exit 1 } platinumBATCH = foundpB } if ( platinumBATCH == "" ) { print "FATAL ERROR: Can't get Platinum BATCH for Specified Invoicenumber = " invoicenumberBATCH exit 1 } } } } this_divgroup = exwebconf_parent_to_cdgroup_arr[DIVID] if ( this_divgroup != "" ) # belongs to a cdgroup act_targdir = "topdat" "/" billperiod "/" platinumBATCH "_" this_divgroup else act_targdir = "topdat" "/" billperiod "/" platinumBATCH "_" thisDIVID if ( ! dot21verify ) { lokfile = act_targdir ".lok" if ( (getline x < lokfile) < 0 ) { print "Running" > lokfile } else { print "FATAL ERROR: already running lokfile = " lokfile exit 1 } } # make symlink if batch run with invoice number or div/sundry if ( platinumBATCH != inp_platinumBATCH ) { dirloc = "topdat" "/" monthtag this_divgroup = exwebconf_parent_to_cdgroup_arr[thisDIVID] if ( this_divgroup != "" ) { # belongs to a cdgroup relact_targdir = platinumBATCH "_" this_divgroup symlink = inp_platinumBATCH "_" this_divgroup } else { relact_targdir = platinumBATCH "_" thisDIVID symlink = inp_platinumBATCH "_" thisDIVID } print "Make symlink dirloc=" dirloc " relact_targdir=" relact_targdir " symlink=" symlink cmd = "cd " dirloc ";" "ln -s \"" relact_targdir "\" \"" symlink "\"" system(cmd) } if ( platinumBATCH == "all" ) { print "INFO: Running for all platinum batch filenames" } else { print "INFO: Running for platinum batch filename = " platinumBATCH } #------------------------ # load t21 directory data ld_t21dircsvfile(t21dircsvfile) #------------------------ # load t21 groups data ld_t21groups2(t21groups2file) #------------------------ if ( dot21verify ) { totalscsvfile = logdir "/" "ex3atotcsv_" batchtag ".csv" totalsrepfile = logdir "/" "ex3atotrep_" batchtag ".txt" tmptotalsrepfile = logdir "/" "ex3atmptotf_" batchtag } else { totalscsvfile = logdir "/" "ex3totcsv_" batchtag ".csv" totalsrepfile = logdir "/" "ex3totrep_" batchtag ".txt" tmptotalsrepfile = logdir "/" "ex3tmptotf_" batchtag } cmd=sprintf("rm -f %s %s", totalsrepfile, totalscsvfile) system(cmd) cmd=sprintf("> %s", totalsrepfile) system(cmd) cmd=sprintf("> %s", totalscsvfile) system(cmd) cmd=sprintf("> %s", tmptotalsrepfile) system(cmd) printf("VICTRACK Web Billing3 (%s) %s Totals For %s\r\n\r\n", dot21verify ? "a (VERIFY)" : "", batchtag, exbillperiod) >>totalsrepfile if ( !dot21verify ) { printf("Invoice Batch: %s\r\n", platinumBATCH) >>totalsrepfile; printf("Switchboard Call Cost: %s\r\n", switchboardcallcost) >>totalsrepfile; } printf("\r\n") >>totalsrepfile; close(totalsrepfile) if ( !dot21verify ) { printf("\r\n") >>totalsrepfile printf("CDE Data\r\n") >>totalsrepfile printf("\r\n") >>totalsrepfile } close(totalsrepfile) #################################################################### # generate t21 verification report and csv if ( dot21verify ) { print "" print "Doing T21 Verification Report and CSV" print "" dot21callsfile(t21callsfile) exit 0 } #################################################################### #------------------------ # load exwebconffile - get groups with NO dialled digit suppression ld_exwebconf(exwebconffile) #------------------------ system("rm -f HIERIDx_" batchtag ".lst") system("rm -f sundrys_" batchtag ".uniq") system("rm -f DEPTID_" batchtag ".lst") #------------------------ # empty out target topdat dir #if ( thisDIVID == "all" ) { print "INFO: REMOVE (and remake) act_targdir " act_targdir system("rm -fr " act_targdir) system("mkdir -p " act_targdir) #system("chown catcom " act_targdir) #system("chgrp catcom " act_targdir) #} #else { # clean out parent only # this_divgroup = exwebconf_parent_to_cdgroup_arr[thisDIVID] # #rs 1 # if ( this_divgroup == "" ) # single div # this_divgroup = thisDIVID # (force single to a divgroup) # #rs 1 # if ( this_divgroup != "" ) # belongs to a cdgroup # pardir = act_targdir "/" thisDIVID "/" thisDIVID # else # pardir = act_targdir "/" thisDIVID # print "INFO: REMOVE pardir " pardir # system("rm -fr " pardir) #} #------------------------ init_totals("DIVID") init_totals("DIVID.SGID") init_totals("DIVID.SGID.SEID") init_totals("DIVID.SGID.SEIDDEPTID") #init_totals("DIVID.SGID.SEID.DEPTID") init_totals("DIVID.SGID.SEID.DEPTID.SID") #------------------------ HIERIDxorder = 0 MAXDEPTID = 0 DEPTID = 0 sundry = "" SID = "" DEPTID = "" SEID = "" SGID = "" DIVID = "" pardir = "" HIERIDx = "" last_HIERIDxDUPcount = "" last_invoiceno = "" last_sundry = "" last_costcentre = "" last_user = "" last_location = "" last_tascode = "" last_supplier = "" last_SID = ""; last_SIDdesc = "" last_DEPTID = "" last_SEID = "" last_SGID = "" last_DIVID = "" last_pardir = "" last_HIERIDx = "" DEPTID_fname = "" SEID_fname = "" SGID_fname = "" DIVID_fname = "" divid_file_exists = 0 sgid_file_exists = 0 seid_file_exists = 0 deptid_file_exists = 0 mobile_file_exists = 0 swbextnsum_file_exists = 0 swbdet_file_exists = 0 #------------------------ # old tbs database #ld_customer(tblCustomerfile) #ld_servicegroup(tblServiceGroupfile) #ld_serviceelements(tblServiceElementsfile) #ld_tassemap(tblTASSEMapfile) # service group report removed so set 1 default service group "All" SGID = 0 SGIDdesc = "All" SGID_to_SGIDdesc_arr[SGID] = SGIDdesc # tbsdata database ld_tbsdata_customer(tbsCustomerfile) ld_tbsdata_servicetype(tbsServiceTypefile) ld_tbsdata_element(tbsElementfile) ld_tbsdata_supplier(tbsSupplierfile) # to translate VRT seid for drill down ld_seidtranslate("indata/" monthtag "/seidtranslate.csv") #------------------------ got_cde_data = 0 #getcdefiles("VODAFONE") #getcdefiles("OPTUS") #getcdefiles("TELSTRA") #getcdefiles("AAPT") #getcdefiles("VICTRACK") #if ( RESTcde == 1 ) { # #getcdefiles("Electricity") # #getcdefiles("Radiolandlines") # #getcdefiles("SACC") # getcdefiles("REST") #} #for ( cstr in cdefile_arr ) #{ # split(cstr, cstr_arr, "|") # cdedir = cstr_arr[1] # cnt_cde = cstr_arr[2] # print "Doing cde dir = " cdedir " cnt= " cnt_cde " cdefile = [" cdefile_arr[cstr] "]" # ld_cde(cdefile_arr[cstr]) #} # now data comes from tbsdata (see getcde3 script) ld_cde(cdefile) if ( got_cde_data != 1 ) { print "FATAL ERROR: NO CDE data loaded (error in CDE or NO matching invoice data)" exit 1 } close("sort >DEPTID_" batchtag ".lst") close("sort >HIERIDx_" batchtag ".lst") close("sort -u >sundrys_" batchtag ".uniq") close("sort | uniq -d >SID_" batchtag ".dup") print "MAXDEPTID = " MAXDEPTID DEPTID_to_department_arr["ALL"] = "All Departments" SEID_to_SEIDdesc_arr["ALL"] = "All Service Types" # get processing order from sorted file pipecmd = "sort >" logdir "/" "HIERIDx_" batchtag ".lst" close(pipecmd) infile = logdir "/" "HIERIDx_" batchtag ".lst" while ( (getline HIERIDx < infile) > 0 ) { HIERIDxorder_to_HIERIDx_arr[++HIERIDxorder] = HIERIDx #print HIERIDxorder " HIERIDx = " HIERIDx } HIERIDxmaxorder = HIERIDxorder print "HIERIDxmaxorder = " HIERIDxmaxorder close(infile) #----------------------------------------------------- # check platinum invoice info has corresponding cde info if ( platinumBATCH == "all" ) { print "INFO: ---- CHECK Platinum invoice info has CDE data ----" for ( itag in platinv_parent_sundry_arr ) { print "itag=[" itag "]" split(itag, itag_arr, "|") parent = itag_arr[1] sundry = itag_arr[2] orgelementid = itag_arr[3] if ( orgelementid == 1 ) # Skip Admin Fee continue if ( cde_parent_sundry_arr[itag] == "" ) { print "WARNING: Platinum Invoice for parent=" parent " sundry=" sundry " orgelementid=" orgelementid " has NO CDE" } } print "INFO: --------------------------------------------------" } exwebconf_parent_arr[exwebconf_parent] = 1 # check platinum invoice info has correesponding exwebconf info if ( platinumBATCH == "all" ) { print "INFO: ---- CHECK Platinum invoice info has exwebconf data ----" for ( parent in platinv_parent_arr ) { if ( exwebconf_parent_arr[parent] == "" ) { print "WARNING: Platinum Invoice for parent=" parent " has NO EXWEBCONF" } } print "INFO: --------------------------------------------------" } #----------------------------------------------------- # process gsm data printf("\n") for ( HIERIDxorder = 1; HIERIDxorder <= HIERIDxmaxorder; ++HIERIDxorder ) { HIERIDx = HIERIDxorder_to_HIERIDx_arr[HIERIDxorder] # # if doing all check if parent is in exwebconf # # and only do it if in exwebconf #split(HIERIDx, HIERIDx_arr, "|") #cde_parent = HIERIDx_arr[1]; # if ( thisDIVID == "all" && !exwebconf_parent_arr[cde_parent] ) { # print "CDE SKIPPING parent = " cde_parent " (NOT in exwebconf)" # continue # } #if ( SGID_to_SGIDdesc_arr[SGID] != "Network Services" ) # continue ## Testing all #split(HIERIDx, HIERIDx_arr, "|") #cde_parent = HIERIDx_arr[1]; #if ( cde_parent != "SPA" && cde_parent != "VRT" && cde_parent != "ALH" && cde_parent != "FRT" && cde_parent != "CGE" ) { # if ( cde_parent != last_skip ) # print "Testing - CDE Skipping " cde_parent # last_skip = cde_parent # continue #} get_HIERIDx_info(HIERIDx, 2) ###################################### # only doing this platinumbatch ## rjs #if ( platinv_batch == "TBSAUG2004001134" ) { # print "Warning 2 Skipping platinv_batch = " platinv_batch # continue #} if (platinumBATCH != "all" && platinumBATCH != platinv_batch) { print "Skipping platinv_batch=" platinv_batch continue } if ( HIERIDx == last_HIERIDx ) { # skip duplicates print "WARNING: duplicate HIERIDx: " HIERIDx continue } handle_SID_change() handle_DEPTID_change() handle_SEID_change() handle_SGID_change() handle_DIVID_change() totid = "DIVID.SGID.SEID.DEPTID.SID" add_totals(totid,"","",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) #totid = "DIVID.SGID.SEID.DEPTID" #add_totals(totid,"","",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) totid = "DIVID.SGID.SEIDDEPTID" add_totals(totid,SEID,DEPTID,invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) add_totals(totid,SEID,"ALL",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) add_totals(totid,"ALL",DEPTID,invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) add_totals(totid,"ALL","ALL",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) totid = "DIVID.SGID.SEID" add_totals(totid,"","",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) totid = "DIVID.SGID" add_totals(totid,"","",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) totid = "DIVID" add_totals(totid,"","",invoiceno,sundry,supplier,rentcost,callcost,othercost,totalcost) last_HIERIDxDUPcount = HIERIDxDUPcount last_invoiceno = invoiceno last_sundry = sundry last_costcentre = costcentre last_user = user last_location = location last_tascode = tascode last_supplier = supplier last_SID = SID; last_SIDdesc = SIDdesc last_DEPTID = DEPTID last_SEID = SEID last_SGID = SGID last_DIVID = DIVID last_pardir = pardir last_HIERIDx = HIERIDx } print "" print "" ##################################### spit_SIDtotals_to_CUSTOMERIMPORTfile(); #spit_DEPTIDtotals_to_SEIDfile(); #spit_SEIDtotals_to_SGIDfile(); spit_SEIDDEPTIDtotals_to_SGIDfile(); spit_SGIDtotals_to_DIVIDfile(); #spit_DIVIDtotals_to_TOTALSfile(); spit_cde_SEIDDEPTID_totals_data(); gen_cde_DIVID_totals_rep(); close(DEPTID_fname); #close(SEID_fname); close(SGID_fname); close(DIVID_fname); #----------------------------------------------------- # NO do it above for for each new SID #procgsmdet(gsmcallsfile) #----------------------------------------------------- # process T21 calls file if (platinumBATCH == "all" || is_t21_platinv_batch(platinumBATCH) || platinv_batch == "VRTBATCHFILENAME" ) { print "INFO: processing t21calls platinumBATCH = " platinumBATCH dot21callsfile(t21callsfile) } else { print "INFO: Skipping t21calls because platinumBATCH = " platinumBATCH } #----------------------------------------------------- #gen_t21_totals_rep(); system("rm -f " tmptotalsrepfile); #----------------------------------------------------- if ( ! dot21verify ) { # remove lock file system("rm -f " lokfile) } #----------------------------------------------------- print "" print "Finish wb3 - " thisDIVID # End BEGIN exit 0 }