You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
438 lines
11 KiB
438 lines
11 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Personalization_model extends MY_Model{
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
|
|
$this->load->model("event_model");
|
|
$this->user_subscriber_reg_form_table = "user_subscriber_reg_form";
|
|
$this->banner = "frontoffice_banner";
|
|
$this->all = "*";
|
|
|
|
$this->footer = "frontoffice_footer";
|
|
$this->privacy = "frontoffice_privacy";
|
|
$this->description = "description";
|
|
$this->status = 1;
|
|
$this->logo = "frontoffice_logo";
|
|
}
|
|
|
|
public function get_user_subscriber_reg_form($active = null){
|
|
$this->db->select($this->all);
|
|
$this->db->from($this->user_subscriber_reg_form_table);
|
|
if($active){
|
|
$this->db->where('display_status', $active);
|
|
$this->db->where('field_status', 'active');
|
|
$this->db->order_by("sort", "asc");
|
|
}
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
public function update_user_subscriber_reg_form()
|
|
{
|
|
$ids = 0;
|
|
$req = "";
|
|
foreach ($_POST as $key => $value) {
|
|
if( $key == 'req')
|
|
$req = $value;
|
|
else if( $key == "ids")
|
|
$ids = $value;
|
|
|
|
$this->db->where('id', $ids);
|
|
$this->db->update($this->user_subscriber_reg_form_table, array(
|
|
'is_required' => $req
|
|
));
|
|
}
|
|
}
|
|
public function insert_contact_email($data)
|
|
{
|
|
$this->db->trans_start();
|
|
$query = "";
|
|
$successful = $this->db->query(
|
|
"INSERT INTO contact_email(c_fullname, c_email, c_category) VALUES (
|
|
?, ?, ?
|
|
)",
|
|
array(
|
|
"{$data['fname']} {$data['name']}",
|
|
"{$data['sender']}",
|
|
$data['nature']
|
|
)
|
|
);
|
|
$this->db->trans_complete();
|
|
}
|
|
public function upload_new_banner($arr = array() )
|
|
{
|
|
$this->db->where('default_banner', 1);
|
|
$this->db->update($this->banner, $arr);
|
|
}
|
|
private function get_university_id_by_domain($domain) {
|
|
$query = $this->db->select('id')
|
|
->from('user_cpay')
|
|
->where('domain', $domain)
|
|
->get();
|
|
|
|
if ($query->num_rows() > 0) {
|
|
return $query->row()->id;
|
|
}
|
|
return null;
|
|
}
|
|
public function upload_get_banner()
|
|
{
|
|
$domain = $_SERVER['HTTP_HOST'];
|
|
$university_id = (int) $this->get_university_id_by_domain($domain);
|
|
|
|
$this->db->where('user_cpay', $university_id);
|
|
$result = $this->db->get($this->banner);
|
|
if($result->num_rows() > 0){
|
|
$ret = $result->row();
|
|
$image = ( $ret->image != "") ? banner_bundle().$ret->image
|
|
: images_bundle()."/frontoffice/homepage/caroussel.png";
|
|
|
|
$description = ( $ret->description != "") ? $ret->description
|
|
: "<p> En remerciement de votre fidélité, <em>Company For Madagascar</em> vous propose d'assister gratuitement aux spectacles et événements ci-dessous. </p>" .
|
|
"<p> Réservez vos places en vous connectant au moyen de vos identifiants <em>LeMonde.fr</em> </p>";
|
|
|
|
return array(
|
|
"image" => $image ,
|
|
"description" => $description
|
|
);
|
|
}
|
|
}
|
|
|
|
public function get_privacy()
|
|
{
|
|
$this->db->select($this->description);
|
|
$this->db->where('status', $this->status);
|
|
$result = $this->db->get($this->privacy);
|
|
if($result->num_rows() > 0){
|
|
$ret = $result->row();
|
|
return $ret->description;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function append_privacy()
|
|
{
|
|
$this->db->select($this->all);
|
|
$this->db->from($this->privacy);
|
|
$query = $this->db->get();
|
|
return $query->row();
|
|
}
|
|
|
|
public function update_privacy($default = 1)
|
|
{
|
|
$this->db->where('id', $default );
|
|
$this->db->update($this->privacy, array(
|
|
'status' => $_POST['status'],
|
|
'description' => $_POST['description']
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
|
|
public function get_mentions_legales()
|
|
{
|
|
$this->db->select($this->description);
|
|
$this->db->where('status', $this->status);
|
|
$result = $this->db->get($this->footer);
|
|
if($result->num_rows() > 0){
|
|
$ret = $result->row();
|
|
return $ret->description;
|
|
}
|
|
return false;
|
|
}
|
|
public function append_mentions_legales()
|
|
{
|
|
$this->db->select($this->all);
|
|
$this->db->from($this->footer);
|
|
$query = $this->db->get();
|
|
return $query->row();
|
|
}
|
|
public function update_mentions_legales($default = 1)
|
|
{
|
|
$this->db->where('id', $default );
|
|
$this->db->update($this->footer, array(
|
|
'status' => $_POST['status'],
|
|
'description' => $_POST['description']
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function insert_logo($arr = array())
|
|
{
|
|
$id = 1;
|
|
$this->db->where('id',$id);
|
|
$q = $this->db->get($this->logo);
|
|
|
|
if ( $q->num_rows() > 0 )
|
|
{
|
|
$this->db->where('id',$id);
|
|
$this->db->update($this->logo,$arr);
|
|
|
|
$this->db->where('id !=',$id);
|
|
$this->db->delete($this->logo);
|
|
}
|
|
else
|
|
{
|
|
$this->db->set('id', $id);
|
|
$this->db->insert($this->logo,$arr);
|
|
}
|
|
}
|
|
public function get_logo()
|
|
{
|
|
$domain = $_SERVER['HTTP_HOST'];
|
|
$university_id = (int) $this->get_university_id_by_domain($domain);
|
|
$this->db->where('id',1);
|
|
$this->db->where('user_cpay',$university_id);
|
|
$query = $this->db->get($this->logo);
|
|
return $query->row_array();
|
|
}
|
|
|
|
public function get_heartstroke(){
|
|
|
|
$this->db->where('id',1);
|
|
$query = $this->db->get($this->logo);
|
|
$row = $query->result();
|
|
foreach($row as $key => $value){
|
|
$res = $value->image;
|
|
}
|
|
|
|
return $res;
|
|
// return $query->row_array();
|
|
}
|
|
|
|
public function contact_email_update($email){
|
|
$data = array(
|
|
'contact_email' => $email
|
|
);
|
|
|
|
$this->db->update('contact_email_info', $data);
|
|
|
|
if ($this->db->trans_status() === FALSE)
|
|
{
|
|
return false;
|
|
}else{
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
public function select_contact_email(){
|
|
$this->db->select('contact_email');
|
|
$this->db->from('contact_email_info');
|
|
$this->db->limit(1);
|
|
$result = $this->db->get();
|
|
if($result->num_rows() > 0){
|
|
$ret = $result->row();
|
|
return $ret->contact_email;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function add_nature_business($nature){
|
|
$data = array(
|
|
'nature_of_business' => $nature
|
|
);
|
|
$this->db->insert('contact_nature_of_business', $data);
|
|
if ($this->db->affected_rows() > 0)
|
|
{
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function getnature(){
|
|
$qry = $this->db->query("SELECT * FROM contact_nature_of_business");
|
|
if ( $qry->num_rows() > 0 ) {
|
|
return $qry->result();
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
public function getnaturebusiness($q){
|
|
$qry = $this->db->query("SELECT * FROM contact_nature_of_business where id = ?",array($q));
|
|
if ( $qry->num_rows() > 0 ) {
|
|
return $qry->row();
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function editNature($nid, $q){
|
|
$data = array(
|
|
'id' => $nid,
|
|
'nature_of_business' => $q,
|
|
);
|
|
$this->db->where('id', $nid);
|
|
$this->db->update('contact_nature_of_business', $data);
|
|
if ($this->db->affected_rows()>0) {
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public function deleteNature($q){
|
|
$this->db->query("DELETE FROM contact_nature_of_business WHERE id=?",array($q));
|
|
if ($this->db->affected_rows()>0) {
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//announcements
|
|
public function getLatestAnnouncement()
|
|
{
|
|
$this->db->select($this->all );
|
|
$this->db->where('status', 'enable');
|
|
$result = $this->db->get('announcement');
|
|
if($result->num_rows() > 0){
|
|
$ret = $result->row();
|
|
return array(
|
|
"id" => $ret->id,
|
|
"title" => $ret->title,
|
|
"content" => $ret->content,
|
|
"cookie_char" => $ret->cookie_char
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
public function save_announcement($random,$default = 1)
|
|
{
|
|
// $this->db->where('id', $default );
|
|
$this->db->where('status', 'enable');
|
|
$this->db->update('announcement', array(
|
|
'status' => 'disable',
|
|
));
|
|
|
|
$this->db->insert('announcement', array(
|
|
'title' => $_POST['announcement_title'],
|
|
'content' => $_POST['content'],
|
|
'expiration ' => $_POST['announcement_expiration'],
|
|
'status' => $_POST['status'],
|
|
'cookie_char' => $random
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function expireAnnouncement()
|
|
{
|
|
$datenow = date('y-m-d');
|
|
|
|
$this->db->where('expiration <=', $datenow);
|
|
$this->db->update('announcement', array(
|
|
'status' => 'disable',
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function check_enable_announcement()
|
|
{
|
|
$this->db->select($this->all );
|
|
$this->db->where('status', 'enable');
|
|
$result = $this->db->get('announcement');
|
|
|
|
if($result->num_rows() > 0){
|
|
return 'full';
|
|
}else{
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
public function enable_announcement($q,$random)
|
|
{
|
|
$this->db->select($this->all );
|
|
$this->db->where('status', 'enable');
|
|
$result = $this->db->get('announcement');
|
|
|
|
if($result->num_rows() > 0){
|
|
return 'full';
|
|
}else{
|
|
$this->db->where('id', $q);
|
|
$this->db->update('announcement', array(
|
|
'status' => 'enable',
|
|
'cookie_char' => $random
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
|
|
}
|
|
public function disable_announcement($q)
|
|
{
|
|
$this->db->where('id', $q);
|
|
$this->db->update('announcement', array(
|
|
'status' => 'disable',
|
|
'cookie_char' => ''
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function update_announcement($q,$title,$date,$content,$random)
|
|
{
|
|
$this->db->where('id', $q);
|
|
$this->db->update('announcement', array(
|
|
'title' => $title,
|
|
'expiration' => $date,
|
|
'content' => $content,
|
|
'cookie_char' => $random
|
|
));
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function delete_announcement($q)
|
|
{
|
|
$this->db->where('id', $q);
|
|
$this->db->delete('announcement');
|
|
|
|
return $this->db->affected_rows() ;
|
|
}
|
|
public function listannouncements()
|
|
{
|
|
$qry = $this->db->query( "SELECT * FROM announcement" );
|
|
if ( $qry->num_rows() > 0 ) {
|
|
return $qry->result();
|
|
}else{
|
|
return 0;
|
|
}
|
|
}
|
|
public function get_announcement($q)
|
|
{
|
|
$qry = $this->db->query( "SELECT * FROM announcement where id='$q'" );
|
|
if ( $qry->num_rows() > 0 ) {
|
|
return $qry->result();
|
|
}
|
|
}
|
|
|
|
public function update_homepage_title($title) {
|
|
$this->db->select('*');
|
|
$data = $this->db->get('frontoffice_homepage_title')->row();
|
|
if(!empty($data) || !is_null($data)) {
|
|
$this->db->set('title', $title);
|
|
$this->db->set('user_cpay', $data->user_cpay);
|
|
$this->db->where('id', $data->id);
|
|
|
|
return $this->db->update('frontoffice_homepage_title');
|
|
} else {
|
|
$$this->db->insert('frontoffice_homepage_title', [
|
|
"title" => $title,
|
|
"user_cpay" => $user_cpay
|
|
]);
|
|
return $this->db->insert_id();
|
|
}
|
|
}
|
|
public function get_homepage_title() {
|
|
$domain = $_SERVER['HTTP_HOST'];
|
|
$university_id = (int) $this->get_university_id_by_domain($domain);
|
|
$this->db->where("user_cpay", $university_id);
|
|
$this->db->select('*');
|
|
return $this->db->get('frontoffice_homepage_title')->row();
|
|
}
|
|
|
|
}
|
|
|
|
?>
|