<?php

include_once("server/lib/mod_dbm/package.dbm.php");

class LocalesManager
{

    static function getLocales( $activeOnly = true)
    {
        $res = null;
        try {
            $q = "SELECT * FROM locales ORDER BY nombre";
            $dao = new dbObject();
            $res = $dao->fetchQuery($q);
        } catch (Exception $e) {
        }
        return $res;
    }
    static function getLocalCoords($idLocal){
        $q = sprintf("SELECT * FROM locales WHERE id_local = %d",$idLocal);
        $dao = new dbObject();
        $res = $dao->fetchQuery($q);
        if(is_array($res) && count($res)){
            $coords['lat'] = $res[0]['lat'];
            $coords['lng'] = $res[0]['lng'];
        } else {
            $coords = null;
        }
        return $coords;
    }
}
