<?php

/* Open CarPool is free software published under GPLv3 license, see license.txt for details. (C) 2009-2014 Oliver Pintat, Clemens Rath */
require_once '../../functions/functions.php';
$lid = $_GET['lid'];
$pid = $_GET['pid'];
$points = c2r_pickuppoints_get(0, $lid);
$key_array_used = array();
foreach ($points as $key => $point) {
    if ($pid != $point->id) {
        $key_array_used[$point->key] = $point->key;
    }
}
$free_keys = array();
for ($i = 1; $i < 100; $i++) {
    if (!in_array($i, $key_array_used)) {
        $obj = null;
        $obj->name = sprintf('%02d', $i);
        $free_keys[sprintf('%02d', $i)] = $obj;
    }
}
$selected = null;
if ($pid) {
    $xpoint = $points[$pid];
    $xkey = $xpoint->key;
    // select if route is in this location
    if ($lid == $xpoint->lid) {
        $selected = $xkey;
    }
}
echo c2r_getHtmlSelect('key', $free_keys, 'name', $selected, 'class="form-control"');
Example #2
0
function c2r_getHmtlSelectPoints($name, $lid, $selected = null, $extra = '')
{
    $liste = c2r_pickuppoints_get(0, $lid);
    return c2r_getHtmlSelect($name, $liste, 'name', $selected, $extra);
}
<?php

/* Open CarPool is free software published under GPLv3 license, see license.txt for details. (C) 2009-2014 Oliver Pintat, Clemens Rath */
require_once '../../functions/functions.php';
$pickupppoints = c2r_pickuppoints_get(0, $_GET['lid']);
echo json_encode($pickupppoints);
Example #4
0
<?php

/* Open CarPool is free software published under GPLv3 license, see license.txt for details. (C) 2009-2014 Oliver Pintat, Clemens Rath */
require_once '../../functions/functions.php';
$rid = $_GET['rid'];
$route = c2r_routes_get($rid);
$points = c2r_route_points_get($route->id);
$gpoints = array();
foreach ($points as $key => $point) {
    $p = c2r_pickuppoints_get($point->point_id);
    $gpoints[] = $p;
}
?>

<script type="text/javascript">
<!--
var map = null;
var marker = null;
function doInit() {
	<?php 
$helper = split(' ', $gpoints[count($gpoints) - 1]->geo);
?>
  lat = <?php 
echo $helper[0];
?>
;
	lng = <?php 
echo $helper[1];
?>
;
	var myLatlng = new google.maps.LatLng(lat, lng);
Example #5
0
    $pid = $_POST['pid'];
    $name = $_POST['name'];
    $lid = $_POST['lid_e'];
    $geo = $_POST['geo_e'];
    $key = $_POST['key'];
    c2r_pickuppoints_update($pid, $name, $lid, $geo, $key);
    addInfoMessage(t('Pick-up point ') . $name . t(' updated'));
}
/* Delete Pickuppoint */
if (isset($_GET['do']) && $_GET['do'] == 'delete') {
    $pid = $_GET['pid'];
    c2r_pickuppoints_delete($pid);
}
/* Edit company */
if (isset($_GET['do']) && $_GET['do'] == 'edit') {
    $edit_pid = $_GET['pid'];
}
$cid_for_loc = 0;
if ($user->group_id < 3) {
    $cid_for_loc = $user->company_id;
}
$locations = c2r_locations_get(0, $cid_for_loc);
$cid_for_pp = 0;
if ($user->group_id < 3) {
    $cid_for_pp = $user->company_id;
}
$pickuppoints = c2r_pickuppoints_get(0, 0, $cid_for_pp);
$smarty->assign('edit_pid', $edit_pid);
$smarty->assign('pickuppoints', $pickuppoints);
$smarty->assign('locations', $locations);
smarty_display('pickuppoints');
Example #6
0
/* Open CarPool is free software published under GPLv3 license, see license.txt for details. (C) 2009-2014 Oliver Pintat, Clemens Rath */
require_once '../../functions/functions.php';
$lid = $_GET['lid'];
$routes = c2r_routes_get(0, $lid, 0, true, 0, $_GET['onlyforuser'] ? $user->id : 0);
// Sort Array by Route Name
usort($routes, "sort_by_route_names");
function sort_by_route_names($a, $b)
{
    if ($a->name == $b->name) {
        return 0;
    }
    return $a->name < $b->name ? -1 : 1;
}
$r2 = array();
foreach ($routes as $r) {
    $r2[$r->id] = $r;
}
$routes = $r2;
foreach ($routes as $key => $r) {
    $rps = c2r_route_points_get($r->id);
    $rp1 = array_shift($rps);
    $rp2 = array_pop($rps);
    $p1 = c2r_pickuppoints_get($rp1->point_id);
    $p2 = c2r_pickuppoints_get($rp2->point_id);
    $routes[$key]->name .= " (" . $p1->name . " - " . $p2->name . ")";
    $routes[$key]->name = "#" . $r->key . " " . $routes[$key]->name;
}
$oc = ($_GET['add_map'] = 1) ? 'onchange="loadmap()"' : '';
echo c2r_getHtmlSelect('route_id', $routes, 'name', null, $oc . ' class="form-control"');
echo '<script>loadmap();</script>';
Example #7
0
        addErrorMessage($e_msg);
        c2r_log_error('Request time order', $e_msg);
    }
    if (!$_GET['route'] && $_GET['start_point'] == $_GET['end_point']) {
        $has_error = true;
        $e_msg = t('Start- and end point are the same. Please select different points.');
        addErrorMessage($e_msg);
        c2r_log_error('Request', $e_msg);
    }
    if (!$has_error) {
        if ($_GET['route']) {
            $r = c2r_routes_get($_GET['route_id']);
            $res = c2r_request_ride_route($_GET['user_number_id'], $_GET['location_id'], $r->key, $_GET['reverse'], $time_earliest, $time_latest, $sdate);
        } else {
            $sp = c2r_pickuppoints_get($_GET['start_point']);
            $ep = c2r_pickuppoints_get($_GET['end_point']);
            $res = c2r_request_ride($_GET['user_number_id'], $_GET['location_id'], $sp->key, $ep->key, $time_earliest, $time_latest, $sdate);
        }
        if ($res) {
            addInfoMessage($res);
            header("Location: " . OCP_BASE_URL . "matchingoffers.php");
            /* Redirect browser */
            exit;
        } else {
            addErrorMessage(t('An error occurred'));
        }
    }
}
smarty_display('request');
exit;
$title = 'Request';