[wpkg_web] / pack_commands.php Repository:
ViewVC logotype

View of /pack_commands.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (download) (annotate)
Mon Jan 22 16:14:12 2007 UTC (11 years ago) by linuxkidd
File size: 16815 byte(s)
Added Edit button for Package Commands page

<?php
  
if(isset($_GET['cmdid'])) {
    
$cmdid=$_GET['cmdid'];
  } else {
    
$cmdid=0;
  }
  if(isset(
$_GET['reorder'])) {
    
$reorder=$_GET['reorder'];
    print 
"<script src=\"reorder.js\" language=\"JavaScript\"></script>\n";
  } else {
    
$reorder='';
  }
?>
<form name='commands' id='commands' method='GET' action='pack_com_sub.php'<?php
    
if($reorder!='') {
      print 
' onSubmit="selectAll(this.id_list)"';
    }
    
?>>
<input type='hidden' id='pack_id' name='pack_id' value='<?php print $pack_id?>'>
<?php
  
include "pack_header.php";
  
$sql="select * from pack_cmdexitactions";
  
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
  
$exit_actions=array();
  while(
$action=mysql_fetch_array($sql_handle)) {
    
$exit_actions[$action['id']]=$action['value'];
  }
  
$sql="select * from pack_cmdtype order by id";
  
