<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[47]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="book_class";
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  if($_POST['classname']=="")
    jump("jump.php?id=2&jump=book_class.php?action=add");
  else
  {
    if($_POST['queue']=="")
      $_POST['queue']="0";
    $phpcolor->field="classname, queue";
    $phpcolor->where="'".$_POST['classname']."', '".$_POST['queue']."'";
    $phpcolor->write();
    jump("jump.php?id=24&jump=book_class.php");
  }
}
if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "del")
{
  $phpcolor->table="book";
  $phpcolor->field="belong='0'";
  $phpcolor->where="belong = '".$_GET['id']."'";
  $phpcolor->upgrade();
  $phpcolor->table="book_class";
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->delete();
  jump("jump.php?id=24&jump=book_class.php");
}
if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "editdo")
{
  if($_POST['classname']=="")
    jump("jump.php?id=2&jump=book_class.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->field="classname='".$_POST['classname']."', queue='".$_POST['queue']."'";
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=book_class.php");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  $phpcolor->where="1 = 1 order by queue";
  $sort=$phpcolor->assignment();
  $count=count($sort);
  $tpl -> assign("sort", $sort);
  $tpl -> assign("count", $count);
  $tpl -> display("book_class.htm");
}
?>