getting the job title from the old job title id
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 21 Sep 2017 20:36:59 +0000 (16:36 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 21 Sep 2017 20:36:59 +0000 (16:36 -0400)
using the old job title id to get the job title name

classes/data/dataJobs.php
models/admin/jobs/index.php
setup/adminTabs.php
setup/databaseScripts/create_database_V0.0.1.sql
views/admin/jobs/edit.html
views/admin/jobs/index.html

index bdd4b5d..7200d28 100644 (file)
@@ -146,7 +146,7 @@ class GlmDataJobs extends GlmDataAbstract
                 'type' => 'pointer',
                     'p_table' => GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . 'job_titles',
                     'p_field' => 'job_title',
-                    'p_orderby' => 'job_Title',
+                    'p_orderby' => 'job_title',
                 'use' => 'a'
             ),
             'descr' => array (
@@ -169,13 +169,13 @@ class GlmDataJobs extends GlmDataAbstract
                 'type' => 'text',
                 'use' => 'a'
             ),
-            'contactname' => array (
-                'field' => 'contactname',
+            'contact_name' => array (
+                'field' => 'contact_name',
                 'type' => 'text',
                 'use' => 'a'
             ),
-            'contactphone' => array (
-                'field' => 'contactphone',
+            'contact_phone' => array (
+                'field' => 'contact_phone',
                 'type' => 'text',
                 'use' => 'a'
             ),
index 709f016..c036c20 100644 (file)
@@ -277,18 +277,45 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                     $jobDeleteError = true;
                 }
                 $view_file = "index";
-                $job_titles = $job_titles->getList();
+                
                 $job_data = $this->getList();
                 break;
             default:
-                $job_data = $this->getList($where);
+//                $job_data = $this->getList($where);
+                $sql = "SELECT * FROM ". GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . "jobs";;
+                $job_data = $this->wpdb->get_results($sql, ARRAY_A);
+                $job_titles = $job_titles->getList();
+                $job_data_new = [];
+                $start = 0;
+                foreach($job_data as $job=>$data){
+                    // echo '<pre>', print_r($data), '</pre>';
+                    $title_text = false;
+                    // echo "<br>START + $start </br>";
+                    // echo '======================<br>';
+                    foreach($job_titles as $job=>$titles){
+                        // echo $data['title'] . " --data <br>";
+                        // echo $titles['old_id'] . " --title <br>";    
+                        if($data['title'] === $titles['old_id']){
+                            $title_text = $titles['job_title'];
+                            break;
+                        } else if($data['title'] === $titles['id']) {
+                            $title_text = $titles['job_title'];
+                            break;
+                        } 
+                    }
+                    $start++;
+                    $data['new_title'] = $title_text;
+                    $job_data_new[] = $data;
+                }
+                
+                echo '<pre>', print_r($job_data_new), '</pre>';
                 $view_file = 'index';
                 break;
         }
 //        echo '<pre>', print_r($this->getList()), '</pre>';
         // Compile template data
         $templateData = array(
-            'jobData'        => $job_data,
+            'jobData'        => $job_data_new,
             'memberList'     => $member_list,
             'lockedToMember' => $lockedToMember,
             'haveMember'     => $haveMember,
index c1dd7e0..eb01c70 100644 (file)
@@ -32,6 +32,7 @@
  * );
  *
  */
