‘Get Coupon Discount’,
‘description’ => ‘Get Coupon Discount’,
‘page callback’ => ‘get_coupon_discount’,
‘access arguments’ => array(‘authenticated user’),
‘type’ => MENU_CALLBACK,
);
return $items;
}
function get_coupon_discount()
{
$ccode = trim($_GET['ccode']);
$subscription_query = db_query(“
SELECT n.title, n.nid, mp.sell_price FROM node AS n
INNER JOIN uc_products AS p ON n.vid = p.vid
INNER JOIN uc_roles_products AS f ON p.nid = f.nid AND f.rid = 6
INNER JOIN uc_multiprice AS mp ON mp.nid = n.nid AND country_id = “.$_SESSION['country_id']
);
$coupons = array();
while($subscriptions = db_fetch_array($subscription_query))
{
$discount = array();
$order = new stdClass;
$order->products[0] = (object)array(‘nid’ => $subscriptions['nid'], ‘qty’ => 1, ‘price’ => $subscriptions['sell_price']);
$discount = uc_coupon_validate($ccode, $order);
if($discount->valid)
{
$_SESSION['uc_coupon'] = $ccode;
$org_price = $subscriptions['sell_price'];
$dis_price = $discount->amount;
$disd_price = $org_price – $dis_price;
$context['subject']['node'] = node_load($subscriptions['nid']);
$disd_price = strip_tags(uc_price($disd_price, $context));
$coupons['pro_'.$subscriptions['nid']] = $disd_price;
}
else
{
unset($_SESSION['uc_coupon']);
}
}
echo json_encode($coupons);
}
function icpforms_form_alter(&$form, &$form_state, $form_id)
{
global $base_path, $user, $base_url;
switch($form_id)
{
case ‘user_pass’:
$form['name']['#prefix'] = ‘
‘;
$form['name']['#title']= t(‘E-mail/Username’);
$form['firstname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘First name’),
‘#description’ => t(”),
‘#required’ => TRUE
);
$form['lastname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Last name’),
‘#description’ => t(”),
‘#required’ => TRUE
);
$form['question'] = array(
‘#type’ => ‘select’,
‘#title’ => t(‘Question’),
‘#description’ => t(‘Choose the question that you would like asked.’),
‘#options’ => password_reset_questions_get(),
‘#required’ => TRUE
);
$form['answer'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Answer’),
‘#description’ => t(‘Enter the answer to the above question.’),
‘#required’ => TRUE,
‘#suffix’ => ‘
‘,
‘#weight’ => 2
);
$form[submit]['#value']= ‘Submit’;
$form[submit]['#weight'] =5;
$form['#validate'][] = ‘icp_password_user_reset_validate’;
break;
case ‘password_reset_form’:
$form['Firstname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘First Name’),
‘#required’ => 1,
‘#weight’ => 1,
‘#description’ => t(‘Please enter your first name.’),
‘#collapsible’ => FALSE,
);
$form['Lastname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Surname’),
‘#required’ => 1,
‘#weight’ => 2,
‘#description’ => t(‘Please enter your surname.’),
‘#collapsible’ => FALSE,
);
$form['username']['#weight']=4;
$form['question']['#weight']=5;
$form['answer']['#weight']=6;
$form['operation']['#weight']=7;
$form['#validate'][] = ‘icp_password_user_registr_validate’;
break;
case ‘user_register’:
//drupal_goto(‘content/contact-us’);
$breadcrumb = array();
$breadcrumb[] = l(t(‘Home’), ”);
$breadcrumb[] = t(‘New User Registration’); // Link to current URL
// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
drupal_set_title(t(‘New User Registration’));
unset($form['account']['pass']);
$form['Address']['profile_postcode']['#maxlength']=15;
$form['Phone']['profile_area_code']['#maxlength']=5;
$form['Phone']['profile_business_phone']['#maxlength']=15;
$form['Phone']['profile_mobile']['#maxlength']=15;
$form['account']['mail']['#description'] = t(‘A valid e-mail address is required.. All contact from iContractor Profile will be sent to this address, including requests by recruiters to contact you.’);
$form['account']['confirm_email'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Re-enter your E-Mail’),
‘#maxlength’ => 64,
‘#required’ => 1,
‘#weight’ => 2,
‘#description’ => t(”),
);
$form['Password'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => t(‘Password’),
‘#description’ => t(‘Please provide a password. Note to meet our security standards, this must be at least 8 characters long and should consist of alpha-numeric-special characters. For example – iCon&!76 – would be an appropriate password.’),
‘#collapsible’ => FALSE,
);
$form['Password']['pass'] = array(
‘#type’ => t(‘password_confirm’),
‘#description’ => t(”),
‘#required’ => 1,
‘#size’ => 25,
);
$form['Name']['#weight'] = 1;
$form['account']['#weight'] = 2;
$form['account']['#title'] = t(‘Logon Information’);
$form['Password']['#weight'] = 3;
$form['password_reset']['#weight'] = 4;
$form['Name']['#prefix'] = ‘
‘;
$form['password_reset']['#suffix'] = ‘
‘;
$form['password_reset']['question']['#attributes'] = array(‘style’ => ‘width:245px’);
$form['password_reset']['answer']['#attributes'] = array(‘style’ => ‘width:245px’);
$form['password_reset']['question']['#description']= ”;
$form['password_reset']['answer']['#description']= ”;
$ads = ‘
‘.
t(‘Discounted subscription packages are available for Recruiters with international offices – ‘).
‘
‘.t(‘contact us’).’ ‘.
t(‘to find out more.’).
‘
‘;
$form['Address']['#weight'] = 5;
$form['Phone']['#weight'] = 6;
$form['autoassignrole_user']['#weight'] = 7;
$form['Address']['#prefix'] = ‘
‘.$ads;
$form['autoassignrole_user']['#suffix'] = ‘
‘;
$form['submit']['#value'] = t(‘Submit’);
$form['#submit'][] = ‘icp_user_registr_submit’;
$form['#validate'][] = ‘icp_user_registr_validate’;
break;
case ‘webform_client_form_5′:
$form['submitted']['left']['#prefix'] = ‘
‘.t(‘We are currently prototyping iContractor Profile with a selected group of recruiters and contractors and we intend on going live in mid 2011. We\’d be happy to hear from you in the meantime!’).’
* required field
‘;
$form['#validate'][] = ‘mycontact_form_validate’;
break;
case ‘user_login_block’:
$form['name']['#title'] = t(‘E-mail’);
$form['name']['#prefix'] = ‘
‘.t(‘Login to iContractor Profile’).’
‘;
$form['links'] = array();
if (variable_get(‘user_register’, 1))
{
$items[] = l(t(‘Not registered? Register Now’), ‘user/register’, array(‘attributes’ => array(‘title’ => t(‘Create a new user account.’))));
}
$items[] = l(t(‘Forgot password’), ‘user/password’, array(‘attributes’ => array(‘title’ => t(‘Request new password via e-mail.’))));
$form['links'] = array(‘#value’ => theme(‘item_list’, $items));
break;
case ‘user_login’:
$form['name']['#prefix'] = ‘
‘;
$form['submit']['#prefix'] = ‘
‘;
break;
case ‘providers_node_form’:
drupal_set_title(t(‘Create Providers’));
$form['taxonomy']['#title'] = t(‘Industry / Type / Name’);
$form['revision_information']['#attributes'] = array(‘style’ => ‘display:none’);
$form['path']['#attributes'] = array(‘style’ => ‘display:none’);
$form['comment_settings']['#attributes'] = array(‘style’ => ‘display:none’);
$form['menu']['#attributes'] = array(‘style’ => ‘display:none’);
$form['author']['#attributes'] = array(‘style’ => ‘display:none’);
$form['options']['#attributes'] = array(‘style’ => ‘display:none’);
$form['buttons']['preview']['#attributes'] = array(‘style’ => ‘display:none’);
break;
case ‘webform_client_form_25′:
$form['submitted']['left']['#prefix'] = ‘
‘.t(‘Please complete the form below so we can process your enquiry on this product/service.’).’
* required field
‘;
$form['submitted']['right']['#suffix'] = ‘
‘;
$form['submitted']['down'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ”,
‘#weight’ => 10,
‘#suffix’ => ‘
‘,
);
$form['submitted']['down']['terms_condition'] = array(
‘#type’ => ‘checkbox’,
‘#title’ => ”,
‘#required’ => 1,
‘#prefix’ => ‘
‘,
);
$form['#validate'][] = ‘product_enquiry_form_validate’;
$form['#submit'][] = ‘product_enquiry_form_submit’;
break;
case ‘user_login_block’:
$form['name']['#title'] = t(‘E-mail’);
$form['name']['#prefix'] = ‘
‘.t(‘Login to iContractor Profile’).’
‘;
$form['links'] = array();
if (variable_get(‘user_register’, 1))
{
$items[] = l(t(‘Not registered? Register Now’), ‘content/contact-us’, array(‘attributes’ => array(‘title’ => t(‘Create a new user account.’))));
}
$items[] = l(t(‘Forgot password’), ‘user/password’, array(‘attributes’ => array(‘title’ => t(‘Request new password via e-mail.’))));
$form['links'] = array(‘#value’ => theme(‘item_list’, $items));
break;
case ‘rcp_node_form’:
//echo ‘
';
//print_r($form['group_phone_email']);
$user_details = user_load($user->uid);
//Auto populate values from pre registration
$form['group_recruiter_name']['field_salutation'][0]['#default_value'] = array(‘value’ => $user_details->profile_salutation );
$form['group_recruiter_name']['field_fname'][0]['#default_value'] = array(‘value’ => $user_details->profile_fname );
$form['group_recruiter_name']['field_surname'][0]['#default_value'] = array(‘value’ => $user_details->profile_surname );
$form['group_recruiter_address']['field_street_address'][0]['#default_value'] = array(‘value’ => $user_details->profile_street_address);
$form['group_recruiter_address']['field_suburb'][0]['#default_value'] = array(‘value’ => $user_details->profile_suburb);
$form['group_recruiter_address']['field_zipcode'][0]['#default_value'] = array(‘value’ => $user_details->profile_postcode);
$form['group_phone_email']['field_area_code'][0]['#default_value'] = array(‘value’ => $user_details->profile_area_code);
$form['group_phone_email']['field_business_phone'][0]['#default_value'] = array(‘value’ => $user_details->profile_business_phone);
$form['group_phone_email']['field_mobile'][0]['#default_value'] = array(‘value’ => $user_details->profile_mobile );
//Override background information title
$form['group_phone_email']['field_bacground_information'][0]['#title'] = t(‘Please provide background information/information that contractors will find relevant about you. This could include things like: -areas/roles that you recruit in -how long you\’ve been with the organisation/company -special skills you offer contractors -services you offer’);
//Fill salutations options from frofile table
$salutation_option = db_fetch_array(db_query(“select `options` from {profile_fields} where title = ‘Salutation’”));
$lines = split(“[\n\r]“, $salutation_option['options']);
foreach ($lines as $line) {
if ($line = trim($line)) {
$salutation_options[$line] = $line;
}
}
//Create business admistratir dynamacially
$form['group_rcp_biz_administration'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ‘Business Administrator Name’,
‘#prefix’ => ‘
‘,
‘#suffix’ => ‘
‘,
‘#weight’ => -6,
‘#attributes’ => array(
‘class’ => ‘group-rcp-biz-administration’,
)
);
$form['group_rcp_biz_administration']['business_salutation'] = array(
‘#type’ => ‘select’,
‘#title’ => t(‘Salutation’),
‘#maxlength’ => 10,
‘#options’ => $salutation_options,
);
$form['group_rcp_biz_administration']['business_fname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘First Name’),
‘#maxlength’ => 30,
);
$form['group_rcp_biz_administration']['business_surname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Surname’),
‘#maxlength’ => 30,
);
$form['group_rcp_biz_administration']['business_role'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Role/Title’),
‘#maxlength’ => 30,
);
$form['group_rcp_biz_administration_phone'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ‘Business Administrator Phone and Email’,
‘#prtefix’ => ‘
‘,
‘#suffix’ => ‘
‘,
‘#weight’ => -5,
‘#attributes’ => array(
‘class’ => ‘group-rcp-biz-administration-phone’,
)
);
$form['group_rcp_biz_administration_phone']['business_business_phone'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Business Hours Phone’),
‘#maxlength’ => 10,
);
$form['group_rcp_biz_administration_phone']['business_area_code'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Area Code’),
‘#maxlength’ => 10,
);
$form['group_rcp_biz_administration_phone']['business_email'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Email’),
‘#maxlength’ => 50,
‘#description’ => t(‘Note: the administrator will need to use this email when you logon’),
);
$form['group_rcp_biz_administration_phone']['business_confirm_email'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Re-enter Email’),
‘#maxlength’ => 50,
);
$form['#validate'][] = ‘icp_rcp_form_validate’;
$form['#submit'][] = ‘icp_rcp_form_submit’;
$form['group_company_referrals']['field_offer_candidate']['#title'] = t(‘Do you offer a candidate referral program that you\’d like us to include details of in your Recruiter Profile on iContractor Profile?’);
$form['group_company_referrals']['field_tell_us'][0]['#title'] = t(‘Tell us more about your referral scheme (we will include these details in your Recruiter Profile on iContractor Profile)’);
$indcheck = db_result(db_query(“
SELECT count(n.nid) FROM node AS n
INNER JOIN users AS u ON u.uid = n.uid AND n.type = ‘rip’
WHERE u.name = ‘”.$form_state['values']['name'].”‘
“));
if(!$indcheck)
{
$form['#redirect'] = ‘node/add/rip’;
}
//Theming company profile
$form['group_recruiter_name']['#prefix'] = ‘
‘.t(‘Hi ‘) .$user_details->profile_fname.t(‘ – to proceed with registering as a recruiter on iContractor Profile, we need you to complete the following information:’).’
‘.t(‘Contact Details’).’
‘.t(‘Please confirm your contact details/or provide updates as required’).’
‘;
$form['group_recruiter_name']['#suffix'] = ‘
‘;
$form['group_recruiter_address']['#prefix'] = ‘
‘;
$form['group_recruiter_address']['#suffix'] = ‘
‘;
$form['group_phone_email']['#prefix'] = ‘
‘;
$form['group_phone_email']['field_business_phone']['#prefix'] = ‘
‘;
$form['group_phone_email']['field_bacground_information']['#suffix'] = ‘
‘;
$form['group_phone_email']['field_photo']['#prefix'] = ‘
‘;
$form['group_phone_email']['field_photo']['#suffix'] = ‘
‘;
$form['group_phone_email']['#suffix'] = ‘
‘;
$form['group_rcp_administration']['#prefix'] = ‘
‘;
$form['group_rcp_administration']['#suffix'] = ‘
‘;
$form['group_organization']['#prefix'] = ‘
‘;
$form['group_organization']['field_company_name']['#prefix'] = ‘
‘;
$form['group_organization']['field_recruitment']['#suffix'] = ‘
‘;
$form['group_organization']['field_company_logo']['#prefix'] = ‘
‘;
$form['group_organization']['field_about_us']['#suffix'] = ‘
‘;
$form['group_organization']['#suffix'] = ‘
‘;
$form['group_company_address']['#prefix'] = ‘
‘;
$form['group_company_address']['field_company_address']['#prefix'] = ‘
‘;
$form['group_company_address']['field_company_phone']['#suffix'] = ‘
‘;
$form['group_company_address']['field_company_country']['#prefix'] = ‘
‘;
$form['group_company_address']['field_company_zip']['#suffix'] = ‘
‘;
$form['group_company_address']['#suffix'] = ‘
‘;
//$form['group_company_referrals']['#prefix'] = ‘
‘;
//$form['group_company_referrals']['#suffix'] = ‘
‘;
break;
case ‘rip_node_form’:
$user_details = user_load($user->uid);
$form['group_recruiter_name']['#prefix'] = ‘
‘.t(‘Hi ‘) .$user_details->profile_fname.t(‘ – you are almost done – we just need you to provide us with the details of users at your end who will require access to iContractor Profile. Don\’t worry if you don\’t remember everyone – once your organisation/company\’s profile is setup, whoever you have selected as your business administrator will be able to add/remove/update your organisation/company\’s users. Each user you provide below will be emailed with a temporary password that they will need to reset, and they can then go ahead and individually update their own recruiter profiles.’).’
‘;
$form['group_recruiter_name'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ‘Business Administrator Name’,
‘#weight’ => -34,
‘#attributes’ => array(
‘class’ => ‘group-recruiter-name’,
)
);
//Fill salutations options from frofile table
$salutation_option = db_fetch_array(db_query(“select `options` from {profile_fields} where title = ‘Salutation’”));
$lines = split(“[\n\r]“, $salutation_option['options']);
foreach ($lines as $line) {
if ($line = trim($line)) {
$salutation_options[$line] = $line;
}
}
$form['group_recruiter_name']['recruiter_salutation'] = array(
‘#type’ => ‘select’,
‘#title’ => t(‘Salutation’),
‘#maxlength’ => 10,
‘#required’ => 1,
‘#options’ => $salutation_options,
);
$form['group_recruiter_name']['recruiter_fname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘First Name’),
‘#required’ => 1,
‘#maxlength’ => 30,
);
$form['group_recruiter_name']['recruiter_surname'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Surname’),
‘#required’ => 1,
‘#maxlength’ => 30,
);
$form['group_recruiter_name']['recruiter_role'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Role/Title’),
‘#required’ => 1,
‘#maxlength’ => 30,
);
$form['group_rip_phone'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ‘Business Administrator Phone and Email’,
‘#suffix’ => ‘
‘,
‘#weight’ => -33,
‘#attributes’ => array(
‘class’ => ‘group-rcp-biz-administration-phone’,
)
);
$form['group_rip_phone']['recruiter_business_phone'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Business Hours Phone’),
‘#required’ => 1,
‘#maxlength’ => 10,
);
$form['group_rip_phone']['recruiter_area_code'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Area Code’),
‘#required’ => 1,
‘#maxlength’ => 10,
);
$form['group_rip_phone']['recruiter_mobile'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Mobile’),
‘#maxlength’ => 10,
);
$form['group_rip_phone']['recruiter_email'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Email’),
‘#required’ => 1,
‘#maxlength’ => 64,
‘#description’ => t(‘Note: the administrator will need to use this email when you logon’),
);
$form['group_rip_phone']['recruiter_confirm_email'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Re-enter the recruiter\’s Email’),
‘#maxlength’ => 64,
‘#required’ => 1,
‘#weight’ => 51,
);
$form['group_rip_address'] = array(
‘#type’ => ‘fieldset’,
‘#title’ => ‘Address’,
‘#weight’ => -32,
‘#attributes’ => array(
‘class’ => ‘group-rip-address’,
)
);
$form['group_rip_address']['field_rip_street'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Street Address’),
‘#required’ => 1,
‘#maxlength’ => 10,
);
$form['group_rip_address']['field_rip_suburb'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Suburb’),
‘#required’ => 1,
‘#maxlength’ => 10,
);
$form['group_rip_address']['field_rip_zip'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘Post Code/ZIP’),
‘#required’ => 1,
‘#maxlength’ => 10,
);
$default_value = empty($form_state['values'][$country]) ? variable_get(‘profile_location_default_country’, PRIMARY_COUNTRY) : $form_state['values'][$country];
$form['group_rip_address']['profile_country'] = array(
‘#type’ => ‘select’,
‘#title’ => t(‘Country’),
‘#options’ => profile_location_countries(),
‘#default_value’ => $default_value,
‘#required’ => 1,
‘#attributes’ => array(‘onchange’ => ‘load_states(\”.$base_url.’\', \’edit-profile-country\’, \’edit-profile-state\’, this.value, 0)’),
);
$form['group_rip_address']['profile_state'] = array(
‘#type’ => ‘select’,
‘#validated’ => TRUE,
‘#title’ => t(‘City’),
‘#options’ => profile_location_states($default_value),
‘#required’ => 1,
);
$form['group_rip_background']['field_rip_background']['#title'] = t(‘Please provide background information/information that contractors will find relevant on the recruiter. This could include things like: -areas/roles that they recruit in -how long they\’ve been with the organisation/company -special skills they offer contractors -services they offer’);
$form['#validate'][] = ‘icp_rip_form_validate’;
$form['#submit'][] = ‘icp_rip_form_submit’;
$indcheck = db_result(db_query(“
SELECT count(n.nid) FROM node AS n
INNER JOIN users AS u ON u.uid = n.uid AND n.type = ‘rsp’
WHERE u.name = ‘”.$form_state['values']['name'].”‘
“));
if(!$indcheck)
{
$form['#redirect'] = ‘node/add/rsp’;
}
break;
case ‘rsp_node_form’:
$subscription_query = db_query(“
SELECT n.title, n.nid, mp.sell_price FROM node AS n
INNER JOIN uc_products AS p ON n.vid = p.vid
INNER JOIN uc_roles_products AS f ON p.nid = f.nid AND f.rid = 6
INNER JOIN uc_multiprice AS mp ON mp.nid = n.nid AND country_id = “.$_SESSION['country_id']
);
$subproducts = array();
$context = array(
‘revision’ => ‘themed’,
‘type’ => ‘price’,
);
$i = 0;
while($subscriptions = db_fetch_array($subscription_query))
{
$sub_node = node_load($subscriptions['nid']);
$price = $sub_node->sell_price;
if(isset($_SESSION['uc_coupon']))
{
$order = new stdClass;
$order->products[0] = (object)array(‘nid’ => $sub_node->nid, ‘qty’ => 1, ‘price’ => $sub_node->sell_price);
$discount = uc_coupon_validate($_SESSION['uc_coupon'], $order);
if($discount->valid)
{
$org_price = $sub_node->sell_price;
$dis_price = $discount->amount;
$price = $org_price – $dis_price;
}
}
$context['subject']['node'] = $sub_node;
$subproducts[$subscriptions['nid']] = $subscriptions['title'].’ ‘.uc_price($price, $context).’ ‘;
$i++;
}
$form['group_rsp_subscription']['field_rsp_period'] = array(
‘#type’ => ‘radios’,
‘#title’ => t(‘Please select a subscription period’),
‘#options’ => $subproducts,
‘#required’ => 1,
‘#attributes’ => array(‘onchange’ => ‘return show_subscription_period(this.value)’),
);
$form['group_rsp_subscription']['field_reference'] = array(
‘#type’ => ‘textfield’,
‘#title’ => t(‘ Reference Code’),
‘#default_value’ => $_SESSION['uc_coupon'],
‘#suffix’ => ‘
‘,
‘#attributes’ => array(‘style’ => ‘width:200px;float:left;margin-right:10px;’),
‘#maxlength’ => 10,
);
$form['group_rsp_subscription']['field_rsp_users']['#suffix'] = ‘
‘.t(‘Subscription Details Selected’).’:
‘.t(‘Period’).’:
‘.t(‘Users’).’:
‘.t(‘Starts’).’:
‘.t(‘Finishes’).’:
‘.t(‘AUD’).’ |
‘;
$form['#validate'][] = ‘icp_rsp_form_validate’;
$form['#submit'][] = ‘icp_rsp_form_submit’;
break;
}
$form['#after_build'][] = ‘my_form_process’;
}
function my_form_process($form, &$form_state) {
$default_value = empty($form_state['values']['field_coutry']['value']) ? variable_get(‘profile_location_default_country’, PRIMARY_COUNTRY) : $form_state['values']['field_coutry']['value'];
my_fix_country_select($form['group_recruiter_address']['field_coutry'], $default_value, ‘edit-field-coutry-value’, ‘edit-field-city-value’);
my_fix_city_select($form['group_recruiter_address']['field_city'], $default_value);
$cdefault_value = empty($form_state['values']['field_company_country']['value']) ? variable_get(‘profile_location_default_country’, PRIMARY_COUNTRY) : $form_state['values']['field_company_country']['value'];
my_fix_country_select($form['group_company_address']['field_company_country'], $cdefault_value, ‘edit-field-company-country-value’, ‘edit-field-company-city-value’);
my_fix_city_select($form['group_company_address']['field_company_city'], $cdefault_value);
return $form;
}
function my_fix_country_select(&$elements, $default_value, $source, $target)
{
global $base_url;
foreach (element_children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
// Recurse through all children elements.
my_fix_country_select($elements[$key], $default_value, $source, $target);
}
}
if (!isset($elements['#attributes'])) {
$elements['#attributes'] = array();
}
$elements['#options'] = profile_location_countries();
$elements['#default_value'] = $default_value;
$elements['#attributes'] = array(‘onchange’ => ‘load_states(\”.$base_url.’\', \”.$source.’\', \”.$target.’\', this.value, 0)’);
}
function my_fix_city_select(&$elements, $default_value)
{
global $base_url;
foreach (element_children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
// Recurse through all children elements.
my_fix_city_select($elements[$key], $default_value);
}
}
if (!isset($elements['#attributes'])) {
$elements['#attributes'] = array();
}
$elements['#options'] = profile_location_states($default_value);
// $elements['#validated'] = TRUE;
}
function icp_rip_form_validate(&$form, &$form_state)
{
global $base_url;
if(isset($form_state['values']['profile_country']))
{
$cid = $form_state['values']['profile_country'];
$sid = $form_state['values']['profile_state'];
drupal_add_js(“load_states(‘$base_url’, ‘edit-profile-country’, ‘edit-profile-state’, ‘$cid’, ‘$sid’)”, ‘inline’);
}
$patt_text = ‘/^[a-zA-Z]+(([\'\,\.\-][a-zA-Z ])?[a-zA-Z ]*)*$/’;
$patt_numeric = ‘/^[0-9]+$/’;
//URL regular expression validation without http.
$patt_url = ‘/^(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]*$/’;
if(!empty($form_state['values']['recruiter_fname']) && !preg_match($patt_text, $form_state['values']['recruiter_fname']))
{
form_set_error(‘recruiter_fname’, t(‘First Name should contain only characters’));
}
if(!empty($form_state['values']['recruiter_surname']) && !preg_match($patt_text, $form_state['values']['recruiter_surname']))
{
form_set_error(‘recruiter_surname’, t(‘Surname should contain only characters’));
}
if(!empty($form_state['values']['recruiter_business_phone']) && !preg_match($patt_numeric, $form_state['values']['recruiter_business_phone']))
{
form_set_error(‘recruiter_business_phone’, t(‘Business Hours Phone is not numeric’));
}
if(!empty($form_state['values']['recruiter_area_code']) && !preg_match($patt_numeric, $form_state['values']['recruiter_area_code']))
{
form_set_error(‘recruiter_area_code’, t(‘Area Code is not numeric’));
}
if(!empty($form_state['values']['recruiter_mobile']) && !preg_match($patt_numeric, $form_state['values']['recruiter_mobile']))
{
form_set_error(‘recruiter_mobile’, t(‘Mobile is not numeric’));
}
if(!empty($form_state['values']['field_rip_zip']) && !preg_match($patt_numeric, $form_state['values']['field_rip_zip']))
{
form_set_error(‘field_rip_zip’, t(‘Post Code/ZIP is not numeric’));
}
if(!valid_email_address(trim($form_state['values']['recruiter_email'])))
{
form_set_error(‘recruiter_email’, t(‘Invalid Email id’));
}
else if($form_state['values']['recruiter_confirm_email'] != $form_state['values']['recruiter_email'])
{
form_set_error(‘recruiter_confirm_email’, ‘Re-enter Email is not matching’);
}
else if($acc = user_load(array(‘mail’ => $form_state['values']['recruiter_email'])))
{
form_set_error(‘recruiter_email’, ‘Email id is existing! Please try with different email’);
}
}
function icp_rip_form_submit(&$form, &$form_state)
{
$new_user = array(
‘mail’ => $form_state['values']['recruiter_email'],
‘pass’ => user_password(),
‘roles’ => array(9 => ‘Recruiter Individuals’),
‘name’ => $form_state['values']['recruiter_email'],
‘profile_salutation’ => $form_state['values']['recruiter_salutation'],
‘profile_fname’ => $form_state['values']['recruiter_fname'],
‘profile_surname’ => $form_state['values']['recruiter_surname'],
‘profile_role_title’ => $form_state['values']['recruiter_role'],
‘profile_street_address’ => $form_state['values']['field_rip_street'],
‘profile_suburb’ => $form_state['values']['field_rip_suburb'],
‘profile_postcode’ => $form_state['values']['field_rip_zip'],
‘profile_country’ => $form_state['values']['profile_country'],
‘profile_state’ => $form_state['values']['profile_state'],
‘profile_business_phone’ => $form_state['values']['recruiter_business_phone'],
‘profile_area_code’ => $form_state['values']['recruiter_area_code'],
‘profile_mobile’ => $form_state['values']['recruiter_mobile'],
);
user_save(array(), $new_user);
}
function icp_rcp_form_validate(&$form, &$form_state)
{
$patt_text = ‘/^[a-zA-Z]+(([\'\,\.\-][a-zA-Z ])?[a-zA-Z ]*)*$/’;
$patt_numeric = ‘/^[0-9]+$/’;
//URL regular expression validation without http.
$patt_url = ‘/^(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]*$/’;
if($form_state['values']['field_administrator'][0]['value'] == 0)
{
if(empty($form_state['values']['business_fname']))
{
form_set_error(‘business_fname’, ‘First Name is required’);
}
if(!empty($form_state['values']['business_fname']) && !preg_match($patt_text, $form_state['values']['business_fname']))
{
form_set_error(‘business_fname’, t(‘First Name should contain only characters’));
}
if(empty($form_state['values']['business_surname']))
{
form_set_error(‘business_surname’, ‘Surname is required’);
}
if(!empty($form_state['values']['business_surname']) && !preg_match($patt_text, $form_state['values']['business_surname']))
{
form_set_error(‘business_surname’, t(‘Surname should contain only characters’));
}
if(empty($form_state['values']['business_role']))
{
form_set_error(‘business_role’, ‘Role/Title is required’);
}
if(empty($form_state['values']['business_business_phone']))
{
form_set_error(‘business_business_phone’, ‘Business Hours Phone is required’);
}
if(!empty($form_state['values']['business_business_phone']) && !preg_match($patt_numeric, $form_state['values']['business_business_phone']))
{
form_set_error(‘business_business_phone’, t(‘Business Hours Phone is not numeric’));
}
if(empty($form_state['values']['business_area_code']))
{
form_set_error(‘business_area_code’, ‘Area Code is required’);
}
if(!empty($form_state['values']['business_area_code']) && !preg_match($patt_numeric, $form_state['values']['business_area_code']))
{
form_set_error(‘business_area_code’, t(‘Area Code is not numeric’));
}
if(empty($form_state['values']['business_email']))
{
form_set_error(‘business_email’, ‘Email is required’);
}
else if(!valid_email_address(trim($form_state['values']['business_email'])))
{
form_set_error(‘business_email’, t(‘Invalid Email id’));
}
else if($form_state['values']['business_confirm_email'] != $form_state['values']['business_email'])
{
form_set_error(‘business_confirm_email’, ‘Re-enter Email is not matching’);
}
else if($acc = user_load(array(‘mail’ => $form_state['values']['business_email'])))
{
form_set_error(‘business_email’, ‘Email id is existing! Please try with different email’);
}
}
if(!empty($form_state['values']['field_website'][0]['value']) && !preg_match($patt_url, $form_state['values']['field_website'][0]['value']))
{
form_set_error(‘field_website’, ‘Invalid website URL’);
}
}
function icp_rcp_form_submit(&$form, &$form_state)
{
if($form_state['values']['field_administrator'][0]['value'] == 0)
{
$new_user = array(
‘mail’ => $form_state['values']['business_email'],
‘pass’ => user_password(),
‘roles’ => array(7 => ‘Recruiter Business Administrator’, 4 => ‘Recruiter’),
‘name’ => $form_state['values']['business_email'],
‘profile_salutation’ => $form_state['values']['business_salutation'],
‘profile_fname’ => $form_state['values']['business_fname'],
‘profile_surname’ => $form_state['values']['business_surname'],
‘profile_role_title’ => $form_state['values']['business_role'],
‘profile_business_phone’ => $form_state['values']['business_business_phone'],
‘profile_area_code’ => $form_state['values']['business_area_code'],
);
user_save(array(), $new_user);
}
}
function icp_rsp_form_validate(&$form, &$form_state)
{
if($form_state['values']['field_rsp_period'] && $form_state['values']['field_reference'] != ”)
{
$sub_prod = node_load($form_state['values']['field_rsp_period']);
$order->products[0] = (object)array(‘nid’ => $sub_prod->nid, ‘qty’ => 1, ‘price’ => $sub_prod->sell_price);
$discount = uc_coupon_validate($form_state['values']['field_reference'], $order);
if(!$discount->valid)
{
form_set_error(‘field_reference’, t(‘Invalid or expired coupon code’));
}
}
}
function icp_rsp_form_submit(&$form, &$form_state)
{
if(!$_SESSION['uc_coupon'] && $form_state['values']['field_reference'] != ”)
{
$_SESSION['uc_coupon'] = trim($form_state['values']['field_reference']);
}
if($form_state['values']['field_reference'] == ”)
{
unset($_SESSION['uc_coupon']);
}
// Empty that cart…
uc_cart_empty(uc_cart_get_id());
//Add item in to cart
uc_cart_add_item($form_state['values']['field_rsp_period']);
//Redirect to checkout page
drupal_goto(‘cart/checkout’);
}
function icp_password_user_reset_validate(&$form, &$form_state)
{
if($form['name']['#value']!=”)
{
$uid = password_reset_uid_get($form['name']['#value']);
if($uid)
{
$question = password_reset_user_question_get($uid);
if($form['question']['#value'] != $question['qid'])// User question in DB
{
form_set_error(‘question’, t(‘Please select the correct question.’));
}
if (!$question || trim(drupal_strtolower($question['answer'])) != trim(drupal_strtolower($form['answer']['#value'])))
{
form_set_error(‘answer’, t(‘Answer incorrect. Please check and try again.’));
}
}
}
}
function product_enquiry_form_validate(&$form, &$form_state)
{
if(!$form_state['values']['submitted']['down']['terms_condition'])
{
form_set_error(‘terms_condition’, t(‘Please confirm that you agree to this’));
}
}
function product_enquiry_form_submit(&$form, &$form_state)
{
//drupal_set_message(t(‘Thank you for your iContractor Products/Services enquiry. Someone from iContractoror the Product/Service provider will be in touch with you shortly.
Thanks again!’));
}
function mycontact_form_validate(&$form, &$form_state)
{
/*
$patt = ‘/^[0-9]+$/’;
if(!empty($form_state['values']['submitted']['right']['area_code']) && !preg_match($patt, $form_state['values']['submitted']['right']['area_code']))
{
form_set_error(‘area_code’, t(‘Area Code is not numeric.’));
}
*/
}
function icp_user_registr_validate(&$form, &$form_state)
{
//echo ‘
';
//print_r($form_state['values']);
$patt = ‘/(?=^.{7,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{:;?])(?!.*\s).*$/’;
if(!preg_match($patt, $form_state['values']['pass']))
{
form_set_error(‘pass’, t(‘The password does not include an appropriate combination of numbers, punctuation and upper and lower case characters. Please try again.’));
}
$patt = ‘/^[a-zA-Z]+(([\'\,\.\-][a-zA-Z ])?[a-zA-Z ]*)*$/’;
if(!preg_match($patt, $form_state['values']['profile_fname']))
{
form_set_error(‘profile_fname’, t(‘First Name should contain only characters’));
}
/*if(!preg_match($patt, $form_state['values']['profile_surname']))
{
form_set_error(‘profile_surname’, t(‘Surname should contain only characters’));
}
if(!preg_match($patt, $form_state['values']['profile_suburb']))
{
form_set_error(‘profile_suburb’, t(‘Suburb should contain only characters’));
}*/
$patt = ‘/^[0-9]+$/’;
if(!preg_match($patt, $form_state['values']['profile_postcode']))
{
form_set_error(‘profile_postcode’, t(‘Post code is not numeric’));
}
if(!preg_match($patt, $form_state['values']['profile_area_code']))
{
form_set_error(‘profile_area_code’, t(‘Business area code is not numeric’));
}
if(!preg_match($patt, $form_state['values']['profile_business_phone']))
{
form_set_error(‘profile_business_phone’, t(‘Business phone is not numeric’));
}
if($form_state['values']['profile_mobile']!=”)
{
if(!preg_match($patt, $form_state['values']['profile_mobile']))
{
form_set_error(‘profile_mobile’, t(‘Mobile number is not numeric’));
}
}
if($form_state['values']['mail'] != $form_state['values']['confirm_email'])
{
form_set_error(‘confirm_email’, t(‘Email ids are not matching’));
}
}
function icp_user_registr_submit(&$form, &$form_state)
{
global $user;
$user_details = user_load($user->uid);
if(in_array(‘contractor’, $user_details->roles))
{
//drupal_set_message(t(‘Hi ‘.$user->profile_fname.’* – to proceed with registering as a contractor on iContractor Profile, we need you to complete the following information:’));
//drupal_goto(‘user/’. $user->uid .’/profile/contractor’);
//drupal_goto(‘content/contractor-dashboard’);
}
else if(in_array(‘recruiter’, $user_details->roles))
{
//drupal_set_message(t(‘Hi ‘.$user->profile_fname.’* – to proceed with registering as a recruiter on iContractor Profile, we need you to complete the following information:’));
//drupal_goto(‘user/’. $user->uid .’/profile/recruiter’);
//drupal_goto(‘content/recruiter-dashboard’);
}
}
/**
* Generate HTML for the onthisdate block
* @param op the operation from the URL
* @param delta offset
* @returns block HTML
*/
function icpforms_block($op=’list’, $delta=0)
{
$block = array();
if ($op == “list”)
{
$block[0]["info"] = t(‘Domain List’);
}
else if ($op == ‘view’)
{
$block = array(
‘subject’ => t(‘Domain List’),
‘content’ => domain_list(),
);
}
return $block;
}
function domain_list()
{
global $_domain;
$domains = domain_domains();
if(count($domains))
{
$dom_array = array(‘China’, ‘Hong Kong’, ‘Singapore’, ‘Malaysia’, ‘South Africa’, ‘UK’, ‘New Zealand’, ‘Thailand’, ‘South Korea’, ‘Bahrain’, ‘United Arab Emirates’, ‘Saudi Arabia’, ‘Iraq’, ‘Jordan’, ‘Japan’, ‘India’, ‘USA’, ‘Canada’, ‘Lebanon’, ‘Israel’, ‘Switzerland’, ‘Germany’, ‘Spain’, ‘Portugal’, ‘Denmark’, ‘France’, ‘Ireland’, ‘Netherlands’, ‘Qatar’, ‘Italy’, ‘Austria’, ‘Poland’, ‘Hungary’);
$content = ‘
$dom_path = array();
foreach ($domains as $domain)
{
if ($domain['valid'])
{
$title = $domain['sitename'];
$dom_array[] = $title;
$dom_path[$title] = domain_get_uri($domain);
}
}
asort($dom_array);
foreach($dom_array as $countries)
{
$selected = ”;
if($countries == $_domain['sitename'])
{
$selected = ‘selected=”selected”‘;
}
$content .= ”.t($countries).”;
}
$content .= ‘
‘;
}
return $content;
}
?>