<?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' => "",
    'Location' => "",
    'Conditions' => "",
    'posted' => "all",
    'display' => "yes",
    'i_from' => 0,
    'i_limit' => 20
);



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


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

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

$ret['link'] = $link;

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

$log = ob_get_contents();
ob_end_clean();

$ret['log'] = $log;

$f = fopen(dirname(__FILE__) . "/ajax_log.txt", "wb");
fwrite($f, $log);
fclose($f);


echo json_encode($ret);
exit();