protected function populateTables()
 {
     $locations = [['name' => "Ravenwood Golf Club", 'address' => "929 Lynaugh Rd.  \r\nVictor, NY 14564", 'phone' => '585-924-5100', 'url' => 'http://www.ravenwoodgolf.com/'], ['name' => "Mill Creek Golf Club", 'address' => "128 Cedars Ave.  \r\nRochester, NY 14428", 'phone' => '585-889-4110', 'url' => 'http://www.millcreekgolf.com/']];
     foreach ($locations as $location) {
         LocationModel::create($location);
     }
 }
Ejemplo n.º 2
0
 public function ad728Action()
 {
     //728*90
     $this->_layout = "empty";
     $jobsModel = new JobsModel();
     $city = LocationModel::city(ToolModel::getRealIpAddr());
     if ($city) {
         if (mb_substr($city, -1) == "市") {
             $city = mb_substr($city, 0, -1);
         }
         $jobs = $jobsModel->newJobsFromCity($city);
         if (!$jobs) {
             $jobs = $jobsModel->newJobs();
         } else {
             if (count($jobs) == 1) {
                 $addJobs = $jobsModel->newJobs();
                 shuffle($addJobs);
                 $jobs = array_merge($jobs, $addJobs);
                 $jobs = array_slice($jobs, 0, 2);
             }
         }
     } else {
         $jobs = $jobsModel->newJobs();
     }
     shuffle($jobs);
     $this->_mainContent->assign("job1", $jobs[0]);
     $this->_mainContent->assign("job2", $jobs[1]);
     $this->display();
 }
Ejemplo n.º 3
0
 /**
  * Insert new image into database.
  *
  * @param $sha1
  * @param $fileSize
  * @param $imageDescription
  * @param $tag
  * @param $location
  * @return Image
  */
 public function insert($sha1, $fileSize, $imageDescription, $tag, $location)
 {
     $image = new Image();
     $image->setHash($sha1);
     $image->setFileSize($fileSize);
     $image->setDescription($imageDescription);
     $dateCreated = gmdate("Y-m-d H:i:s");
     $image->setDateCreated($dateCreated);
     $query = $this->db->prepare("\n            INSERT INTO images (description, file_size, sha1_hash, date_created, tag_id, location_id)\n            VALUES(:description, :file_size, :sha1_hash, :date_created, :tag_id, :location_id)\n        ");
     $query->bindValue(":description", $imageDescription);
     $query->bindValue(":file_size", $fileSize);
     $query->bindValue(":sha1_hash", $sha1);
     $query->bindValue(":date_created", $dateCreated);
     if ($tag != null) {
         $tagModel = new TagModel($this->db);
         $myTag = $tagModel->getTagByValue($tag->getValue());
         if ($myTag == null) {
             $myTag = $tagModel->insert($tag->getValue());
         }
         $query->bindValue(":tag_id", $myTag->getId());
         $image->setTag($myTag);
     } else {
         $query->bindValue(":tag_id", 0);
     }
     if ($location != null) {
         $locationModel = new LocationModel($this->db);
         $myLocation = $locationModel->getLocationByValue($location->getLat(), $location->getLon());
         if ($myLocation == null) {
             $myLocation = $locationModel->insert($location->getLat(), $location->getLon());
         }
         $query->bindValue(":location_id", $myLocation->getId());
         $image->setLocation($myLocation);
     } else {
         $query->bindValue(":location_id", 0);
     }
     $query->execute();
     $image->setId($this->db->lastInsertId());
     return $image;
 }
