Skip to content

Commit

Permalink
fixes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
Courier-Online committed Jul 30, 2016
1 parent b9932e3 commit 29eaabf
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 133 deletions.
2 changes: 0 additions & 2 deletions files/cojm/live/ajaxchangejob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3017,8 +3017,6 @@

// echo ' 3064 ID is '.$id;



$testfile="cache/jstrack/".$folder.'/'.$id.'.js';
$infotext.= ' test file is '.$testfile;
if (file_exists($testfile)) {
Expand Down
31 changes: 30 additions & 1 deletion files/cojm/live/changejob.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

$cj_time = microtime(TRUE);


$origid='';


// echo memory_get_usage();
Expand Down Expand Up @@ -2329,10 +2329,39 @@ function myErrorHandler($errno, $errstr, $errfile, $errline)
$result = mysql_query($sql, $conn_id);

if (mysql_affected_rows()>'0') {



$alerttext=$alerttext."". mysql_affected_rows().' tracking positions deleted.<br>';
$infotext=$infotext."". mysql_affected_rows().' tracking positions deleted.<br>';



$testfile="cache/jstrack/".date('Y/m', $startdate).'/'.date('Y_m_d', $startdate).'_'.$_POST['newcyclist'].'.js';
$infotext.=" 2343 test file : ". $testfile.' <br />';
if (!file_exists($testfile)) {
$infotext.= ' <br /> cj 2349 Cache does not exist, no action needed. '.$testfile;
} else {
$infotext.= ' <br /> cj 2351 Cache exists, needs deleting. '.$testfile;
unlink($testfile);
if (file_exists($testfile)) {
$infotext.= ' not deleted ';
}
}














} else { $pagetext=$pagetext.'Tracking data unchanged.'; }


Expand Down
148 changes: 21 additions & 127 deletions files/cojm/live/startuploadgpx.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
$second='00';
$sqlstart= date("Y-m-d H:i:s", mktime($hour, $minutes, $second, $month, $day, $year));
$dstart= date("U", mktime($hour, $minutes, $second, $month, $day, $year));



if ($year) { $inputstart=$day.'/'.$month.'/'.$year; }
} else { // nothing posted
$inputstart='';
Expand Down Expand Up @@ -236,144 +239,37 @@
include"trackstats.php";


// move_uploaded_file( $_FILES['userFile']['tmp_name'], $target);


}
}
}
}
} // ends check to make sure that some sort of file has been uploaded



// delete cache positions





if (($dstart<>'') and ($thisCyclistID)) {

$dinterim=$dstart;

while ($dinterim<$dend) {
$dinterif=$dinterim+'86399';
// echo '<br /> dstart : '.$dstart.' dinterim : '.$dinterim.' dinterif : '.$dinterif.' dend '.$dend.'';
if ($thisCyclistID == 'all') {
$query = "SELECT CyclistID, cojmname, trackerid FROM Cyclist ORDER BY CyclistID"; }
else { $query = "SELECT CyclistID, cojmname, trackerid FROM Cyclist WHERE CyclistID = ". $thisCyclistID; }
$result_id = mysql_query ($query, $conn_id);

echo $query;



while (list ($CyclistID, $cojmname, $trackerid) = mysql_fetch_row ($result_id)) {
$sql="SELECT latitude, longitude, speed, timestamp FROM `instamapper`
WHERE `device_key` = '$trackerid'
AND `timestamp` >= '$dinterim'
AND `timestamp` <= '$dinterif'
ORDER BY `timestamp` ASC ";
$sql_resulth = mysql_query($sql,$conn_id) or mysql_error();
$num_rows = mysql_num_rows($sql_resulth);
if ($num_rows>'0') {
$prevts='';
$tablecount='';
$tabledatestart='';
while ($map = mysql_fetch_array($sql_resulth)) {
$i++;
$tablecount++;

extract($map);
if ($clientview=='blurred') {
$map['latitude']=round($map['latitude'],2);
$map['longitude']=round($map['longitude'],2);
} elseif ($clientview=='cluster') {
$map['latitude']=round($map['latitude'],3);
$map['longitude']=round($map['longitude'],3);
} else {
$map['latitude']=round($map['latitude'],5);
$map['longitude']=round($map['longitude'],5);
}
$map['speed']=round($map['speed']);


if($map['longitude']>$max_lon) { $max_lon = $map['longitude']; }
if($map['longitude']<$min_lon) { $min_lon = $map['longitude']; }


if($map['latitude']>$max_lat) { $max_lat = $map['latitude']; }
if($map['latitude']<$min_lat) { $min_lat = $map['latitude']; }






if ($thisCyclistID<>'all') { $linecoords=$linecoords.' ['.$map['latitude'] . "," . $map['longitude'].'],'; }
$clusterdata=$clusterdata.' ['.$map['latitude'] . "," . $map['longitude'].'],';
$thists=date('H:i A D j M ', $map['timestamp']);
if ($thists<>$prevts) {
$comments=$cojmname.' <br />'.date('H:i D j M ', $map['timestamp']);
$comments=$comments.'<br />'.$map['speed'];
if ($globalprefrow['distanceunit']=='miles') { $comments=$comments. 'mph '; }
if ($globalprefrow['distanceunit']=='km') { $comments=$comments. 'km ph '; }
$thists=date('H:i A D j M ', $map['timestamp']);

$gmapdata=$gmapdata. "['" . $comments ."',". $map['latitude'] . "," . $map['longitude'] . "," . $i ."],";

$lattot=$lattot+$map['latitude'];
$lontot=$lontot+$map['longitude'];
$prevts=date('H:i A D j M ', $map['timestamp']);
$tabledate= date('D j M ', $map['timestamp']);
$tabledatefinish=date('H:i A ', $map['timestamp']);






if ($tabledatestart=='') { $tabledatestart=date('H:i A ', $map['timestamp']);
}

$loop++;
}
}

$tabletext=$tabletext.'<tr>
<td>'.$cojmname.'</td>
<td>'.$tabledate.'</td>
<td>'.$tabledatestart.'</td>
<td>'.$tabledatefinish.'</td>
<td>'.$tablecount.'</td>
</tr>';













// move_uploaded_file( $_FILES['userFile']['tmp_name'], $target);


}

}
$dinterim=$dinterim+'86400';
}

// echo $loop;

if ($loop) {

$avglat=($lattot/$loop);
$avglon=($lontot/$loop);
} else {

echo ' No tracking positions to display ';



}

} // ends check for $dstart
} // ends check to make sure that some sort of file has been uploaded





