function _view() { $select_items = "U.*"; $sql_from = " FROM user U"; $sql_join = ""; $sql_where = '1'; $sql_order = ""; $qry = "SELECT {$select_items} {$sql_from} {$sql_join} WHERE {$sql_where} {$sql_order}"; $ret = db_query($qry); $hi = "#,userid,service_Infra_id,name,keepAgentNO"; table_head($hi); // 변수명#옵션 // 옵션 _:일반변수, L:왼쪽정렬 R:오른쪽정렬 C:가운데정렬 $tdk = "userid#C,service_Infra_id,name,keepAgentNO"; $items = preg_split("/,/", $tdk); $cnt = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; $id = $row['id']; $var = array(); //$var['agents'] = span_link('agents', "_list1('$id')"); $fields = array(); $fields[] = array($cnt, ''); _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS /* function _list1(id) { var url = "agent.php?mode=view&userid="+id; document.location.href = url; } */ EOS; table_close($script); }
function _listview() { global $form; $page = $form['page']; ## {{ print <<<EOS <table border='0'> <form name='form' method='get' action='{$self}'> <tr> <td> <input type='hidden' name='mode' value='{$mode}'> <input type='hidden' name='page' value='{$page}'> <input type='submit' value='OK' style="width:50;height:50;"> </td> <td> EOS; if ($form['ckrf']) { $ck = ' checked'; } else { $ck = ''; } print <<<EOS <span class='label'>Refresh</span> <input type='checkbox' name='ckrf' id='ckrf'{$ck} onclick='_clk_reload()'><label for='ckrf'>automatic</label> EOS; $v = $form['rftime']; $sel = array(); if (!$v) { $v = 5; } $sel[$v] = ' selected'; print <<<EOS <select name='rftime' onchange='_change_rftime()'> <option value='2'{$sel['2']}>2 seconds</option> <option value='5'{$sel['5']}>5 seconds</option> <option value='10'{$sel['10']}>10 seconds</option> <option value='30'{$sel['30']}>30 seconds</option> <option value='60'{$sel['60']}>60 seconds</option> </select> <span id='spanTimer'></span> EOS; print "<br>"; $td = $form['td']; if ($td == '') { $td = date('Y-m-d'); } print <<<EOS <span class='label'>Date</span><input name="td" value="{$td}" size="10"><a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(document.form.td);return false;" ><img class="PopcalTrigger" align="absmiddle" src="/dbmon/utl/DateInput/calbtn.gif" width="34" height="22" border="0" alt=""></a> <iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="/dbmon/utl/DateInput/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;"></iframe> EOS; $t1 = $form['t1']; $t2 = $form['t2']; if ($t1 == '') { $t1 = '00:00:00'; } if ($t2 == '') { $t2 = '23:59:59'; } print <<<EOS <span class='label'>Time Range</span> <input type=text name='t1' size='10' value='{$t1}' onclick="this.select()"> ~ <input type=text name='t2' size='10' value='{$t2}' onclick="this.select()"> EOS; print ' '; print '<br>'; $list = array('', 'new', 'pushed', 'submitted', 'running', 'done', 'canceled', 'failed', 'running-stopped', 'new-zombie', 'submitted-zombie', 'running-zombie', 'running-zombie-stopped', 'submit-error', 'agentQuid'); $preset = $form['status']; $opt = option_general($list, $preset); print <<<EOS <span class='label'>Status</span><select name='status'>{$opt}</select> EOS; print ' '; $preset = $form['userid']; $opt = option_user($preset); print <<<EOS <span class='label'>User</span><select name='userid'>{$opt}</select> EOS; print ' '; $ipp = _get_ipp(); $sel = array(); $sel[$ipp] = ' selected'; print <<<EOS <span class='label'>#/Page</span><select name='ipp'> <option value='10'{$sel['10']}>10</option> <option value='20'{$sel['20']}>20</option> <option value='50'{$sel['50']}>50</option> <option value='100'{$sel['100']}>100</option> <option value='200'{$sel['200']}>200</option> <option value='500'{$sel['500']}>500</option> <option value='1000'{$sel['1000']}>1000</option> <option value='2000'{$sel['2000']}>2000</option> </select> <br> EOS; print ' '; print <<<EOS </td> </tr> </form> </table> EOS; global $page_title; print <<<EOS <script> var timer = 5; var form = document.form; var span = document.getElementById('spanTimer'); var stoptimer = 0; function _reload() { if (!form.ckrf.checked) return; form.submit(); //document.location.reload(); } function _countdown() { if (stoptimer) { setTimeout("_countdown()", 1000); return; } if (!form.ckrf.checked) return; var str = "" + timer + " sec"; parent.top.document.title = "{$page_title} (" + str + ")"; span.innerHTML = str; timer--; if (timer <= 0) _reload(); setTimeout("_countdown()", 1000); } function _change_rftime() { var interval = parseInt(form.rftime.value); timer = interval; } function _clk_reload() { setTimeout("_countdown()", 1000); } function _onload() { setTimeout("_countdown()", 1000); var interval = parseInt(form.rftime.value); timer = interval; } if (window.addEventListener) { window.addEventListener("load", _onload, false); } else if (document.attachEvent) { window.attachEvent("onload", _onload); } </script> EOS; ## }} //dd($form); $w = array('1'); $td = $form['td']; $t1 = $form['t1']; $t2 = $form['t2']; $w[] = "AG.submittedTimestamp >= '{$td} {$t1}'"; $w[] = "AG.submittedTimestamp <= '{$td} {$t2}'"; $v = $form['status']; if ($v != '') { $w[] = "AG.status='{$v}'"; } $v = $form['userid']; if ($v != '') { $w[] = "U.userid='{$v}'"; } $sql_where = " WHERE " . join(" AND ", $w); $select_items = "AG.*, U.userid Uname, CE.name CEname, IF(AG.quit,'quit','') AS AGquit, J.name Jname"; $sql_from = " FROM agent AG"; $sql_join = " LEFT JOIN User U ON AG.user_id=U.id" . " LEFT JOIN CE ON AG.CE_id=CE.id" . " LEFT JOIN job J ON AG.currentJob=J.id"; $sql_order = " ORDER BY AG.submittedTimestamp DESC"; $qry = "SELECT COUNT(*) AS total {$sql_from} {$sql_join} {$sql_where}"; $ret = db_query($qry); $row = mysql_fetch_assoc($ret); $total = $row['total']; $ipp = _get_ipp(); $page = $form['page']; list($start, $last, $page) = pager_calc_page($ipp, $total); $qry = "SELECT {$select_items} {$sql_from} {$sql_join} {$sql_where} {$sql_order}"; $qry .= " LIMIT {$start},{$ipp}"; // 페이지 이동 $html = pager_html($total, $page, $last, $ipp, 'form'); print $html; //dd($qry); $ret = db_query($qry); $hi = "#,agent.id,submitId,status" . ",host,CE,CE.name,user.name,quit" . ",submittedTimestamp,runningTime,runningTimestamp,waitingTime,lastSignal" . ",currentJob,job.name"; table_head($hi); // 변수명#옵션 // 옵션 _:일반변수, L:왼쪽정렬 R:오른쪽정렬 C:가운데정렬 $tdk = "id#_,submitId,status" . ",host,CE_id,CEname,Uname,AGquit" . ",submittedTimestamp,runningTime,runningTimestamp,waitingTime,lastSignal" . ",currentJob,Jname"; $items = preg_split("/,/", $tdk); $cnt = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; //dd($row); $id = $row['id']; $status = $row['status']; $var['id'] = span_link($id, "_view('{$id}')"); //$s = $row['startTimestamp']; //$e = $row['lastUpdateTime']; //$var['elapsed'] = diff_time($e, $s); $fields = array(); $fields[] = array($cnt, ''); _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _view(agid) { var url = "{$env['self']}?mode=view&agid="+agid; wopen(url, 500,500,1,1); } EOS; table_close($script); }
function _listview() { global $form; ## {{ print <<<EOS <table border='0'> <form name='form' method='get' action='{$self}'> <tr> <td> <input type='hidden' name='mode' value='{$mode}'> <input type='submit' value='OK' style="width:50;height:50;"> </td> <td> EOS; if ($form['ckrf']) { $ck = ' checked'; } else { $ck = ''; } print <<<EOS <span class='label'>Refresh</span> <input type='checkbox' name='ckrf' id='ckrf'{$ck} onclick='_clk_reload()'><label for='ckrf'>automatic</label> EOS; $v = $form['rftime']; $sel = array(); if (!$v) { $v = 5; } $sel[$v] = ' selected'; print <<<EOS <select name='rftime' onchange='_change_rftime()'> <option value='2'{$sel['2']}>2 seconds</option> <option value='5'{$sel['5']}>5 seconds</option> <option value='10'{$sel['10']}>10 seconds</option> <option value='30'{$sel['30']}>30 seconds</option> <option value='60'{$sel['60']}>60 seconds</option> </select> <span id='spanTimer'></span> EOS; print "<br>"; $sd = getvalue($form['sd'], $_SESSION['metajob_sd'], date('Y-m-d')); $ed = getvalue($form['ed'], $_SESSION['metajob_ed'], date('Y-m-d')); $_SESSION['metajob_sd'] = $sd; $_SESSION['metajob_ed'] = $ed; print <<<EOS <span class='label'>Start Date</span> <input name="sd" value="{$sd}" size="12" class='a' onkeypress='keypress_text()'{$dis}><a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fStartPop(document.form.sd,document.form.ed);return false;" ><img class="PopcalTrigger" align="absmiddle" src="/dbmon/utl/DateRange/calbtn.gif" width="34" height="22" border="0" alt=""></a> ~ <input name="ed" value="{$ed}" size="12" class='a' onkeypress='keypress_text()'{$dis}><a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fEndPop(document.form.sd,document.form.ed);return false;" ><img class="PopcalTrigger" align="absmiddle" src="/dbmon/utl/DateRange/calbtn.gif" width="34" height="22" border="0" alt=""></a> <iframe width=132 height=142 name="gToday:contrast:agenda.js" id="gToday:contrast:agenda.js" src="/dbmon/utl/DateRange/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;"> </iframe> EOS; print <<<EOS </td> </tr> </form> </table> EOS; global $page_title; print <<<EOS <script> var timer = 5; var form = document.form; var span = document.getElementById('spanTimer'); var stoptimer = 0; function _reload() { if (!form.ckrf.checked) return; form.submit(); //document.location.reload(); } function _countdown() { if (stoptimer) { setTimeout("_countdown()", 1000); return; } if (!form.ckrf.checked) return; var str = "" + timer + " sec"; parent.top.document.title = "{$page_title} (" + str + ")"; span.innerHTML = str; timer--; if (timer <= 0) _reload(); setTimeout("_countdown()", 1000); } function _change_rftime() { var interval = parseInt(form.rftime.value); timer = interval; } function _clk_reload() { setTimeout("_countdown()", 1000); } function _onload() { setTimeout("_countdown()", 1000); var interval = parseInt(form.rftime.value); timer = interval; } if (window.addEventListener) { window.addEventListener("load", _onload, false); } else if (document.attachEvent) { window.attachEvent("onload", _onload); } </script> EOS; ## }} $select_items = "MJ.*, U.userid, U.service_Infra_id, A.name appname"; $sql_join = " LEFT JOIN User U ON MJ.user_id=U.id" . " LEFT JOIN application A ON MJ.app_id=A.id"; $w = array('1'); $sd = $form['sd']; $ed = $form['ed']; $w[] = "DATE(MJ.startTimestamp) >= '{$sd}'"; $w[] = "DATE(MJ.startTimestamp) <= '{$ed}'"; $sql_where = join(" AND ", $w); $sql_order = " ORDER BY MJ.startTimestamp DESC"; $qry = "SELECT {$select_items} FROM metajob MJ {$sql_join} WHERE {$sql_where} {$sql_order}"; //dd($qry); $ret = db_query($qry); $hi = "#,id,status,user,appname,startTime,updateTime,elapsed,num,total,subjobs,results"; table_head($hi); // 변수명#옵션 // 옵션 _:일반변수, L:왼쪽정렬 R:오른쪽정렬 C:가운데정렬 $tdk = "id#_,status,userid,appname,startTimestamp,lastUpdateTime,elapsed#_,num,total,subjobs#_,results#_"; $items = preg_split("/,/", $tdk); $cnt = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; //dd($row); $id = $row['id']; $var['id'] = span_link($id, "_view_md('{$id}')"); $var['subjobs'] = span_link('subjobs', "_list_subjobs('{$id}')"); $var['results'] = span_link('results', "_list_results('{$id}')"); $s = $row['startTimestamp']; $e = $row['lastUpdateTime']; $var['elapsed'] = diff_time($e, $s); $fields = array(); $fields[] = array($cnt, ''); _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _view_md(mjid) { var url = "{$env['self']}?mode=view&mjid="+mjid; wopen(url,1000,1000,1,1); //document.location.href = url; } function _list_subjobs(id) { var url = "subjob.php?mode=view&id="+id; document.location.href = url; } function _list_results(mjid) { var url = "result.php?mode=view&mjid="+mjid; document.location.href = url; } EOS; table_close($script); }
function _view($sjid, $mjid) { global $form; $select_items = "R.*, J.seq"; $sql_join = " LEFT JOIN job J ON R.job_id=J.id"; if ($sjid) { $sql_where = "R.job_id='{$sjid}'"; } else { if ($mjid) { $sql_where = "R.metajob_id='{$mjid}'"; } else { die('Error' . ':' . __FILE__ . ':' . __LINE__); } } $sql_order = " ORDER BY R.id DESC"; $sql_from_join_where = "FROM result R {$sql_join} WHERE {$sql_where}"; $total = _total_count($sql_from_join_where); $ipp = 100; $page = $form['page']; list($start, $last, $page) = pager_calc_page($ipp, $total); //dd("$total, $start, $last, $page"); global $mode; $id = $form['id']; print <<<EOS <form name='sform'> <input type='hidden' name='mode' value='{$mode}'> <input type='hidden' name='id' value='{$id}'> <input type='hidden' name='mjid' value='{$mjid}'> <input type='hidden' name='page' value='{$page}'> </form> EOS; // 페이지 이동 $html = pager_html($total, $page, $last, $ipp, 'sform'); print $html; $qry = "SELECT {$select_items} FROM result R {$sql_join} WHERE {$sql_where} {$sql_order}"; $qry .= " LIMIT {$start},{$ipp}"; //dd($qry); $ret = db_query($qry); $hi = "#,id,LFN,size,job_id,metajob_id,seq,download"; table_head($hi); // 변수명#옵션 // 옵션 _:일반변수, L:왼쪽정렬 R:오른쪽정렬 C:가운데정렬 $tdk = "id,LFN#L,size#_R,job_id,metajob_id,seq,download#_"; $items = preg_split("/,/", $tdk); $cnt = 0; $sizesum = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; //dd($seq); //dd($row); $id = $row['id']; $seq = $row['seq']; $fields = array(); $fields[] = array($cnt, ''); $var = array(); $lfn = $row['LFN']; $size = filesize($lfn); $sizesum += $size; list($s, $u) = FormatByteDown($size, 3, 1); $var['size'] = "{$s}{$u}"; $var['download'] = <<<EOS <a href="DownloadJobFiles.php?mode=sj&mjid={$mjid}&seq={$seq}">down</a> EOS; _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _down(mjid) { var url = "result.php?mode=download&mjid="+mjid; document.location.href = url; } EOS; list($s, $u) = FormatByteDown($sizesum, 3, 1); $dn = span_link('download', "_down('{$mjid}')"); $ss = "{$s}{$u}<br>{$dn}"; $hi = "#,,,{$ss},,,"; table_head($hi, $table_open = false); table_close($script); }
function _list() { global $form; ## {{ print <<<EOS <table border='0'> <form name='form' method='get' action='{$self}'> <tr> <td> <input type='hidden' name='mode' value='{$mode}'> <input type='submit' value='OK' style="width:50;height:50;"> </td> <td> EOS; if ($form['ckrf']) { $ck = ' checked'; } else { $ck = ''; } print <<<EOS <span class='label'>Refresh</span> <input type='checkbox' name='ckrf' id='ckrf'{$ck} onclick='_clk_reload()'><label for='ckrf'>automatic</label> EOS; $v = $form['rftime']; $sel = array(); if (!$v) { $v = 5; } $sel[$v] = ' selected'; print <<<EOS <select name='rftime' onchange='_change_rftime()'> <option value='2'{$sel['2']}>2 seconds</option> <option value='5'{$sel['5']}>5 seconds</option> <option value='10'{$sel['10']}>10 seconds</option> <option value='30'{$sel['30']}>30 seconds</option> <option value='60'{$sel['60']}>60 seconds</option> </select> <span id='spanTimer'></span> EOS; print "<br>"; print <<<EOS </td> </tr> </form> </table> EOS; global $page_title; print <<<EOS <script> var timer = 5; var form = document.form; var span = document.getElementById('spanTimer'); var stoptimer = 0; function _reload() { if (!form.ckrf.checked) return; form.submit(); } function _countdown() { if (_count_checked() > 0) stoptimer = true; else stoptimer = false; if (stoptimer) { setTimeout("_countdown()", 1000); return; } if (!form.ckrf.checked) return; var str = "" + timer + " sec"; parent.top.document.title = "{$page_title} (" + str + ")"; span.innerHTML = str; timer--; if (timer <= 0) _reload(); setTimeout("_countdown()", 1000); } function _change_rftime() { var interval = parseInt(form.rftime.value); timer = interval; } function _clk_reload() { setTimeout("_countdown()", 1000); } function _onload() { setTimeout("_countdown()", 1000); var interval = parseInt(form.rftime.value); timer = interval; } if (window.addEventListener) { window.addEventListener("load", _onload, false); } else if (document.attachEvent) { window.attachEvent("onload", _onload); } </script> EOS; ## }} $sql_from = " FROM CE CE"; $select_items = "CE.*, SI.name SIname" . ", IF(CE.available,'1','0') avail" . ", IF(CE.banned,'1','0') banned"; $sql_join = " LEFT JOIN service_infra SI ON CE.service_Infra_id=SI.id"; $w = array('1'); $sql_where = " WHERE " . join(" AND ", $w); $sql_order = " ORDER BY CE.name"; //$sql_order = " ORDER BY CE.banned, CE.available,CE.lastUpdateTime DESC"; $qry = "SELECT {$select_items} {$sql_from} {$sql_join} {$sql_where} {$sql_order}"; //dd($qry); $ret = db_query($qry); print <<<EOS <input type='button' onclick='_setavail(1)' value='Set Available'> <input type='button' onclick='_setavail(0)' value='Set UnAvailable'> <script> function _count_checked() { var form = document.form2; var cbs = document.getElementsByName('cb[]'); var len = cbs.length; var count = 0; for (i = 0; i < len; i++) { var cb = cbs[i]; if (cb.checked) { count++; } } return count; } function _setavail(flag) { var form = document.form2; var count = _count_checked(); if (count == 0) { alert("No Selection!!"); return; } if (!confirm("Mark the selected "+ count +" CE(s) as available?")) return; if (flag) form.mode2.value = '1'; else form.mode2.value = '0'; form.target = 'hiddenframe'; form.mode.value = 'setavail'; form.submit(); } </script> EOS; print <<<EOS <iframe name='hiddenframe' width='100' height='100' style="display:none"></iframe> EOS; $hi = "#,,ID,name,sInfra,banned,available,lastUpdate,elapsed,maxRunningTime,free,free(%),total,limit"; table_head($hi); print <<<EOS <form name='form2' action='{$env['self']}' method='post'> <input type='hidden' name='mode' value=''> <input type='hidden' name='mode2' value=''> EOS; // 변수명#옵션 // 옵션 _:일반변수, L:왼쪽정렬 R:오른쪽정렬 C:가운데정렬 $tdk = "cb#_,id,name,SIname,banned#_,avail#_,lastUpdateTime,elapsed#_,maxRunningTime,freeCPU,percent#_R,totalCPU,limitCPU"; $items = preg_split("/,/", $tdk); $count_banned = 0; $count_avail = 0; $count_total = 0; $sum = array(); $cnt = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; $count_total++; //dd($row); //var_dump($row); $id = $row['id']; //$var['id'] = span_link($id, "_view_md('$id')"); $t1 = $row['lastUpdateTime']; $t2 = date('Y-m-d H:i:s'); $var['elapsed'] = diff_time($t2, $t1); if ($row['avail'] == '1') { $count_avail++; $var['avail'] = 'avail'; } else { $var['avail'] = '-'; } if ($row['banned'] == '1') { $count_banned++; $var['banned'] = 'banned'; } else { $var['banned'] = '-'; } $free = $row['freeCPU']; $sum['free'] += $free; $total = $row['totalCPU']; $sum['total'] += $total; $limit = $row['limitCPU']; $sum['limit'] += $limit; $var['percent'] = sprintf("%2.1f%%", $free / $total * 100); $var['cb'] = <<<EOS <input type='checkbox' name='cb[]' value='{$id}'> EOS; $fields = array(); $fields[] = array($cnt, ''); _push($fields, $items, $row, $var); print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _view_md(mjid) { var url = "{$env['self']}?mode=view&mjid="+mjid; document.location.href = url; } EOS; $free = $sum['free']; $total = $sum['total']; $limit = $sum['limit']; $percent = sprintf("%2.1f%%", $sum['free'] / $sum['total'] * 100); $hi = "#,,,{$count_total},,{$count_banned},{$count_avail},,,,{$free},{$percent},{$total},{$limit}"; table_head($hi, $table_open = false); print <<<EOS </form> EOS; table_close($script); }
function _view() { global $form; $mjid = $form['id']; $select_items = "J.*, A.host, CE.name CEname"; $sql_from = " FROM Job J"; $sql_join = " LEFT JOIN Agent A ON J.agent_id=A.id" . " LEFT JOIN CE ON J.CE_id=CE.id"; $w = array(); $w[] = "J.metajob_id='{$mjid}'"; $v = $form['host']; if ($v != '') { $w[] = "A.host LIKE '%{$v}%'"; } $v = $form['status']; if ($v != '') { $w[] = "J.status='{$v}'"; } $sql_where = " WHERE " . join(" AND ", $w); $sql_order = " ORDER BY J.seq DESC"; $sql_from_join_where = "{$sql_from} {$sql_join} {$sql_where}"; $total = _total_count($sql_from_join_where); $ipp = 100; $page = $form['page']; list($start, $last, $page) = pager_calc_page($ipp, $total); //dd("$total, $start, $last, $page"); global $mode; print <<<EOS <form action='{$self}' method='get' name='sform'> EOS; $v = $form['host']; print <<<EOS <span class='lbl'>host</span><input type='text' name='host' size='10' value='{$v}' onclick="this.value=''"> EOS; $list = array('', 'preparing', 'running', 'done', 'failed'); $preset = $form['status']; $opt = option_general($list, $preset); print <<<EOS <span class='lbl'>status</span><select name='status'>{$opt}</select> EOS; global $mode; print <<<EOS <input type='hidden' name='mode' value='{$mode}'> <input type='hidden' name='id' value='{$form['id']}'> <input type='hidden' name='page' value='{$page}'> <input type='button' onclick='_submit()' value=' OK ' style="width:60px; height:30px;"> </form> <script> function _submit() { document.sform.submit(); } </script> EOS; // 페이지 이동 $html = pager_html($total, $page, $last, $ipp, 'sform'); print $html; $qry = "SELECT {$select_items} {$sql_from} {$sql_join} {$sql_where} {$sql_order}"; $qry .= " LIMIT {$start},{$ipp}"; //dd($qry); $ret = db_query($qry); $hi = "#,metajob_id,id,seq,name,errormsg,startTimestamp,lastUpdateTime,elapsed" . ",status,CE,agent_id,host,results"; table_head($hi); // 변수앞에 _을 붙이면 일반변수, 그렇지 않으면 $row의 key값 $tdk = "metajob_id,id,seq,name,errormsg,startTimestamp,lastUpdateTime,_elapsed" . ",status,CEname,agent_id,host,_results"; $items = preg_split("/,/", $tdk); $cnt = 0; while ($row = mysql_fetch_assoc($ret)) { $cnt++; //dd($row); $id = $row['id']; $results = span_link('results', "_list_results('{$id}')"); $s = $row['startTimestamp']; $e = $row['lastUpdateTime']; $elapsed = diff_time($e, $s); $fields = array(); $fields[] = array($cnt, $atr1); foreach ($items as $item) { $a = substr($item, 0, 1); // $item = '_cnt' if ($a == '_') { $key = substr($item, 1); // $key = 'cnt' $value = ${$key}; // $value = $cnt } else { if ($a == '') { $value = ''; } else { $value = $row[$item]; } } $fields[] = array($value, $atr1); } print "<tr>"; for ($i = 0; $i < count($fields); $i++) { list($str, $attr) = $fields[$i]; table_data_text($str, $attr, $nowrap = 1); } print "</tr>"; } $script = <<<EOS function _list_results(subjob_id) { var url = "result.php?mode=view&sjid="+subjob_id; document.location.href = url; } EOS; table_close($script); }
function table_data_row(&$row, $keys, $attr, $nowrap = 0) { if (is_string($keys)) { $list = preg_split("/,/", $keys); } else { if (is_array($keys)) { $list = $keys; } else { die('Error' . ':' . __FILE__ . ':' . __LINE__); } } foreach ($list as $a) { $val = $row[$a]; table_data_text($val, $attr, $nowrap); } }