$sql_handle=mysql_query($sql) or error_report($sql,mysql_error());
  while(
$cmdtype=mysql_fetch_array($sql_handle)) {
?>
<table class='tbl_sub2' cellspacing='0' cellpadding='2'>
  <tr class='headline'>
    <td colspan='2'><input type='button' onclick='window.location="packages.php?pack_id=<?php
      
print $pack_id?>&page=<?php print $page?>&new=<?php print $cmdtype['id']; ?>"'
      value="Add" style='font-weight: normal;'> &nbsp; <?php print $vocab['title-' $cmdtype['value']];
      print 
" &nbsp; <input type='button' id='{$cmdtype['value']}_order' onclick='window.location=\"packages.php?pack_id=" .
          
"{$pack_id}&page={$page}&reorder={$cmdtype['value']}\"' value=\"{$vocab['button-mass_reorder']}\" style='font-weight: normal; display: none;'>";
 
?></td>
  </tr>
<?php
    $sql2
=sprintf("select count(id) from pack_cmds where pack_id=%s and cmdtype_id=%s"quote_smart($pack_id), quote_smart($cmdtype['id']));
    
$sql2_handle=mysql_query($sql2) or error_report($sql2,mysql_error());
    list(
$cmd_count)=mysql_fetch_array($sql2_handle);
    
$sql2=sprintf("select pack_cmds.id as id,priority,pack_cmds.cmd as cmd,pack_cmds.timeout as timeout from pack_cmds where pack_id=%s and cmdtype_id=%s order by priority"quote_smart($pack_id), quote_smart($cmdtype['id']));
    
$fields=array('id','priority','cmd');
    
$sql2_handle=mysql_query($sql2) or error_report($sql2,mysql_error());
    
$count=0;
    if(
$reorder==$cmdtype['value']) {
      
reorder_list($cmdtype['value'],$sql2_handle);
      continue;
    }
    while(
$data=mysql_fetch_array($sql2_handle)) {
      print 
"  <tr>\n";
      if(
$cmdid==$data['id'] && !isset($_GET['exitcode'])) {
        
######################################################################
        ######################################################################
        ##                                                                  ##
        ##                  Begin Edit Entry Section                        ##
        ##                                                                  ##
        ######################################################################
        ######################################################################
        
print "    <td colspan='2' style='background:{$alt_bg_colors[$count%2]};' valign='middle'>";
      
?>
      <input type='hidden' id='cmd_id' name='cmd_id' value='<?php print $data['id']; ?>'>
      <?php print $vocab['title-command']; ?>: <textarea cols='60' rows='1' wrap='off' id='cmd' name='cmd' size='65' maxlength='64000'><?php print $data['cmd']; ?></textarea>
      <?php print $vocab['title-timeout']; ?>: <input type='text' id='timeout' name='timeout' size='4' maxlength='9' value='<?php print $data['timeout']; ?>'> <?php print $vocab['title-seconds']; ?>
    </td>
  </tr>
  <tr>
    <td colspan='2' style='background: <?php print $alt_bg_colors[$count%2]; ?>;' valign='middle'>
      <div style='margin-left: 75px;'><input type='submit' id='Update' name='Update' value='<?php print $vocab['button-update']; ?>'> <input type='button' onclick='window.location="packages.php?pack_id=<?php print $pack_id?>&page=<?php
        
print $page?>"' value='<?php print $vocab['button-cancel']; ?>'></div>
    </td>
  </tr>
      <?php
        
continue;
      }
      
######################################################################
      ######################################################################
      ##                                                                  ##
      ##                  Begin Print Entry Section                       ##
      ##                                                                  ##
      ######################################################################
      ######################################################################
      
print "    <td style='background:{$alt_bg_colors[$count%2]};' valign='middle' width='95'>";
      if(
$count) {
        
######################################################################
        ## Print Up Arrow if were not the first entry                       ##
        ######################################################################
        
print "<a href='pack_com_sub.php?cmdid={$data['id']}&dir=1&pri={$data['priority']}&pack_id={$pack_id}'
          title='Raise Priority'>
{$icon['up'][0]}</a>";
      } else {
        print 
$icon['space'][0];
      }
      if(
$cmd_count>&& $count<($cmd_count-1)) {
        
######################################################################
        ## Print Down Arrow if we have more than one entry,                 ##
        ##   and we're not the last entry                                   ##
        ######################################################################
        
print "<a href='pack_com_sub.php?cmdid={$data['id']}&dir=3&pri={$data['priority']}&pack_id={$pack_id}'
          title='Lower Priority'>
{$icon['down'][0]}</a>";
      } else {
        print 
$icon['space'][0];
      }
      
######################################################################
      ## Print Delete Button                                              ##
      ######################################################################
      
print "<a href='pack_com_sub.php?cmdid={$data['id']}&pack_id={$pack_id}&del=1' title='Delete'
      onClick=\"return confirm('Clicking OK will permanently delete this 
{$cmdtype['value']} command. ARE YOU SURE?!');\">{$icon['delete'][0]}</a>";
      
######################################################################
      ## Print Add Exit Code Button                                       ##
      ######################################################################
      
print "<a href='packages.php?page={$page}&pack_id={$pack_id}&addexit={$data['id']}' title='Add Exit Code'>{$icon['plus'][0]}</a>";
      
######################################################################
      ## Print Edit Button                                                ##
      ######################################################################
      
print "<a href='packages.php?pack_id={$pack_id}&page={$page}&cmdid={$data['id']}' title='{$vocab['title-edit']}'>{$icon['edit'][0]}<a>";

      print 
"</td><td style='background:{$alt_bg_colors[$count%2]};' valign='middle'> &nbsp; ";
      print 
"<textarea cols='60' style='background:{$alt_bg_colors[$count%2]};' rows='1' wrap='off' maxlength='65000' readonly>" .
           
htmlspecialchars($data['cmd']) . "</textarea>";
      
# onDblClick='window.location=\"packages.php?pack_id={$pack_id}&page={$page}&cmdid={$data['id']}\"'
      
print " &nbsp; {$vocab['title-timeout']}{$data['timeout']} {$vocab['title-seconds']} ";
      print 
"</td>\n  </tr>\n";
      
$sql3="select * from pack_cmdexits where cmd_id=" quote_smart($data['id']);
      
$sql3_handle=mysql_query($sql3) or error_report($sql3,mysql_error());
      while (
$exit_data=mysql_fetch_array($sql3_handle)) {
        if(isset(
$_GET['exitcode']) && $_GET['exitcode']==$exit_data['exitcode']) {
          
######################################################################
          ######################################################################
          ##                                                                  ##
          ##                  Begin Edit Exit Code Section                    ##
          ##                                                                  ##
          ######################################################################
          ######################################################################
          
print "  <tr style='background:{$alt_bg_colors[$count%2]};'>\n    <td width='76px'>&nbsp;</td><td>";
          print 
"<input type='hidden' name='cmdid' id='cmdid' value='{$data['id']}'>{$vocab['title-exitcode']}{$exit_data['exitcode']} &nbsp; ";
          print 
"<input type='hidden' name='exitcode' id='exitcode' value='{$exit_data['exitcode']}'>";
          print 
"<select id='action_id' name='action_id'>\n";
          foreach (
$exit_actions as $act_id=>$action) {
            print 
"        <option value='{$act_id}'";
            if(
$act_id==$exit_data['action_id']) {
              print 
" SELECTED";
            }
            print 
">{$action}</option>\n";
          }
          print 
"</select>";
          print 
"      <input type='submit' id='updateexit' name='updateexit' value='{$vocab['button-update_exit']}'><input type='button' onclick='window.location=\"packages.php?pack_id={$pack_id}&page={$page}\"' value='{$vocab['button-cancel']}'>";
        print 
"</td>\n  </tr>";
        } else {
          
######################################################################
          ######################################################################
          ##                                                                  ##
          ##                  Begin Print Exit Code Section                   ##
          ##                                                                  ##
          ######################################################################
          ######################################################################
          
print "  <tr style='background:{$alt_bg_colors[$count%2]};'>\n    <td width='76px'>&nbsp;</td><td>";
          print 
"<a href='pack_com_sub.php?cmdid={$data['id']}&pack_id={$pack_id}&delexit={$exit_data['exitcode']}' title='{$vocab['title-delete']}' onClick=\"return confirm('{$vocab['popup-permdel']} {$exit_data['exitcode']} {$vocab['popup-exitcode']}{$vocab['gen-confirm']}');\">{$icon['delete'][0]}</a> &nbsp; ";
          print 
"<a href='packages.php?pack_id={$pack_id}&cmdid={$data['id']}&page={$page}&exitcode={$exit_data['exitcode']}' title='{$vocab['title-edit']}'>";
          print 
"{$vocab['title-exitcode']}{$exit_data['exitcode']} ( {$exit_actions[$exit_data['action_id']]} )</td>\n  </tr>";
        }
      }
      if(isset(
$_GET['addexit']) && $_GET['addexit']==$data['id']) {
        
######################################################################
        ######################################################################
        ##                                                                  ##
        ##                  Begin Add New Exit Code Section                 ##
        ##                                                                  ##
        ######################################################################
        ######################################################################
        
print "  <tr>\n    <td width='76px'><input type='hidden' name='cmdid' id='cmdid' value='{$data['id']}'>&nbsp;</td><td>";
        print 
"{$vocab['title-exitcode']}: <input type='text' name='exitcode' id='exitcode' size='4' maxlength='8'> &nbsp; ";
        print 
"<select id='action_id' name='action_id'>\n";
        foreach (
$exit_actions as $act_id=>$action) {
          print 
"        <option value='{$act_id}'>{$action}</option>\n";
        }
        print 
"      </select>\n";
        print 
"      <input type='submit' id='addexit' name='addexit' value='{$vocab['button-addexit']}'><input type='button' onclick='window.location=\"packages.php?pack_id={$pack_id}&page={$page}\"' value='{$vocab['button-cancel']}'>";
        print 
"</td>\n  </tr>";
      }
      
$count++;
    }
    
$gotit=0;
    if(isset(
$_GET['new'])){
      
######################################################################
      ######################################################################
      ##                                                                  ##
      ##                  Begin Add New Command Section                   ##
      ##                                                                  ##
      ######################################################################
      ######################################################################
      
if($_GET['new']==$cmdtype['id']){
        
$gotit=1;
        
$cmd_count++;
        
?>
  <tr>
    <td colspan='2' style='background: <?php print $alt_bg_colors[$count%2]; ?>'>
      <input type='hidden' id='cmdtype_id' name='cmdtype_id' value='<?php print $cmdtype['id']; ?>'>
      <input type='hidden' id='priority' name='priority' value='<?php print $cmd_count?>'>
      <?php print $vocab['title-command']; ?>: <textarea cols='60' rows='1' wrap='off' id='cmd' name='cmd' size='65' maxlength='64000'></textarea>
      <?php print $vocab['title-timeout']; ?>: <input type='text' id='timeout' name='timeout' size='4' maxlength='9' value='3600'> <?php print $vocab['title-seconds']; ?>
    </td>
  </tr>
  <tr>
    <td colspan='2' style='background: <?php print $alt_bg_colors[$count%2]; ?>'><div style='margin-left: 75px;'>
      <input type='submit' id='Add' name='Add' value='<?php print $vocab['button-add']; ?>'>
      <input type='button' onclick='window.location="packages.php?pack_id=<?php print $pack_id?>&page=<?php
        
print $page?>"' value='<?php print $vocab['button-cancel']; ?>'></div>
    </td>
  </tr>
  <?php
      
}
    }
    if(
$cmd_count>4) {
?>
<script type="text/javascript">
  document.getElementById("<?php print $cmdtype['value']; ?>_order").style.display="inline";
</script>
<?php
    
}
    if(!
$cmd_count && !$gotit) {
      print 
"  <tr>\n    <td style='background: {$alt_bg_colors[0]};'>{$vocab['gen-com_none']} " .
        
strtolower($vocab['title-' $cmdtype['value']]) . {$vocab['gen-com_none-2']}</td>\n  </tr>\n";
    }
    print 
"</table>\n";
  }

