<?php
/**
 * Created by PhpStorm.
 * User: IOAN
 * Date: 10/23/2015
 * Time: 1:41 PM
 */

require_once(dirname(__FILE__) . "/../../../adbcon.php");

ob_start();

$ret = array(
    "result" => 1,
    "error" => array()
);


$session = $_POST['session'];
$baseurl = $_POST['baseurl'];

$search = array(
    'job_cat_id' => "",
    'JobLocation' => "",
    'CountryOfOrigin' => "",
    'posted' => "all",
    'display' => "yes",
    'i_from' => 0,
    'i_limit' => 20
);



//echo '<pre>$_POST = ', var_export($_POST, true), '</pre>';


if(isset($_POST['cv']) && isset($_POST['cv']['display']) && $_POST['cv']['display'] == "yes") {
    $have_filters = true;
    $resumes = $_POST['cv'];
    foreach($search as $fld=>$val) {
        if(isset($resumes[$fld])) $search[$fld] = $resumes[$fld];
    }
    //echo '<pre>$search = ', var_export($search, true), '</pre>';
}

$filter = base64_encode(http_build_query($search));
$link = $baseurl . "/resumes/?filter=" . $filter;

$ret['link'] = $link;

$log = ob_get_contents();
ob_end_clean();

$ret['log'] = $log;

echo json_encode($ret);
exit();