} if ($_POST['action'] == 'extend') { $mysqli = Database::connect(); // check whether subscription has expired $employer = new Employer($_POST['employer']); if ($employer->has_free_job_postings() === false) { // check whether employer has paid job postings? if ($employer->has_paid_job_postings() === false) { // check whether subscription has expired $result = $employer->get_subscriptions_details(); if ($result[0]['expired'] < 0 || $result[0]['subscription_suspended'] != '0') { echo '-2'; exit; } } else { $employer->used_paid_job_posting(); } } else { $employer->used_free_job_posting(); } $query = "INSERT INTO job_extensions \n SELECT 0, id, created_on, expire_on, for_replacement, invoiced FROM jobs WHERE id = " . $_POST['job']; if (!$mysqli->execute($query)) { echo "ko"; exit; } $query = "SELECT expire_on \n FROM jobs \n WHERE id = " . $_POST['job'] . " LIMIT 1"; $result = $mysqli->query($query); $is_expired = sql_date_diff($result[0]['expire_on'], now()) <= 0 ? true : false; $expire_on = $result[0]['expire_on']; if ($is_expired) { $expire_on = now();