Ejemplo n.º 1
0
    }
    $query = "INSERT INTO job_extensions \n              SELECT 0, id, created_on, expire_on, for_replacement, invoiced FROM jobs WHERE id = " . $_POST['id'];
    if (!$mysqli->execute($query)) {
        echo "ko";
        exit;
    }
    $query = "SELECT expire_on \n              FROM jobs \n              WHERE id = " . $_POST['id'] . " 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();
    }
    $data = array();
    $data['created_on'] = $expire_on;
    $data['expire_on'] = sql_date_add($data['created_on'], 30, 'day');
    $data['closed'] = 'N';
    $job = new Job($_POST['id']);
    if ($job->update($data) == false) {
        echo "ko";
        exit;
    }
    echo "ok";
    exit;
}
if ($_POST['action'] == 'get_currency') {
    $employer = new Employer($_POST['id']);
    $branch = $employer->get_branch();
    echo Currency::getSymbolFromCountryCode($branch[0]['country']);
    exit;
}
Ejemplo n.º 2
0
 $data['employer'] = $_POST['id'];
 $data['payable_by'] = sql_date_add($data['issued_on'], $employer->get_payment_terms_days(), 'day');
 $invoice = Invoice::create($data);
 if ($invoice === false) {
     echo 'ko';
     exit;
 }
 $desc = $_POST['period'] . ' month(s) of subscription';
 $item_added = Invoice::add_item($invoice, $_POST['amount'], '1', $desc);
 $items = array();
 $items[0]['itemdesc'] = $desc;
 $items[0]['amount'] = number_format($_POST['price'], '2', '.', ', ');
 $items[1]['itemdesc'] = 'Administration Fee';
 $items[1]['amount'] = number_format($_POST['admin_fee'], '2', '.', ', ');
 // 2. generate the PDF version to be attached to sales.xx and the employer
 $branch_raw = $employer->get_branch();
 $sales = 'sales.' . strtolower($branch_raw[0]['country']) . '@yellowelevator.com';
 $branch_raw[0]['address'] = str_replace(array("\r\n", "\r"), "\n", $branch_raw[0]['address']);
 $branch_raw['address_lines'] = explode("\n", $branch_raw[0]['address']);
 $currency = $_POST['currency'];
 $pdf = new SubscriptionInvoice();
 $pdf->AliasNbPages();
 $pdf->SetAuthor('Yellow Elevator. This invoice was automatically generated. Signature is not required.');
 $pdf->SetTitle($GLOBALS['COMPANYNAME'] . ' - Invoice ' . pad($invoice, 11, '0'));
 $pdf->SetCurrency($currency);
 $pdf->SetBranch($branch_raw);
 $pdf->AddPage();
 $pdf->SetFont('Arial', '', 10);
 $pdf->SetTextColor(255, 255, 255);
 $pdf->SetFillColor(54, 54, 54);
 $pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);