<?php
/*
	[Office 515158] (C) 2009-2014 天生创想 Inc.
	$Id: mod_workclass mobile $
*/
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
$type=getGP('type','G');
$type_name='工作流';	
empty($do) && $do = 'list';
if ($do == 'list') {
	if($type==1){
		$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."workclass a,".DB_TABLEPRE."workclass_personnel b WHERE  a.id=b.workid and (b.pertype=0 or b.pertype=4) and b.name like '%".get_realname($_USER->id)."%' and a.type!=1 order by b.perid asc");
		$sql = "SELECT a.* FROM ".DB_TABLEPRE."workclass a,".DB_TABLEPRE."workclass_personnel b WHERE a.id=b.workid and (b.pertype=0 or b.pertype=4) and b.name like '%".get_realname($_USER->id)."%' and a.type!=1 order by b.perid asc LIMIT 100";
	}elseif($type==2){
		$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."workclass a,".DB_TABLEPRE."workclass_personnel b WHERE  a.id=b.workid and b.pertype!=0 and b.name like '%".get_realname($_USER->id)."%' order by b.perid desc");
		$sql = "SELECT a.* FROM ".DB_TABLEPRE."workclass a,".DB_TABLEPRE."workclass_personnel b WHERE a.id=b.workid and b.pertype<>'0' and b.name like '%".get_realname($_USER->id)."%' order by b.perid desc LIMIT 100";
	}else{
		$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."workclass WHERE uid='".$_USER->id."' order by id desc");
		$sql = "SELECT * FROM ".DB_TABLEPRE."workclass WHERE uid='".$_USER->id."' order by id desc LIMIT 100";
	}
	$result = $db->fetch_all($sql);
	include_once('template/workclass.php');

}elseif ($do == 'views') {
	$workid=getGP('workid','G','int');
	if($workid!=''){
		$work = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."workclass  WHERE id = '".$workid."'  ");
		$tpl = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."workclass_template  WHERE tplid = '".$work['tplid']."'  ");
		include_once('template/workclass_view.php');
	}
}
?>