<?php
// 本文档自动生成，仅供测试运行
require "IndexAction.class.php";
class readAction extends IndexAction
{
	//文章预览
	public function index()
	{
	    $this->nav();
	    $id = $_GET["id"];
        if(!is_numeric($id))
	    {
	      
	     $this->error("参数错误1");
	     }
	  else
	  {
	      $news = M("news");
		 $map["del"] = array("eq",0);
		 $map["id"] = array("eq",$id);
		 $data = $news->where($map)->select();
		  if(empty($data))
		 {
		    $this->error("参数错误2");
		
		  }else
		 {
		    $this->assign("data",$data);
		 }
	  }
	  
	   //$CategoryName = $this->getCategoryName($_GET["id"]);
	   //$this->assign("CategoryName",$CategoryName);
       $this->assign("NewsId","25");
	   $Categoryid = $this->GetCategoryId($_GET["id"]);
	   if(is_array($Category))
	   {
	      
	   }else
	   {
	     $CategoryName = $this->getCategoryName($Categoryid);
	   }
	  //获取上下页
	  $next = $this->getPage($_GET["id"],"lt");
	  $this->assign("getNextPage",$next);

	  $head = $this->getPage($_GET["id"],"gt");
	  $this->assign("getHeadPage",$head);
	  //获取栏目名称
	  $this->assign("CategoryName",$CategoryName);
	  $this->assign("CategoryNum",$Categoryid);
$this->friendship();
	  $this->display();
	}
	