function 
reorder_list($type,$handle) {
  global 
$pack_id,$alt_bg_colors,$page,$vocab;
?>
  <input type='hidden' name='type' value='<?php print $type?>'>
  <table class='tbl_sub2' cellspacing='0'>
  <tr>
     <th class='headline' style='text-align: center;' colspan='3'><?php print $vocab['title-reorder'] . " " $vocab['title-' $type]; ?></th>
  </tr>
  <tr>
    <td align='center' colspan='3'>
      <select id='id_list' name='id_list[]' multiple size='10'>
<?php
  $count
=0;
  while(
$cmd_data=mysql_fetch_array($handle)) {
    print 
"        <option value='{$cmd_data['id']}'>{$cmd_data['cmd']}</option>\n";
  }
?>
      </select>
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td align="right">
      <input style="width: 100px" type="button" onClick="moveOption(this.form.id_list, -1)"
         value="<?php print $vocab['button-up']; ?>" title="Up">
    </td>
    <td align="center">
      <input style="width: 100px" type="button" onClick="moveOptionVar(this.form.id_list, -1, 20)"
         value="<?php print $vocab['button-pageup']; ?>" title="Page Up">
    </td>
    <td align="left">
      <input style="width: 100px" type="button" onClick="moveOptionAllWay(this.form.id_list, -1)"
         value="<?php print $vocab['button-top']; ?>" title="Top">
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td align="right">
      <input style="width: 100px" type="button" onClick="moveOption(this.form.id_list, 1)"
         value="<?php print $vocab['button-down']; ?>" title="Down">
    </td>
    <td align="center">
      <input style="width: 100px" type="button" onClick="moveOptionVar(this.form.id_list, 1, 20)"
         value="<?php print $vocab['button-pagedown']; ?>" title="Page Down">
    </td>
    <td align="left">
      <input style="width: 100px" type="button" onClick="moveOptionAllWay(this.form.id_list, 1)"
         value="<?php print $vocab['button-bottom']; ?>" title="Bottom">
    </td>
  </tr>
  <tr style='background: <?php print $alt_bg_colors[0]; ?>;'>
    <td colspan="3" align="center">
      <input type="submit" name='save' id='save' value="<?php print $vocab['button-saveorder']; ?>"> &nbsp; <input type='button' name='cancel' id='cancel' value='<?php print $vocab['button-cancelorder']; ?>' onclick='window.location="packages.php?pack_id=<?php print $pack_id?>&page=<?php print $page?>"'>
    </td>
  </tr>
</table>
<?php
}
 
?>

ViewVC Help
Powered by ViewVC 1.0.3