Ejemplo n.º 4
0
 /**
  * Initialize the DisplayModel class
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     try {
         $pdo_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
         $this->db = new \PDO('mysql:host=' . _HOST_ . ';dbname=' . _DATABASE_, _LOGIN_, _PASSWORD_, $pdo_options);
         $this->db->exec('SET NAMES utf8');
     } catch (Exception $e) {
         throw new Exception('Connexion à la base de données impossible: ' . $e->getMessage());
     }
 }
Ejemplo n.º 5
0
<div id="content" class="NewEventContent">
    <h1 id="RegisterTitle">Entdecken</h1>

    <form method="post" action="NewEventInput.php">


        <label for="eventname" class="SettingsLabel"> Event Name </label> <br />
             <input type="text" name="eventname" class="ContentInput" id="eventname"> <br />

        <label for="NewEventTextarea" class="SettingsLabel">Beschreibung</label> <br />
            <textarea name="eventdescription" id="NewEventTextarea" class="NevEventTextarea"></textarea> <br />

        <label for="NewEventLocationSelection" class="SettingsLabel"> Ort: </label> <br />
            <select name="location" id="NewEventLocationSelection" class="NewEventDropdown">
                <?php 
$model = new LocationModel();
$temp = $model->getLocations();
while ($locations = sqlsrv_fetch_array($temp)) {
    $loc = $locations['name'];
    $locID = $locations['id'];
    echo "<option value='{$locID}' >{$loc}</option>";
}
?>
            </select>

        <a href="Event.php?action=NewPlace" id="NewLocLink">Neuer Ort</a> <br />

        <input type="submit" id="Submit" class="RegisterButton" value="Erstellen">
        <input type="reset" id="Reset" class="RegisterButton" value="Abbrechen">
    </form>
 public static function saveDistrictCityFromLatLng($lat, $lng, $accId, $isCashier)
 {
     $lat = trim($lat);
     $lng = trim($lng);
     if (self::IsNullOrEmptyString($lat) || self::IsNullOrEmptyString($lng)) {
         return;
     }
     $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng={$lat},{$lng}&result_type=administrative_area_level_3&key=" . self::$geoCodingServerKey;
     $json = json_decode(file_get_contents($url), true);
     $addressComponents = $json['results'][0]['address_components'];
     if (count($addressComponents) < 2) {
         return;
     }
     $district = strtoupper($addressComponents[0]['long_name']);
     $city = strtoupper($addressComponents[1]['long_name']);
     $loc = new LocationModel();
     $arrLoc = $loc->getWhere("district='{$district}' AND city='{$city}'");
     if (count($arrLoc) == 0) {
         $l = new LocationModel();
         $l->district = $district;
         $l->city = $city;
         if ($isCashier) {
             $l->cashier_visit_count = 1;
             $l->user_visit_count = 0;
         } else {
             $l->cashier_visit_count = 0;
             $l->user_visit_count = 1;
         }
         $l->visit_count = 1;
         $l->save();
     } else {
         $l = new LocationModel();
         $l->getByID($arrLoc[0]->id_location);
         if ($isCashier) {
             $l->cashier_visit_count = $l->cashier_visit_count + 1;
         } else {
             $l->user_visit_count = $l->user_visit_count + 1;
         }
         $l->save();
     }
     if ($accId != 0 && !$isCashier) {
         $user = new UserModel();
         $user->getByID($accId);
         $user->last_lat = $lat;
         $user->last_long = $lng;
         $user->last_city = $city;
         $user->last_district = $district;
         if (Generic::IsNullOrEmptyString($user->latitude)) {
             $user->latitude = $lat;
         }
         if (Generic::IsNullOrEmptyString($user->longitude)) {
             $user->longitude = $lng;
         }
         if (Generic::IsNullOrEmptyString($user->district)) {
             $user->district = $district;
         }
         if (Generic::IsNullOrEmptyString($user->city)) {
             $user->city = $city;
         }
         $user->save();
     }
 }
Ejemplo n.º 7
0
 public function sessionAction()
 {
     $id = Zend_Filter::filterStatic($this->getRequest()->getParam('id'), 'StripTags');
     if (is_numeric($id)) {
         try {
             $session = new SessionModel($id);
             $init = $session->getInitiative();
             $rootLoc = $init->getRootLocation();
             $treeString = LocationModel::walkTree($rootLoc->getMetadata('id'));
             $treeArray = explode(",", $treeString);
             $locations = array();
             foreach ($treeArray as $locId) {
                 $locations[] = new LocationModel($locId);
             }
             $this->view->locations = $locations;
             $this->view->session = $session;
             $this->view->init = $init;
         } catch (Exception $e) {
             $this->view->error = $e->getMessage();
             Globals::getLog()->err('ADMIN sessions error: ' . $this->view->error);
             $this->render('error');
             return false;
         }
     } else {
         $this->view->error = 'Invalid session ID';
         Globals::getLog()->err('ADMIN sessions error: ' . $this->view->error);
         $this->render('error');
         return false;
     }
 }
 public function ListAmphur($param)
 {
     $dataset = parent::ListAmphurProcess($param);
     $this->RenderOption($mode, $dataset, $param['current']);
 }
Ejemplo n.º 9
0
 public static function updateLocTree($locTree, $parentID = null, $rank = 0)
 {
     // FIXME: redundant validation
     if (self::validateLocTree($locTree)) {
         $locDataArr = array('fk_parent' => $parentID, 'title' => $locTree['title'], 'description' => $locTree['description'], 'enabled' => (int) $locTree['enabled'], 'rank' => $rank);
         if (is_numeric($locTree['id'])) {
             $loc = new LocationModel($locTree['id']);
             if ($loc) {
                 $loc->update($locDataArr);
             } else {
                 return false;
             }
         } elseif ('new-loc' === $locTree['id']) {
             $locID = self::create($locDataArr);
             $loc = new LocationModel($locID);
             if (!$loc) {
                 throw new Exception("Unable to create new location");
             }
         } else {
             throw new Exception('Invalid location ID: ' . $locTree['id']);
         }
         if (isset($locTree['children']) && is_array($locTree['children'])) {
             foreach ($locTree['children'] as $locKey => $childLoc) {
                 $updateRes = self::updateLocTree($childLoc, $loc->getMetadata('id'), $locKey);
             }
         }
     } else {
         throw new Exception('Invalid location tree');
     }
     return true;
 }
    public function pushLocation()
    {
        $identifier = time() . rand(0, 100);
        $l = new LocationModel();
        $arrCities = $l->getWhere("id_location!='0' GROUP BY city ORDER BY city ASC");
        ?>

        <div id="formgroup_city<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="city<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">City</label>

            <div class="col-sm-10">
                <select class="form-control" name="city<?php 
        echo $identifier;
        ?>
" id="city<?php 
        echo $identifier;
        ?>
">
                    <option value="-1" selected="">Select City</option>
                    <option value="0">ALL CITIES</option>
                    <?php 
        foreach ($arrCities as $city) {
            ?>
                        <option value="<?php 
            echo $city->city;
            ?>
"><?php 
            echo $city->city;
            ?>
</option>
                        <?php 
        }
        ?>

                </select>
                <span class="help-block" id="warning_city<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_district<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="district<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">District</label>

            <div class="col-sm-10">
                <select disabled class="form-control" name="district<?php 
        echo $identifier;
        ?>
"
                        id="district<?php 
        echo $identifier;
        ?>
">
                    <option value="-1" selected="">Select District</option>

                </select>
                <span class="help-block" id="warning_district<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_target_device<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="target_device<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Target User(s)</label>

            <div class="col-sm-10">
                <div class="input-group">
                    <input type="text" name="target_device<?php 
        echo $identifier;
        ?>
" value="0"
                           id="target_device<?php 
        echo $identifier;
        ?>
" class="form-control" disabled readonly>
                    <span class='input-group-addon'>User(s)</span>
                    <span class="help-block" id="warning_target_device<?php 
        echo $identifier;
        ?>
"></span>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_user_ids<?php 
        echo $identifier;
        ?>
" class="form-group" hidden>
            <label for="user_ids<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">User Ids</label>

            <div class="col-sm-10">
                <input type="text" name="user_ids<?php 
        echo $identifier;
        ?>
" value=""
                       id="user_ids<?php 
        echo $identifier;
        ?>
" class="form-control">
                <span class="help-block" id="warning_user_ids<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_title<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="title<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Title</label>

            <div class="col-sm-10">
                <input type="text" name="title<?php 
        echo $identifier;
        ?>
" value=""
                       id="title<?php 
        echo $identifier;
        ?>
" class="form-control">
                <span class="help-block" id="warning_title<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_message<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="message<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Message</label>

            <div class="col-sm-10">

                <textarea class="form-control" rows="5" id="message<?php 
        echo $identifier;
        ?>
"
                          name="message<?php 
        echo $identifier;
        ?>
"></textarea>
                <span class="help-block" id="warning_message<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_image<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="image<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Image</label>

            <div class="col-sm-10">
                <?php 
        $b = new \Leap\View\InputFoto("image{$identifier}", "image{$identifier}", "");
        $b->p();
        ?>
                <span class="help-block" id="warning_message<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <button type="button" class="btn btn-default" id="button_submit<?php 
        echo $identifier;
        ?>
">submit</button>
            </div>
        </div>

        <script>
            var targetDevice = $('#target_device<?php 
        echo $identifier;
        ?>
');
            var userIds = $('#user_ids<?php 
        echo $identifier;
        ?>
');
            var cities = $('#city<?php 
        echo $identifier;
        ?>
');
            var districts = $('#district<?php 
        echo $identifier;
        ?>
');

            cities.change(function () {
                districts.prop("disabled", false);
                var v = $(this).val();
                if (v == -1) {
                    targetDevice.val(0);
                    userIds.val("");
                    districts.prop("disabled", true);
                    return;
                } else if (v == 0) {
                    targetDevice.val(0);
                    userIds.val("");
                    districts.prop("disabled", true);
                }
                $.ajax({
                    method: "GET",
                    url: _sppath + "PushMR/getDistrictByCity",
                    data: {city: cities.val()}
                })
                    .done(function (msg) {
                        districts.empty();
                        districts.append($("<option></option>")
                            .attr("value", "-1")
                            .text("Select District"));
                        districts.append($("<option></option>")
                            .attr("value", "0")
                            .text("SELECT ALL"));
                        var json_obj = $.parseJSON(msg);
                        var status_code = json_obj.status_code;
                        if (status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        }
                        var results = json_obj.results;//parse JSON
                        var dist = results.district;
//                        console.log(results);
                        for (var i in dist) {
                            districts.append($("<option></option>")
                                .attr("value", dist[i].value)
                                .text(dist[i].text));
                        }
                        var user_count = json_obj.results.user_count;
                        var user_ids = json_obj.results.user_ids;
                        userIds.val(user_ids);
                        targetDevice.val(user_count);
                        districts.prop("disabled", results.length <= 0);
                    });

            });

            districts.change(function () {

                if (districts.val() == "-1") {
                    return;
                }
                $.ajax({
                    method: "GET",
                    url: _sppath + "PushMR/getUserCountInDistrict",
                    data: {
                        district: districts.val(),
                        city: cities.val()
                    }
                })
                    .done(function (msg) {
                        targetDevice.val(0);
                        var json_obj = $.parseJSON(msg);
                        var status_code = json_obj.status_code;
                        if (status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        }
                        var results = json_obj.results;//parse JSON

//                        console.log(results);
                        var user_count = json_obj.results.user_count;
                        targetDevice.val(user_count);
                        var user_ids = json_obj.results.user_ids;
                        userIds.val(user_ids);
                    });

            });

            $('#button_submit<?php 
        echo $identifier;
        ?>
').click(function () {
                var v<?php 
        echo $identifier;
        ?>
 = userIds.val();
                var tit<?php 
        echo $identifier;
        ?>
 = $('#title<?php 
        echo $identifier;
        ?>
').val();
                var msg<?php 
        echo $identifier;
        ?>
 = $('#message<?php 
        echo $identifier;
        ?>
').val();
                var img<?php 
        echo $identifier;
        ?>
 = $('#image<?php 
        echo $identifier;
        ?>
').val();
                if (v<?php 
        echo $identifier;
        ?>
 == ',' || v<?php 
        echo $identifier;
        ?>
 == '' || v<?php 
        echo $identifier;
        ?>
 == null) {
                    alert("No Target User");
                    return;
                }

                $.ajax({
                    method: "POST",
                    url: _sppath + "PushMR/pushByLocation",
                    data: {
                        id_users: v<?php 
        echo $identifier;
        ?>
,
                        title: tit<?php 
        echo $identifier;
        ?>
,
                        message: msg<?php 
        echo $identifier;
        ?>
,
                        image: img<?php 
        echo $identifier;
        ?>
                    }
                })
                    .done(function (msg) {
                        console.log(msg);
                        var json_obj = $.parseJSON(msg);//parse JSON

                        if (json_obj.status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        } else {
                            alert("Success");
                            var psh = json_obj.results.push;
                        }
                        lwrefresh("PushLocation");
                    });
            });
        </script>
        <?php 
    }
Ejemplo n.º 11
0
 /**
  * Get all tags around some location within some $radius.
  *
  * @param $lat
  * @param $lon
  * @param $radius
  * @return array
  */
 public function getTagsAroundLocation($lat, $lon, $radius)
 {
     $locationModel = new LocationModel($this->db);
     $locations = $locationModel->getLocations($lat, $lon, $radius);
     $locationsIds = array();
     foreach ($locations as $location) {
         $locationsIds[] = $location->getId();
     }
     $tagIds = array();
     $query = $this->db->prepare("SELECT tag_id FROM images WHERE location_id IN(" . implode(',', $locationsIds) . ")");
     $query->setFetchMode(PDO::FETCH_ASSOC);
     $query->execute();
     while ($row = $query->fetch()) {
         $tagId = $row['tag_id'];
         if (!in_array($tagId, $tagIds)) {
             $tagIds[] = $tagId;
         }
     }
     $tags = array();
     $tagModel = new TagModel($this->db);
     foreach ($tagIds as $id) {
         $tag = $tagModel->getTagById($id);
         if ($tag != null) {
             $tags[] = $tag;
         }
     }
     return $tags;
 }
