function fetch_action_listing($action) { $string = "<span style='margin-left:20px;cursor:pointer;"; $string = has_action_been_worked_on($action->id) ? $string . "color:grey;text-decoration:line-through;' \n title='Cancel work' \n onmouseover=\"\$(this).css('text-decoration', 'none');\" \n onmouseleave=\"\$(this).css('text-decoration', 'line-through');\"\n onclick=\"cancelWork({$action->id});\"" : $string . "' title='Click to indicate action worked.' \n onmouseover=\"\$(this).css('text-decoration', 'line-through');\" \n onmouseleave=\"\$(this).css('text-decoration', 'none');\" \n onclick=\"createWork({$action->id});\""; $string = $string . "> {$action->name} [" . convert_work_num_to_caption($action->work) . "]</span>"; if ($action->type == 1) { $string = $string . "<input id='action_quantity_{$action->id}' type='number' value='{$action->default_quantity}'/>"; } return $string; }
function has_achievement_been_worked_on($id) { $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD); $statement = $connection->prepare("select count(*) from actions where achievement_id=? and active=1"); $statement->bindValue(1, $id, PDO::PARAM_INT); $statement->execute(); if ($statement->fetchColumn() == 0) { return false; } $statement = $connection->prepare("select * from actions where achievement_id=? and active=1"); $statement->bindValue(1, $id, PDO::PARAM_INT); $statement->execute(); while ($action = $statement->fetchObject()) { if (!has_action_been_worked_on($action->id)) { return false; } } return true; }