コード例 #1
0
<?php

include "../../include/functions.php";
include "../../include/push_functions.inc.php";
include "../../include/dbcon.inc.php";
header('Content-Type: application/json');
$user_id = getUserIdFromToken($con, @$_POST["token"]);
$request_id = $con->real_escape_string(@$_POST["request_id"]);
$dog_id = $con->real_escape_string(@$_POST["dog_id"]);
$res = $con->query("INSERT INTO `donate`(`donate_id`, `request_id`, `dog_id`, `donate_date`," . " `donate_status`, `donate_lastupdate`) " . "VALUES (null,'{$request_id}','{$dog_id}',0,0,now())");
$request = getRequestById($request_id, $con);
$requser_id = $request["from_user_id"];
$status = getDonatorStatus($request_id, $dog_id, $con);
if ($status == "real") {
    pushToUser($requser_id, "แจ้งเตือนการขอเลือด", "มีผู้บริจาคเลือดให้กับสุนัขของคุณ", "requester", $request_id, $con);
}
if ($con->error == "") {
    $response = array("result" => 1);
} else {
    $response = array("result" => 0);
}
echo json_encode($response);
コード例 #2
0
ファイル: timer.php プロジェクト: Devdits/pinboard
<?php

use Pinboard\Utils\Utils;
use Symfony\Component\HttpFoundation\Request;
$server = $app['controllers_factory'];
$requestTypes = array('live', 'req_time');
$server->get('/{type}/{requestId}/{grouping}', function ($type, $requestId, $grouping) use($app, $requestTypes) {
    if (!in_array($type, $requestTypes)) {
        $app->abort(404, "Type {$type} not allowed. Allowed types: " . implode(', ', $requestTypes));
    }
    $date = null;
    if (stripos($requestId, '::') !== false) {
        list($requestId, $date) = explode('::', $requestId);
    }
    $request = getRequestById($app['db'], $type, $requestId, $date);
    if (!$request) {
        $app->abort(404, "Request #{$requestId} not found.");
    }
    Utils::checkUserAccess($app, $request['server_name']);
    $request['script_name'] = Utils::urlDecode($request['script_name']);
    $request = Utils::parseRequestTags($request);
    $request['timers'] = getTimers($app['db'], $type, $requestId, $date);
    $groupingTags = findGroupingTags($request['timers']);
    if (strlen($grouping)) {
        $grouping = preg_replace('/^grouping\\-/', '', $grouping);
    }
    if (empty($grouping)) {
        if (sizeof($groupingTags)) {
            if (in_array('group', $groupingTags)) {
                $grouping = 'group';
            } else {
コード例 #3
0
                                <th>Dog Donor Name</th>
                                <th>Blood Type</th>
                                <th>For Dog Name</th>
                                <th>Volume (CC.)</th>
                                <th>Requester Name</th>

                            </tr>                                        
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
include "../dbcon.inc.php";
$currentdate = date('Y-m-d', time());
$res = $con->query("SELECT * FROM donate WHERE dog_id IN " . "(SELECT dog_id FROM user_dog WHERE user_id = '" . $_SESSION["userdata"]["user_id"] . "') " . " AND donate_status IN (1)");
while ($data = $res->fetch_assoc()) {
    $request = getRequestById($data["request_id"], $con);
    $donator_dog = getDogById($data["dog_id"], $con);
    $requester_dog = getDogById($request["for_dog_id"], $con);
    $requester_owner = getUserById($requester_dog["user_id"], $con);
    ?>
                             
                                <tr class="showdonate">
                                    <td><?php 
    echo $data["donate_lastupdate"];
    ?>
</td>
                                    <td><?php 
    echo $donator_dog["dog_name"];
    ?>
</td>
                                    <td><?php 
コード例 #4
0
 $isAbleToDonate = true;
 if ($dog["dog_bloodtype_id"] == 1 | $dog["dog_bloodtype_id"] == 2) {
     $isAbleToDonate = false;
 }
 if ($dog["disease_id"] > 2) {
     $isAbleToDonate = false;
 }
 $breeds = getBreedsById($dog["breeds_id"], $con);
 $disease = getDiseaseBloodById($dog["disease_id"], $con);
 $blood = getBloodTypeById($dog["dog_bloodtype_id"], $con);
 //get current donate for dog
 $isDonating = isDogDonatingByDogId($dog["dog_id"], $con);
 $donatedata = array();
 if ($isDonating) {
     $donate = getCurrentDonateByDogId($dog["dog_id"], $con);
     $request = getRequestById($donate["request_id"], $con);
     $requestdog = getDogById($request["for_dog_id"], $con);
     $donators = getDonatorByRequestId($request["request_id"], $con);
     $real = sortRealDonator($donators, calculateDonator($request["amount_volume"]));
     $alt = sortAltDonator($donators, calculateDonator($request["amount_volume"]));
     //find out if user can cancle and calculate the time left in Days
     $duedate = $request["duedate"];
     $createddate = $request["created_time"];
     $reason = "";
     if (sizeof($alt) > 0) {
         //have alt donator
         $now = time();
         // or your date as well
         $your_date = strtotime($duedate);
         $datediff = $your_date - $now;
         $daydiff = floor($datediff / (60 * 60 * 24));
コード例 #5
0
function getDonatorStatus($request_id, $dog_id, $con)
{
    $request = getRequestById($request_id, $con);
    $donators = getDonatorByRequestId($request_id, $con);
    $calc = calculateDonator($request["amount_volume"]);
    $realdonator = sortRealDonator($donators, $calc);
    foreach ($realdonator as $key => $real) {
        if ($real["dog_id"] == $dog_id) {
            return "real";
        }
    }
    $altdonator = sortAltDonator($donators, $calc);
    foreach ($altdonator as $key => $alt) {
        if ($alt["dog_id"] == $dog_id) {
            return "alt";
        }
    }
    return "error";
}