Пример #1
0
/**
  Returns a single Offer
*/
function c2r_offer_get($id)
{
    $data = '{"method": "offer_get", "params": [' . $id . '], "id": 0}';
    $value = post($data);
    $o = null;
    $o->id = $value[0];
    $o->user_number_id = $value[1];
    $o->user_number = c2r_get_user_number($o->user_number_id);
    $o->route_id = $value[2];
    $o->route = c2r_routes_get($o->route_id);
    $location = c2r_locations_get($o->route->lid);
    $timezone = $location->timezone;
    $o->start_time = convertDatetime($value[3], $timezone);
    $o->request_time = $value[4];
    $o->status = $value[5];
    $o->reverse = $value[6];
    return $o;
}
Пример #2
0
    if ($user_id == 'user_id') {
        $user_id = $user->id;
    }
    $status = $_POST['status'];
    c2r_routes_update($rid, $origin, $destination, $status, $key, $lid, $user_id);
}
/* Delete Route */
if (isset($_GET['do']) && $_GET['do'] == 'delete') {
    $rid = $_GET['rid'];
    c2r_routes_delete($rid);
}
/* Edit company */
if (isset($_GET['do']) && $_GET['do'] == 'edit') {
    $edit_rid = $_GET['rid'];
}
$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_routes = 0;
if ($user->group_id < 3) {
    $cid_for_routes = $user->company_id;
}
$routes = c2r_routes_get(0, 0, $myroutes ? $user->id : 0, false, $cid_for_routes);
$smarty->assign('myroutes', $myroutes);
$smarty->assign('edit_rid', $edit_rid);
$smarty->assign('user_id', $user_id);
$smarty->assign('locations', $locations);
$smarty->assign('routes', $routes);
smarty_display('routes');
Пример #3
0
        checkMinGroup(3);
    }
}
// Submit
if (!$_GET['rid']) {
    $rid = $_POST['rid'];
    c2r_routepoints_delete($rid);
    $pos = 0;
    for ($i = 0; $i < 10; $i++) {
        if (!$_POST['delete_' . $i]) {
            $pos++;
            $pid = $_POST['point'][$i];
            $st = $_POST['steptime'][$i];
            c2r_routepoints_insert($rid, $pid, $st, $pos);
        }
    }
    addInfoMessage('Route Points saved!');
    // Reload route
    $route = c2r_routes_get($rid);
}
$rps = c2r_route_points_get($rid);
if ($_GET['my']) {
    $smarty->assign('my', true);
}
$smarty->assign('rid', $rid);
$smarty->assign('rps', $rps);
$smarty->assign('locations', $locations);
$smarty->assign('location', $location);
$smarty->assign('route', $route);
#$smarty->assign('company', $company);
smarty_display('route_points');
Пример #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';
$uid = $_GET['uid'];
$lid = $_GET['lid'];
$rid = $_GET['rid'];
$routes = c2r_routes_get(0, $lid, $uid);
$key_array_used = array();
foreach ($routes as $key => $route) {
    if ($rid != $route->id) {
        $key_array_used[$route->key] = $route->key;
    }
}
$free_keys = array();
for ($i = $uid ? 90 : 10; $i < ($uid ? 100 : 90); $i++) {
    if (!in_array($i, $key_array_used)) {
        $obj = null;
        $obj->name = $i;
        $free_keys[$i] = $obj;
    }
}
$selected = null;
if ($rid) {
    $xroute = $routes[$rid];
    $xkey = $xroute->key;
    // select if route is in this location
    if ($lid == $xroute->lid) {
        $selected = $xkey;
    }
}
Пример #5
0
<?php

/* Standard include */
require_once '../functions/functions.php';
/* Check User rights */
checkMinGroup(1);
$lid = $user->default_location_id;
$routes = c2r_routes_get(0, $lid, 0, true);
$smarty->assign('routes', $routes);
smarty_display('allroutes');
Пример #6
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';
$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"');
Пример #7
0
<?php

/* Standard include */
require_once '../functions/functions.php';
/* Check User rights */
checkMinGroup(1);
if ($_GET['do'] == 'offerride') {
    $time = checkTime($_GET['time']);
    $time_ok = true;
    if (!only_digits($time)) {
        $time_ok = false;
        $e_msg = t('Time: ') . $time;
        addErrorMessage($e_msg);
        c2r_log_error('Offer time format', $e_msg . ' - ' . $_GET['time']);
    }
    $route = c2r_routes_get($_GET['route_id']);
    $sdate = explode('-', $_GET['start_date']);
    $sdate = join('', $sdate);
    if (!count($errors)) {
        $result = c2r_offer_ride($_GET['user_number_id'], $_GET['location_id'], $route->key, $time, $_GET['reverse'], $sdate);
        if ($result && substr($result, 0, 5) != 'ERROR') {
            addInfoMessage($result);
            header("Location: " . OCP_BASE_URL . "matchingrequests.php");
            /* Redirect browser */
            exit;
        } else {
            $e_msg = $result ? $result : t('An error occurred');
            addErrorMessage($e_msg);
            c2r_log_error('Offer time format', $e_msg);
        }
    }
Пример #8
0
<?php

require_once '../functions/functions.php';
/* Check User rights */
checkMinGroup(1);
$lid = $user->default_location_id;
$rid = $_GET['rid'];
//$routes = $routes = c2r_routes_get(0, $lid, 0, true);
//echo "<pre>";print_r($routes);echo "</pre>";
//echo "<br>done";
//$locations = c2r_locations_get($rid);
//echo "<pre>";print_r($locations);echo "</pre>";
//echo "<br>done";
//$locations = c2r_routes_get();
//echo "<pre>";print_r($locations);echo "</pre>";
//echo "<br>done";
//$locations = c2r_route_points_get($rid);
//echo "<pre>";print_r($locations);echo "</pre>";
//echo "<br>done";
//$locations = c2r_pickuppoints_get();
//echo "<pre>";print_r($locations);echo "</pre>";
//echo "<br>done";
//echo "<br>done";
$routes = c2r_routes_get();
foreach ($routes as $key => $r) {
    $rps = c2r_route_points_get($r->id);
    $rp2 = array_pop($rps);
    $p2 = c2r_pickuppoints_get($rp2->point_id);
    echo $r->id . " -> " . $p2->geo . "<br>";
}