From: Steve Sutton Date: Mon, 18 Jan 2016 17:23:28 +0000 (-0500) Subject: initial commit X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=45f9865a6c828098e92b37070c17bdd6d4349b7f;p=prog%2FEmploymentExport.git initial commit --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4015fd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tmp_c diff --git a/index.php b/index.php new file mode 100644 index 0000000..72c3d04 --- /dev/null +++ b/index.php @@ -0,0 +1,130 @@ +setTemplateDir('./tmp/'); +$smarty->setCompileDir('./tmp_c/'); +$smarty->setConfigDir('./configs/'); +$smarty->setCacheDir('./cache/'); + +$dbh = Toolkit_Database::getInstance(); + +$sql = " +SELECT * + FROM employment +ORDER BY employment_id"; + +$stmt = $dbh->query($sql); + +$getCategorySql = " + SELECT emp_cat_name + FROM emp_cat + WHERE emp_cat_id = :emp_cat_id"; +$getCategory = $dbh->prepare($getCategorySql); + +$getDepartmentSql = " + SELECT department_name + FROM department + WHERE department_id = :department_id"; +$getDepartment = $dbh->prepare($getDepartmentSql); + +$getTitleSql = " + SELECT title_name + FROM title + WHERE title_id = :title_id"; +$getTitle = $dbh->prepare($getTitleSql); + +$getEduSql = " + SELECT edu_req_name + FROM edu_req + WHERE edu_req_id = :edu_req_id"; +$getEdu = $dbh->prepare($getEduSql); + +$getLicSql = " + SELECT lic_req_name + FROM lic_req + WHERE lic_req_id = :lic_req_id"; +$getLic = $dbh->prepare($getLicSql); +$data = array(); + +function nicename($name) { + $name = str_replace('\'"', '', $name); + $name = str_replace(' ', '-', $name); + return strtolower($name); +} + +while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $prDate = mktime(); + $row['pubDate'] = date('r', $prDate); + $row['pr_date'] = date('Y-m-d H:i:s', $prDate); + if ($row['status'] == '1') { + $row['status'] = 'Full Time'; + } else if ($row['status'] == 2) { + $row['status'] = 'Part Time'; + } + $getTitle->bindParam(':title_id', $row['title_id'], PDO::PARAM_INT); + $getTitle->execute(); + $row['title'] = $getTitle->fetchColumn(); + $row['ping_name'] = nicename($row['title']); + + // for the description + $description = ''; + if ($row['edu_req_id']) { + $getEdu->bindParam(':edu_req_id', $row['edu_req_id'], PDO::PARAM_INT); + $getEdu->execute(); + $description .= '

Education Requirement: ' . $getEdu->fetchColumn().'

'; + } + if ($row['lic_req_id']) { + $getLic->bindParam(':lic_req_id', $row['lic_req_id'], PDO::PARAM_INT); + $getLic->execute(); + $description .= '

License/Certifications: ' . $getLic->fetchColumn().'

'; + } + if ($row['comments']) { + $description .= '

Comments: ' . $row['comments']; + } + if ($row['qualifications']) { + $description .= '

Primary Purpose: ' . $row['qualifications'].'

'; + } + if ($row['benefits']) { + $description .= '

Essential Responsibilities: ' . $row['benefits'].'

'; + } + if ($row['add_job_resp']) { + $description .= '

Additional Job Responsibilities: ' . $row['add_job_resp'].'

'; + } + if ($row['description']) { + $description .= '

General Information: ' . $row['description'].'

'; + } + $row['description'] = $description; + $data[$row['employment_id']] = $row; + // getting category + $getCategory->bindParam(':emp_cat_id', $row['emp_cat_id'], PDO::PARAM_INT); + $getCategory->execute(); + $categories = $getCategory->fetchAll(PDO::FETCH_ASSOC); + $data[$row['employment_id']]['categories'] = array(); + $data[$row['employment_id']]['start_date'] = mktime(); + $data[$row['employment_id']]['expire_date'] = strtotime($row['expire_date']); + foreach ($categories as $category) { + $data[$row['employment_id']]['categories'][] = array( + 'nicename' => nicename($category['emp_cat_name']), + 'name' => $category['emp_cat_name'] + ); + } + //getting department + $getDepartment->bindParam(':department_id', $row['department_id'], PDO::PARAM_INT); + $getDepartment->execute(); + $department = $getDepartment->fetchAll(PDO::FETCH_ASSOC); + $data[$row['employment_id']]['departments'] = array(); + foreach ($department as $department) { + $data[$row['employment_id']]['departments'][] = array( + 'nicename' => nicename($department['department_name']), + 'name' => $department['department_name'] + ); + } +} +$smarty->assign('created_date', date('Y-m-d H:i')); +$smarty->assign('exportTitle', 'Emmet County Government'); +$smarty->assign('siteUrl', 'www.emmetcounty.org'); +$smarty->assign('data', $data); +$smarty->display('wordPress.tpl'); + diff --git a/tmp/wordPress.tpl b/tmp/wordPress.tpl new file mode 100644 index 0000000..37b57c6 --- /dev/null +++ b/tmp/wordPress.tpl @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + {$exportTitle} + http://{$siteUrl} + + {$pubDate} + en-US + 1.2 + http://{$siteUrl} + http://{$siteUrl} + + 1Stevesteve@gaslightmedia.com + + + http://wordpress.org/?v=4.3.1 + {foreach $data as $row} + + {$row.title} + http://{$siteUrl}/{$row.ping_name}/ + {$row.pubDate} + + http://{$siteUrl}/?p={$row.employment_id} + + + + {$row.id} + {$row.pr_date} + {$row.pr_date} + closed + open + {$row.ping_name} + publish + 0 + 0 + emmet_jobs + + 0 + {foreach $row.categories as $category} + + {/foreach} + {foreach $row.departments as $department} + + {/foreach} + + _edit_last + + + + emmet_jobs_startdate + + + + emmet_jobs_enddate + + + + emmet_jobs_status + + + + emmet_jobs_pay_grade + + + + emmet_jobs_shift + + + + emmet_jobs_contact + + + + emmet_jobs_phone + + + + emmet_jobs_email + + + + emmet_jobs_comments + + + + emmet_jobs_code + + + + {/foreach} + +