예제 #1
0
    }
});
// BIDS
$app->get('/api/bids', function (Request $request, Response $response) {
    try {
        if (!array_key_exists('cnt_session_id', $request->getCookieParams())) {
            logger($this)->addWarning('No contractor session id', getPath($request));
            return forbidden($response);
        }
        $contractorSessionId = $request->getCookieParams()['cnt_session_id'];
        $contractorId = getContractorId($contractorSessionId);
        if (!isset($contractorId)) {
            logger($this)->addWarning('No contractor found by session id', array('cnt_session_id' => $contractorSessionId, 'uri' => $request->getUri()->getPath()));
            return forbidden($response);
        }
        $bids = getBids();
        // Escape HTML output
        array_walk_recursive($bids, "escapeValue");
        $response->getBody()->write(json_encode($bids));
        return $response->withHeader('Content-Type', 'application/json');
    } catch (PDOException $e) {
        return handleError($e, $response);
    }
});
$app->get('/api/bids/{id}', function (Request $request, Response $response) {
    $id = $request->getAttribute("id");
    if (!is_numeric($id)) {
        logger($this)->addWarning('Wrong bid id', getPath($request));
        return badRequest($response);
    }
    try {
예제 #2
0
    }
    return $bids;
}
?>
<html>
    <head>
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    </head>
<body>
<table class="table table-striped">
						<th>Driver Name</th>
						<th>Bid</th>
						<?php 
$hireBids = getBids();
foreach ($hireBids as $bid) {
    ?>
								
									<tr>
										<td><?php 
    echo $bid[0];
    ?>
</td>
										<td><?php 
    echo $bid[1];
    ?>
</td>
										<td>
                                            <button type="button" value="<?php 
    echo $bid[2];
function createShiftsFromBids($data)
{
    global $hourSize;
    $time = date('H:i:s', strtotime($data['startTime']));
    //The start of the trade
    $newShifts = array();
    //This will hold all of the new shift we need to create
    $curShift = array();
    $curShift['employee'] = "";
    $curShift['hourType'] = $data['hourType'];
    //set hour type
    $curShift['area'] = $data['area'];
    //set area
    $curShift['startDate'] = $data['startDate'];
    //TODO set startDate
    $curShift['hourTotal'] = 0;
    //start hour total at 0
    //Columns needed to create a new shift: Employee|startTime|startDate|endTime|endDate|hourType|hourTotal|area|trade
    while ($time != $data['endTime']) {
        $curBid = getBids($time, $data['ID']);
        //Base Cases
        if ($time == $data['startTime'] && $curBid != 0) {
            $curShift['startTime'] = $data['startTime'];
            //set start time
            $curShift['employee'] = $curBid['employee'];
            //set employee
        } else {
            if ($curBid == 0 || $curShift['employee'] != $curBid['employee']) {
                //Finish data for current new shift
                $curShift['endTime'] = $time;
                if ($data['endTime'] == '00:00:00' && $time != '00:00:00') {
                    $curShift['endDate'] = $data['startDate'];
                } else {
                    $curShift['endDate'] = $data['endDate'];
                    //TODO
                }
                if ($curShift['employee'] != "") {
                    $newShifts[] = $curShift;
                    //Insert it into the new shift array as long as we're not in a null shift.
                }
                //reset curShift
                $curShift['startDate'] = $data['startDate'];
                //TODO
                $curShift['startTime'] = $time;
                $curShift['hourTotal'] = 0;
                $curShift['employee'] = "";
                if ($curBid != 0) {
                    $curShift['employee'] = $curBid['employee'];
                }
            }
        }
        $curShift['hourTotal'] = $curShift['hourTotal'] + $hourSize;
        //Add an hour total
        //update Hour for next pass through
        $timestamp = strtotime($time) + 60 * (60 * $hourSize);
        $time = date('H:i:s', $timestamp);
        $curShift['endTime'] = $time;
        //this updates the time to the next hour
        if ($time == $data['endTime'] && $curBid != 0) {
            //This checks if we're at the end of the trade and inserts the trade into the array
            $curShift['endTime'] = $time;
            $curShift['endDate'] = $data['endDate'];
            //TODO
            $newShifts[] = $curShift;
            //Insert it into the new shift array
        }
    }
    return $newShifts;
}