<?php
require 'inc.php';
$obj_tab_pay_type=new cls_tab_pay_type();

$arr_type_class=$obj_tab_pay_type->type_class;

if(!isset($int_pagesize)) $int_pagesize=10;
if(!isset($get_act)) $get_act="";
(!isset($get_page))? $get_page=0:$get_page=intval($get_page);

$str_type_class="";
if(isset($get_type_class)&&$get_type_class!=""&&isset($arr_type_class[$get_type_class])){
	$str_type_class=$get_type_class;
}


if($get_act=="del")
{
	$str_msg=$obj_db->execute("delete from ".DB_PRE."pay_type where type_class='".$str_type_class."'");
}


if($get_act=='save'){
	$arr_fields=array();
	$arr_fields["type_class"]=$str_type_class;
	$arr_msg=$obj_tab_pay_type->on_save($arr_fields);
	if($arr_msg["err"]==""){
		$obj_msg->alert("³É¹¦±£´æ!");
	}else{
		$obj_msg->alert($arr_msg["err"]);
	}
	$get_act="edit";
}

switch($get_act)
{	
	case 'edit':
	{
		$arr_type=array();
		$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."pay_type where type_class='".$str_type_class."'");
		if($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_type["type_fields"]=$obj_tab_pay_type->get_pay_fields_html($obj_rs["type_class"],$obj_rs["type_fields"]);
		}else{
			$arr_type["type_fields"]=$obj_tab_pay_type->get_pay_fields_html($str_type_class,"");
		}
		include 'tpl/type.edit.tpl.php';
		break;
	}
	default:
	{
		$arr_open_type=array();
		$obj_result=$obj_db->query("select * from ".DB_PRE."pay_type");
		while($obj_rs=$obj_db->fetch_array($obj_result)){
			$arr_open_type[]=$obj_rs["type_class"];
		}
		include 'tpl/type.tpl.php';
	}
}

?>