Updating the taxonomy name to properties and redo the form to use them.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Dec 2015 20:28:10 +0000 (15:28 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Dec 2015 20:28:10 +0000 (15:28 -0500)
The form is now using these properties to build the form and will select
them off if the job is assigned to them.

config/settings1.php
controllers/front.php
models/job.php
views/front/formTemplate.php
views/front/jobSearch.php

index 67c0d03..3102a3c 100644 (file)
@@ -209,37 +209,25 @@ $salary_desired = [
     'label' => 'Salary Desired',
     'grid' => 6
 ];
+$properties = get_terms(STAFFORDS_EMP_TAX_DEPARTMENTS, array(
+    'heirarchical' => false,
+    'hide_empty'   => false
+));
+$opts = array();
+foreach ( $properties as $term ) {
+    $opts[] = array(
+        'name'  => 'location_preference_' . $term->slug,
+        'label' => $term->name,
+        'value' => $term->name
+    );
+}
 $location_preference = [
     'type'  => 'checkbox',
     'name'  => 'location_preference',
     'label' => 'Property',
-    'grid' => 12,
+    'grid'  => 12,
     'req'   => false,
-    'opts'  => [[
-        'name' => 'location_preference_bayview',
-        'label' => 'Bay View Inn',
-        'value' => 'Bay View Inn'
-    ],[
-        'name' => 'location_preference_crookedriver',
-        'label' => 'Crooked River Lodge',
-        'value' => 'Crooked River Lodge'
-    ],[
-        'name' => 'location_preference_perryhotel',
-        'label' => 'Perry Hotel',
-        'value' => 'Perry Hotel'
-    ],[
-        'name' => 'location_preference_pier',
-        'label' => 'Pier Restaurant',
-        'value' => 'Pier Restaurant'
-    ],[
-        'name' => 'location_preference_weathervane',
-        'label' => 'Weathervane Restaurant',
-        'value' => 'Weathervane Restaurant'
-    ],[
-        'name' => 'location_preference_drawbridge',
-        'label' => 'Drawbridge Bistro',
-        'value' => 'Drawbridge Bistro'
-    ]]
+    'opts'  => $opts
 ];
 $high_school_name = [
     'type'  => 'text',
index b4886c8..17f069c 100644 (file)
@@ -161,6 +161,26 @@ class staffords_employment_front
             }
             $formPart = 1;
             $form     = $this->load_form_settings($formPart);
+            $termArray = array();
+            if ( $jobId ) {
+                $terms = wp_get_post_terms( $jobId, STAFFORDS_EMP_TAX_DEPARTMENTS, 'name' );
+                foreach ($terms as $term) {
+                    $termArray[] = $term->name;
+                }
+                if ( !empty( $termArray ) ) {
+                    foreach ( $form as $key => $formPart ) {
+                        if ( is_array( $formPart[0] ) && $formPart[0]['name'] == 'location_preference' ) {
+                            foreach ( $termArray as $termName ) {
+                                foreach ( $formPart[0]['opts'] as $optkey => $option ) {
+                                    if ( $option['label'] == $termName ) {
+                                        $form[$key][0]['opts'][$optkey]['checked'] = 'checked';
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
             include $this->frontViewDir . '/' . self::FORM_TEMPLATE;
             break;
         }
index 3905b29..8f107ec 100644 (file)
@@ -436,19 +436,19 @@ class staffords_employment_job
         ));
 
         $labels = array(
-            'name'                       => _x('Departments',
+            'name'                       => _x('Properties',
                                                'taxonomy general name'),
-            'singular_name'              => _x('Department',
+            'singular_name'              => _x('Property',
                                                'taxonomy singular name'),
-            'search_items'               => __('Search Departments'),
-            'popular_items'              => __('Popular Departments'),
-            'all_items'                  => __('All Departments'),
+            'search_items'               => __('Search Properties'),
+            'popular_items'              => __('Popular Properties'),
+            'all_items'                  => __('All Properties'),
             'parent_item'                => null,
             'parent_item_colon'          => null,
-            'edit_item'                  => __('Edit Department'),
-            'update_item'                => __('Update Department'),
-            'add_new_item'               => __('Add New Department'),
-            'new_item_name'              => __('New Department Name'),
+            'edit_item'                  => __('Edit Property'),
+            'update_item'                => __('Update Property'),
+            'add_new_item'               => __('Add New Property'),
+            'new_item_name'              => __('New Property Name'),
             'separate_items_with_commas' => __('Separate departments with commas'),
             'add_or_remove_items'        => __('Add or remove departments'),
             'choose_from_most_used'      => __('Choose from the most used departments'),
@@ -457,7 +457,7 @@ class staffords_employment_job
         register_taxonomy(
             STAFFORDS_EMP_TAX_DEPARTMENTS, STAFFORDS_EMP_POST_TYPE,
             array(
-            'label'        => __('Job Department'),
+            'label'        => __('Job Property'),
             'labels'       => $labels,
             'hierarchical' => true,
             'show_ui'      => true,
@@ -479,7 +479,7 @@ class staffords_employment_job
             "cb"               => "<input type=\"checkbox\" />",
             "title"            => "Job Title",
             "glmjobs_col_cat"  => "Category",
-            "glmjobs_col_dep"  => "Department",
+            "glmjobs_col_dep"  => "Property",
             "glmjobs_col_date" => "Dates",
         );
         return $columns;
index a520a51..cd7fe1d 100644 (file)
                                 <?php endforeach;?>
                             <?php break;?>
                             <?php case 'checkbox':?>
-                                <?php foreach($field['opts'] as $option) :?>
+                                <?php $opCounter = 1; $totalOpts = count($field['opts']);?>
+                                <?php foreach($field['opts'] as $option) :?><label for="<?php echo $option['name'];?>"
+                                    class="small-12 medium-6 large-4 columns<?php if ($opCounter == $totalOpts) {echo ' end';}?>">
                                     <input
                                         <?php if (isset($field['error']) && $field['error']){echo 'class="error"';}?>
                                         <?php if (isset($field['req']) && $field['req']){echo 'required';}?>
                                         <?php if (isset($option['checked']) && $option['checked']) {
                                             echo 'checked';
                                         }?> />
-                                    <label for="<?php echo $option['name'];?>"><?php echo $option['label'];?></label>
+                                    <?php echo $option['label'];?></label>
+                                    <?php ++$opCounter;?>
                                 <?php endforeach;?>
                             <?php break;?>
                             <?php endswitch;?>
index 7dbaa99..39f5389 100644 (file)
@@ -7,11 +7,11 @@
             <?php wp_dropdown_categories( $cat_args );?>
         </div>
         <div class="small-12 medium-5 columns">
-            <label>Search by Department</label>
+            <label>Search by Property</label>
             <?php wp_dropdown_categories( $dep_args );?>
         </div>
         <div class="small-12 medium-2 columns">
             <input class="button" type="submit" value="Search">
         </div>
     </div>
-</form>
\ No newline at end of file
+</form>