'label' => 'How Many',
'grid' => 4
];
-if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) {
- $jobData = get_post($jobId);
- $jobTitle = $jobData->post_title;
-}
$position_applied_for = [
'type' => 'text',
'name' => 'position_applied_for',
'label' => 'Position Applied For',
'grid' => 6,
- 'value' => $jobTitle
+ 'value' => $this->jobTitle
];
$date_available_for_work = [
'type' => 'text',
'grid' => 3
];
}
+$resume_file = [
+ 'type' => 'file',
+ 'label' => 'Upload your resume',
+ 'grid' => 12
+];
$form = [
['type' => 'header', 'label' => 'Driver Experience and Qualification'],
[$date_of_birth, $date_of_birth_explain],
[$traffic_convictions_locations1, $traffic_convictions_date1, $traffic_convictions_charge1, $traffic_convictions_penalty1],
[$traffic_convictions_locations2, $traffic_convictions_date2, $traffic_convictions_charge2, $traffic_convictions_penalty2],
[$traffic_convictions_locations3, $traffic_convictions_date3, $traffic_convictions_charge3, $traffic_convictions_penalty3],
+ [$resume_file]
];
public $fname;
public $lname;
public $mname;
+ public $job;
public $resume;
public $appId;
public $formId;
+ public $jobTitle;
// class constants
const FORM_VAR = 'applyOnline';
$this->appId = $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT);
$form = $this->form_process($formPart);
// echo '<pre>'.print_r('appId:' . $this->appId, true).'</pre>';
-// echo '<pre>'.print_r($_POST, true).'</pre>';
// echo '<pre>'.print_r('fname:' . $this->fname, true).'</pre>';
// echo '<pre>'.print_r('form:' . $form, true).'</pre>';
// wp_die('test');
break;
default:
unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']);
+ if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) {
+ $jobData = get_post($jobId);
+ $this->jobTitle = $jobTitle = $jobData->post_title;
+ }
$formPart = 1;
- $form = $this->load_form_settings($formPart);
+ $form = $this->load_form_settings($formPart);
include $this->frontViewDir . '/' . self::FORM_TEMPLATE;
break;
}
-// echo '<pre>'.print_r($_SESSION, true).'</pre>';
+ }
+
+ public function store_resume_file()
+ {
+ echo '<pre>'.print_r($form, true).'</pre>';
+ if (!$appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) {
+ return false;
+ }
+ echo '<pre>'.print_r($_FILES, true).'</pre>';
+ preg_match("%\.[A-Za-z]*$%", $_FILES['resume_file']['name'], $ext);
+ $size = getImageSize($_FILES['resume_file']['tmp_name']);
+ $resumeFile = tempnam(GLM_EMP_UPLOAD_DIR, "RESUME");
+ unlink($resumeFile);
+ $resumeFile = $resumeFile.$ext[0];
+ if (move_uploaded_file($_FILES['resume_file']['tmp_name'], $resumeFile)) {
+ $resumeFile = basename($resumeFile);
+ $this->wpdb->update(
+ $this->appTable,
+ array('resume' => $resumeFile),
+ array('id' => $appId),
+ array('%s'),
+ array('%d')
+ );
+ }
}
public function store_application_data($form)
'create_time' => date('Y-m-d, h:i:s a'),
'fname' => $this->fname,
'lname' => $this->lname,
- 'mname' => $this->mname
+ 'mname' => $this->mname,
+ 'position' => $this->job
),
array(
'%s',
'%s',
'%s',
'%s',
+ '%d'
)
);
$this->appId = $this->wpdb->insert_id;
);
}
+ if (isset($_FILES['resume_file']) && !$_FILES['resume_file']['error']) {
+ $this->store_resume_file($form);
+ }
+
$this->formId = $this->wpdb->insert_id;
$_SESSION['glmJobsAppForm'] = array(
'id' => $this->formId,
{
$this->clean_post();
$form = $this->load_form_settings($part);
+ if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) {
+ $this->job = $jobId;
+ }
foreach ($form as $rowKey => $row) {
if ($row['type'] != 'header') {
defined('ABSPATH') or die();
define('GLM_EMP_PLUGIN_PATH_FILE', __FILE__);
-define('GLM_EMP_VERSION', '1.0');
+define('GLM_EMP_VERSION', '0.0.1');
define('GLM_EMP_VRS_OPTION_NAME', 'glm_jobs_db_version');
define('GLM_EMP_POST_TYPE', 'glm_jobs');
define('GLM_EMP_TAX_CATEGORIES', 'glm_jobscategory');
define('GLM_EMP_TAX_DEPARTMENTS', 'glm_jobsdepartment');
define('GLM_EMP_APPLICATION_TABLE', 'glm_jobs_application');
define('GLM_EMP_FORM_TABLE', 'glm_jobs_app_form');
+$wp_upload_dir = wp_upload_dir();
+define('GLM_EMP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/glm-emp/');
+define('GLM_EMP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/glm-emp/');
+if (!is_dir(GLM_EMP_UPLOAD_DIR)) {
+ // create the upload directory
+ $oldUmask = umask(0);
+ mkdir(GLM_EMP_UPLOAD_DIR, 0770);
+ umask($oldUmask);
+}
require_once 'controllers/admin.php';
require_once 'controllers/front.php';
fname TEXT NOT NULL,
lname TEXT NOT NULL,
mname TEXT DEFAULT '' NOT NULL,
+ position BIGINT(20) DEFAULT 0 NOT NULL,
resume TEXT DEFAULT '' NOT NULL,
archived BOOLEAN DEFAULT false NOT NULL,
UNIQUE KEY id (id)
{
$where = array();
if ($_POST['s']) {
-// var_dump($_POST);
$search = filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING);
$where[] = "CONCAT(UPPER(fname), UPPER(lname)) like '%".strtoupper($search)."%'";
}
$where[] = "archived <> true";
}
$sql = "
- SELECT id as ID,fname,lname,create_time
+ SELECT id as ID,fname,lname,create_time,archived,position,resume
FROM " . $this->wpdb->prefix . GLM_EMP_APPLICATION_TABLE . "
";
if (!empty($where)) {
$sql .= " WHERE ".implode(" AND ", $where);
}
-// var_dump($sql);
return $this->wpdb->get_results(
$sql,
ARRAY_A
case 'lname':
case 'position':
case 'create_time':
+ case 'archived':
+ case 'resume':
return $item[$column_name];
default:
return print_r($item,true); //Show the whole array for troubleshooting purposes
* @return string Text to be placed inside the column <td> (movie title only)
**************************************************************************/
function column_fname($item){
-
//Build row actions
- $actions = array(
- 'view' => sprintf(
- '<a href="?post_type=%s&page=%s&action=%s&application=%s">View</a>',
- GLM_EMP_POST_TYPE,
- $_REQUEST['page'],
- 'view',
- $item['ID']
- ),
- 'archive' => sprintf(
- '<a href="?post_type=%s&page=%s&action=%s&application=%s">Archive</a>',
- GLM_EMP_POST_TYPE,
- $_REQUEST['page'],
- 'archive',
- $item['ID']
- ),
- );
+ $urlFormat = '?post_type=%s&page=%s&action=%s&application=%s&archived=%d';
+ if ($archivedList = filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN)) {
+ $actions = array(
+ 'unarchive' => sprintf(
+ '<a href="'.$urlFormat.'">Unarchive</a>',
+ GLM_EMP_POST_TYPE,
+ $_REQUEST['page'],
+ 'unarchive',
+ $item['ID'],
+ $_REQUEST['archived']
+ ),
+ 'delete' => sprintf(
+ '<a href="'.$urlFormat.'">Delete Permanently</a>',
+ GLM_EMP_POST_TYPE,
+ $_REQUEST['page'],
+ 'delete',
+ $item['ID'],
+ $_REQUEST['archived']
+ ),
+ );
+ } else {
+ $actions = array(
+ 'view' => sprintf(
+ '<a href="?post_type=%s&page=%s&action=%s&application=%s">View</a>',
+ GLM_EMP_POST_TYPE,
+ $_REQUEST['page'],
+ 'view',
+ $item['ID']
+ ),
+ 'archive' => sprintf(
+ '<a href="?post_type=%s&page=%s&action=%s&application=%s">Archive</a>',
+ GLM_EMP_POST_TYPE,
+ $_REQUEST['page'],
+ 'archive',
+ $item['ID']
+ )
+ );
+ }
+
//Return the title contents
return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
);
}
+ function column_position($item)
+ {
+ if ($item['position']) {
+ $jobData = get_post($item['position']);
+ return $jobData->post_title;
+ } else {
+ return '';
+ }
+ }
+
+ function column_resume($item)
+ {
+ if ($item['resume'] && is_file(GLM_EMP_UPLOAD_DIR . $item['resume'])) {
+ $format = '<a href="%s%s">Resume File</a>';
+ return sprintf(
+ $format,
+ GLM_EMP_UPLOAD_URL,
+ $item['resume']
+ );
+ } else {
+ return '';
+ }
+ }
+
/** ************************************************************************
* REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
'fname' => 'First Name',
'lname' => 'Last Name',
+ 'resume' => 'Resume File',
'position' => 'Position',
'create_time' => 'Created'
);
* @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
**************************************************************************/
function get_bulk_actions() {
- $actions = array(
- 'archive' => 'Archive'
- );
+ if ($archivedList = filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN)) {
+ $actions = array(
+ 'delete' => 'Delete Permanently',
+ 'unarchive' => 'Unarchive'
+ );
+ } else {
+ $actions = array(
+ 'archive' => 'Archive'
+ );
+ }
+
return $actions;
}
//Detect when a bulk action is being triggered...
if( 'delete'===$this->current_action() ) {
- wp_die('Items deleted (or they would be if we had items to delete)!');
+// wp_die('Items deleted (or they would be if we had items to delete)!');
+ $applications = filter_var(
+ $_REQUEST['application'],
+ FILTER_VALIDATE_INT,
+ array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_FORCE_ARRAY)
+ );
+ $appId = filter_var($_REQUEST['application'], FILTER_VALIDATE_INT);
+ if (!$applications && $appId) {
+ $applications[0] = $appId;
+ }
+ foreach ($applications as $app) {
+ $sql = "
+ DELETE FROM " . $this->wpdb->prefix . GLM_EMP_APPLICATION_TABLE ."
+ WHERE id = {$app}";
+ $this->wpdb->query($sql);
+ $sql = "
+ DELETE FROM " . $this->wpdb->prefix . GLM_EMP_FORM_TABLE ."
+ WHERE application = {$app}";
+ $this->wpdb->query($sql);
+ }
}
if( 'archive'===$this->current_action() ) {
$applications = filter_var(
WHERE id = {$app}";
$this->wpdb->query($sql);
}
-// wp_die('Items archived (or they would be if we had items to archive)!');
}
-
+ if( 'unarchive'===$this->current_action() ) {
+ $applications = filter_var(
+ $_REQUEST['application'],
+ FILTER_VALIDATE_INT,
+ array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_FORCE_ARRAY)
+ );
+ $appId = filter_var($_REQUEST['application'], FILTER_VALIDATE_INT);
+ if (!$applications && $appId) {
+ $applications[0] = $appId;
+ }
+ foreach ($applications as $app) {
+ $sql = "
+ UPDATE " . $this->wpdb->prefix . GLM_EMP_APPLICATION_TABLE ."
+ SET archived = false
+ WHERE id = {$app}";
+ $this->wpdb->query($sql);
+ }
+ }
}
}
?>
<ul class="subsubsub">
- <li class="all"><a href="edit.php?post_type=<?php echo GLM_EMP_POST_TYPE;?>&page=applications">All</a> |</li>
+ <li class="all"><a href="edit.php?post_type=<?php echo GLM_EMP_POST_TYPE;?>&page=applications">Unarchived</a> |</li>
<li class="all"><a href="edit.php?post_type=<?php echo GLM_EMP_POST_TYPE;?>&page=applications&archived=1">Archived</a></li>
</ul>
<div class="row">
<div class="small-12 columns">
<h1><?php echo $formTitle;?></h1>
- <form method="post" action="<?php echo $formAction;?>">
+ <form method="post" action="<?php echo $formAction;?>" enctype="multipart/form-data">
<input type="hidden" name="<?php echo self::FORM_VAR;?>" value="1">
<input type="hidden" name="form_part" value="<?php echo $formPart;?>" />
<?php if ($appId):?>
<input type="hidden" name="appId" value="<?php echo $appId;?>">
<?php endif;?>
+ <?php if ($jobId):?>
+ <input type="hidden" name="job" value="<?php echo $jobId;?>">
+ <?php endif;?>
<?php foreach($form as $row):?>
<?php if ($row['type'] == 'header') :?>
<h3><?php echo $row['label'];?></h3>
<?php case 'static':?>
<?php echo $field['value'];?>
<?php break;?>
+ <?php case 'file':?>
+ <input type="file" name="resume_file">
+ <?php break;?>
<?php case 'textarea':?>
<textarea
<?php if ($field['error']){echo 'class="error"';}?>