Location: PHPKode > projects > QT-registrations > qtregistrations/qtr_adm_statuses.php
<?php

/**
* PHP versions 4 and 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    QT-registerations
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.4 build:20100313
*/

session_start();
require_once('bin/qtr_init.php');
include(Translate('qtr_adm.php'));

if ( $oVIP->role!='A' ) die(Error(13));

// INITIALISE

$oVIP->selfurl = 'qtr_adm_statuses.php';
$oVIP->exiturl = 'qtr_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 ".Error(1)." (B-Y)";
  $name = trim($_POST['name']); if ( get_magic_quotes_gpc() ) $name = stripslashes($name);
  if ( $name=='' ) $error = $L['Status'].' '.Error(1);
  if ( array_key_exists($id,$oVIP->statuses) ) $error = $L['Status'].' ID '.strtolower($L['E_already_used']);
  
  // add and exit

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

// --------
// 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("'.$L['Missing'].': Id"); return false; }
  if (theForm.name.value.length==0) { alert("'.$L['Missing'].': '.$L['Status'].'"); return false; }
  return null;
}
-->
</script>
';

include('qtr_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="th_o">Id</td>
<td class="th_o">&nbsp;</td>
<td class="th_o" style="text-align:left">',$L['Status'],'</td>
<td class="th_o">',$L['Email'],'</td>
<td class="th_o">',$L['Status_background'],'</td>
<td class="th_o">',$L['Action'],'</td>
</tr>
';

foreach($oVIP->statuses as $id=>$arrStatus)
{
  echo '<tr class="rowlight">',N;
  echo '<td class="td_o td_o_sta">',$id,'</td>',N;
  echo '<td class="td_o td_o_sta">',AsImg($_SESSION[QT]['skin_dir'].'/'.$arrStatus['icon'],'-',$arrStatus['statusname'],'ico i_status'),'</td>',N;
  echo '<td class="td_o td_o_inf"><a class="bold" href="qtr_adm_status.php?id=',$id,'">',$arrStatus['statusname'],'</a>',(empty($arrStatus['statusdesc']) ? '' : '<span class="disabled"> &middot; '.$arrStatus['statusdesc'].'</span>'),'</td>',N;
  echo '<td class="td_o td_o_sta">',($arrStatus['mailto']!='' ? $L['Y'] : '<span class="disabled">'.$L['None'].'</span>'),'</td>',N;
  echo '<td class="td_o td_o_sta" ',( empty($arrStatus['color']) ? '' : 'style="background-color:'.$arrStatus['color'].'"'),'>&nbsp;</td>',N;
  echo '<td class="td_o td_o_sta"><a class="small" href="qtr_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="qtr_adm_change.php?a=status_del&amp;v=',$id,'">',$L['Delete'],'</a>'; }
  echo '</td>',N,'</tr>',N;
}
echo '
<tr class="data_o">
<td class="td_o_all"><input type="text" name="id" value="" size="1" maxlength="1" class="small"/></td>
<td class="td_o_all">&nbsp;</td>
<td class="td_o_all" 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="th_o th_o_first" style="width:150px"><label for="show_closed">',$L['Show_z'],'</label></td>
<td class="td_o"><select id="show_closed" name="show_closed" onchange="bEdited=true;">
<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="td_o"><input type="submit" name="ok_show" value="',$L['Ok'],'"/></td>
</tr>
</table>
</form>
';

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

include('qtr_adm_p_footer.php');

?>
Return current item: QT-registrations