+
 if (current_user_can('glm_members_members')) {
     if (apply_filters('glm_members_permit_admin_members_jobTitles_tab', true)) {
 
index cb4d254..d5ccb80 100644 (file)
@@ -20,8 +20,8 @@ CREATE TABLE {prefix}jobs (
     salary TINYTEXT NULL ,
     email_location TINYTEXT NULL ,
     resume_location TINYTEXT NULL ,
-    contactname TINYTEXT NULL ,
-    contactphone TINYTEXT NULL ,
+    contact_name TINYTEXT NULL ,
+    contact_phone TINYTEXT NULL ,
     post_date DATETIME NULL DEFAULT NOW(),
     updated DATETIME NULL DEFAULT NOW(),
     visible BOOL NULL,
@@ -51,14 +51,14 @@ CREATE TABLE {prefix}job_titles (
 ----
 
 -- Job Titles default entries in table
-INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES
-(1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor');
+-- INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES
+-- (1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor');
 
 ----
 
 -- Job Titles default entries in table
 INSERT INTO {prefix}jobs ( 
-id,old_id,title,descr,salary, email_location,resume_location,contactname,contactphone,post_date,updated,visible, 
+id,old_id,title,descr,salary, email_location,resume_location,contact_name,contact_phone,post_date,updated,visible, 
 facility_operation,requirements,job_location,job_expiration,duration,deadline,position_available,
 company,member,benefits
 ) VALUES ( 1,1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'RESUME LOCATION','CONTACT NAME', '453-3443', NOW(),NOW(), true,
index c889f0e..d38278c 100644 (file)
             <div class="glm-small-12 glm-medium-2 glm-columns admin-job-label">
                 Job Title
             </div>
+            <!-- <pre>{$job.fieldData|@print_r}</pre> -->
             <div class="glm-small-12 glm-medium-2 glm-columns admin-job-input">
                 <select id="job_title" data-id="title" name="title">
                     <option value="">Select a Job Title</option>
-                    {$jobTitles|@print_r}
                     {foreach from=$jobTitles item=j}
                         {if 'fieldData'|array_key_exists:$job}
-                            <option value="{$j.id}" {if $job.fieldData.title.name == {$j.job_title}} selected="selected"{/if}>
+                        <!-- {$j|@print_r} -->
+                            <option value="{$j.id}" {if $job.fieldData.title.value == {$j.old_id}} selected="selected"{/if}>
                         {else if}
                             <option value="{$j.id}">
                         {/if}
                     Contact Name
             </div>
             <div class="glm-small-12 glm-medium-5 glm-columns admin-job-input">
-                <input type="text" name="contactname" {if $job.fieldData.contactname} value='{$job.fieldData.contactname}' {/if}>
+                <input type="text" name="contactname" {if $job.fieldData.contact_name} value='{$job.fieldData.contact_name}' {/if}>
             </div>
         </div>
        <!-- EMAIL TO -->
                     Contact Phone
             </div>
             <div class="glm-small-12 glm-medium-5 glm-columns admin-job-input">
-                <input type="text" name="contactphone" {if $job.fieldData.contactphone} value='{$job.fieldData.contactphone}' {/if}>
+                <input type="text" name="contactphone" {if $job.fieldData.contact_phone} value='{$job.fieldData.contact_phone}' {/if}>
             </div>
         </div>
        <!-- VISIBLE -->
index 7dbf365..ce644ef 100644 (file)
             <div class='glm-row admin-job-list-row'>
                 <div class="glm-small-12 glm-columns admin-job-list">
                     <div class="glm-row admin-job-data">
-                        <div class="job-title-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{$data.title}</div>
-                        <div class="job-company-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{$data.company}</div>
-                        <div class="job-member-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{$data.member}</div>
-                        <div class="job-date-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{$data.post_date.timestamp|date_format:"%Y-%m-%d"}</div>
+                        <div class="job-title-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{if $data.new_title} {$data.new_title} {else} &nbsp; {/if}</div>
+                        <div class="job-company-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{if $data.company} {$data.company} {else} &nbsp; {/if}</div>
+                        <div class="job-member-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{if $data.member} {$data.member} {else} &nbsp; {/if}</div>
+                        <div class="job-date-list glm-small-12 glm-medium-4 glm-large-3 glm-columns no-padding">{$data.post_date|date_format:"%Y-%m-%d"}</div>
                     </div>
                 </div>
                 <div class="glm-small-12 glm-columns admin-job-list">