Ejemplo n.º 12
0
 public function ListDistrict($param)
 {
     $data = parent::ListDistrictProcess(array('city_id' => $param['city_id']));
     $CityData = $this->GetCity(array('city_id' => $param['city_id']));
     $this->ToJson($data, $CityData, 'district');
 }
 public function constraints()
 {
     $err = array();
     if (!isset($this->name)) {
         $err['name'] = Lang::t('Name cannot be empty');
     }
     if (!isset($this->address)) {
         $err['address'] = Lang::t('address cannot be empty');
     }
     if (!isset($this->district)) {
         $err['district'] = Lang::t('District cannot be empty');
     }
     if (!isset($this->city)) {
         $err['city'] = Lang::t('City cannot be empty');
     }
     if (!isset($this->email)) {
         $err['email'] = Lang::t('Email cannot be empty');
     }
     if (!isset($this->phone_no)) {
         $err['phone_no'] = Lang::t('phone no cannot be empty');
     }
     if (!isset($this->time_open)) {
         $err['time_open'] = Lang::t('Time open cannot be empty');
     }
     if (!isset($this->time_close)) {
         $err['time_close'] = Lang::t('Time Close cannot be empty');
     }
     if (!isset($this->halal)) {
         $err['halal'] = Lang::t('Halal cannot be empty');
     }
     //Set Default Values
     if (count($err) <= 0) {
         //SAVING NEW LOCATION TO Location DB
         $ll = new LocationModel();
         $arrLoc = $ll->getWhere("district='{$this->district}' AND city='{$this->city}'");
         if (count($arrLoc) <= 0) {
             $loc = new LocationModel();
             $loc->district = $this->district;
             $loc->city = $this->city;
             $loc->user_visit_count = 0;
             $loc->cashier_visit_count = 0;
             if (!Generic::IsNullOrEmptyString($this->district) && !Generic::IsNullOrEmptyString($this->city)) {
                 $loc->save();
             }
         }
         //MAKE id_categories always have 0
         if (Generic::IsNullOrEmptyString($this->id_categories)) {
             $this->id_categories;
         } else {
             $arrCats = explode(',', $this->id_categories);
             if (!in_array("0", $arrCats)) {
                 $arrCats[] = "0";
                 $this->id_categories = implode(',', $arrCats);
             }
         }
     }
     return $err;
 }