本文整理汇总了PHP中utils::getMileageFromMeters方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::getMileageFromMeters方法的具体用法?PHP utils::getMileageFromMeters怎么用?PHP utils::getMileageFromMeters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::getMileageFromMeters方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDistanceReportData
public static function getDistanceReportData($report, $userId, $bikeId, $rideId, $fromDate, $toDate)
{
$dateFormat = '%v';
$datasetName = 'Weekly Total';
$week = true;
if ($report == 1) {
//month query
$dateFormat = '%M';
$datasetName = 'Monthly Total';
$week = false;
}
$weekAvg = array();
$avg = array();
$connection = Propel::getConnection();
$query = "select date_FORMAT(us.ride_date,'%x') as year, date_FORMAT(us.ride_date,'" . $dateFormat . "') as weekinyear, sum(ur.mileage) as mileage from user_stats us, user_rides ur where us.user_id=? and date_FORMAT(us.RIDE_DATE,'%Y%m%d')>=? and date_FORMAT(us.RIDE_DATE,'%Y%m%d')<=? and ur.USER_RIDE_ID=us.RIDE_KEY ";
$bikeclause = " and us.bike_id=" . $bikeId;
$rideclaue = " and us.ride_key=" . $rideId;
$groupclause = " group by weekinyear order by 1,2 asc";
if ($bikeId && $bikeId >= 0) {
$query = $query . $bikeclause;
}
if ($rideId && $rideId >= 0) {
$query = $query . $rideclaue;
}
$query = $query . $groupclause;
sfContext::getInstance()->getLogger()->info('@@@@@@@@@@@@@@@executing week query ' . $query);
$statement = $connection->prepare($query);
$statement->bindValue(1, $userId);
$statement->bindValue(2, date("Ymd", strtotime($fromDate)));
$statement->bindValue(3, date("Ymd", strtotime($toDate)));
$resultset = $statement->execute();
$count = 0;
$total = 0;
while ($row = $statement->fetch()) {
$mileage = utils::getMileageFromMeters($row['mileage']);
$weekInYear = $row['weekinyear'];
$year = $row['year'];
$display = $weekInYear;
if ($week) {
$display = reportQueries::getStartOfWeekFromWeekYear($weekInYear, $year);
}
$display = $display . "-" . $year;
$weekAvg[$display] = $mileage;
$avg[$display] = 0;
$total = $total + $mileage;
$count++;
}
//go through and set avg
if ($count > 0) {
$average = $total / $count;
} else {
$average = 0;
}
foreach (array_keys($weekAvg) as $a) {
$avg[$a] = $average;
}
$return = array($datasetName => $weekAvg, 'Average' => $avg);
return $return;
}
示例2: executeEdit
public function executeEdit()
{
$userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
$rideId = $this->getRequestParameter('rideid');
sfContext::getInstance()->getLogger()->info('########@@@@@@@@@@@@@@@rideId ' . $this->getRequestParameter('rideid'));
$this->rideName = "";
$r = UserRidesPeer::retrieveByPK($rideId);
$this->rideid = $r->getUserRideId();
$this->userRide = $r;
$this->description = $r->getDescription();
$this->mileage = utils::getMileageFromMeters($r->getMileage());
$this->altitude = $r->getAltitudeGain();
if ($this->getRequest()->getMethod() == sfRequest::POST) {
if ($this->rideid) {
$this->userRide->setDescription($this->getRequestParameter('route_desc'));
$this->userRide->setMileage(utils::getMetersFromMileage($this->getRequestParameter('distance')));
$this->userRide->setUserId($userId);
$this->userRide->setRideId(1);
$this->userRide->save();
if ($this->getRequestParameter('AddCreateMap') || $this->getRequestParameter('AddEditMap')) {
//set up necessary parameters
$this->mileagePref = sfContext::getInstance()->getUser()->getAttribute('mileage', null, 'subscriber');
$this->totalMileage = 0;
//get profile to get mileage preference
$this->rideId = $r->getUserRideId();
sfContext::getInstance()->getLogger()->info('^^^^^@@@@@@@@@@@@@@@rideId ' . $r->getUserRideId());
$this->coords = null;
$ride = UserRidesPeer::retrieveByPK($r->getUserRideId());
$mapPoints = null;
if ($ride) {
$this->rideName = $ride->getDescription();
//see if there are any coords
$c = new Criteria();
$c->add(UserRideMapPeer::USER_RIDE_ID, $r->getUserRideId());
$mapPoints = UserRideMapPeer::doSelect($c);
$this->coords = UserRideMap::createMapString($mapPoints);
}
sfContext::getInstance()->getLogger()->info('@@@@@@@@@@@@@@@REDIRECT ' . 'userrides/map?rideId=' . $r->getUserRideId());
return $this->redirect('userrides/map?rideId=' . $r->getUserRideId());
} else {
return $this->redirect('userrides/index');
}
}
}
}
示例3: getWeekTopRiders
public static function getWeekTopRiders()
{
$results = array();
$from_date = date("Ymd", mktime(1, 0, 0, date('m'), date('d') - date('w'), date('Y')));
$connection = Propel::getConnection();
//$query = "SELECT u.username username, sum(ur.MILEAGE) mileage FROM user_rides ur, user_stats us,users u WHERE date_FORMAT(us.RIDE_DATE,'%Y%m%d')>=? AND ur.USER_RIDE_ID=us.RIDE_KEY and u.user_id=ur.user_id group by ur.user_id order by 2 desc limit 5";
$query = "SELECT u.username username, sum(us.MILEAGE) mileage FROM user_stats us,users u WHERE date_FORMAT(us.RIDE_DATE,'%Y%m%d')>=? and u.user_id=us.user_id group by us.user_id order by 2 desc limit 5;";
$statement = $connection->prepare($query);
$statement->bindValue(1, $from_date);
$resultset = $statement->execute();
$count = 1;
while ($row = $statement->fetch()) {
$value = $row['username'] . ' - ' . utils::getMileageFromMeters($row['mileage']);
$results[$count] = $value;
$count++;
}
return $results;
}
示例4: getBikeMileage
public function getBikeMileage()
{
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn('SUM(' . UserStatsPeer::MILEAGE . ')');
//$c->addGroupByColumn(UserRidesPeer::MILEAGE);
$c->add(UserStatsPeer::USER_ID, $this->getUserId());
$c->add(UserStatsPeer::BIKE_ID, $this->getUserBikeId());
// $c->addJoin(UserRidesPeer::USER_RIDE_ID, UserStatsPeer::RIDE_KEY);
$stmt = UserStatsPeer::doSelectStmt($c);
$sum = 0;
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
if ($row) {
$sum = $row[0];
}
}
}
return utils::getMileageFromMeters($sum);
}
示例5: getYearlyMileage
public function getYearlyMileage()
{
$from_date = mktime(0, 0, 0, 1, 1, date("Y"));
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn('SUM(' . UserRidesPeer::MILEAGE . ')');
$c->add(UserStatsPeer::USER_ID, $this->getUserId());
$criterion = $c->getNewCriterion(UserStatsPeer::RIDE_DATE, date('Y-m-d', $from_date), Criteria::GREATER_EQUAL);
$c->add($criterion);
$c->addJoin(UserRidesPeer::USER_RIDE_ID, UserStatsPeer::RIDE_KEY);
$stmt = UserStatsPeer::doSelectStmt($c);
$sum = 0;
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
if ($row) {
$sum = $row[0];
}
}
}
return utils::getMileageFromMeters($sum);
}
示例6: use_helper
<?php
use_helper('Object');
echo form_tag('userrides/edit');
use_helper('Javascript');
include_partial('ride_form', array('route_desc' => $userRide->getDescription(), 'distance' => utils::getMileageFromMeters($userRide->getMileage())));
?>
<div class="submit-row">
<?php
echo input_hidden_tag('rideid', $rideid);
?>
<input type="submit" name="Save" value="Save" />
<input type="submit" name="AddCreateMap" value="Save & Create Map" />
<input type="submit" name="AddEditMap" value="Save & EditMap" />
</div>
</form>
示例7: link_to_function
echo link_to_function(image_tag('/images/Add.png'), "Modalbox.show('userstats/add', {title:' Add Ride', width: 600});return false;");
?>
</span>
</span>
</div>
<?php
}
?>
<div id="calInfo" >
<?php
if ($statsByDay) {
if (array_key_exists($day, $statsByDay)) {
$stats = $statsByDay[$day];
foreach ($stats as $s) {
$editUrl = "Modalbox.show('userstats/view?statid=" . $s->getStatNo() . "', {title:' Ride Details', width: 400});return false;";
echo link_to_function(utils::getMileageFromMeters($s->getMileage()) . ' ' . utils::getMileageString(), $editUrl);
?>
<br>
<?php
}
?>
<?php
}
?>
<?php
}
?>
</div>
<div id="calInfo" >
</div>
示例8: link_to_function
<h2><?php
echo $user_route->getDescription();
?>
<?php
$editUrl = "Modalbox.show('userrides/edit?rideid=" . $user_route->getUserRideId() . "', {title:' Edit Route', width: 600});return false;";
echo link_to_function(image_tag('/images/Modify.png'), $editUrl);
?>
<?php
$url = "Modalbox.show('userrides/delete?rideid=" . $user_route->getUserRideId() . "', {title:' Delete Route', width: 600});return false;";
?>
<?php
echo link_to_function(image_tag('/images/Delete.png'), $url);
?>
</h2>
<p>Total Mileage: <?php
echo utils::getMileageFromMeters($user_route->getMileage()) . " " . utils::getMileageString();
?>
</p>
</li>
<?php
}
?>
</ol>
</div>
</div>
<div id="content-1-right">
<h2 class="rounded-heading"><span>Route Details</span></h2>
<div class="content-1-details">
<div id="userrides"></div>
</div>
示例9: executeGetBikeEquipment
public function executeGetBikeEquipment($request)
{
$this->forward404unless($request->isXmlHttpRequest());
//get bikeId
$bikeId = intval($request->getParameter("param"));
//get userId
$userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
if ($userId && $bikeId) {
$c = new Criteria();
$c->add(UserEquipementPeer::BIKE_ID, $bikeId);
$c->add(UserEquipementPeer::USER_ID, $userId);
$this->equips = UserEquipementPeer::doSelect($c);
//now get the mileage for each equipment
$mileage = UserEquipement::getEquipmentMileage($userId, $bikeId);
//now set mileage on equipment
if ($mileage && $this->equips) {
foreach ($this->equips as $userEquip) {
//if(in_array($userEquip->getEquipmentId(),$mileage)){
if (isset($mileage[$userEquip->getEquipmentId()])) {
// echo 'found';
$userEquip->setMileage(utils::getMileageFromMeters($mileage[$userEquip->getEquipmentId()]));
} else {
// echo $userEquip->getEquipmentId();
$userEquip->setMileage(0);
}
}
}
} else {
$this->equips = null;
}
}