Пример #1
0
 /**
  * Calculates invoice numbers
  * @param array $row The invoice
  * @return array
  */
 public function calculateInvoice(array $row)
 {
     $model = new Events($this->db);
     $employerModel = new Employers($this->db);
     $totalBeforeTax = 0;
     // Get event price and add it to the total
     $totalBeforeTax += $row['event_price'];
     // Get employer info
     $employer = $employerModel->getAllEmployer($row['employer_id']);
     $employer = $employer[0];
     // Get Services for this employer in this event, multiply the service price by the quantity and add it to the total
     $services = $model->getEventEmployerServices($row['employer_id'], $row['event_id']);
     if ($services != null) {
         foreach ($services as $s) {
             $totalBeforeTax += $s['price'] * $s['quantity'];
         }
     }
     $requestedINV['total_before_tax'] = $totalBeforeTax;
     $totalAfterTax = $totalBeforeTax;
     // default values of taxes are 0
     $requestedINV['hst'] = $requestedINV['gst'] = $requestedINV['pst'] = 0;
     // check cases where tax is not exempt and add to total after tax accordingly
     if ($employer['hst_exempt'] === 0) {
         if ($employer['pst_exempt'] === 1) {
             $totalAfterTax = $totalBeforeTax * 1.05;
             $requestedINV['hst'] = $requestedINV['gst'] = $totalBeforeTax * 0.05;
         } else {
             $totalAfterTax = $totalBeforeTax * 1.13;
             $requestedINV['hst'] = $totalBeforeTax * 0.13;
             $requestedINV['gst'] = $totalBeforeTax * 0.05;
             $requestedINV['pst'] = $totalBeforeTax * 0.08;
         }
     }
     $requestedINV['total_after_tax'] = $totalAfterTax;
     return $requestedINV;
 }
Пример #2
0
    exit;
} elseif ($_GET['page'] === "show-registered-employers") {
    header('Content-Type: application/json; charset=utf-8');
    $employers = $model->getEventRegistrationEvent($_POST['id']);
    $l10n->addResource(__DIR__ . '/l10n/events.json');
    $l10n->localizeArray($employers, 'org_name');
    $l10n->localizeArray($employers, 'dep_name');
    echo json_encode(array("Event" => $model->getEvent($_POST['id']), "Employers" => $employers));
    exit;
} elseif ($_GET['page'] === "all-events") {
    header('Content-Type: application/json; charset=utf-8');
    $events = $model->getEventDetailWithName(trim(strip_tags($_GET['term'])));
    echo json_encode($events);
    exit;
} elseif ($_GET['page'] === "add-employers-to-event-dialog") {
    $allEmployers = $employerModel->getAllEmployer();
    $registeredEmployers = $model->getEventRegistrationEvent($_POST['id']);
    $registeredIDs = array();
    if (is_array($registeredEmployers)) {
        foreach ($registeredEmployers as $r) {
            $registeredIDs[] = intval($r['employer_id']);
        }
    }
    usort($allEmployers, function (array $a, array $b) {
        return strcmp($a["org_name_en"], $b["org_name_en"]);
    });
    // alphabetically sort organization names
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode(array('event_info' => $model->getEvent($_POST['id']), 'registered_ids' => array_unique($registeredIDs), 'all_employers' => $allEmployers));
    exit;
} elseif ($_GET['page'] === "get-employers-services-of-event") {
Пример #3
0
$SESSION = new \Zend_Session_Namespace('internal', true);
if (!isset($SESSION->lang)) {
    $SESSION->lang = DEFAULT_LANGUAGE;
}
$l10n->setLanguage($SESSION->lang);
//============================================================================================
// Model
//============================================================================================
$model = new Employers($dbo);
//============================================================================================
// Load the page requested by the user
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = 'employers';
    $employers = $model->getAllEmployer();
    $l10n->addResource(__DIR__ . '/l10n/employers.json');
    $l10n->localizeArray($employers, 'org_name');
    $l10n->localizeArray($employers, 'dep_name');
    $l10n->localizeArray($employers, 'website');
    $viewFile = 'views/employers.php';
} elseif ($_GET['page'] === "check-unique-employer") {
    $englishMap['org_name_en'] = $_POST['org_name_en'];
    $englishMap['dep_name_en'] = $_POST['dep_name_en'];
    $frenchMap['org_name_fr'] = $_POST['org_name_fr'];
    $frenchMap['dep_name_fr'] = $_POST['dep_name_fr'];
    $employerDetail["en_unique"] = sizeof($model->getEmployerByMap($englishMap)) === 0;
    $employerDetail["fr_unique"] = sizeof($model->getEmployerByMap($frenchMap)) === 0;
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($employerDetail);
    exit;