<?php

include_once "server/lib/mod_dbm/package.dbm.php";
include_once "server/class/LocationManager.php";


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of POI
 *
 * @author pc
 */
class POI {
    //put your code here
    private $id;
    private $name;
    private $lat;
    private $lng;
    private $iconId;
    private $activo;
    private $dao;
    private $groupId;
    private $orgId;
    private $locationId;

    function __construct() {
        $this->dao = new dbObject();
    }
    
    function insertPOI(){
        //$locationManager = new LocationManager($this->dao);
        //$location = $locationManager->getCloseLocation($this->lat, $this->lng,true);
        $poiInsertQ = sprintf("INSERT INTO pois (id_organizacion, lat, lng, nombre_poi, icon_id, location_id, activo) VALUES (%d,%s,%s,'%s',%d,%d,%d);", $this->orgId,$this->lat,$this->lng,$this->name,$this->iconId,$this->locationId,$this->activo);
        //return $this->dao->execute($insertQuery);
        $this->dao->execute($poiInsertQ);
        return $this->dao->getAutoInc();
    }
    
    function delete(){
        return $this->dao->execute(sprintf("UPDATE pois SET activo = 0 WHERE id_poi = %d",$this->id));
    }
    
    public function getId() {
        return $this->id;
    }

    public function getName() {
        return $this->name;
    }

    public function getLat() {
        return $this->lat;
    }

    public function getLng() {
        return $this->lng;
    }

    public function getIconId() {
        return $this->iconId;
    }

    public function getActivo() {
        return $this->activo;
    }

    public function getDao() {
        return $this->dao;
    }

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

    public function setName($name): void {
        $this->name = $name;
    }

    public function setLat($lat): void {
        $this->lat = $lat;
    }

    public function setLng($lng): void {
        $this->lng = $lng;
    }

    public function setIconId($iconId): void {
        $this->iconId = $iconId;
    }

    public function setActivo($activo): void {
        $this->activo = $activo;
    }

    public function setDao($dao): void {
        $this->dao = $dao;
    }
    public function getGroupId() {
        return $this->groupId;
    }

    public function setGroupId($orgId): void {
        $this->groupId = $orgId;
    }
    
    public function setLocationId($locationId){
        $this->locationId = $locationId;
    }
    
    public function getOrgId() {
        return $this->orgId;
    }

    public function setOrgId($orgId): void {
        $this->orgId = $orgId;
    }
}
