$this->wpdb = $wpdb;
$jobs = new staffords_employment_job($path);
add_action('admin_menu', array($this, 'add_job_menus'));
- add_action('admin-init', array($this, 'job_settings_init') );
+ add_action('admin_init', array($this, 'job_settings_init') );
}
/**
public function job_settings_init()
{
- register_setting(STAFFORDS_EMP_SETTINGS, STAFFORDS_EMP_SETTINGS);
- add_filter(
- 'option_page_capability_job-setting-group',
- array($this, 'staffords_option_page_capability')
+ //add_filter(
+ //'option_page_capability_job-setting-group',
+ //array($this, 'staffords_option_page_capability')
+ //);
+ add_settings_section(
+ 'staffordsjobs_setting_section_two',
+ 'Edit Confirmations',
+ array($this, 'staffords_settings_two_section_callback'),
+ 'staffordsjobs_settings'
+ );
+ add_settings_field(
+ 'thank_you_text',
+ 'Thank You Message',
+ array($this, 'glmclientinfoRenderTextArea'),
+ 'staffordsjobs_settings',
+ 'staffordsjobs_setting_section_two',
+ 'thank_you_text'
);
add_settings_section(
- 'staffordsjobs_main',
- __('Edit Jobs Settings', 'wordpress'),
+ 'staffordsjobs_setting_section',
+ 'Edit Notifications',
array($this, 'staffords_settings_section_callback'),
- 'job-setting-group'
+ 'staffordsjobs_settings'
);
$fieldNames = array(
array(
- 'name' => 'notificationEmail',
- 'label' => 'Notification Email Address',
+ 'name' => 'notification_name',
+ 'label' => 'Staffords Notify: Name',
+ 'type' => 'text'
+ ),
+ array(
+ 'name' => 'notification_email',
+ 'label' => 'Staffords Notify: Email',
+ 'type' => 'text'
+ ),
+ array(
+ 'name' => 'from_name',
+ 'label' => 'From: Name',
+ 'type' => 'text'
+ ),
+ array(
+ 'name' => 'from_email',
+ 'label' => 'From: Email',
+ 'type' => 'text'
+ ),
+ array(
+ 'name' => 'replyto_name',
+ 'label' => 'Reply-To: Name',
+ 'type' => 'text'
+ ),
+ array(
+ 'name' => 'replyto_email',
+ 'label' => 'Reply-To: Email',
'type' => 'text'
+ ),
+ array(
+ 'name' => 'notification_message',
+ 'label' => 'Notification Message',
+ 'type' => 'textarea'
+ ),
+ );
+ $terms = get_terms(
+ STAFFORDS_EMP_TAX_DEPARTMENTS,
+ array(
+ 'hide_empty' => false
)
);
+ foreach ($terms as $term) {
+ $termArray[] = $term->name;
+ $fieldNames[] = array(
+ 'name' => $term->slug . '_notification_name',
+ 'label' => $term->name . ': Name',
+ 'type' => 'text'
+ );
+ $fieldNames[] = array(
+ 'name' => $term->slug . '_notification_email',
+ 'label' => $term->name . ': Email',
+ 'type' => 'text'
+ );
+ }
foreach ($fieldNames as $field) {
$this->staffords_add_setting_text_field(
$field['type']
);
}
+ register_setting(STAFFORDS_EMP_SETTINGS, STAFFORDS_EMP_SETTING_NAME);
}
public function staffords_add_setting_text_field($name, $label, $type)
}
add_settings_field(
$name,
- __($label, 'wordpress'),
+ $label,
array($this, $callback),
- 'job-setting-group',
- STAFFORDS_EMP_SETTINGS,
+ 'staffordsjobs_settings',
+ 'staffordsjobs_setting_section',
$name
);
}
echo __('Employment Form Email Notification', 'wordpress');
}
+ public function staffords_settings_two_section_callback()
+ {
+ echo __('Employment Form Thank You', 'wordpress');
+ }
+
public function staffords_option_page_capability()
{
return STAFFORDS_EMP_NEW_CAPABILITY;
return $form;
}
+ public function get_job_application_properties()
+ {
+ if (!$this->appId) {
+ return false;
+ }
+
+ $sql = "
+ SELECT *
+ FROM " . $this->wpdb->prefix . STAFFORDS_EMP_FORM_TABLE . "
+ WHERE application = $this->appId
+ AND form_part = 1";
+ $form = $this->wpdb->get_row($sql, ARRAY_A);
+ $formsData = unserialize($form['form_data']);
+ //echo '<pre>data from form part table: ' . print_r($formsData, true) . '</pre>';
+ $options = array();
+ foreach ( $formsData as $row ) {
+ foreach ( $row as $elem ) {
+ if ( $elem['name'] == 'location_preference' ) {
+ foreach ( $elem['opts'] as $opt ) {
+ if ( $opt['checked'] ) {
+ $options[] = str_replace( 'location_preference_', '', $opt['name'] );
+ }
+ }
+ }
+ }
+ }
+ return $options;
+ }
+
public function email_owner()
{
- $to = 'steve@localhost';
- $name = 'Person Test';
- $email = 'user@gaslightmedia.com';
- $message .= "A new employment application has been submitted. To review this "
- . "application, log into your "
- . "Web site administration area.\n\n";
- $message .= admin_url() . "edit.php?post_type@staffords_jobs&page=applications\n\n";
- $headers = "From: Online Employment Application Form <server@gaslightmedia.com>\r\nReply-To: {$name} <{$email}>";
+ $properies_applied_for = $this->get_job_application_properties();
+ $plugin_options = get_option(STAFFORDS_EMP_SETTING_NAME);
+ if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) {
+ $jobData = get_post($jobId);
+ $this->jobTitle = $jobTitle = $jobData->post_title;
+ }
+ // get the notification emails for this plugin
+ $fromName = $plugin_options['from_name'];
+ $from = $plugin_options['from_email'];
+ $to = $plugin_options['notification_email'];
+ $name = $plugin_name['replyto_name'];
+ $email = $plugin_name['replyto_email'];
+ $message = $plugin_options['notification_message'];
+ $message .= admin_url() . "edit.php?post_type=staffords_jobs&page=applications\n\n";
+ $headers = array();
+ $headers[] = "From: {$fromName} <{$from}>";
+ $headers[] = "Reply-To: {$name} <{$email}>";
+ foreach ( $properies_applied_for as $cc_email ) {
+ $headers[] = "Cc: " . $plugin_options[$cc_email . '_notification_name'] . " <" . $plugin_options[$cc_email . '_notification_email']. ">";
+ }
+ // get the property for this application
+
+ $depTax = wp_get_post_terms( $job->ID, STAFFORDS_EMP_TAX_DEPARTMENTS, 'name' );
+ foreach ($depTax as $depTerm) {
+ $deps[] = $depTerm->name;
+ }
wp_mail(
$to,
'New Online Application Submission',