	//文章预览
	public function index2()
	{
	    $this->nav();
	    $id = $_GET["id"];
        if(!is_numeric($id))
	    {
	      
	     $this->error("参数错误1");
	     }
	  else
	  {
	      $news = M("news");
		 $map["del"] = array("eq",0);
		 $map["id"] = array("eq",$id);
		 $data = $news->where($map)->select();
		  if(empty($data))
		 {
		    $this->error("参数错误2");
		
		  }else
		 {
		    $this->assign("data",$data);
		 }
	  }
       $this->assign("NewsId","25");
	   $Categoryid = $this->GetCategoryId($_GET["id"]);
	   if(is_array($Category))
	   {
	      
	   }else
	   {
	     $CategoryName = $this->getCategoryName($Categoryid);
	   }
	  $this->assign("CategoryName",$CategoryName);
	  $this->assign("CategoryNum",$Categoryid);
$this->friendship();
	  $this->display();
	}
	//获取栏目ID,传人文章ID
	public function GetCategoryId($id)
	{
	   if(!is_numeric($id))
	   {
	      $this->assign("jumpUrl",__APP__."/index.php/");
	      $this->error("参数错3误");
	   }
	   else
	   {
	      $news = M("news");
		  $maps["del"] = array("eq",0);
		  $maps["id"] = array("eq",$id);
		  $categoryId = $news->where($maps)->getField("category");
		  //判断是否有父亲节点
		  $category = M("category");
		  $map["id"] = array("eq",$categoryId);
		  $parentid = $category->where($map)->getField("parentid");
		  if(empty($parentid))
		  {
		      //不存在父亲节点
			  return $categoryId;
		  }
		  else
		  {
		      //存在父亲节点
			  return $categoryId;
			  return array($parentid,$category);   
		  }
	   }
	}
	//获取上一页
	public function getPage($id,$bz="lt")
	{
	  $Categoryid = $this->GetCategoryId($_GET["id"]);
	  $map["del"] = array("eq",0);
	  $map["category"] = array("eq",$Categoryid);
	  $map["id"] = array($bz,$id);
	  $news = M("news");
	  $data = $news->where($map)->limit(1)->Field("id,title")->select();
	  return $data;
	}
	//公司介绍
	public function subClass()
	{
	  $news = M("news");
	  $map["del"] = array("eq",0);
	  $data = $news->where($map)->limit(1)->order("id desc")->select();
	  if(empty($data))
	  {
	      return "没有内容";
	  }
	  else
	  {
	     $this->assign("data",$data);
	  }
$this->friendship();
	  $this->display();
	}
	//企业资质
	public function qualification()
	{  
	    $this->nav();
		$this->assign("NewsId","25");
	    $qualification = M("qualification");
		//定义一个数字
	  
	    $map["del"] = array("eq",0);
	   import("@.ORG.Page");       //导入分页类
	   $count = $qualification->where($map)->count();    //计算总数
	   $p = new Page ( $count, 6 );
	   $data = $qualification->limit($p->firstRow.','.$p->listRows)->where($map)->order("id desc")->field("name,s_images,id,name")->findall();
	   $j=0;
	   $n=0;
	   for($i=0;$i<6;$i++)
	   {
	     while($j != 3)
		 {
		  //申请新节点
		  $temp[$j] = array();
		  for($k=0;$k<2;$k++)
		  {
		    if(!empty($data[$n]))
			{
		      array_push($temp[$j],$data[$n]);
			}
		
			$n++;
		  }
		  $j++;
		 }
	   }
       $p->setConfig('header','个资质');
	   $page = $p->show ();            //分页的导航条的输出变量
	   $this->assign( "page", $page);
	   $this->assign("data2",$temp);
	   $this->assign("category",$category);
	   //获取所属
	   $our = $qualification->where($map)->getfield("our");
	   dump($our);	
	   $this->assign("title",$title);
       $this->friendship();
       $this->display();
	}
	public function project()
	{	 
       $this->nav();
	   $this->assign("NewsId","25");
	   $industry= M("industry");
	   $performance = M("honor");
	   $map["del"] = array("eq",0);
	   $inData = $industry->where($map)->order("sort desc")->field("id,name")->select();
	   //申请新节点
	   $inData2 = array();
	   foreach($inData as $value)
	   {
	      $maps["industry"] = array("eq",$value["id"]); 
	      $num = $performance->where($maps)->count();
		  $v = array("id"=>$value["id"],"name"=>$value["name"],"num"=>$num);
		  array_push($inData2,$v);
	   }
	   $this->assign("inData",$inData2);
	   import("@.ORG.Page");       //导入分页类
	   if(!empty($_GET["type"]))
	   {
	      $map["industry"] = array("eq",$_GET["type"]);
	   }
	   $count = $performance->where($map)->count();    //计算总数
	   $p = new Page ( $count, 10 );
	   $hoData = $performance->limit($p->firstRow.','.$p->listRows)->where($map)->order("id desc")->select();
	   $p->setConfig('header','个代表性工程');
	   $page = $p->show ();            //分页的导航条的输出变量
	   $this->assign("page", $page);
	   $this->assign("hoData",$hoData);
	   //dump($hoData);
$this->friendship();
	   $this->display();
	}
	//获奖工程
	public function award()
	{
	   $this->nav();
	   $this->assign("NewsId","25");
	   $award_type = M("award_type");
	   $honor = M("honor");
	   $map["del"] = array("eq",0);
	   $inData = $award_type->where($map)->order("sort desc")->field("id,name")->select();
	   //申请新节点
	   $inData2 = array();
	   foreach($inData as $value)
	   {
	      $maps["type"] = array("eq",$value["id"]); 
	      $num = $honor->where($maps)->count();
		  $v = array("id"=>$value["id"],"name"=>$value["name"],"num"=>$num);
		  array_push($inData2,$v);
	   }
	   $this->assign("inData",$inData2);
	   import("@.ORG.Page");       //导入分页类
	   if(!empty($_GET["type"]))
	   {
	      $map["type"] = array("eq",$_GET["type"]);
	   }
	   $count = $honor->where($map)->count();    //计算总数
	   $p = new Page ( $count, 10 );
	   $hoData = $honor->limit($p->firstRow.','.$p->listRows)->where($map)->order("type desc")->select();
	     $p->setConfig('header','个工程');
	      $page = $p->show ();            //分页的导航条的输出变量
	      $this->assign("page", $page);
	   $this->assign("hoData",$hoData);
$this->friendship();
	   $this->display();
	}
	//度大图
	public function bigimages()
	{
	 $id = $_GET["id"];
	 if(!is_numeric($id))
	   {
	      $this->assign("jumpUrl",__APP__);
	      $this->error("参数错误");
	   }
	   else
	   {
	      $qualification = M("qualification");
		  $map["del"] = array("eq",0);
		  $map["id"] = array("eq",$id);
		  $data = $qualification->where($map)->field("b_images,name")->select();
		
		  $this->assign("data",$data);
	   }
	   $this->display();
	}
	//企业资质
	public function zizhi()
	{
	   $this->nav();
	   $CategoryName = getCategoryName("14");
	   $this->assign("CategoryName",$CategoryName);
	   $this->assign("NewsId","25");
	   $zizhi = M("zizhi");
	   $stack = array();
	   $our = $zizhi->where($map)->Field("our")->select();
	   foreach($our as $value)
	   {
	       if(!in_array(trim($value["our"]),$stack))
		   {
		      array_push($stack,trim($value["our"]));
		   }
	   }
	  
	  if(!empty($_GET["name"]))
	  {
	    if(!in_array($_GET["name"],$stack))
		{
		   $this->assign("jumpUrl",__APP__);
		   $this->error("参数错误");
		}else
		{
		   $map["our"] = array("eq",$_GET["name"]);
		}
	  }
	   $map["del"] = array("eq","0");
	   import("@.ORG.Page");       //导入分页类
	   $count = $zizhi->where($map)->count();    //计算总数
	   $p = new Page ( $count, 10 );
	   $data = $zizhi->limit($p->firstRow.','.$p->listRows)->where($map)->order("id desc")->select();
	   $p->setConfig('header','个企业资质');
	   $page = $p->show ();            //分页的导航条的输出变量
	   $this->assign("page", $page);
	   $this->assign("data",$data);
       $this->friendship();
	   
	    $this->assign("our",$stack);
	   $this->display();
	}
	
}
?>