//Set view_term
    $user_id = $argv[2];
    //Set user_id
} else {
    if (isset($_POST['search_begin']) && isset($_POST['search_end'])) {
        $search_begin = $_POST['search_begin'];
        $search_end = $_POST['search_end'];
    }
    if (isset($_POST['user_id'])) {
        $user_id = $_POST['user_id'];
    }
}
$timecard = new Timecard_IndividualSQL();
$timecard_obj = new Timecard_IndividualSQL();
$timecard_obj->setZeroFilled(1);
$data = $timecard_obj->getData($search_begin, $search_end, $user_id);
$column_num = count($data["column"]);
$search_period = "{$search_begin} .. {$search_end}";
$json = "{ \"search_period\": \"{$search_period}\", \n";
$json .= " \"detail\" : ";
$json .= "[ \n";
$i = 0;
while ($i < count($data["row"])) {
    $json .= " {";
    for ($ii = 0; $ii < count($data["column"]); $ii++) {
        $json .= "\"" . $data["column"][$ii] . "\" : \"" . $data["row"][$i][$ii] . "\"";
        if ($ii != count($data["column"]) - 1) {
            $json .= ",\n";
        } else {
            $json .= "\n";
        }
    public function show($user_id)
    {
        $timecard_obj = new Timecard_IndividualSQL();
        $timecard_obj->setZeroFilled(1);
        $data = $timecard_obj->getData($user_id);
        $column_num = count($data["column"]);
        $view_period = "{$data["search_period"]["begin"]} .. {$data["search_period"]["end"]}";
        $html = <<<EOF

<script type="text/javascript">
\tjQuery(function (\$) {
  \tvar viewTerm = culculateBiWeeklyTerm("{$data["search_period"]["begin"]}");
\t\tvar css_link = \$("<link>", {href:"./modules/timecard_gadget.css",rel:"stylesheet",type:"text/css"});
\t\t\$("head").append(css_link);
\t\t\$("#view_term").datepicker ( {
\t\t\tminDate: '-20w',
\t\t\tmaxDate: '+1m',
\t\t\tdateFormat: 'yy-mm-dd'
\t\t});
\t\t\$("#view_term").change(function() {
\t\t\t\tviewTerm = culculateBiWeeklyTerm(\$("#view_term").val());
\t\t\t\t\$("#view_term").val(viewTerm.begin + ".." + viewTerm.end);
\t\t\t\treviewIndividualTimecard();
\t\t});

\tfunction reviewIndividualTimecard() {
\t\t\tvar jsonHTTP = new XMLHttpRequest();
\t\t\tvar refTimecardUrl = "http://localhost/kowork/modules/ajax_timecard_individual.php";
\t\t\tvar user_id = "{$user_id}";
\t\t\t\$.ajax({
\t\t\t\turl: refTimecardUrl,
\t\t\t\ttype: 'POST',
\t\t\t\tdataType: 'json',
\t\t\t\tdata: {'search_begin' : viewTerm.begin, 'search_end' : viewTerm.end, 'user_id' : user_id},
\t\t\t\ttimeout: 10000,
\t\t\t\tsuccess : function(data) {
\t\t\t\t\t\trefreshUI(data);
\t\t\t\t},
\t\t\t\terror: function(XMLHttpRequest, textStatus, errorThrown) {
\t\t\t\t\t\t\t\talert("error"  + XMLHttpRequest);
\t\t\t\t\t\t\t}
\t\t\t});
\t}
\tfunction refreshUI(data) {
\t\t//\$('.timecard_detail').fadeOut(200, function(){ \$(this).remove(); });
\t\t\$('.timecard_detail').remove();
\t\teval(data);
\t\t\$('#view_term').val(data.search_period);
\t\tfor(var i in data.detail) {
\t\t\t\$(' <tr class=\\"timecard_detail\\">' + 
\t\t\t\t'<td>' + data.detail[i].Date + '</td>' +
\t\t\t\t'<td>' + data.detail[i].Begin + '</td>' +
\t\t\t\t'<td>' + data.detail[i].End + '</td>' +
\t\t\t\t'<td>' + data.detail[i].RH + '</td>' +
\t\t\t\t'<td>' + data.detail[i].OT + '</td>' +
\t\t\t\t'<td>' + data.detail[i].TPO + '</td>' +
\t\t\t\t'</tr>'
\t\t\t).appendTo('#tc_gadget'); 
\t\t}
\t}

\t\t\$('#previous_period').click(function() {
\t\t\tviewTerm = culculateBiWeeklyTerm(viewTerm.begin, -1);
\t\t\treviewIndividualTimecard();
\t\t});
\t\t\$('#next_period').click(function() {
\t\t\tviewTerm = culculateBiWeeklyTerm(viewTerm.begin, +1);
\t\t\treviewIndividualTimecard();
\t\t});
\t\t
\t});
</script>

<table id="tc_gadget">
\t<tbody>
\t\t<tr>
\t\t\t<th class="header" colspan="{$column_num}">
\t\t\t\t{$user_id}
\t\t\t\t&nbsp; <a id="previous_period" href="#">Previous</a>
\t\t\t\t&nbsp; <span> <input id="view_term" type="text" value="{$view_period}"> </span>
\t\t\t\t&nbsp; <a id="next_period" href="#">Next</a>
\t\t\t</th>
\t\t</tr>
\t\t<tr>
EOF;
        for ($i = 0; $i < count($data["column"]); $i++) {
            $html .= "<th>{$data["column"][$i]}</th>\n";
        }
        $html .= <<<EOF
\t\t  </tr>
\t\t<tr>

EOF;
        for ($i = 0; $i < count($data["row"]); $i++) {
            $html .= "\t\t<tr class=\"timecard_detail\">\n";
            for ($column_num = 0; $column_num < count($data["row"][$i]); $column_num++) {
                $html .= "\t\t\t<td>" . $data["row"][$i][$column_num] . "</td>\n";
            }
            $html .= "\t\t</tr>\n";
        }
        $html .= <<<EOF

\t</tbody>
</table>

EOF;
        return $this->adjust_output($html);
    }