Ejemplo n.º 1
0
function delete_action($id)
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $action = fetch_action($id);
    $statement = $connection->prepare("select count(*) from actions where active=1 and achievement_id!=0 and name=?");
    $statement->bindValue(1, $action->name, PDO::PARAM_STR);
    $statement->execute();
    if ((int) $statement->fetchColumn() == 1) {
        $statement = $connection->prepare("update actions set active=0 where achievement_id=0 and name=?");
        $statement = $connection->bindValue(1, $action->name, PDO::PARAM_STR);
        $statement->execute();
    }
    $statement = $connection->prepare("update actions set active=0 where id=?");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
}
Ejemplo n.º 2
0
function should_it_have_been_worked_on($id)
{
    $action = fetch_action($id);
    $days_since_last_work = days_since_last_worked($id);
    if (!$days_since_last_work) {
        return false;
        //deal with when it has no previous work history
    }
    if ($action->work == 2 && $days_since_last_work > 0) {
        return true;
    } else {
        if ($action->work == 3 && $days_since_last_work > 6) {
            return true;
        } else {
            if ($action->work == 4 && $days_since_last_work > 28) {
                return true;
            }
        }
    }
    return false;
}
Ejemplo n.º 3
0
<?php

require_once "../php/config.php";
require_once "../php/work.php";
require_once "../php/actions.php";
require_once "../php/achievements.php";
$connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
$today = 0;
$last_time = 0;
if (!has_work_been_checked()) {
    check_work();
}
$statement = $connection->query("select * from work where action_id!=0 and active=1 order by created desc");
$statement->execute();
while ($work = $statement->fetchObject()) {
    $action = fetch_action($work->action_id);
    $achievement = fetch_achievement($action->achievement_id);
    if ($today != date("m/d/y", strtotime($work->created))) {
        echo "<h2>" . date("m/d/y l", strtotime($work->created)) . "</h2>";
        $today = date("m/d/y", strtotime($work->created));
    }
    if ($last_time != date("H:i", strtotime($work->created))) {
        echo "<div style='margin-top:24px'>" . date("H:i", strtotime($work->created)) . "</div>";
        $last_time = date("H:i", strtotime($work->created));
    }
    echo "<div style='margin-top:8px'>";
    if (!strtotime($work->updated) && $work->worked) {
        echo " <input style='margin-right:8px;' type='button' value='X' onclick=\"cancelWork({$action->id});\" />";
    }
    echo $work->worked ? "Finished " : "<span style='color:red;'>Incompleted </span> ";
    echo strtolower(convert_work_num_to_caption($work->work)) . " work on \"{$action->name}\"";