From: Steve Sutton Date: Fri, 12 Dec 2014 18:19:48 +0000 (-0500) Subject: Work on putting hard coded template names into class variables. X-Git-Tag: v1.0.1~27 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=fee425152715f52cf043857afaf554278684b681;p=WP-Plugins%2Fglm-employment.git Work on putting hard coded template names into class variables. --- diff --git a/config/settings1.php b/config/settings1.php index 88c13ad..6894d8b 100644 --- a/config/settings1.php +++ b/config/settings1.php @@ -10,37 +10,43 @@ $lname = [ 'type' => 'text', 'name' => 'lname', 'label' => 'Last Name', - 'grid' => 5 + 'grid' => 5, + 'req' => true ]; $mname = [ 'type' => 'text', 'name' => 'mname', 'label' => 'Middle Name', - 'grid' => 2 + 'grid' => 2, + 'req' => true ]; $street = [ 'type' => 'text', 'name' => 'street', 'label' => 'Street', - 'grid' => 3 + 'grid' => 3, + 'req' => true ]; $city = [ 'type' => 'text', 'name' => 'city', 'label' => 'City', - 'grid' => 3 + 'grid' => 3, + 'req' => true ]; $state = [ 'type' => 'text', 'name' => 'state', 'label' => 'State', - 'grid' => 3 + 'grid' => 3, + 'req' => true ]; $zip = [ 'type' => 'text', 'name' => 'zip', 'label' => 'ZIP', - 'grid' => 3 + 'grid' => 3, + 'req' => true ]; $phone = [ diff --git a/config/settings3.php b/config/settings3.php index 48ebfb9..c94a815 100644 --- a/config/settings3.php +++ b/config/settings3.php @@ -267,6 +267,7 @@ $form = [ [$employment_title_sub4, $employment_dates_to4, $employment_supervisor4, $employment_salary_end4,$employment_position_sub4, $employment_reason_sub4], [$may_we_contact, $who_to_not_contact], + ['type' => 'header', 'label' => 'Education & Training'], [$edu_titleHdr, $edu_schoolHdr, $edu_yearsHdr, $edu_gradHdr, $edu_subjectHdr], [$edu_title2Hdr, $edu_school2Hdr, $edu_years2Hdr, $edu_grad_degreeHdr, $edu_grad_certificateHdr, $edu_subject2Hdr], [$edu_title1, $edu_school1, $edu_years1, $edu_grad_degree1, $edu_grad_certificate1, $edu_subject1], diff --git a/config/settings4.php b/config/settings4.php index 3356b37..aca8386 100644 --- a/config/settings4.php +++ b/config/settings4.php @@ -24,11 +24,161 @@ $military_branch = [ $military_date_entered = [ 'type' => 'text', 'name' => 'military_date_entered', - 'label' => 'Date Entered?', + 'label' => 'Date Entered', + 'grid' => 4, + 'req' => false +]; +$military_rank = [ + 'type' => 'text', + 'name' => 'military_rank', + 'label' => 'Rank at Discharge', + 'grid' => 4, + 'req' => false +]; +$military_discharge_date = [ + 'type' => 'text', + 'name' => 'military_discharge_date', + 'label' => 'Date of Discharge', + 'grid' => 4, + 'req' => false +]; +$military_reserves = [ + 'type' => 'radio', + 'name' => 'military_reserves', + 'label' => 'Are you in the reserves?', + 'grid' => 6, + 'req' => true, + 'opts' => [[ + 'name' => 'military_reserves_yes', + 'label' => 'Yes', + 'value' => 1 + ],[ + 'name' => 'military_reserves_no', + 'label' => 'No', + 'value' => 0]] +]; +$military_reserves_end = [ + 'type' => 'text', + 'name' => 'military_reserves_end', + 'label' => 'If yes, date obligation ends?', 'grid' => 6, 'req' => false ]; +$military_training = [ + 'type' => 'textarea', + 'name' => 'military_training', + 'label' => 'Special/technical training', + 'grid' => 12, + 'req' => false +]; +$crimes_in_past_7_years = [ + 'type' => 'radio', + 'name' => 'crimes_in_past_7_years', + 'label' => 'Have you ever been convicted of a crime in the past seven years?', + 'grid' => 6, + 'req' => true, + 'opts' => [[ + 'name' => 'crimes_in_past_7_years_yes', + 'label' => 'Yes', + 'value' => 1 + ],[ + 'name' => 'crimes_in_past_7_years_no', + 'label' => 'No', + 'value' => 0]] +]; +$crimes_explain = [ + 'type' => 'text', + 'name' => 'crimes_explain', + 'label' => 'If so, where, when ,and nature of offense?', + 'grid' => 6, + 'req' => false +]; +$training_skills = [ + 'type' => 'textarea', + 'name' => 'training_skills', + 'label' => 'Please provide any addional information such as special skills, ' + . 'training, management experiences, equipment operation or qualifications ' + . 'you feel will be helpful to us in considering your application', + 'grid' => 12, + 'req' => false +]; +$additional_info = [ + 'type' => 'textarea', + 'name' => 'additinal_info', + 'label' => 'State any additional information that you feel may be helpful ' + . 'to us in considering your application.', + 'grid' => 12, + 'req' => false +]; +$referenceReq = false; +$nameHdr = [ + 'type' => 'static', + 'label' => 'Name', + 'grid' => 3, + 'req' => $referenceReq +]; +$addressHdr = [ + 'type' => 'static', + 'label' => 'Address and Telephone', + 'grid' => 3, + 'req' => $referenceReq +]; +$relationshipHdr = [ + 'type' => 'static', + 'label' => 'Relationship', + 'grid' => 3, + 'req' => $referenceReq +]; +$yearHdr = [ + 'type' => 'static', + 'label' => 'Years Acquainted', + 'grid' => 3, + 'req' => $referenceReq +]; +for ($i = 1; $i <= 3; ++$i) { + $referenceReq = false; + ${'name'.$i} = [ + 'type' => 'text', + 'name' => 'name' . $i, + 'label' => '', + 'grid' => 3, + 'req' => $referenceReq + ]; + ${'address'.$i} = [ + 'type' => 'text', + 'name' => 'address' . $i, + 'label' => '', + 'grid' => 3, + 'req' => $referenceReq + ]; + ${'relationship'.$i} = [ + 'type' => 'text', + 'name' => 'relationship' . $i, + 'label' => '', + 'grid' => 3, + 'req' => $referenceReq + ]; + ${'year'.$i} = [ + 'type' => 'text', + 'name' => 'years' . $i, + 'label' => '', + 'grid' => 3, + 'req' => $referenceReq + ]; +} $form = [ - ['type' => 'header', 'label' => 'page 4'], - [$military_experience, $military_branch] + ['type' => 'header', 'label' => 'Military Service Record'], + [$military_experience, $military_branch], + [$military_date_entered, $military_rank, $military_discharge_date], + [$military_reserves, $military_reserves_end], + [$military_training], + ['type' => 'header', 'label' => 'Additional Information'], + [$crimes_in_past_7_years, $crimes_explain], + [$training_skills], + [$additional_info], + ['type' => 'header', 'label' => 'References'], + [$nameHdr, $addressHdr, $relationshipHdr, $yearHdr], + [$name1, $address1, $relationship1, $year1], + [$name2, $address2, $relationship2, $year2], + [$name3, $address3, $relationship3, $year3], ]; diff --git a/controllers/front.php b/controllers/front.php index 7d715fe..b58dde1 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -11,6 +11,9 @@ class glm_employment_front { // class properties public $pluginDirName; + public $viewDir; + public $adminViewDir; + public $frontViewDir; public $formSuccess; public $formFail; public $formSubmitted; @@ -28,6 +31,10 @@ class glm_employment_front // class constants const FORM_VAR = 'applyOnline'; const FORM_SETTINGS_DIR = 'config'; + const FORM_VIEW_DIR = 'views'; + const FINAL_FORM = 5; + const FORM_TEMPLATE = 'formTemplate.php'; + const SUCCESS_TEMPLATE = 'thankYou.php'; /** * Register Hooks and Actions @@ -42,6 +49,9 @@ class glm_employment_front $this->formTable = $wpdb->prefix . GLM_EMP_FORM_TABLE; $this->appTable = $wpdb->prefix . GLM_EMP_APPLICATION_TABLE; add_action('init', array($this, 'startJobSession')); + $this->viewDir = $this->pluginDirName . self::FORM_VIEW_DIR; + $this->adminViewDir = $this->viewDir . '/admin'; + $this->frontViewDir = $this->viewDir . '/front'; } public function set_form_state() @@ -73,7 +83,7 @@ class glm_employment_front $setting_file = $this->pluginDirName . self::FORM_SETTINGS_DIR . "/settings{$form_part}.php"; include $setting_file; - return (is_array($form)) ? $form : array(); + return $form; } public function show_apply_form() @@ -81,78 +91,64 @@ class glm_employment_front $formPart = (isset($_REQUEST['form_part'])) ? filter_var($_REQUEST['form_part'], FILTER_VALIDATE_INT) : false; + // form Action $formAction = ''; +// echo '
'.print_r($formPart, true).'
'; switch ($formPart) { - default: - unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']); - $form = $this->load_form_settings(1); - $formPart = 1; - include $this->pluginDirName . 'views/front/form_1.php'; - break; - case 1: - if ($this->formSubmitted) { - $form = $this->load_form_settings(1); - $this->form_process($form, 1); - $this->appId = $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT); - if (!$appId) { - // insert new application and form data - if ($this->fname) { - $this->store_application_data($form); - } - if ($this->appId) { - $this->store_form_data($form, 1); - } - } else { - // need to update form data - } - if ($this->errorCount > 0) { - include $this->pluginDirName . 'views/front/form_1.php'; - } else { - // next form part - $formPart = 2; - $appId = $this->appId; - $form = $this->load_form_settings(2); - include $this->pluginDirName . 'views/front/form_1.php'; - } - } else { - wp_die('An Error!:('); - } - break; - case 2: case 3: case 4: if ($this->formSubmitted) { - $form = $this->load_form_settings($formPart); - $this->form_process($form, $formPart); - +// $form = $this->load_form_settings($formPart); $this->appId = $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT); + $form = $this->form_process($formPart); +// echo '
'.print_r('appId:' . $this->appId, true).'
'; +// echo '
'.print_r($_POST, true).'
'; +// echo '
'.print_r('fname:' . $this->fname, true).'
'; +// echo '
'.print_r('form:' . $form, true).'
'; +// wp_die('test'); + if (!$this->appId && $this->fname) { + // insert new application and form data + $appId = $this->store_application_data($form); + } + //check for errors if ($this->errorCount > 0) { - include $this->pluginDirName . 'views/front/form_1.php'; + include $this->frontViewDir . self::FORM_TEMPLATE; } else { $this->store_form_data($form, $formPart); // next form part ++$formPart; - $form = $this->load_form_settings($formPart); - include $this->pluginDirName . 'views/front/form_1.php'; + if ($formPart == self::FINAL_FORM) { + include $this->frontViewDir . self::SUCCESS_TEMPLATE; + unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']); + } else { + $form = $this->load_form_settings($formPart); + include $this->frontViewDir . self::FORM_TEMPLATE; + } } } else { wp_die('An Error!:('); } break; + default: + unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']); + $formPart = 1; + $form = $this->load_form_settings($formPart); + include $this->frontViewDir . self::FORM_TEMPLATE; + break; } - echo '
'.print_r($_SESSION, true).'
'; +// echo '
'.print_r($_SESSION, true).'
'; } public function store_application_data($form) { if ($this->appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) { - return; + return $this->appId; } else if ($this->appId = filter_var($_SESSION['glmJobsApplication'], FILTER_VALIDATE_INT)) { - return; + return $this->appId; } $this->wpdb->insert( $this->appTable, @@ -171,11 +167,15 @@ class glm_employment_front ); $this->appId = $this->wpdb->insert_id; $_SESSION['glmJobsApplication'] = $this->appId; + return $this->appId; } public function store_form_data($form, $form_part) { // check if there's one stored first + if (!$this->appId) { + return false; + } $sql = " SELECT id FROM {$this->formTable} @@ -225,10 +225,10 @@ class glm_employment_front ); } - public function form_process(&$form, $part) + public function form_process($part) { $this->clean_post(); - $form = $this->load_form_settings($form, $part); + $form = $this->load_form_settings($part); foreach ($form as $rowKey => $row) { if ($row['type'] != 'header') { @@ -261,6 +261,7 @@ class glm_employment_front } } } + return $form; } public function clean_post() @@ -289,7 +290,7 @@ class glm_employment_front $applyOnlineHref = $current_url . ((strpos($current_url, '?')) ? '&' : '?') . self::FORM_VAR . "=1&job=" . $job->ID; - include $this->pluginDirName . 'views/front/jobDetail.php'; + include $this->frontViewDir . '/jobDetail.php'; return; } @@ -354,7 +355,7 @@ class glm_employment_front . ((strpos($current_url, '?')) ? '&' : '?') . "job=" . $job->ID; } - include $this->pluginDirName . 'views/front/jobList.php'; + include $this->frontViewDir . '/jobList.php'; return; } @@ -408,7 +409,7 @@ class glm_employment_front ); $form_url = home_url() . '/searchJobs/?search=1'; $categories = get_terms('glm_jobscategory'); - include $this->pluginDirName . 'views/front/jobSearch.php'; + include $this->frontViewDir . '/jobSearch.php'; } public function setPluginDir($dir) diff --git a/models/forms/builder.php b/models/forms/builder.php deleted file mode 100644 index 1e54580..0000000 --- a/models/forms/builder.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_builder - * - * Description of builder - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class builder -{ - public function buildForm($formData) - { - $form = ''; - if (isset($formData) && is_array($formData) && !empty($formData)) { - foreach ($formData as $rows) { - foreach ($row as $fields) { - - } - } - } else { - return false; - } - } -} diff --git a/models/forms/elementAbstract.php b/models/forms/elementAbstract.php deleted file mode 100644 index 3cc0ecc..0000000 --- a/models/forms/elementAbstract.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_element - * - * Description of element - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -abstract class elementAbstract -{ - public $name; - public $required; - public $validation; - public $label; - public $value; - public $filter; - - public function __construct($config) - { - foreach ($config as $prop => $value) { - if (isset($this->$prop)) { - $this->$prop = $value; - } else { - die('error: ' . $prop . ' not defined in object'); - } - - } - } -} diff --git a/models/forms/elementInterface.php b/models/forms/elementInterface.php deleted file mode 100644 index a17c9f7..0000000 --- a/models/forms/elementInterface.php +++ /dev/null @@ -1,17 +0,0 @@ - - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_form1 - * - * Description of form1 - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class form1 -{ - public $rows = array(); - - public function __construct() - { - - } -} diff --git a/models/forms/text.php b/models/forms/text.php deleted file mode 100644 index dd6f6e1..0000000 --- a/models/forms/text.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_text - * - * Description of text - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class text extends elementAbstract implements elementInterface -{ - - public function toArray() - { - - } - - public function toString() - { - - } -} diff --git a/models/forms/textarea.php b/models/forms/textarea.php deleted file mode 100644 index a32e8cc..0000000 --- a/models/forms/textarea.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_textarea - * - * Description of textarea - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class textarea implements elementInterface -{ - public function toArray() - { - - } - - public function toString() - { - - } - -} diff --git a/views/front/form.php b/views/front/form.php deleted file mode 100644 index 3c28b8a..0000000 --- a/views/front/form.php +++ /dev/null @@ -1,107 +0,0 @@ -
-
-

