<?php
class flowClassAction extends Action
{
	
	public function checkAjax()
	{
		$flownum	= $this->rock->post('flownum');
		$id			= (int)$this->rock->post('id');
		$zt			= (int)$this->rock->post('zt');
		$sm			= $this->rock->post('sm');
		
		$flow = f($flownum);
		$flow->initrecord($id);
		echo $flow->check($zt,$sm);
	}
	
	public function getinforAjax()
	{
		$rows	= array();
		$log	= array();
		$table	= $this->rock->post('table');
		$mid	= $this->rock->post('mid');
		$where	= "`table`='$table' and `mid`='$mid'";
		
		$rows	= m('flow_log')->getall("$where order by `id`");
		$rs		= m($table)->getone("`id`='$mid'");
		
		if($rs){
			if($rs['isturn']==1 && $rs['status'] != 1){
				$flars = m('flow_rule')->getone($where);
				if($flars){
					$nowuserid	= $flars['nowuserid'];
					$userarr	= explode('|', $flars['alluser']);
					$useridarr	= explode('|', $flars['alluserid']);
					$step		= $flars['step'];
					for($i=0; $i<$flars['allstep']; $i++){
						$zt = 2;
						$oi	= $i+1;
						if($oi<$step)$zt=0;
						if($oi==$step)$zt=1;
						$log[] = array(
							'name'	=> $userarr[$i],
							'zt'	=> $zt
						);
					}
				}
			}
		}
		
		echo json_encode(array(
			'totalCount'=> 10,
			'rows'		=> $rows,
			'log'		=> $log
		));
	}
}