Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class DriverApplicationController extends ApplicationController {
- function main() {
- $common_trucks = array(
- 'Tanker',
- 'Bus-Straight',
- 'Bus-Articulated',
- 'Cabover Tractor',
- 'Class B Vehicle',
- 'Conventional Tractor',
- 'Tractor-Trailer',
- 'Day Cab',
- 'Day Cab Conventional',
- 'Dump Truck',
- 'LC Truck',
- 'Straight Truck',
- 'Other'
- );
- $common_trailers = array(
- 'Flatbed',
- 'Van',
- 'Container',
- 'Doubles',
- 'Liftgate',
- 'Reefer Trailer',
- 'Tank Trailer',
- 'Step Deck',
- 'Other'
- );
- $trailer_lengths = array(
- '31 feet or less',
- '32 to 44 feet',
- '45 to 52 feet',
- '53 feet or more',
- 'Other'
- );
- $this->assign('common_trucks', $common_trucks);
- $this->assign('common_trailers', $common_trailers);
- $this->assign('trailer_lengths', $trailer_lengths);
- $this->assign('states', get_states());
- $this->assign('countries', get_countries());
- $data = array(
- 'pi' => array(
- 'country_id' => 'US'
- ),
- 'employment0' => array(
- 'country_id' => 'US'
- )
- );
- if (isset($_GET['_debug']))
- $data = array(
- 'pi' => array(
- 'first_name' => 'Marius',
- 'last_name' => 'Valeanu',
- 'address' => '8 W Maple St',
- 'city' => 'Chicago',
- 'state_id' => 'IL',
- 'zip' => '66000',
- 'country_id' => 'US',
- 'address_since_m' => '01',
- 'address_since_y' => '2006',
- 'ssn' => '123456789',
- 'dob_m' => '09',
- 'dob_d' => '03',
- 'dob_y' => '1979',
- 'phone' => '1234567890',
- 'alt_phone' => '0987654321',
- 'contact_time' => '9am - 6pm',
- 'how' => 'Friends'
- ),
- 'gi' => array(
- 'us_citizen' => 'yes',
- 'eligible' => 'yes',
- 'employed' => 'yes',
- 'english' => 'Yes',
- 'worked_before' => 'no',
- 'any_other_name' => 'no',
- 'notify' => 'Silviana Valeanu, Same address, 0760830522'
- ),
- 'de' => array(
- 'experience_st' => '1 year',
- 'experience_tst' => '2 years',
- 'experience_ttt' => '3 years',
- 'awards' => 'None'
- ),
- 'ed' => array(
- 'highest_grade' => 'University',
- 'last_school' => 'Al. I. Cuza, Iasi, RO'
- ),
- 'licenses' => array(
- 'no' => '123',
- 'expiration' => '07/12/2024',
- 'physical_expiration' => '07/11/2024',
- 'state' => 'IL',
- 'current' => 'yes',
- 'commercial' => 'yes',
- 'cdl_class' => 'Some class'
- ),
- 'endorsements' => array(
- 'tanker' => 'Ta1',
- 'HAZMAT' => 'HA2',
- 'x' => 'x3',
- 'dt' => 'dt4'
- ),
- 'military' => array(
- 'service' => 'Not done'
- ),
- 'employment0' => array(
- 'start_m' => '01',
- 'start_y' => '2008',
- 'company' => 'Image Factory',
- 'street' => '2310 Morning Way',
- 'city' => 'La Jolla',
- 'state_id' => 'CA',
- 'zip' => '90100',
- 'country_id' => 'US',
- 'phone' => '1234567890',
- 'position' => 'Programmer',
- 'reason' => 'Other better offer',
- 'commercial' => 'yes',
- 'terminated' => 'no',
- 'fmcsr' => 'no',
- 'sensitive' => 'no',
- 'areas' => 'California',
- 'miles' => '50 - 60',
- 'pay' => 'so so',
- 'equipment' => 'Tanker',
- 'trailer' => 'Van',
- 'length' => '31 feet or less'
- ),
- 'mvr' => array(
- 'privilege' => 'no',
- 'suspension' => 'no',
- 'alcohol' => 'no',
- 'drug' => 'no',
- 'reckless' => 'no',
- 'positive' => 'no'
- ),
- 'tcv' => array(
- 'violations' => 'no'
- ),
- 'var' => array(
- 'involved' => 'no'
- ),
- 'cr' => array(
- 'convicted' => 'no',
- 'deferred' => 'no',
- 'felony' => 'no',
- 'permit' => 'NA',
- 'misdemeanor' => 'no'
- )
- );
- $this->assign('data', $data);
- $content = get_content('driver-application');
- $this->assign('content', $content);
- $this->assign('_page_title', $content['title']);
- }
- function post() {
- $data = $_POST;
- clean_post_data_rec($data);
- $return = array('success' => 1, 'step' => 1);
- if (!isset($data['step']) || $data['step'] < 1 || $data['step'] > 4) {
- $return['success'] = 0;
- $return['message'] = 'Current form step is invalid!';
- }
- else {
- for ($i = 1; $i <= $data['step']; $i++) {
- $return['step'] = $i;
- $method = 'checkStep' . intval($i);
- if (method_exists($this, $method)) {
- $return = array_merge($return, $this->$method($data));
- if (!$return['success'])
- break;
- }
- }
- }
- if ($return['success'] && $data['step'] == 4) {
- $pdf_file = $this->generatePdf($data);
- send_mail(
- CONTACT_EMAIL,
- 'Driver Application: ' . $data['pi']['last_name'] . ', ' . $data['pi']['first_name'],
- 'You can find the pdf application attached.',
- false,
- array(rewrite_escape(date('Y m d') . ' ' . $data['pi']['last_name'] . ' ' . $data['pi']['first_name'], '_') => $pdf_file)
- );
- unlink($pdf_file);
- $return['message'] = "Your application has been successfully received!\nThank you for your time.";
- }
- header('Cache-Control: no-cache, must-revalidate');
- header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
- header('Content-type: application/json');
- echo json_encode($return);
- return $this->render(null);
- }
- function checkStep1($data) {
- $return = array('error_fields' => array());
- $fields = array(
- 'first_name',
- 'last_name',
- 'address',
- 'city',
- 'state_id',
- 'zip',
- 'country_id',
- 'address_since_m',
- 'address_since_y',
- /*'address_3_years',*/
- 'ssn',
- 'dob_m',
- 'dob_d',
- 'dob_y',
- 'phone',
- 'contact_time',
- 'how'
- );
- foreach ($fields as $field)
- if (!isset($data['pi'][$field]))
- $return['error_fields'][] = 'pi-' . $field;
- if ($return['error_fields']) {
- $return['success'] = 0;
- $return['message'] = 'The fields in red are required!';
- }
- else {
- $return['message'] = array();
- $address_since = date('Y-m', strtotime($data['pi']['address_since_y'] . '-' . $data['pi']['address_since_m'] . '-01'));
- if ($address_since > date('Y-m', strtotime('-7 years'))) {
- $return['error_fields'][] = 'pi-address_3_years';
- $return['message'][] = 'Please enter previous residences to cover the last 7 years!';
- }
- $dob = date('Y-m-d', strtotime($data['pi']['dob_y'] . '-' . $data['pi']['dob_m'] . '-' . $data['pi']['dob_d']));
- if ($dob > date('Y-m-d', strtotime('-18 years'))) {
- $return['error_fields'][] = 'pi-dob_m';
- $return['message'][] = 'You must be 18 to apply!';
- }
- if ($data['pi']['country_id'] == 'US' && strlen(preg_replace('/[^\d]+/', '', $data['pi']['ssn'])) != 9) {
- $return['error_fields'][] = 'pi-ssn';
- $return['message'][] = 'SSN is invalid (9 digits required)!';
- }
- if (strlen(preg_replace('/[^\d]+/', '', $data['pi']['phone'])) < 10) {
- $return['error_fields'][] = 'pi-phone';
- $return['message'][] = 'Phone is invalid (10 digits required)!';
- }
- if (isset($data['pi']['alt_phone']) && strlen(preg_replace('/[^\d]+/', '', $data['pi']['alt_phone'])) < 10) {
- $return['error_fields'][] = 'pi-alt_phone';
- $return['message'][] = 'Alt. phone is invalid (10 digits required)!';
- }
- if ($return['error_fields']) {
- $return['success'] = 0;
- $return['message'] = implode("\n", $return['message']);
- }
- else
- unset($return['error_fields'], $return['message']);
- }
- return $return;
- }
- function generatePdf($data) {
- require_once(LIB_DIR . 'tcpdf/config/lang/eng.php');
- require_once(LIB_DIR . 'tcpdf/tcpdf.php');
- // create new PDF document
- $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
- // set document information
- $pdf->SetCreator(PDF_CREATOR);
- $pdf->SetAuthor(SITE_NAME);
- $pdf->SetTitle('Driver Application');
- $pdf->SetSubject('Driver Application');
- $pdf->SetKeywords('Driver Application');
- // remove default header/footer
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- // set default monospaced font
- $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
- //set margins
- $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
- //set auto page breaks
- $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
- //set image scale factor
- $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
- //set some language-dependent strings
- $pdf->setLanguageArray($l);
- // ---------------------------------------------------------
- // add a page
- $pdf->AddPage();
- // start writing
- $pdf->SetFont('times', 'B', 24);
- $txt = 'Driver Application';
- $pdf->Write(0, $txt, '', 0, 'C');
- $pdf->Ln(20);
- $groups = array(
- 'PERSONAL INFORMATION' => array(
- array('Name:', $data['pi']['last_name'] . ', ' . $data['pi']['first_name']),
- array('Address:', $data['pi']['address']),
- array('City, State Zip:', $data['pi']['city'] . ', ' . ($data['pi']['state_id'] ? $data['pi']['state_id'] : 'Non US') . ' ' . $data['pi']['zip']),
- array('Country:', $this->dbi->getOne('select label from countries where id = ?', $data['pi']['country_id'])),
- array('Previous addressed:', isset($data['pi']['address_3_years']) ? $data['pi']['address_3_years'] : 'NA'),
- array('SSN:', $data['pi']['ssn']),
- array('Date of Birth:', $data['pi']['dob_m'] . '/' . $data['pi']['dob_d'] . '/' . $data['pi']['dob_y']),
- array('Phone:', $data['pi']['phone']),
- array('Alt. Phone:', isset($data['pi']['alt_phone']) ? $data['pi']['alt_phone'] : 'NA'),
- array('Best Contact Time:', $data['pi']['contact_time']),
- array('How did you hear about us?', $data['pi']['how'])
- ),
- 'GENERAL INFORMATION' => array(
- array('What position are you applying for?', 'Sub Contractor'),
- array('If you are applying for a sub-contractor position, who would you be driving for?', 'Butacis Trucking'),
- array('Are you a U.S. citizen?', $data['gi']['us_citizen']),
- array('Are you legally eligible for employment in the United States?', $data['gi']['eligible']),
- array('Are you currently employed?', $data['gi']['employed']),
- array('What date did your last employment end?', isset($data['gi']['employment_end']) ? $data['gi']['employment_end'] : 'NA'),
- array('Do you read, write and speak English?', $data['gi']['english']),
- array('Have you ever worked for this company before?', $data['gi']['worked_before']),
- array('Enter start and end dates, location, position, rate of pay, and reason for leaving:', isset($data['gi']['worked_before_details']) ? $data['gi']['worked_before_details'] : 'NA'),
- /*array('Do you have a current TWIC card?', $data['gi']['twic']),
- array('Expiration date:', isset($data['gi']['twic_expiration']) ? $data['gi']['twic_expiration'] : 'NA'),*/
- array('Please enter the names of any relatives employed here:', isset($data['gi']['relatives']) ? $data['gi']['relatives'] : 'NA'),
- array('Have you ever been known by any other name?', $data['gi']['any_other_name']),
- array('Enter name:', isset($data['gi']['other_name']) ? $data['gi']['other_name'] : 'NA'),
- array('Who referred you?', isset($data['gi']['referrals']) ? $data['gi']['referrals'] : 'NA'),
- array('In case of Emergency, notify (list name, address, and phone):', $data['gi']['notify']),
- ),
- 'DRIVING EXPERIENCE' => array(
- array('How much experience do you have in each of these types of equipment?', ''),
- array('Straight Truck:', $data['de']['experience_st']),
- array('Tractor and Semi-Trailer:', $data['de']['experience_tst']),
- array('Tractor - Two Trailers:', $data['de']['experience_ttt']),
- array('Other:', isset($data['de']['experience_other']) ? $data['de']['experience_other'] : 'NA'),
- array('Which safe driving awards do you hold and from whom?', $data['de']['awards'])
- ),
- 'EDUCATION' => array(
- array('List highest grade completed:', $data['ed']['highest_grade']),
- array('List last school attended (name, city, and state):', $data['ed']['last_school'])
- ),
- 'LICENSES' => array(
- array('License Number:', $data['licenses']['no']),
- array('License Expiration Date:', $data['licenses']['expiration']),
- array('Physical Expiration Date:', $data['licenses']['physical_expiration']),
- array('State, Country:', $data['licenses']['state']),
- array('Is this your current driver license?', $data['licenses']['current']),
- array('Is this a commercial driver license?', $data['licenses']['commercial']),
- array('CDL Class:', $data['licenses']['cdl_class'])
- ),
- 'ENDORSEMENTS' => array(
- array('Tanker Endorsement:', $data['endorsements']['tanker']),
- array('HAZMAT Endorsement:', $data['endorsements']['HAZMAT']),
- array('X Endorsement:', $data['endorsements']['x']),
- array('Doubles / Triples Endorsement:', $data['endorsements']['dt']),
- array('Other Endorsement:', isset($data['endorsements']['other']) ? $data['endorsements']['other'] : 'NA'),
- ),
- 'MILITARY' => array(
- array('Military Service:', $data['military']['service'])
- )
- );
- $groups['PREVIOUS EMPLOYMENT INFORMATION'] = array();
- for ($i = 0; $i < $data['employment_records']; $i++)
- $groups['EMPLOYMENT RECORD #' . ($i + 1)] = array(
- array('Starting Date:', $data['employment' . $i]['start_m'] . '/' . $data['employment' . $i]['start_y']),
- array('Ending Date:', isset($data['employment' . $i]['end_m']) && isset($data['employment' . $i]['end_y']) ? $data['employment' . $i]['end_m'] . '/' . $data['employment' . $i]['end_y'] : 'Current'),
- array('Company Name:', $data['employment' . $i]['company']),
- array('Street Address:', $data['employment' . $i]['street']),
- array('City, State Zip:', $data['employment' . $i]['city'] . ', ' . ($data['employment' . $i]['state_id'] ? $data['employment' . $i]['state_id'] : 'Non US') . ' ' . $data['employment' . $i]['zip']),
- array('Country:', $this->dbi->getOne('select label from countries where id = ?', $data['employment' . $i]['country_id'])),
- array('Telephone:', $data['employment' . $i]['phone']),
- array('Position Held:', $data['employment' . $i]['position']),
- array('Reason for Leaving:', isset($data['employment' . $i]['reason']) ? $data['employment' . $i]['reason'] : 'NA'),
- array('Did you operate a commercial motor vehicle?', $data['employment' . $i]['commercial']),
- array('Were you terminated?', $data['employment' . $i]['terminated']),
- array('Were you subject to the Federal Motor Carrier Safety Regulations while employed by this employer?', $data['employment' . $i]['fmcsr']),
- array('Did you perform any safety sensitive functions in this job, regulated by DOT, and subject to drug and alcohol testing?', $data['employment' . $i]['sensitive']),
- /*array('Is this your current employer?', $data['employment' . $i]['current']),*/
- array('Areas Driven:', $data['employment' . $i]['areas']),
- array('Miles Weekly:', $data['employment' . $i]['miles']),
- array('Pay Range (cents/mile):', $data['employment' . $i]['pay']),
- array('Type of Equipment:', $data['employment' . $i]['equipment']),
- array('Type Of Trailer:', $data['employment' . $i]['trailer']),
- array('Trailer Length:', $data['employment' . $i]['length'])
- );
- $groups['MOTOR VEHICLE RECORD'] = array(
- array('Has any license, permit or privilege ever been denied, suspended or revoked for any reason?', $data['mvr']['privilege']),
- array('Have you ever been convicted of driving during license suspension or revocation, or driving without a valid license or an expired license, or are any charges pending?', $data['mvr']['suspension']),
- array('Have you ever been convicted for any alcohol or controlled substance related offense while operating a motor vehicle, or are any charges pending?', $data['mvr']['alcohol']),
- array('Have you ever been convicted for possession, sale or transfer of a drug, marijuana, amphetamines, or derivatives thereof, or are any charges pending?', $data['mvr']['drug']),
- array('Have you ever been convicted of reckless driving, careless driving or careless operation of a motor vehicle, or are any charges pending?', $data['mvr']['reckless']),
- array('Have you ever tested positive, or refused to test, on any pre-employment drug or alcohol test administered by an employer to which you applied for, but did not obtain, safety-sensitive transportation work covered by DOT agency drug and alcohol testing rules during the past three years?', $data['mvr']['positive'])
- );
- $groups['TRAFFIC CONVICTIONS / VIOLATIONS'] = array(
- array('Have you had any moving violations or traffic convictions in the past 3 years?', $data['tcv']['violations']),
- array('Violation Date(s):', isset($data['tcv']['date']) ? $data['tcv']['date'] : 'NA'),
- array('Violation Charge(s)/Description(s):', isset($data['tcv']['description']) ? $data['tcv']['description'] : 'NA'),
- array('If Speeding, MPH over the speed limit:', isset($data['tcv']['mph']) ? $data['tcv']['mph'] : 'NA'),
- array('State(s):', isset($data['tcv']['state']) ? $data['tcv']['state'] : 'NA')
- );
- $penalties = array('Penalty/Fine (select all that apply):', '');
- if (isset($data['tcv']['penalty'])) {
- foreach ($data['tcv']['penalty'] as $penalty)
- $penalties[1] .= ($penalties[1] ? ', ' : '') . $penalty;
- }
- else
- $penalties[1] = 'NA';
- $groups['TRAFFIC CONVICTIONS / VIOLATIONS'][] = $penalties;
- $groups['TRAFFIC CONVICTIONS / VIOLATIONS'][] = array('Fine Amount (If Applicable):', isset($data['tcv']['amount']) ? $data['tcv']['amount'] : 'NA');
- $groups['TRAFFIC CONVICTIONS / VIOLATIONS'][] = array('Comments - If you answered "Other Penalty", please provide additional detail:', isset($data['tcv']['comments']) ? $data['tcv']['comments'] : 'NA');
- $groups['VEHICLE ACCIDENT RECORD'] = array(
- array('Were you involved in any accidents/incidents with any vehicle in the last 3 Years (even if not at fault)?', $data['var']['involved']),
- array('Date(s) of accident/incident:', isset($data['var']['date']) ? $data['var']['date'] : 'NA'),
- array('Type(s) of accident/incident:', isset($data['var']['type']) ? $data['var']['type'] : 'NA'),
- array('Please describe:', isset($data['var']['describe']) ? $data['var']['describe'] : 'NA'),
- array('Were you in a commercial vehicle?', $data['var']['commercial']),
- array('If yes, was this a Department of Transportation reportable accident?', $data['var']['reportable']),
- array('Were you at fault?', $data['var']['fault']),
- array('Were you ticketed?', $data['var']['ticketed']),
- array('State/Prov:', isset($data['var']['state']) ? $data['var']['state'] : 'NA'),
- );
- $groups['CRIMINAL RECORD'] = array(
- array('Have you ever been convicted of a crime?', $data['cr']['convicted']),
- array('Do you have any Deferred Prosecutions or any criminal charges pending?', $data['cr']['deferred']),
- array('Have you ever pled "guilty" to, been convicted of, pled "no contest" to a felony?', $data['cr']['felony']),
- array('If you have any felony convictions, do you currently hold a Ministers Permit to enter or exit Canada?', $data['cr']['permit']),
- array('Have you, within the last 7 years, pled guilty to, been convicted of, had prosecution deferred in connection with, or pled "no contest" to a misdemeanor?', $data['cr']['misdemeanor'])
- );
- foreach ($groups as $group => $lines) {
- $pdf->SetFont('times', 'B', 14);
- $pdf->Write(0, $group, '', 0, 'C');
- $pdf->Ln(10);
- foreach ($lines as $line) {
- $pdf->SetFont('times', 'I' . (!$line[1] ? 'B' : ''), 11);
- $pdf->Write(0, $line[0]);
- if ($line[1]) {
- $pdf->Ln();
- $pdf->SetFont('times', 'B', 12);
- $pdf->Write(0, $line[1]);
- }
- $pdf->Ln(10);
- }
- $pdf->Ln(4);
- }
- // ---------------------------------------------------------
- //Close and output PDF document
- $filename = ROOT_DIR . TMP_DIR . generate_filename_from_time() . '.pdf';
- $pdf->Output($filename, 'F');
- return $filename;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement