Updates for front end output of search form and listings
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Jan 2016 16:37:18 +0000 (11:37 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Jan 2016 16:37:18 +0000 (11:37 -0500)
If no jobs currently avaible then display non available text.
If no jobs then don't show search.

controllers/front.php
views/front/jobList.php

index 3221ed7..bd59e3e 100644 (file)
@@ -90,7 +90,10 @@ class glm_employment_front
         } else if ($job_id) {
             $this->show_job($job_id);
         } else {
-            $this->search_form();
+            $number_of_jobs = $this->get_number_of_jobs();
+            if ($number_of_jobs) {
+                $this->search_form();
+            }
             $this->list_jobs();
         }
         $output = ob_get_contents();
@@ -431,6 +434,29 @@ class glm_employment_front
         return;
     }
 
+    public function get_number_of_jobs()
+    {
+        global $wpdb, $wp;
+        $midnight           = strtotime(date('Y-m-d',time()).' 00:00:00');
+        $args = array(
+            'post_type' => GLM_EMP_POST_TYPE,
+            'meta_query' => array(
+                array(
+                    'key'     => 'glm_jobs_enddate',
+                    'value'   => $midnight,
+                    'compare' => '>='
+                ),
+                array(
+                    'key'     => 'glm_jobs_startdate',
+                    'value'   => $midnight,
+                    'compare' => '<='
+                )
+            )
+        );
+        $jobs = get_posts($args);
+        return count($jobs);
+    }
+
     /**
      * List the jobs that are currently set to display
      * based on start and end dates
index 1cd1cc4..de4eec3 100644 (file)
@@ -7,6 +7,9 @@
             <div><strong>Status: </strong><?php echo $job->glm_jobs_status;?></div>
             <div><a href="<?php echo $job->href;?>">Full Job Description</a></div>
         </div>
-        <?php endforeach; endif;?>
+        <?php endforeach;?>
+        <?php else:?>
+        <h3>There are currently no positions available.</h3>
+        <?php endif;?>
     </div>
 </div>