<?php

class Client {
    
    protected $id;
    protected $client;
    protected $url_opac3d;
    protected $ip_agent;
    protected $url_testconfig;
    protected $url_monitoring;
    protected $url_infosclass;
    protected $erreur_agent;
    protected $erreur_config;
    protected $last_complet;
    protected $last_partiel;
    protected $infos_monitoring;
    protected $class_name;
    protected $class_version;
    protected $date_check;
    
    public function getId() {
        return $this->id;
    }

    public function getClient() {
        return $this->client;
    }

    public function getUrl_opac3d() {
        return $this->url_opac3d;
    }

    public function getIp_agent() {
        return $this->ip_agent;
    }

    public function getUrl_testconfig() {
        return $this->url_testconfig;
    }
    
    public function getUrl_monitoring() {
        return $this->url_monitoring;
    }
    
    public function getUrl_infosclass() {
        return $this->url_infosclass;
    }

    public function getErreur_agent() {
        return $this->erreur_agent;
    }

    public function getErreur_config() {
        return $this->erreur_config;
    }

    public function getLast_complet() {
        return $this->last_complet;
    }

    public function getLast_partiel() {
        return $this->last_partiel;
    }

    public function getInfos_monitoring() {
        return $this->infos_monitoring;
    }

    public function getClass_name() {
        return $this->class_name;
    }

    public function getClass_version() {
        return $this->class_version;
    }

    public function getDate_check() {
        return $this->date_check;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setClient($client) {
        $this->client = $client;
    }

    public function setUrl_opac3d($url_opac3d) {
        $this->url_opac3d = $url_opac3d;
    }

    public function setIp_agent($ip_agent) {
        $this->ip_agent = $ip_agent;
    }

    public function setUrl_testconfig($url_testconfig) {
        $this->url_testconfig = $url_testconfig;
    }
    
    public function setUrl_monitoring($url_monitoring) {
        $this->url_monitoring = $url_monitoring;
    }
    
    public function setUrl_infosclass($url_infosclass) {
        $this->url_infosclass = $url_infosclass;
    }

    public function setErreur_agent($erreur_agent) {
        $this->erreur_agent = $erreur_agent;
    }

    public function setErreur_config($erreur_config) {
        $this->erreur_config = $erreur_config;
    }

    public function setLast_complet($last_complet) {
        $this->last_complet = $last_complet;
    }

    public function setLast_partiel($last_partiel) {
        $this->last_partiel = $last_partiel;
    }

    public function setInfos_monitoring($infos_monitoring) {
        $this->infos_monitoring = $infos_monitoring;
    }

    public function setClass_name($class_name) {
        $this->class_name = $class_name;
    }

    public function setClass_version($class_version) {
        $this->class_version = $class_version;
    }

    public function setDate_check($date_check) {
        $this->date_check = $date_check;
    }

    public function save() {
        $reqSQL = "INSERT INTO client 
                    (id,
                     client,
                     url_opac3d,
                     ip_agent,
                     url_testconfig,
                     url_monitoring,
                     url_infosclass,
                     erreur_agent,
                     erreur_config,
                     last_complet,
                     last_partiel,
                     infos_monitoring,
                     class_name,
                     class_version,
                     date_check)
                    VALUES
                    ('".mysql_real_escape_string($this->id)."',
                     '".mysql_real_escape_string($this->client)."',
                     '".mysql_real_escape_string($this->url_opac3d)."',
                     '".mysql_real_escape_string($this->ip_agent)."',
                     '".mysql_real_escape_string($this->url_testconfig)."',
                     '".mysql_real_escape_string($this->url_monitoring)."',
                     '".mysql_real_escape_string($this->url_infosclass)."',
                     '".mysql_real_escape_string($this->erreur_agent)."',
                     '".mysql_real_escape_string($this->erreur_config)."',
                     '".mysql_real_escape_string($this->last_complet)."',
                     '".mysql_real_escape_string($this->last_partiel)."',
                     '".mysql_real_escape_string($this->infos_monitoring)."',
                     '".mysql_real_escape_string($this->class_name)."',
                     '".mysql_real_escape_string($this->class_version)."',
                     '".mysql_real_escape_string($this->date_check)."')
                    ON DUPLICATE KEY UPDATE
                     client = '".mysql_real_escape_string($this->client)."',
                     url_opac3d = '".mysql_real_escape_string($this->url_opac3d)."',
                     ip_agent = '".mysql_real_escape_string($this->ip_agent)."',
                     url_testconfig = '".mysql_real_escape_string($this->url_testconfig)."',
                     url_monitoring = '".mysql_real_escape_string($this->url_monitoring)."',
                     url_infosclass = '".mysql_real_escape_string($this->url_infosclass)."',
                     erreur_agent = '".mysql_real_escape_string($this->erreur_agent)."',
                     erreur_config = '".mysql_real_escape_string($this->erreur_config)."',
                     last_complet = '".mysql_real_escape_string($this->last_complet)."',
                     last_partiel = '".mysql_real_escape_string($this->last_partiel)."',
                     infos_monitoring = '".mysql_real_escape_string($this->infos_monitoring)."',
                     class_name = '".mysql_real_escape_string($this->class_name)."',
                     class_version = '".mysql_real_escape_string($this->class_version)."',
                     date_check = '".mysql_real_escape_string($this->date_check)."'";
        
        $rez = mysql_query($reqSQL);
        if($rez === false) {
            return false;
        }
        else {
            if(empty($this->id) || $this->id < 1)
                $this->id = mysql_insert_id();
            return true;
        }
    }
    
}