Online Application Form

-
- -

Name

-
-
- -
-
- -
-
- -
-
- -

Current Address

-
-
- -
-
- -
-
- -
-
- -
-
- -

Telephone#

-
-
- -
-
- -
-
- -
-
- -
-
- - /> - - /> - -
-
- - /> - - /> - -
-
- -
-
- - /> - - /> - -
-
-
-
- - /> - - /> - -
-
- -
-
- -
-
- -
-
-
-
- -
diff --git a/views/front/formTemplate.php b/views/front/formTemplate.php new file mode 100644 index 0000000..856fb84 --- /dev/null +++ b/views/front/formTemplate.php @@ -0,0 +1,130 @@ + +
+
+

+
+ + + + + + + +

+ +

+ + +

+ + +
+ +
+ class="error"> + + + + + + + + pattern="" + + name="" + type="text" + value="" /> + + + + + + pattern="" + + name="" + type="tel" + value="" /> + + + + + + pattern="" + + name="" + type="email" + value="" /> + + + + + + + + + + + + + pattern="" + + id="" + name="" + type="radio" + value="" + /> + + + + + + + + + pattern="" + + id="" + name="" + type="checkbox" + value="" + /> + + + + + + + +
+ +
+ + +
+
+ +
+
+
+
+ +
diff --git a/views/front/form_1.php b/views/front/form_1.php deleted file mode 100644 index 856fb84..0000000 --- a/views/front/form_1.php +++ /dev/null @@ -1,130 +0,0 @@ - -
-
-

-
- - - - - - - -

- -

- - -

- - -
- -
- class="error"> - - - - - - - - pattern="" - - name="" - type="text" - value="" /> - - - - - - pattern="" - - name="" - type="tel" - value="" /> - - - - - - pattern="" - - name="" - type="email" - value="" /> - - - - - - - - - - - - - pattern="" - - id="" - name="" - type="radio" - value="" - /> - - - - - - - - - pattern="" - - id="" - name="" - type="checkbox" - value="" - /> - - - - - - - -
- -
- - -
-
- -
-
-
-
- -
diff --git a/views/front/thankYou.php b/views/front/thankYou.php new file mode 100644 index 0000000..ec1cefd --- /dev/null +++ b/views/front/thankYou.php @@ -0,0 +1,3 @@ +
+ Thank you for your time. +