Advertisement
jegtheme

edit-job-form.php

Jan 28th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.75 KB | None | 0 0
  1. <?php
  2. $job_id = apply_filters('jeg_job_id', 0);
  3.  
  4. $job = new WP_Query(array(
  5.     'post_type' => 'job',
  6.     'post__in' => array($job_id),
  7.     'orderby' => 'date',
  8.     'order' => 'desc',
  9.     'posts_per_page' => -1,
  10.     'post_status' => array('preview', 'pending', 'publish', 'expired')
  11. ));
  12.  
  13. if($job->have_posts()) {
  14.     while ($job->have_posts()) {
  15.         $job->the_post();
  16.         if(get_current_user_id() === get_the_author_meta('ID')) {
  17. ?>
  18. <form method="post">
  19.     <div class="row">
  20.  
  21.         <div class="col-md-12">
  22.             <div class="form-group">
  23.                 <label for="title"><?php _e('Job title', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  24.                 <input id="title" name="job_title" placeholder="<?php _e('Job Title, ex : Full Stack Web Developer', 'jobplanet-plugin'); ?>"  type="text" class="form-control" value="<?php the_title(); ?>">
  25.             </div>
  26.         </div>
  27.  
  28.         <?php if(apply_filters('jeg_show_company_form', true)) : ?>
  29.         <div class="col-md-12">
  30.             <div class="form-group">
  31.                 <label for="company_id"><?php _e('Company', 'jobplanet-plugin'); ?> </label>
  32.                 <select id="company_id" name="company_id" class="form-control chosen-select" data-placeholder="<?php _e('Choose company for this job vacancy', 'jobplanet-plugin'); ?>" >
  33.                     <?php
  34.                     $companies = jeg_get_current_user_company();
  35.                     $company = vp_metabox('jobplanet_job.company_id');
  36.                     if($companies) {
  37.                         foreach($companies as $corp) {
  38.                             ?>
  39.                             <option <?php if(isset($company)) { echo ( $company == $corp['value'] ) ? "selected" : ""; } ?> value="<?php echo esc_attr($corp['value']) ?>"><?php echo esc_attr($corp['label']) ?></option>
  40.                             <?php
  41.                         }
  42.                     }
  43.                     ?>
  44.                 </select>
  45.             </div>
  46.         </div>
  47.         <?php endif; ?>
  48.  
  49.         <div class="col-md-12">
  50.             <div class="form-group">
  51.                 <label for="application_email"><?php _e('Notification Email', 'jobplanet-plugin'); ?></label>
  52.                 <input id="application_email" name="application_email" placeholder="<?php _e('Notification email sent', 'jobplanet-plugin'); ?>"  type="text" class="form-control" value="<?php echo vp_metabox('jobplanet_job.application_email'); ?>">
  53.                 <small class="color-white-mute"><?php _e('Leave the notification email address field empty if you wish to send notifications to your default user registration email', 'jobplanet-plugin'); ?></small>
  54.             </div>
  55.         </div>
  56.  
  57.         <?php if(apply_filters('jeg_featured_listing_form', false)) : ?>
  58.         <div class="col-md-12">
  59.             <div class="form-group">
  60.                 <label for="application_email"><?php _e('Featured Listing', 'jobplanet-plugin'); ?></label>
  61.                 <div class="checkbox flat-checkbox">
  62.                     <label>
  63.                         <input type="checkbox" name="featured" value="1" <?php echo vp_metabox('jobplanet_job.featured') == 1  ? "checked" : "";  ?>>
  64.                         <span class="fa fa-check"></span>
  65.                         <?php _e('Feature this job listing', 'jobplanet-plugin'); ?>
  66.                     </label>
  67.                 </div>
  68.                 <small class="color-white-mute"><?php _e('By enabling this feature, your job vacancy listing will be shown at the top of the job listings search feature', 'jobplanet-plugin'); ?></small>
  69.             </div>
  70.         </div>
  71.         <?php endif; ?>
  72.  
  73.         <div class="col-md-12">
  74.             <div class="form-group">
  75.                 <label for="title"><?php _e('Job Description', 'jobplanet-plugin'); ?></label>
  76.                 <?php
  77.                 wp_editor(get_the_content(), 'description', array(
  78.                     'textarea_name' => 'description',
  79.                     'drag_drop_upload' => false,
  80.                     'media_buttons' => false,
  81.                     'textarea_rows' => 10,
  82.                     'teeny' => true,
  83.                     'quicktags' => false
  84.                 ));
  85.                 ?>
  86.                 <small class="color-white-mute"><?php _e('You may use the job template as a starter in writing your job description, you may also use your own format for the job description.', 'jobplanet-plugin'); ?></small>
  87.             </div>
  88.         </div>
  89.  
  90.         <div class="col-md-12">
  91.             <div class="form-group">
  92.                 <label for="job_type"><?php _e('Job Type', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  93.                 <select id="job_type" name="job_type" class="form-control chosen-select" data-placeholder="<?php _e('Job Type', 'jobplanet-plugin'); ?>" >
  94.                     <?php
  95.                     $types = jeg_get_job_type();
  96.                     $jobtype = jeg_extract_id_term(get_the_terms(get_the_ID(), 'job-type'));
  97.                     if($types) {
  98.                         foreach($types as $type) {
  99.                             ?>
  100.                             <option <?php if(isset($jobtype)) { echo in_array($type['value'], $jobtype)   ? "selected" : ""; } ?> value="<?php echo esc_attr($type['value']) ?>"><?php echo esc_attr($type['label']) ?></option>
  101.                             <?php
  102.                         }
  103.                     }
  104.                     ?>
  105.                 </select>
  106.             </div>
  107.         </div>
  108.  
  109.         <div class="col-md-12">
  110.             <div class="form-group">
  111.                 <label for="categories"><?php _e('Job Category', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  112.                 <div class="row">
  113.                     <?php
  114.                     $categories = jeg_get_job_category();
  115.                     $selected_category = jeg_extract_id_term(get_the_terms(get_the_ID(), 'job-category'));
  116.  
  117.                     if($categories) {
  118.                         $sizecategory = sizeof($categories);
  119.                         $repeatdone = ceil($sizecategory / 2);
  120.  
  121.                         foreach ($categories as $index => $category) {
  122.                             if($index % $repeatdone === 0)
  123.                             {
  124.                                 echo "<!-- buka --><div class='col-md-6'>";
  125.                             }
  126.                             ?>
  127.                             <div class="checkbox flat-checkbox">
  128.                                 <label>
  129.                                     <input type="checkbox" name="categories[]" value="<?php echo esc_attr($category['value']) ?>" <?php if(isset($selected_category)) { echo in_array($category['value'], $selected_category) ? "checked" : ""; } ?>>
  130.                                     <span class="fa fa-check"></span>
  131.                                     <?php echo esc_attr($category['label']) ?>
  132.                                 </label>
  133.                             </div>
  134.                             <?php
  135.                             if( ($index + 1) % $repeatdone === 0 )
  136.                             {
  137.                                 echo "</div> <!-- tutup -->";
  138.                             }
  139.                         }
  140.  
  141.                         if( ($index + 1) % $repeatdone !== 0 )
  142.                         {
  143.                             echo "</div> <!-- tutup -->";
  144.                         }
  145.                     }
  146.                     ?>
  147.                 </div>
  148.             </div>
  149.         </div>
  150.  
  151.         <div class="col-md-4">
  152.             <div class="form-group">
  153.                 <label for="salary_bottom"><?php _e('Minimum Salary', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  154.                 <input id="salary_bottom" placeholder="<?php _e('ex : 5000', 'jobplanet-plugin'); ?>" name="salary_bottom" type="text" class="form-control number" value="<?php echo vp_metabox('jobplanet_job.salary_bottom'); ?>">
  155.             </div>
  156.         </div>
  157.         <div class="col-md-4">
  158.             <div class="form-group">
  159.                 <label for="salary_top"><?php _e('Maximum Salary', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  160.                 <input id="salary_top" placeholder="<?php _e('ex : 10000', 'jobplanet-plugin'); ?>" name="salary_top" type="text" class="form-control number" value="<?php echo vp_metabox('jobplanet_job.salary_top'); ?>">
  161.             </div>
  162.         </div>
  163.         <div class="col-md-4">
  164.             <div class="form-group">
  165.                 <label for="salary_range"><?php _e('Salary Range', 'jobplanet-plugin'); ?> <span class="mandatory">*</span></label>
  166.                 <select id="salary_range" class="form-control chosen-select" name="salary_range">
  167.                     <?php $salary_range = vp_metabox('jobplanet_job.salary_range') ?>
  168.                     <option value="hourly"  <?php echo $salary_range === 'hourly' ? 'selected' : ''; ?>><?php _e('Hourly', 'jobplanet-plugin'); ?></option>
  169.                     <option value="weekly"  <?php echo $salary_range === 'weekly' ? 'selected' : ''; ?>><?php _e('Weekly', 'jobplanet-plugin'); ?></option>
  170.                     <option value="monthly" <?php echo $salary_range === 'monthly' ? 'selected' : ''; ?>><?php _e('Monthly', 'jobplanet-plugin'); ?></option>
  171.                     <option value="yearly"  <?php echo $salary_range === 'yearly' ? 'selected' : ''; ?>><?php _e('Yearly', 'jobplanet-plugin'); ?></option>
  172.                 </select>
  173.             </div>
  174.         </div>
  175.  
  176.         <div class="col-md-12">
  177.             <div class="form-group">
  178.                 <label for="closing"><?php _e('Closing Date', 'jobplanet-plugin'); ?></label>
  179.                 <input id="closing" name="closing" placeholder="<?php _e('Closing Date', 'jobplanet-plugin'); ?>"  type="text" class="form-control datetimepicker" value="<?php echo vp_metabox('jobplanet_job.closing'); ?>">
  180.                 <small class="color-white-mute"><?php _e('Closing date for applicants to apply for this job, leave empty if you do not have a closing date.', 'jobplanet-plugin'); ?></small>
  181.             </div>
  182.         </div>
  183.  
  184.         <div class="col-md-12">
  185.             <div class="white-space-20"></div>
  186.             <h4><?php _e('Job Location', 'jobplanet-plugin'); ?></h4>
  187.             <hr/>
  188.         </div>
  189.  
  190.         <div class="col-md-12">
  191.             <div class="form-group">
  192.                 <label for="location"><?php _e('Job Location', 'jobplanet-plugin'); ?> </label>
  193.                 <?php
  194.                 $location = jeg_extract_id_term(get_the_terms(get_the_ID(), 'job-location'));
  195.                 wp_dropdown_categories(array(
  196.                     'taxonomy' => 'job-location',
  197.                     'hide_empty' => 0,
  198.                     'hierarchical' => 1,
  199.                     'class' => 'form-control chosen-select',
  200.                     'name' => 'location',
  201.                     'selected' => isset($location) ? $location[0] : ''
  202.                 ));
  203.                 ?>
  204.             </div>
  205.         </div>
  206.  
  207.         <div class="col-md-12">
  208.             <div class="form-group">
  209.                 <label for="address"><?php _e('Address', 'jobplanet-plugin'); ?></label>
  210.                 <textarea id="address" class="form-control" name="address" placeholder="<?php _e("Enter Detail Address", 'jobplanet-plugin'); ?>" rows="4"><?php echo vp_metabox('jobplanet_job.address'); ?></textarea>
  211.             </div>
  212.         </div>
  213.  
  214.         <div class="col-md-12">
  215.             <div class="form-group">
  216.                 <label for="map_location"><?php _e('Location (Drag marker to the job\'s location)', 'jobplanet-plugin'); ?></label>
  217.                 <input type="hidden" name="map_location" class="form-control" id="map_location" value="<?php echo vp_metabox('jobplanet_job.map_location'); ?>">
  218.                 <div id="jobmap"></div>
  219.             </div>
  220.         </div>
  221.  
  222.         <div class="col-md-12">
  223.             <div class="white-space-20"></div>
  224.             <div class="form-group text-right">
  225.                 <input type="hidden" name="jeg_action" value="edit-job" />
  226.                 <input type="hidden" name="job_id" value="<?php echo esc_attr($job_id); ?>" />
  227.                 <?php if(apply_filters('jeg_is_create_vacancy', false)) : ?>
  228.                     <input type="hidden" name="is_create_vacancy" value="1" />
  229.                 <?php endif; ?>
  230.                 <input type="hidden" name="jobplanet_nonce" value="<?php echo esc_attr( wp_create_nonce('jobplanet') ); ?>"/>
  231.                 <input type="submit" class="btn btn-theme btn-t-primary btn-block-xs" value="<?php echo apply_filters('jeg_job_form_title', esc_html(__('Edit Job Vacancy', 'jobplanet-plugin'))); ?>"/>
  232.             </div>
  233.         </div>
  234.  
  235.     </div>
  236.  
  237.  
  238. </form>
  239. <?php
  240.         } else {
  241.             jeg_get_template_part('account/restricted-edit');
  242.         }
  243.     }
  244.     wp_reset_postdata();
  245. }
  246. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement