//handle edit if (isset($_POST['submit'])) { //concat the closing date values $year = intval($_POST['year_jb_closing_date']); $month = intval($_POST['month_jb_closing_date']); $month = $month < 10 ? '0' . $month : $month; $day = intval($_POST['day_jb_closing_date']); $day = $day < 10 ? '0' . $day : $day; $hour = intval($_POST['hour_jb_closing_date']); $hour = $hour < 10 ? '0' . $hour : $hour; $min = intval($_POST['min_jb_closing_date']); $min = $min < 10 ? '0' . $min : $min; $jb_closing_date = $year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $min . ':00'; //approval state. $approval_state = $_config['jb_posting_approval'] == 1 ? AT_JB_POSTING_STATUS_UNCONFIRMED : AT_JB_POSTING_STATUS_CONFIRMED; $job->updateJob($jid, $_POST['title'], $_POST['jb_description'], $_POST['jb_categories'], $_POST['jb_is_public'], $jb_closing_date, $approval_state); $msg->addFeedback('JB_POST_UPDATED_SUCCESS'); header('Location: home.php'); exit; } //load visual editor base on personal preferences if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) { if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) { $_POST['formatting'] = 1; $_REQUEST['settext'] = 0; $_REQUEST['setvisual'] = 0; } else { if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) { $_POST['formatting'] = 1; $_POST['settext'] = 0; $_POST['setvisual'] = 1;
public static function updateJobField($jobId, $jobFieldName, $jobFieldValue, $userId) { $job = array($jobFieldName => $jobFieldValue); $res = Job::updateJob($jobId, $job, $userId); return $res; }
public function postEditJob() { $data = \Input::get('data'); $_hash = new Hash(); $_hash = $_hash->getHasher(); if (!($job = \Job::findJobById(trim(\Input::get('job'))))) { return \Response::json(['type' => 'danger', 'message' => 'Job not found.']); } if (!($company = \Company::findCompanyById($_hash->decode($data['company'])))) { return \Response::json(['type' => 'danger', 'message' => 'Company not found.']); } if (!($agency = \Agency::getAgency())) { return \Response::json(['type' => 'danger', 'message' => 'Not an agency account.']); } if ($data['job_post_duration'] !== '0') { if (!$agency->is_vip) { $value = ['1' => -1, '2' => -3]; $checkValue = abs($value[$data['job_post_duration']]); if ($agency->credit < $checkValue) { return \Response::json(['type' => 'warning', 'message' => 'You have ' . $agency->credit . ' credit. You need at least ' . $checkValue . ' credit(s) to post this job.']); } } } $status = $company->agencies()->wherePivot('company_id', $company->id)->wherePivot('status', 'accept')->first(); if (!$status) { return \Response::json(['type' => 'danger', 'message' => 'You do not have permission from this company to post a job']); } $data['agency_id'] = $agency->id; $data['company_id'] = $company->id; if ($data['job_apply_type'] === 'job_apply_by_email') { if ($data['job_apply_application_email'] === '' && $data['job_apply_direct_email'] === '') { return \Response::json(['type' => 'warning', 'message' => 'Job application by email is chosen, please input at least one email.']); } $data['job_apply_details'] = json_encode(['type' => 'email', 'application_email' => $data['job_apply_application_email'], 'direct_email' => $data['job_apply_direct_email']]); } elseif ($data['job_apply_type'] === 'job_apply_by_url') { if ($data['job_apply_url'] === '') { return \Response::json(['type' => 'warning', 'message' => 'Job application by url is chosen, please input the application url.']); } $data['job_apply_details'] = json_encode(['type' => 'url', 'url' => $data['job_apply_url']]); } try { $job = \Job::updateJob($job, $data); if (!$agency->is_vip && $data['job_post_duration'] !== '0') { \Agency::updateCredit($agency, $value[$data['job_post_duration']]); } return \Response::json(['type' => 'success', 'message' => 'Job updated successfully.']); } catch (\Exception $e) { return \Response::json(['type' => 'danger', 'message' => env('APP_DEBUG') ? $e->getMessage() : 'Error, please contact webmaster.']); } }
public function postEditJob() { $data = \Input::get('data'); $job = \Job::findJobById(trim(\Input::get('job'))); $company = \Company::getCompany(); if ($job->company_id !== $company->id) { return \Response::json(['type' => 'danger', 'message' => 'You cannot edit the job that does not belong to you.']); } // if company not subscribed to 6 month contract, check the credit // TODO: update this to retrieve from db if ($data['job_post_duration'] !== '0') { if (!$company->is_vip) { $value = ['1' => -1, '2' => -3]; $checkValue = abs($value[$data['job_post_duration']]); if ($company->credit < $checkValue) { return \Response::json(['type' => 'warning', 'message' => 'You have ' . $company->credit . ' credit. You need at least ' . $checkValue . ' credit(s) to post this job.']); } } } $data['company_id'] = $company->id; // WTF? // TODO: move to model if ($data['job_apply_type'] === 'job_apply_by_email') { if ($data['job_apply_application_email'] === '' && $data['job_apply_direct_email'] === '') { return \Response::json(['type' => 'warning', 'message' => 'Job application by email is chosen, please input at least one email.']); } $data['job_apply_details'] = json_encode(['type' => 'email', 'application_email' => $data['job_apply_application_email'], 'direct_email' => $data['job_apply_direct_email']]); } elseif ($data['job_apply_type'] === 'job_apply_by_url') { if ($data['job_apply_url'] === '') { return \Response::json(['type' => 'warning', 'message' => 'Job application by url is chosen, please input the application url.']); } $data['job_apply_details'] = json_encode(['type' => 'url', 'url' => $data['job_apply_url']]); } try { $job = \Job::updateJob($job, $data); // if company not subscribed to 6 month contract, substract the credit if (!$company->is_vip && $data['job_post_duration'] !== '0') { \Company::updateCredit($company, $value[$data['job_post_duration']]); } return \Response::json(['type' => 'success', 'message' => 'Job updated successfully']); } catch (\Exception $e) { return \Response::json(['type' => 'danger', 'message' => env('APP_DEBUG') ? $e->getMessage() : 'Error, please contact webmaster.']); } }