<?php
class Config {
    private static function getConfigValue($champ)  {
        $query = "SELECT * FROM config".ID_GARAGE." WHERE champ=:champ";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":champ", $champ);
        $statement->execute();
        $val = $statement->fetch();
        if($val == false) {
            return null;
        }
        return $val['valeur'];
    }

    private static function updateConfigValue($champ, $val)  {
        $query = "UPDATE config".ID_GARAGE." SET valeur=:val WHERE champ=:champ";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":champ", $champ);
        $statement->bindParam(":val", $val);
        return $statement->execute();
    }

    private static function getConfigValueOrDefault($champ, $default)  {
        $val = self::getConfigValue($champ);
        if(is_null($val)) {
            return $default;
        }
        return $val;
    }

    public static function getTVA() {
        return self::getConfigValue('TVA');
    }

    public static function getLigne1Adresse() {
        return self::getConfigValue('LIGNE1_ADRESSE');
    }

    public static function getLigne2Adresse() {
        return self::getConfigValue('LIGNE2_ADRESSE');
    }

    public static function getLigne3Adresse() {
        return self::getConfigValue('LIGNE3_ADRESSE');
    }

    public static function getLigne4Adresse() {
        return self::getConfigValue('LIGNE4_ADRESSE');
    }

    public static function getNoTelephone() {
        return self::getConfigValue('NO_TELEPHONE');
    }

    public static function getNoFax() {
        return self::getConfigValue('NO_FAX');
    }

    public static function getEmail() {
        return self::getConfigValue('EMAIL');
    }

    public static function getNoTVA() {
        return self::getConfigValue('NO_TVA');
    }

    public static function getNoIBAN() {
        return self::getConfigValue('NO_IBAN');
    }

    public static function getNoBIC() {
        return self::getConfigValue('NO_BIC');
    }

    public static function getUrlWeb() {
        return self::getConfigValue('URL_WEB');
    }

    public static function getAdresseFacture() {
        return self::getConfigValue('ADRESSE_FACTURE');
    }

    public static function getInfoRappel() {
        return self::getConfigValue('INFO_RAPPEL');
    }

    public static function getMontantRappel1() {
        return self::getConfigValueOrDefault('MONTANT_RAPPEL_1', 10);
    }

    public static function getMontantRappel2() {
        return self::getConfigValueOrDefault('MONTANT_RAPPEL_2', 20);
    }

    public static function getLogo() {
        return self::getConfigValue('LOGO');
    }

    public static function getGMMO() {
        return self::getConfigValue('GM_MO');
    }

    public static function getPrefixAchat() {
        return self::getConfigValue('PREFIX_ACHAT');
    }

    public static function getNbJoursAtelier() {
        return self::getConfigValueOrDefault('NB_JOURS_ATELIER', 22);
    }

    public static function getNoClient() {
        return self::getConfigValue('NO_CLIENT');
    }

    public static function updateNoClient($value) {
        return self::updateConfigValue('NO_CLIENT', $value);
    }

    public static function getSMSClient() {
        return self::getConfigValue('SMS_CLIENT_CONFIG');
    }

    public static function getSMSAtelier() {
        return self::getConfigValue('SMS_ATELIER');
    }

    public static function getSMSAnniversaire() {
        return self::getConfigValue('SMS_ANNIVERSAIRE');
    }
    
    public static function getSMSCommandeRecue() {
        return self::getConfigValue('SMS_COMMANDE_RECUE');
    }

    public static function getSMSCommandeRecueMontangeSansRDV() {
        return self::getConfigValue('SMS_COMMANDE_RECUE_MONTAGE_SANS_RDV_ATELIER');
    }
    
    public static function getSMSPieceRecuPourRDV() {
        return self::getConfigValue('SMS_PIECES_RECUES_POUR_RDV_ATELIER');
    }  

    public static function getVOIP() {
        return self::getConfigValue('VOIP');
    }  

    public static function getNbCaisse() {
        return self::getConfigValue('NBCAISSES');
    }

    public static function getImprimanteLocation() {
        return self::getConfigValue('IMPRIMANTE_LOCATION');
    }  

    public static function getLastRappel() {
        return self::getConfigValue('last_rappel');
    } 
    

    
}