From: http://www.icc.illinois.gov/mc/EOSSirp.aspx (Credential information updated by communications with Mick Ramirez)
The IRP is an agreement among 48 states, 10 Canadian Provinces and the District of Columbia whereby a motor carrier can register commercial vehicle fleets for travel in all IRP jurisdictions by filing the paperwork with the home (base) jurisdiction.
Interstate commercial vehicles legally based in Illinois must be registered under the International Registration Plan (IRP). The Office of the Secretary of State Commercial and Farm Truck Division administers IRP in Illinois. The IRP is a registration reciprocity agreement among jurisdictions in the United States and Canada, which provides for payment of license fees on the basis of fleet miles operated in various jurisdictions. The unique feature of the IRP Plan is that only one license plate and one cab card is issued for each fleet vehicle even though license fees are paid to the various jurisdictions in which fleet vehicles are operated. A fleet vehicle may be operated both inter-jurisdictionally and intra-jurisdictionally.
The IRP registration cycle in Illinois is April 1 through March 31 each year and the renewal period extends from December until March. In 2006, the Secretary of State issued 165,810 IRP credentials to Illinois-based carriers.
There are two sources of registration information of commercial vehicles at the Secretary of State. The IRP system is documented here. There is also the Motor Vehicle Registration (MVR) system for intrastate vehicles. The documentation of the MVR system is documented on the MVR tab.
The database server is an IBM DB2 database environment. There are the following tables:
Table | Notes |
---|---|
IR_FIRM | Carrier info |
IR_ADDRESS | |
IR_FLEET | |
IR_VEHICLE | |
IR_FINANCE | Contains Registration Start Date |
IR_WEIGHT | See Notes in Mapping area |
Dates are of the form ccyymmdd format which will need to be converted to yyyy-mm-dd format.
T0020V1 Field | Legacy Field | Comments |
---|---|---|
IRP_CARRIER_ID_NUMBER(12) | IR_FIRM.US_DOT_NUMBER_1(12) | |
IRP_BASE_COUNTRY(2) | "US" | |
IRP_BASE_STATE(2) | "IL" | |
IRP_ACCOUNT_NUMBER(32) | IR_FIRM.FIRM_NO(5) | |
IRP_ACCOUNT_TYPE(1) | "I" | |
IRP_STATUS_CODE(3) | IR_FIRM.STATUS_CODE(1) | See Note 1 below |
IRP_STATUS_DATE (yyyy-mm-dd) | IR_FIRM.LAST_ACTION_DATE (ccyymmdd) | See Note above about dates |
IRP_UPDATE_DATE (yyyy-mm-dd) | IR_FIRM.LAST_ACTION_DATE (ccyymmdd) | |
IRP_NAME.NAME[LG](120) | IR_FIRM.NAME(35) | LG (Legal) Name |
IRP_NAME.NAME[DB](120) | IR_FIRM.DBA_NAME(35) | DB (Doing Business as) Name |
IRP_NAME.STREET_LINE_1[LG][PH](90) | IR_ADDRESS.FLEET_STREET(35) | PH (Physical Address) |
IRP_NAME.STREET_LINE_2[LG][PH](90) | (none) | |
IRP_NAME.PO_BOX[LG][PH](90) | (none) | |
IRP_NAME.CITY[LG][PH](90) | IR_ADDRESS.FLEET_CITY(21) | |
IRP_NAME.STATE[LG][PH](2) | "IL" | |
IRP_NAME.ZIP[LG][PH](9) | IR_ADDRESS.FLEET_ZIP(9) | |
IRP_NAME.COUNTY[LG][PH](90) | (none) | |
IRP_NAME.COLONIA[LG][PH](90) | (none) | |
IRP_NAME.COUNTRY[LG][PH](2) | "US" | |
IRP_NAME.STREET_LINE_1[LG][MA](90) | IRP_ADDRESS.MAIL_STREET(35) | MA (Mail Address) |
IRP_NAME.STREET_LINE_2[LG][MA}(90) | (none) | |
IRP_NAME.PO_BOX[LG][MA}(90) | (none) | |
IRP_NAME.CITY[LG][MA](90) | IRP_ADDRESS.MAIL_CITY(21) | |
IRP_NAME.STATE[LG][MA](2) | IRP_ADDRESS.MAIL_STATE(2) | |
IRP_NAME.ZIP[LG][MA](9) | IRP_ADDRESS.MAIL_ZIP(9) | |
IRP_NAME.COUNTY[LG][MA](90) | (none) | |
IRP_NAME.COLONIA[LG][MA](90) | (none) | |
IRP_NAME.COUNTRY[LG][MA](2) | See Note 2 below |
SOS Status Code | CVIEW IRP_STATUS_CODE | Meaning |
---|---|---|
A | 100 | Active |
I | 900 | Inactive |
D | 999 | Deleted |
2) The COUNTRY[MA] is determined by the MAIL_STATE. If the MAIL_STATE is MX then COUNTRY[MA] IS MX. If the MAIL_STATE is a Canadian Province or Territory then the COUNTRY[MA] IS CA, otherwise the COUNTRY[MA] is US. See Jurisdiction Mappings below for valid Canadian Jurisdictions
Note: Fleet information has no name or address - only fleet number
T0021V1 Field | Legacy Field | Comment |
---|---|---|
IRP_ACCOUNT_NUMBER(32) | IR_FIRM.FIRM_NO(5) | |
IRP_BASE_COUNTRY(2) | "US" | |
IRP_BASE_STATE(2) | "IL" | |
FLEET_NUMBER(15) | IR_FLEET.FLEET_NO(3) | |
FLEET_STATUS_CODE(3) | IR_FLEET.FLEET_STATUS_CODE | See Note 1 above |
FLEET_STATUS_DATE | IR_FLEET.FLEET_STAT_DATE | See Note above about dates |
FLEET_EXPIRE_DATE | March 31 or STAT_DATE if not active | See Note above about dates |
FLEET_UPDATE_DATE | IR_FLEET.FLEET_STAT_DATE | See Note above about dates |
FLEET_NAME | (none) |
T0022V2 Field | Legacy Field | Notes |
---|---|---|
VIN(30) | IR_VEHICLE.VIN(20) | |
TITLE_NUMBER(17) | IR_VEHICLE.TITLE_NO(10) | |
TITLE_JURISDICTION(4) | IR_VEHICLE.TITLE_STATE(2) | See Note 5 below |
OWNER_NAME(55) | IR_FIRM.FIRM_NAME(35) or IR_VEHICLE.LESSOR(35) | See Note 1 below |
MODEL_YEAR(4) | IR_VEHICLE.VEH_YEAR(4) | |
MAKE(10) | IR_VEHICLE.VEH_MAKE(4) | |
TYPE(2) | IR_VEHICLE.VEH_TYPE(2) | See Note 2 below |
MODEL(3) | (none) | |
FUEL(1) | IR_VEHICLE.FUEL(1) | |
UNLADEN_WEIGHT(8) | IR_VEHICLE.UNLADEN_WEIGHT(5) | |
NUMBER_OF_AXLES(2) | IR_VEHICLE.AXLES(2) | |
LICENSE_PLATE_NUMBER(12) | IR_VEHICLE.PLATE_NO(9) | |
IRP_BASE_COUNTRY(2) | "US" | |
IRP_BASE_STATE(2) | "IL" | |
UNIT_NUMBER(20) | IR_VEHICLE.UNIT_NO(9) | |
LAST_UPDATE(10) | IR_VEHICLE.STATUS_DATE(8) | See Note above about dates |
INTERSTATE_FLAG(1) | "I" | |
IRP_STATUS_CODE | IR_VEHICLE.STATUS_CODE | See Note 1 above |
IRP_STATUS_DATE | IR_VEHICLE.STATUS_DATE | See Note above about dates |
IRP_ACCOUNT_NUMBER(32) | IR_VEHICLE.FIRM_NO(5) | |
IRP_FLEET_NUMBER(15) | IR_VEHICLE.FLEET_NO(3) | |
REGISTRATION_START_DATE | IR_FINANCE.PAY_DATE(8) | See note above about dates |
REGISTRATION_STOP_DATE | IR_VEHICLE.STATUS_DATE(8)
or "March 31" |
See Note 3 below |
OPERATOR_NAME(55) | (none) | |
SAFETY_CARRIER(12) | IR_FIRM.US_DOT_NUMBER_1(12) | |
IRP_CARRIER_NUMBER(12) | IR_FIRM.US_DOT_NUMBER_1(12) | |
IFTA_LICENSE_NUMBER(18) | (none) | |
GVW(8) | See Note 4 below | |
GVW_EXPIRE_DATE | IR_VEHICLE.STATUS_DATE(8)
or "March 31" |
See Note 3 below |
IRP_PRORATION.IRP_JURISDICTION(4) | See Note 5 below | |
IRP_PRORATION.IRP_WEIGHT(8) | See Note 6 below | |
IRP_PRORATION. IRP_WEIGHT_EXPIRATION_DATE |
IR_VEHICLE.STATUS_DATE(8)
or "March 31" |
See Note 3 below |
1) If LESSOR exists then OWNER_NAME is LESSOR, otherwise OWNER_NAME is FIRM_NAME.
2) The vehicle type mapping codes used in Illinois IRP are similar but have slightly different mappings. Below is the table to convert IL codes to SAFER/CVIEW codes:
(IL)VEH_TYPE(2) | Name | (CVIEW)TYPE(2) | Name |
---|---|---|---|
BS | Bus | BS | Bus |
FT | Full Trailer | FT | Full Trailer |
MT | Mobile Home Trailer | MT | Mobile Home Trailer |
PW | Power Wrecker | WR | Tow Truck Wrecker |
ST | Semi-Trailer | SR | Semi-Trailer |
TR | Tractor | TT | Truck Tractor |
TT | Truck Tractor | TT | Truck Tractor |
TK | Truck (single) | ST | Straight Truck |
3) In addition to date mapping documented above the expiration date is either IR_VEHICLE.STATUS_DATE if the IR_VEHICLE.STATUS_CODE is "I" or March 31 of the year associated IR_FINANCE.PAY_DATE.
4) The
weights allowed in various jurisdictions are explained in more detail
in note 6 (see below). One uses the IR_VEHICLE.WTG_GRP to
determine
which weight group is appropriate for this vehicle. To find
the Illinois weight, consult the field IR_WEIGHT.STATE_WEIGHT_10_18
character positions 37-42.
Consult note 6 for more information on why this is the
case.
5) The mapping of JURISDICTION in TITLE_JURISDICTION or IRP_PRORATION is a full jurisdiction which is 4 characters in size. The first two characters are the country code (US, CA, MX) and the last two are the state/province code (et IL, CA, ...). Examples:
6) The mapping of IRP_WEIGHT for IRP_PRORATION is accomplished by first looking at the IR_VEHICLE.WTG_GRP to determine which weight group is appropriate. There are fields of the form IR_WEIGHT.STATE_WEIGHT_X_Y where X is the starting jurisdiction index (1, 10, 19, 28, 37, 46, 55) and Y is X+8 (9, 18, 27, 36, 45, 54, 63). The jurisdiction index is given below. To find the weight for a particular jurisdiction one first determines the jurisdiction index then consults the appropriate STATE_WEIGHT_X_Y field. This is the smallest X which is greater or equal to the jurisdiction index.
One then subtracts the X from the jurisdiction index and multiplies by 6 then add 1 to get the starting character offset in the STATE_WEIGHT_X_Y field. Then 6 characters starting at that position is the weight.
As an example case: IL is index 16. This indicates STATE_WEIGHT_10_18 is the appropriate STATE_WEIGHT field to consult. (16-10)*6 + 1 = 37 as the starting character position. 37-42 is where the weight is stored for IL.
Jurisdiction Index | Jurisdiction Code | Country(US unless specified) | Not Used Has space |
---|---|---|---|
1 | AB | CA | |
2 | AK | YES | |
3 | AL | ||
4 | AR | ||
5 | AZ | ||
6 | BC | CA | |
7 | CA | ||
8 | CO | ||
9 | CT | ||
10 | DC | ||
11 | DE | ||
12 | FL | ||
13 | GA | ||
14 | IA | ||
15 | ID | ||
16 | IL | ||
17 | IN | ||
18 | KS | ||
19 | KY | ||
20 | LA | ||
21 | MA | ||
22 | MB | CA | |
23 | MD | ||
24 | ME | ||
25 | MI | ||
26 | MN | ||
27 | MO | ||
28 | MS | ||
29 | MT | ||
30 | MX | MX | YES |
31 | NB | CA | |
32 | NC | ||
33 | ND | ||
34 | NE | ||
35 | NF | CA | |
36 | NH | ||
37 | NJ | ||
38 | NM | ||
39 | NS | CA | |
40 | NT | CA | YES |
41 | NV | ||
42 | NY | ||
43 | OH | ||
44 | OK | ||
45 | ON | CA | |
46 | OR | ||
47 | PA | ||
48 | PE | CA | |
49 | QC | CA | |
50 | RI | ||
51 | SC | ||
52 | SD | ||
53 | SK | CA | |
54 | TN | ||
55 | TX | ||
56 | UT | ||
57 | VA | ||
58 | VT | ||
59 | WA | ||
60 | WI | ||
61 | WV | ||
62 | WY | ||
63 | YT | CA | YES |
The trigger field for transactions are as follows:
Transaction | Field |
---|---|
T0020 - Carrier info | IR_FIRM.LAST_ACTION_DATE |
T0021 - Fleet info | IR_FLEET.FLEET_STAT_DATE |
T0022 - Vehicle (cab) info | IR_VEHICLE.STATUS_DATE |
According to Marinda Beccue in a conversation on 10/23/2006, all carrier IRP registrations or renewals now require a US_DOT Carrier ID. This was implemented at least one year ago so all carriers who are current with their IRP have a US_DOT Carrier ID. Based on this information, the US_DOT Cross Reference Mapping is complete.
Below is a php script which was used to generate T0020, T0021, and T0022 transactions which were then applied to XCVIEW implementation of CVIEW. A database was created and minimally populated with test data. The application of the test cases were successful and the scripts could be used as the basis for an implementation of a XML creation script for the IRP system.
The $Host, $Username, $Password, "LSI_IRP" database would need to be adjusted to reflect the actual IRP database. This script assumes the IRP database is a MS-SQL 2005 database. This is not the case and minor modifications to the script are required to operate with the DB2 database.
<?php
$Host = "lsiirphost";
// This script will open up the IRP database and produce a transaction
// file for processing in the augmented cview tasks
/* Connecting, selecting database */
$Username = "username";
$Password = "password";
function ConvertDate($InDate){
return substr($InDate,0,4) . "-" . substr($InDate,4,2) . "-" . substr($InDate,6,2);
}
function ConvertFullJurisdiction($State){
global $CanadaStates;
if ($State == "MX") return "MXMX";
if (array_search($State, $CanadaStates) !== FALSE) return "CA" . $State;
return "US" . $State;
}
$CanadaStates = array("AB","BC","MB","NB","NF","NT","NS","ON","PE","PQ","SN","YT");
$Jurisdictions = array(
"AB", "AK", "AL", "AR", "AZ", "BC", "CA", "CO", "CT",
"DC", "DE", "FL", "GA", "IA", "ID", "IL", "IN", "KS", "KY",
"LA", "MA", "MB", "MD", "ME", "MI", "MN", "MO", "MS", "MT",
"MX", "NB", "NC", "ND", "NE", "NF", "NH", "NJ", "NM", "NS",
"NT", "NV", "NY", "OH", "OK", "ON", "OR", "PA", "PE", "PQ",
"RI", "SC", "SD", "SN", "TN", "TX", "UT", "VA", "VT", "WA",
"WI", "WV", "WY", "YT");
$OmitJurisdiction = array("AK", "MX", "NT", "YT");
$link = mssql_connect($Host, $Username, $Password)
or die('Could not connect\n');
if (!mssql_select_db("LSI_IRP"))
die("Could not select LSI_IRP\n");
// open output file
$FileNameOut = ($argc > 1) ? $argv[1] : "CVIEWT0020V1.xml";
($fhout = fopen($FileNameOut, "w")) || die("Cannot open output file $FileNameOut\n");
$QryStr = "SELECT * FROM IR_FIRM JOIN IR_ADDRESS ON IR_FIRM.FIRM_NO = IR_ADDRESS.FIRM_NO";
$Results = mssql_query($QryStr);
if ($Results === FALSE)
die("Failed Query - $QryStr\n");
if ($Results === TRUE) die("no rows");
$SnapDate = date("Y-m-d\Th:i:s");
// output XML heading
$XMLHeader = "<?xml version=\"1.0\"?>
<T0020 xmlns=\"http://www.safersys.org/namespaces/T0020V1\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd\">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>$SnapDate</DATE_TIME>
<TZ>CD</TZ>
</TRANSACTION>\n";
fwrite($fhout,$XMLHeader);
while ($Row = mssql_fetch_object($Results)){
$XMLAccount = " <IRP_ACCOUNT>\n";
// IRP_CARRIER info
$IRP_CARRIER_ID_NUMBER = $Row->US_DOT_NUMBER_1;
$IRP_ACCOUNT_NUMBER = $Row->FIRM_NO;
switch ($Row->STATUS_CODE) {
case 'A': $IRP_STATUS_CODE = '100';
break;
case 'I': $IRP_STATUS_CODE = '900';
break;
case 'D': $IRP_STATUS_CODE = '999';
break;
default:
$IRP_STATUS_CODE = '000'; // check this
}
$IRP_STATUS_DATE = ConvertDate($Row->LAST_ACTION_DATE);
$IRP_UPDATE_DATE = $IRP_STATUS_DATE;
$NAME_LG = $Row->NAME;
$NAME_DBA = $Row->DBA_NAME;
$STREET_LINE_1_PH = $Row->FLEET_STREET;
$CITY_PH = $Row->FLEET_CITY;
$ZIP_CODE_PH = $Row->FLEET_ZIP;
$STREET_LINE_1_MA = $Row->MAIL_STREET;
$CITY_MA = $Row->MAIL_CITY;
$STATE_MA = $Row->MAIL_STATE;
$ZIP_CODE_MA = $Row->MAIL_ZIP;
if (array_search($STATE_MA, $CanadaStates) !== FALSE)
$COUNTRY_MA = "CA";
else if ($STATE_MA == "MX")
$COUNTRY_MA = "MX";
else $COUNTRY_MA = "US";
$XMLAccount .=
" <IRP_CARRIER_ID_NUMBER>$IRP_CARRIER_ID_NUMBER</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>IL</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>$IRP_ACCOUNT_NUMBER</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>$IRP_STATUS_CODE</IRP_STATUS_CODE>
<IRP_STATUS_DATE>$IRP_STATUS_DATE</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>$IRP_UPDATE_DATE</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>$NAME_LG</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>$STREET_LINE_1_PH</STREET_LINE_1>
<CITY>$CITY_PH</CITY>
<STATE>IL</STATE>
<ZIP_CODE>$ZIP_CODE_PH</ZIP_CODE>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
<IRP_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>$STREET_LINE_1_MA</STREET_LINE_1>
<CITY>$CITY_MA</CITY>
<STATE>IL</STATE>
<ZIP_CODE>$ZIP_CODE_MA</ZIP_CODE>
<COUNTRY>$COUNTRY_MA</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>";
if ($NAME_DBA != ""){
$XMLAccount .=
" <IRP_NAME>
<NAME_TYPE>DB</NAME_TYPE>
<NAME>$NAME_DBA</NAME>
</IRP_NAME>";
}
fwrite($fhout, $XMLAccount);
}
$XMLAccount =
" </IRP_ACCOUNT>
</T0020>\n";
fwrite($fhout,$XMLAccount);
fclose($fhout);
// open output file
$FileNameOut = ($argc > 2) ? $argv[2] : "CVIEWT0021V1.xml";
($fhout = fopen($FileNameOut, "w")) || die("Cannot open output file $FileNameOut\n");
$QryStr = "SELECT * FROM IR_FLEET";
$Results = mssql_query($QryStr);
if ($Results === FALSE)
die("Failed Query - $QryStr\n");
if ($Results === TRUE) die("no rows");
$SnapDate = date("Y-m-d\Th:i:s");
// output XML heading
$XMLHeader = "<?xml version=\"1.0\"?>
<T0021 xmlns=\"http://www.safersys.org/namespaces/T0021V1\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.safersys.org/namespaces/T0021V1 T0021V1.xsd\">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>$SnapDate</DATE_TIME>
<TZ>CD</TZ>
</TRANSACTION>\n";
fwrite($fhout,$XMLHeader);
while ($Row = mssql_fetch_object($Results)){
$XMLFleet = " <FLEET_ACCOUNT>\n";
// IRP_FLEET info
$IRP_ACCOUNT_NUMBER = $Row->FIRM_NO;
$FLEET_NUMBER = $Row->FLEET_NO;
$FLEET_STATUS_DATE = ConvertDate($Row->FLEET_STAT_DATE);
$FLEET_UPDATE_DATE = $FLEET_STATUS_DATE;
switch ($Row->FLEET_STAT_CODE) {
case 'A': $FLEET_STATUS_CODE = '100';
// check date break on April 1
$FLEET_EXPIRE_DATE = (substr($Row->FLEET_STAT_DATE,0,4)+1) . "-03-31";
break;
case 'I': $FLEET_STATUS_CODE = '900';
$FLEET_EXPIRE_DATE = $FLEET_STATUS_DATE;
break;
case 'D': $FLEET_STATUS_CODE = '999';
$FLEET_EXPIRE_DATE = $FLEET_STATUS_DATE;
break;
default:
$FLEET_STATUS_CODE = '000'; // check this
}
$XMLFleet .= "
<IRP_ACCOUNT_NUMBER>$IRP_ACCOUNT_NUMBER</IRP_ACCOUNT_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>IL</IRP_BASE_STATE>
<FLEET_NUMBER>$FLEET_NUMBER</FLEET_NUMBER>
<FLEET_STATUS_CODE>$FLEET_STATUS_CODE</FLEET_STATUS_CODE>
<FLEET_STATUS_DATE>$FLEET_STATUS_DATE</FLEET_STATUS_DATE>
<FLEET_EXPIRE_DATE>$FLEET_EXPIRE_DATE</FLEET_EXPIRE_DATE>
<FLEET_UPDATE_DATE>$FLEET_STATUS_DATE</FLEET_UPDATE_DATE>
</FLEET_ACCOUNT>";
fwrite($fhout, $XMLFleet);
}
$XMLFleet =
"</T0021>\n";
fwrite($fhout,$XMLFleet);
fclose($fhout);
// open output file
$FileNameOut = ($argc > 3) ? $argv[3] : "CVIEWT0022V1.xml";
($fhout = fopen($FileNameOut, "w")) || die("Cannot open output file $FileNameOut\n");
$QryStr = "SELECT * FROM IR_VEHICLE JOIN IR_FLEET ON
IR_VEHICLE.FIRM_NO = IR_FLEET.FIRM_NO AND
IR_VEHICLE.FLEET_NO = IR_FLEET.FLEET_NO JOIN IR_FIRM ON
IR_FLEET.FIRM_NO = IR_FIRM.FIRM_NO JOIN IR_FINANCE ON
IR_VEHICLE.FIRM_NO = IR_FINANCE.FIRM_NO JOIN IR_WEIGHT ON
IR_VEHICLE.WGT_GRP = IR_WEIGHT.WGT_GRP";
$Results = mssql_query($QryStr);
if ($Results === FALSE)
die("Failed Query - $QryStr\n");
if ($Results === TRUE) die("no rows");
$SnapDate = date("Y-m-d\Th:i:s");
// output XML heading
$XMLHeader = "<?xml version=\"1.0\"?>
<T0022 xmlns=\"http://www.safersys.org/namespaces/T0022V1\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.safersys.org/namespaces/T0022V1 T0022V1.xsd\">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>$SnapDate</DATE_TIME>
<TZ>CD</TZ>
</TRANSACTION>\n";
fwrite($fhout,$XMLHeader);
while ($Row = mssql_fetch_object($Results)){
$XMLCab = " <IRP_REGISTRATION>\n";
// IRP_REGISTRATION (Cab) info
$VIN = $Row->VIN;
$TITLE_NUMBER = $Row->TITLE_NO;
$TITLE_JURISDICTION = ConvertFullJurisdiction($Row->TITLE_STATE);
if ($Row->LESSOR !== "") $OWNER_NAME = $Row->LESSOR;
else $OWNER_NAME = $Row->FIRM_NAME;
$MODEL_YEAR = $Row->VEH_YEAR;
$MAKE = $Row->VEH_MAKE;
$TYPE = $Row->VEH_TYPE;
// fix up special values:
switch ($TYPE) {
case "PR": $TYPE = "WR"; // Tow Truck Wrecker
break;
case "ST": $TYPE = "SR"; // Semi-Trailer
break;
case "TR": $TYPE = "TT"; // Truck Tractor
break;
case "TK": $TYPE = "ST"; // Straight Truck
break;
default: break;
}
$FUEL = $Row->FUEL;
$UNLADEN_WEIGHT = $Row->UNLADEN_WEIGHT;
$NUMBER_OF_AXLES = $Row->AXLES;
$LICENSE_PLATE_NUMBER = $Row->PLATE_NO;
$UNIT_NUMBER = $Row->UNIT_NO;
$LAST_UPDATE_DATE = ConvertDate($Row->STATUS_DATE); // check for vehicle
switch ($Row->STATUS_CODE) { // is this IR_VEHICLE.STATUS_CODE
case 'A': $IRP_STATUS_CODE = '100';
// check date wrap at April 1
$REGISTRATION_EXPIRE_DATE = (substr($Row->STATUS_DATE,0,4)+1) . "-03-31";
break;
case 'I': $IRP_STATUS_CODE = '900';
$REGISTRATION_EXPIRE_DATE = $LAST_UPDATE_DATE;
break;
case 'D': $IRP_STATUS_CODE = '999';
$REGISTRATION_EXPIRE_DATE = $LAST_UPDATE_DATE;
break;
default:
$IRP_STATUS_CODE = '000'; // check this
$REGISTRATION_EXPIRE_DATE = $LAST_UPDATE_DATE;
}
$IRP_CARRIER_NUMBER = $Row->US_DOT_NUMBER_1;
// obtain GVW
$IRP_STATUS_DATE = $LAST_UPDATE_DATE;
$IRP_ACCOUNT_NUMBER = $Row->FIRM_NO;
$IRP_FLEET_NUMBER = $Row->FLEET_NO;
$REGISTRATION_START_DATE = ConvertDate($Row->PAY_DATE);
$GVW = substr($Row->STATE_WEIGHT_10_18,36,6);
$GVW_EXPIRE_DATE = $REGISTRATION_EXPIRE_DATE;
$XMLCab = "
<IRP_REGISTRATION>
<VIN>$VIN</VIN>
<TITLE_NUMBER>$TITLE_NUMBER</TITLE_NUMBER>
<TITLE_JURISDICTION>$TITLE_JURISDICTION</TITLE_JURISDICTION>
<OWNER_NAME>$OWNER_NAME</OWNER_NAME>
<MODEL_YEAR>$MODEL_YEAR</MODEL_YEAR>
<MAKE>$MAKE</MAKE>
<TYPE>$TYPE</TYPE>
<FUEL>$FUEL</FUEL>
<UNLADEN_WEIGHT>$UNLADEN_WEIGHT</UNLADEN_WEIGHT>
<NUMBER_OF_AXLES>$NUMBER_OF_AXLES</NUMBER_OF_AXLES>
<LICENSE_PLATE_NUMBER>$LICENSE_PLATE_NUMBER</LICENSE_PLATE_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>IL</IRP_BASE_STATE>
<UNIT_NUMBER>$UNIT_NUMBER</UNIT_NUMBER>
<LAST_UPDATE_DATE>$LAST_UPDATE_DATE</LAST_UPDATE_DATE>
<INTERSTATE_FLAG>1</INTERSTATE_FLAG>
<IRP_STATUS_CODE>$IRP_STATUS_CODE</IRP_STATUS_CODE>
<IRP_STATUS_DATE>$IRP_STATUS_DATE</IRP_STATUS_DATE>
<IRP_ACCOUNT_NUMBER>$IRP_ACCOUNT_NUMBER</IRP_ACCOUNT_NUMBER>
<IRP_FLEET_NUMBER>$IRP_FLEET_NUMBER</IRP_FLEET_NUMBER>
<REGISTRATION_START_DATE>$REGISTRATION_START_DATE</REGISTRATION_START_DATE>
<REGISTRATION_EXPIRE_DATE>$REGISTRATION_EXPIRE_DATE</REGISTRATION_EXPIRE_DATE>
<SAFETY_CARRIER>$IRP_CARRIER_ID_NUMBER</SAFETY_CARRIER>
<IRP_CARRIER_ID_NUMBER>$IRP_CARRIER_ID_NUMBER</IRP_CARRIER_ID_NUMBER>
<GVW>$GVW</GVW>
<GVW_EXPIRE_DATE>$GVW_EXPIRE_DATE</GVW_EXPIRE_DATE>\n";
// Jurisdiction weight mapping
$StartIx = 0;
foreach ($Jurisdictions as $Index => $Value){
if (array_search($Value, $OmitJurisdiction) !== FALSE) continue;
$FullJurisdiction = ConvertFullJurisdiction($Value);
$Ix = $Index + 1;
if ($Ix <= 9)
$Weight = substr($Row->STATE_WEIGHT_1_9, ($Index % 9)*6, 6);
else if ($Ix <= 18)
$Weight = substr($Row->STATE_WEIGHT_10_18, ($Index % 9)*6, 6);
else if ($Ix <= 27)
$Weight = substr($Row->STATE_WEIGHT_19_27, ($Index % 9)*6, 6);
else if ($Ix <= 36)
$Weight = substr($Row->STATE_WEIGHT_28_36, ($Index % 9)*6, 6);
else if ($Ix <= 45)
$Weight = substr($Row->STATE_WEIGHT_37_45, ($Index % 9)*6, 6);
else if ($Ix <= 54)
$Weight = substr($Row->STATE_WEIGHT_46_54, ($Index % 9)*6, 6);
else if ($Ix <= 63)
$Weight = substr($Row->STATE_WEIGHT_55_63, ($Index % 9)*6, 6);
$XMLCab .= "
<IRP_PRORATION>
<IRP_JURISDICTION>$FullJurisdiction</IRP_JURISDICTION>
<IRP_WEIGHT_CARRIED>$Weight</IRP_WEIGHT_CARRIED>
<IRP_WEIGHT_EXPIRE_DATE>$GVW_EXPIRE_DATE</IRP_WEIGHT_EXPIRE_DATE>
</IRP_PRORATION>\n";
}
$XMLCab .= "
</IRP_REGISTRATION>\n";
fwrite($fhout, $XMLCab);
}
$XMLCab =
"</T0022>\n";
fwrite($fhout,$XMLCab);
fclose($fhout);
?>
There are three CVIEW transactions in the IRP system. The three transactions are IRP Carrier account (T0020), IRP Fleet account (T0021) and IRP cab (T0022) - the first two deal with possibly groups of vehicles while the cab transaction corresponds to one vehicle.