load->model('pagination/WalletIlinkTransaction_model', 'wit_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->wit_model->getRows($_POST); $i = $_POST['start']; foreach ($witData as $row) { $i++; $created = $row->date ; //date('jS M Y', strtotime($row->date)); // $status = ($row->status == 1)?'Active':'Inactive'; $operation = strtoupper($row->acteur) . ' - ' . ($this->session->userdata('site_lang') === 'french' ? $row->operation_fr : $row->operation_en); $numero_carte = join(" ", str_split($row->numero_carte, 4)); $moneyNetInit = Money::of(round($row->montant_net, 2), $row->init_currency, $this->context); $agent = $row->agent ? ($row->agent . " | " . $row->code_agent . " | " . $row->phone_agent) : ""; if ($row->destinataire_phone) { $destinataire = $row->destinataire_phone . ' | ' . $row->destinataire_name; } else { $destinataire = ($row->id_destinataire ? $row->id_destinataire . ' | ' : '') . ($row->nom_destinataire ? $row->nom_destinataire : '') . (' ' . $row->prenom_destinataire ? $row->prenom_destinataire : ''); } if ($row->user_phone) { $emetteur = $row->user_phone . ' | ' . $row->user; } else { $emetteur = ($row->nom_emetteur ? $row->nom_emetteur : '') . (' ' . $row->prenom_emetteur ? $row->prenom_emetteur : ''); } $moneyNetFinal = Money::of(round($row->montant_net_final_country, 2), $row->final_currency ? $row->final_currency : 'XAF', $this->context); $data[] = array($row->id_transaction, $operation, $numero_carte, $moneyNetInit->formatTo('fr_FR'), $moneyNetFinal->formatTo('fr_FR'), Money::of(round($row->part_reseau_payeur_final_country ? $row->part_reseau_payeur_final_country : 0, 2), $row->final_currency ? $row->final_currency : 'XAF', $this->context)->formatTo('fr_FR'), $this->lang->line($row->status_reseau_payeur), $row->final_currency, $row->pays_init,$row->pays_final, Money::of(round($row->frais,2), $row->init_currency,$this->context)->formatTo('fr_FR'), Money::of(round($row->taxe, 2),$row->init_currency,$this->context)->formatTo('fr_FR'),Money::of(round($row->commission_banque ? $row->commission_banque : 0, 2),$row->init_currency,$this->context)->formatTo('fr_FR'), Money::of(round($row->commission_hyp ? $row->commission_hyp : 0, 2),$row->init_currency,$this->context)->formatTo('fr_FR'),Money::of(round($row->commission_sup ? $row->commission_sup : 0 , 2),$row->init_currency,$this->context)->formatTo('fr_FR'), Money::of(round($row->commission_ag ? $row->commission_ag : 0, 2),$row->init_currency,$this->context)->formatTo('fr_FR'), $agent , $emetteur, $destinataire, $created); } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->wit_model->countAll($_POST), "recordsFiltered" => $this->wit_model->countFiltered($_POST), "data" => $data, ); // Output to JSON format echo json_encode($output); } }