Location: PHPKode > projects > QuickTicket > quickticket/qti_adm_statuses.php
<?php

/**
* PHP versions 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package    QuickTicket
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20101222
*/

session_start();
require_once('bin/qti_init.php');
if ( $oVIP->role!='A' ) die(Error(13));
include(Translate('qti_adm.php'));

// INITIALISE

$oVIP->selfurl = 'qti_adm_statuses.php';
$oVIP->exiturl = 'qti_adm_statuses.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br />'.$L['Statuses'];
$oVIP->exitname = $L['Statuses'];

// --------
// SUBMITTED for add
// --------

if ( isset($_POST['ok_add']) )
{
  // Check id, name and duplicate id

  $id = strtoupper($_POST['id']);
  if ( !preg_match('/[B-Y]/',$id) ) $error="Id $id ".$L['E_invalid']." (B-Y)";
  $name = trim($_POST['name']); if ( get_magic_quotes_gpc() ) $name = stripslashes($name);
  if ( $name=='' ) $error = $L['Status'].' '.$L['E_invalid'];
  if ( array_key_exists($id,$oVIP->statuses) ) $error = $L['Status'].' id ['.$id.'] '.strtolower($L['E_already_used']);

  // Add

  if ( empty($error) )
  {
    $error = $oVIP->StatusAdd($id,$name,'ico_status0.gif');
  }
  
  // Exit
  
  if ( empty($error) )
  {
    $oVIP->exiturl = 'qti_adm_status.php?id='.$id;
    $oVIP->exitname = $L['Status_upd'];
    $oVIP->EndMessage('0');
    exit;
  }
}

// --------
// SUBMITTED for show
// --------

if ( isset($_POST['ok_show']) )
{
    $_SESSION[QT]['show_closed'] = $_POST['show_closed'];
    $oDB->Query('UPDATE '.TABSETTING.' SET setting="'.$_SESSION[QT]['show_closed'].'" WHERE param="show_closed"');
    // exit
    $strInfo = $L['S_save'];
}

// --------
// HTML START
// --------

$strHeadScript = '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
  if (theForm.id.value.length==0) { alert("Id ?"); return false; }
  if (theForm.name.value.length==0) { alert("'.$L['Status'].' ?"); return false; }
  return null;
}
-->
</script>
';
include('qti_adm_p_header.php');

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(this);">
<table cellspacing="0" class="data_o">
<colgroup span="6"><col width="30"></col><col width="30"></col><col></col><col></col><col width="75"></col><col></col></colgroup>
<tr class="data_o">
<td class="colhd">Id</td>
<td class="colhd">&nbsp;</td>
<td class="colhd" style="text-align:left">',$L['Status'],'</td>
<td class="colhd">',$L['Email'],'</td>
<td class="colhd">',$L['Status_background'],'</td>
<td class="colhd">',$L['Action'],'</td>
</tr>
';

foreach($oVIP->statuses as $id=>$arrStatus)
{
  echo '<tr onmouseover="this.style.backgroundColor=\'#eeeeee\';" onmouseout="this.style.backgroundColor=\'#ffffff\';">',N;
  echo '<td class="colct">',$id,'</td>',N;
  echo '<td class="colct">',AsImg($_SESSION[QT]['skin_dir'].'/'.$arrStatus['icon'],'-',$arrStatus['statusname'],'ico ico_status'),'</td>',N;
  echo '<td class="colct"><a class="bold" href="qti_adm_status.php?id=',$id,'">',$arrStatus['statusname'],'</a>',(empty($arrStatus['statusdesc']) ? '' : '<span class="disabled"> &middot; '.$arrStatus['statusdesc'].'</span>'),'</td>',N;
  echo '<td class="colct">',($arrStatus['mailto']!='' ? $L['Y'] : '<span class="disabled">'.$L['None'].'</span>'),'</td>',N;
  echo '<td class="colct" ',( empty($arrStatus['color']) ? '' : 'style="background-color:'.$arrStatus['color'].'"'),'>&nbsp;</td>',N;
  echo '<td class="colct"><a class="small" href="qti_adm_status.php?id=',$id,'">',$L['Edit'],'</a>&nbsp;&middot;&nbsp;';
  if ( ($id=='A') || ($id=='Z') ) { echo '<span class="disabled">',$L['Delete']; } else { echo '<a class="small" href="qti_adm_change.php?a=status_del&amp;v=',$id,'">',$L['Delete'],'</a>'; }
  echo '</td>',N,'</tr>',N;
}
echo '
<tr class="tr">
<td class="colgroup"><input type="text" name="id" value="" size="1" maxlength="1" class="small" /></td>
<td class="colgroup">&nbsp;</td>
<td class="colgroup" colspan="4"><input type="text" name="name" value="" size="20" maxlength="24" class="small" /> <input type="submit" name="ok_add" value="',$L['Add'],'" /></td>
</tr>
</table>
</form>
';

echo '<h2>',$L['Display_options'],'</h2>';

echo '
<form method="post" action="',$oVIP->selfurl,'">
<table cellspacing="0" class="data_o">
<tr class="data_o">
<td class="colhd colhdfirst" style="width:150px"><label for="show_closed">',$L['Show_z'],'</label></td>
<td class="colct"><select id="show_closed" name="show_closed">
<option value="0"',($_SESSION[QT]['show_closed']=='0' ? QSEL : ''),'>',$L['N'],'</option>
<option value="1"',($_SESSION[QT]['show_closed']=='1' ? QSEL : ''),'>',$L['Y'],'</option>
</select> <span class="small">',sprintf($L['H_Show_z'],$oVIP->statuses['Z']['statusname']),'</span></td>
<td class="colct"><input type="submit" name="ok_show" value="',$L['Ok'],'" /></td>
</tr>
</table>
</form>
';

// --------
// HTML END
// --------

include('qti_adm_p_footer.php');

?>
Return current item: QuickTicket