backoffice/application/models/nano_credit_model.php

100 lines
3.4 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: capp
* Date: 29/05/2018
* Time: 15:49
*/
class Nano_Credit_model extends CI_Model
{
// Nano credit
public function insertCreditLimit($limit_min, $limit_max, $has_nano_credit, $id_network)
{
$sql = "UPDATE `configWallet` SET `has_nano_credit` = ?, `limite_credit_min` = ? , `limite_credit_max` = ? WHERE (`id_network` = ? );";
return $this->db->query($sql, array($has_nano_credit, $limit_min, $limit_max, $id_network));
}
public function insertNanoCreditSharedRates($taux_ag, $taux_sup, $taux_hyp, $id_network)
{
$sql = "UPDATE `configWallet` SET `taux_com_ag_nano_credit` = ?, `taux_com_sup_nano_credit` = ? , `taux_com_hyp_nano_credit` = ? WHERE (`id_network` = ? );";
return $this->db->query($sql, array($taux_ag, $taux_sup, $taux_hyp, $id_network));
}
public function getAllIlinkWorldNetworks()
{
$query = $this->db->query("SELECT networks.name AS network,networks.status AS status,networks.id,cc.name AS country,networks.country_id , configWallet.id_network , configWallet.type,cc.currency_code,
configWallet.limite_credit_min , configWallet.limite_credit_max , configWallet.has_nano_credit FROM `networks`
INNER JOIN countries_currencies cc ON networks.country_id=cc.id LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND configWallet.type = 'ilink'");
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
public function getUsersGroups($id_network)
{
$query = $this->db->query("SELECT * FROM infos_users_groups WHERE id_network = '" . $id_network . "'");
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
public function getNanoCreditRates($idConfig, $type = 'nano_credit')
{
$sql = "SELECT * FROM `paliersConfigNanoCredit` WHERE (`idConfig` = ? AND `type` = ? );";
$query = $this->db->query($sql, array($idConfig, $type));
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
public function deleteNanoCreditRates($idConfig, $type = 'nano_credit')
{
$sql = "DELETE FROM `paliersConfigNanoCredit` WHERE (`idConfig` = ? AND `type` = ? );";
$query = $this->db->query($sql, array($idConfig, $type));
return $query;
}
public function addNanoCreditRates($idConfig, $duree, $valeur, $type = 'nano_credit')
{
$sql = "INSERT INTO `paliersConfigNanoCredit` (`duree_mois`, `taux`, `idConfig` ,`type`) VALUES (?,?,?,?);";
$query = $this->db->query($sql, array($duree, $valeur, $idConfig, $type));
return $query;
}
public function getUserDemandesCredit($debut, $fin, $id_network)
{
$chain = $debut ? " AND date_creation BETWEEN '" . $debut . "' AND '" . $fin . "'" : "";
$query = $this->db->query("SELECT *
FROM infos_users_demandes_credits
WHERE `id_network`='" . $id_network . "'" . $chain);
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
public function getUsersSavings($debut, $fin, $id_network)
{
$chain = $debut ? " AND date_creation BETWEEN '" . $debut . "' AND '" . $fin . "'" : "";
$query = $this->db->query("SELECT *
FROM infos_users_epargnes
WHERE `id_network`='" . $id_network . "'" . $chain);
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
}