if ($gmapdata) {

Expand Down Expand Up @@ -524,8 +420,6 @@ function initialize() {

echo ' <br />
<div class="ui-state-highlight ui-corner-all p15 " >
<!-- The data encoding type, enctype, MUST be specified as below -->
Expand Down Expand Up @@ -606,10 +500,10 @@ function initialize() {
$(function() {
var dates = $( "#gpsdeletedate" ).datepicker({
numberOfMonths: 1,
changeYear:true,
changeYear:false,
firstDay: 1,
dateFormat: 'dd-mm-yy ',
changeMonth:true,
changeMonth:false,
beforeShow: function(input, instance) {
$(input).datepicker('setDate', new Date() );
}
Expand Down
71 changes: 68 additions & 3 deletions files/cojm/live/trackstats.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
<?php

// needs original trackstats license adding



/*
COJM Courier Online Operations Management
trackstats.php - Create a PDF invoice
Copyright (C) 2016 S.Young cojm.co.uk
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


/**********************************************************
* Creates statistics from given GPX file
**********************************************************/
Expand Down Expand Up @@ -32,7 +58,9 @@

$tempdate='';
$newsql = array();

$firstrun=1;
$device_key=$_POST['newcyclist'];
$device_label='GPX Upload';

// INITIALIZATION
require_once($classpath."require.php");
Expand Down Expand Up @@ -143,6 +171,37 @@ function filter($in, $out, &$consumed, $closing)
// $timestamp = str_replace ("Z", " ", strtoupper($timestamp));
// echo ($timestamp).' ';



if ($firstrun==0) {

if ($confirmgpx=='confirm') {

$testfile="cache/jstrack/".date('Y/m', $timestamp).'/'.date('Y_m_d', $timestamp).'_'.$device_key.'.js';
$infotext.=" trackstats.php 179 file : ". $testfile.' <br />';
if (!file_exists($testfile)) {
$infotext.= ' <br /> cj 2349 Cache does not exist, no action needed. '.$testfile;
} else {
$infotext.= ' <br /> cj 2351 Cache exists, needs deleting. '.$testfile;
unlink($testfile);
if (file_exists($testfile)) {
$infotext.= ' not deleted ';
}
}


} // ends confirm check



} // ends firstrun

$firstrun++;





$timestamp = strtotime($timestamp);
$map['latitude']=round($map['latitude'],5);

Expand All @@ -164,8 +223,7 @@ function filter($in, $out, &$consumed, $closing)
$lon=round($lon,5);


$device_key=$_POST['newcyclist'];
$device_label='GPX Upload';

$latitude=$lat;
$longitude=$lon;
$altitude=$ele;
Expand Down Expand Up @@ -361,6 +419,13 @@ function filter($in, $out, &$consumed, $closing)
if ($alreadyondb=='1') { echo '<h2> '.$numberofondbtracks.' locations were found which were already on the GPS tracking Database</h2>';}
if ($addedtodb=='1') { echo '<h2> '.$numberoftracks.' locations were added to the GPS tracking database.</h2>';}








// print($template);

?>

0 comments on commit 29eaabf

Please sign in to comment.