Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.12 KB | None | 0 0
  1. function velosurance_quote_multistep_auto_create_bike($type, $bike, $usage, $specials) {
  2.   $node = new stdClass();
  3.   $node->title     = $bike['year'] .' '. $bike['make'] . ' ' . $bike['model'];
  4.   $node->type      = 'bike';
  5.   $node->created   = time();
  6.   $node->status    = 1;
  7.   $node->promote   = 0;
  8.   $node->sticky    = 0;
  9.   $node->uid       = 1;
  10.   $node->language  = 'en';
  11.   $node->timestamp = time();
  12.   $node->revision  = 0;
  13.   $node->runtime   = 0;
  14.   $node->active    = 1;
  15.   $node->field_bike_year[LANGUAGE_NONE][0]['value']      = $bike['year'];
  16.   $node->field_bike_make[LANGUAGE_NONE][0]['value']      = ucfirst($bike['make']);
  17.   $node->field_bike_model[LANGUAGE_NONE][0]['value']     = ucfirst($bike['model']);
  18.   $node->field_bike_status[LANGUAGE_NONE][0]['value']    = $bike['condition'];
  19.   $node->field_bike_usage[LANGUAGE_NONE][0]['value']     = $usage;
  20.  
  21.   $node->field_bike_purchase_year[LANGUAGE_NONE][0]['value']  = $bike['purchased_year'] . '-01-01 00:00:00';
  22.   $node->field_bike_current_value[LANGUAGE_NONE][0]['value']  = (int) preg_replace("/[^(\d)\.]/", "", $bike['current_value']);
  23.   $node->field_bike_type[LANGUAGE_NONE][0]['value']           = $bike['bike_type'];
  24.   $node->field_bike_construction[LANGUAGE_NONE][0]['value']   = $bike['construction'];
  25.   $node->field_bike_price[LANGUAGE_NONE][0]['value']          = (int) preg_replace("/[^(\d)\.]/", "", $bike['price']);
  26.   $node->field_deductible[LANGUAGE_NONE][0]['value']          = $bike['deductible'];
  27.   $node->field_roadside_assistance[LANGUAGE_NONE][0]['value'] = $bike['roadside_assist'];
  28.   $node->field_worldwide_covarage[LANGUAGE_NONE][0]['value']  = $bike['wwcoverage'];
  29.   $node->field_liability_limit[LANGUAGE_NONE][0]['value']     = $specials['liability_limit'];
  30.   $node->field_vehicle_contact_protection[LANGUAGE_NONE][0]['value'] = $specials['vehicle_contact_protection'];
  31.   $node->field_medical_payments[LANGUAGE_NONE][0]['value']    = $specials['medical_payments'];
  32.  
  33.  
  34.   if ($type == 'basic') {
  35.     $node->field_deductible[LANGUAGE_NONE][0]['value']                  = 500;
  36.     $node->field_roadside_assistance[LANGUAGE_NONE][0]['value']         = 0;
  37.     $node->field_worldwide_covarage[LANGUAGE_NONE][0]['value']          = 0;
  38.     $node->field_liability_limit[LANGUAGE_NONE][0]['value']             = 0;
  39.     $node->field_vehicle_contact_protection[LANGUAGE_NONE][0]['value']  = 0;
  40.     $node->field_medical_payments[LANGUAGE_NONE][0]['value']            = 0;
  41.   }
  42.  
  43.   if ($type == 'plus') {
  44.     $node->field_deductible[LANGUAGE_NONE][0]['value']                  = 300;
  45.     $node->field_roadside_assistance[LANGUAGE_NONE][0]['value']         = 0;
  46.     $node->field_worldwide_covarage[LANGUAGE_NONE][0]['value']          = 0;
  47.     $node->field_liability_limit[LANGUAGE_NONE][0]['value']             = 0;
  48.     $node->field_medical_payments[LANGUAGE_NONE][0]['value']            = 0;
  49.  
  50.     if ($specials['personal_insurance'] == 'No') {
  51.       $node->field_vehicle_contact_protection[LANGUAGE_NONE][0]['value'] = 25000;
  52.     }
  53.     else {
  54.       $node->field_vehicle_contact_protection[LANGUAGE_NONE][0]['value'] = 0;
  55.     }
  56.   }
  57.  
  58.   node_save($node);
  59.   return $node;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement