$query .= ")"; $mysqli = Database::connect(); if (!$mysqli->execute($query)) { echo "ko"; exit; } echo "ok"; exit; } 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";
<?php require_once dirname(__FILE__) . "/../private/lib/utilities.php"; require_once dirname(__FILE__) . "/subscription_invoice.php"; session_start(); if (!isset($_POST['id'])) { echo "ko"; exit; //redirect_to('login.php'); } $xml_dom = new XMLDOM(); if ($_POST['action'] == 'get_subscriptions_details') { $employer = new Employer($_POST['id']); $result = $employer->get_subscriptions_details(); $result[0]['has_free_postings'] = $employer->has_free_job_postings() === false ? '0' : $employer->has_free_job_postings(); $result[0]['has_paid_postings'] = $employer->has_paid_job_postings() === false ? '0' : $employer->has_paid_job_postings(); $response = array('subscription' => $result[0]); header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array($response); exit; } if ($_POST['action'] == 'buy_subscriptions') { $mysqli = Database::connect(); $employer = new Employer($_POST['id']); // 1. generate invoice in the system $data = array(); $data['issued_on'] = today(); $data['type'] = 'J'; $data['employer'] = $_POST['id']; $data['payable_by'] = sql_date_add($data['issued_on'], $employer->get_payment_terms_days(), 'day'); $invoice = Invoice::create($data);