80 lines
2.5 KiB
PHP
Executable File
80 lines
2.5 KiB
PHP
Executable File
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
use Brick\Money\Context\AutoContext;
|
|
use Brick\Money\CurrencyConverter;
|
|
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
|
|
use Brick\Money\ExchangeRateProvider\PDOProvider;
|
|
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
|
|
use Brick\Money\Money;
|
|
|
|
class InsuranceSubscription extends CI_Controller
|
|
{
|
|
private $converter = null;
|
|
private $context = null;
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
// Load member model
|
|
$this->load->model('pagination/InsuranceSubscription_model', 'model');
|
|
|
|
// set to whatever your rates are relative to
|
|
$baseCurrency = 'USD';
|
|
|
|
// use your own credentials, or re-use your existing PDO connection
|
|
$pdo = new PDO('mysql:host=' . $this->db->hostname . ';dbname=' . $this->db->database, $this->db->username, $this->db->password);
|
|
|
|
$configuration = new PDOProviderConfiguration();
|
|
|
|
$configuration->tableName = 'exchange_rate';
|
|
$configuration->exchangeRateColumnName = 'exchange_rate';
|
|
$configuration->targetCurrencyColumnName = 'target_currency';
|
|
$configuration->sourceCurrencyCode = $baseCurrency;
|
|
|
|
// this provider loads exchange rates from your database
|
|
$provider = new PDOProvider($pdo, $configuration);
|
|
|
|
// this provider calculates exchange rates relative to the base currency
|
|
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
|
|
|
|
// this currency converter can now handle any currency pair
|
|
$this->converter = new CurrencyConverter($provider);
|
|
$this->context = new AutoContext();
|
|
|
|
}
|
|
|
|
|
|
function getLists()
|
|
{
|
|
$data = $row = array();
|
|
|
|
// Fetch member's records
|
|
$witData = $this->model->getRows($_POST);
|
|
|
|
$i = $_POST['start'];
|
|
$current_url = $_POST['currentURL'];
|
|
foreach ($witData as $row) {
|
|
$i++;
|
|
|
|
$bonus_amount = Money::of(round($row->total_bonus_amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR');
|
|
|
|
$data[] = array($i,$row->insurance_subscription_id, $row->lastname, $row->phone, $row->number_of_months, $row->number_of_beneficiaries,
|
|
$bonus_amount, mb_strtoupper($this->lang->line($row->state) ,'UTF-8'), $row->created_at,
|
|
'<a href="'.$current_url.'?history=insurance-subscriptions&id='.$row->insurance_subscription_id.'" class="btn btn-primary" > '.$this->lang->line('Voir plus...').'</a>');
|
|
}
|
|
|
|
$output = array(
|
|
"draw" => $_POST['draw'],
|
|
"recordsTotal" => $this->model->countAll($_POST),
|
|
"recordsFiltered" => $this->model->countFiltered($_POST),
|
|
"data" => $data,
|
|
);
|
|
|
|
// Output to JSON format
|
|
echo json_encode($output);
|
|
}
|
|
|
|
}
|