Chinaunix首页 | 论坛 | 博客
  • 博客访问: 545070
  • 博文数量: 29
  • 博客积分: 1785
  • 博客等级: 上尉
  • 技术积分: 821
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-29 17:28
个人简介

我,计算机应用技术嵌入式方向出身,从事软件工程师工作,主要负责linux服务器维护,asterisk呼叫中心服务器维护,ERP和CRM系统开发,pbx系统开发,以及网站建设。 希望能交更多的朋友。

文章分类
文章存档

2015年(1)

2014年(2)

2013年(9)

2012年(10)

2011年(1)

2010年(3)

2009年(3)

分类: PHP

2013-11-19 10:29:55

Hospital.php代码



require_once('Smarty_setup.php'); //初始化
$smarty = new vtigerCRM_Smarty(); 


$do = isset($_REQUEST['mode'])?strtolower(trim($_REQUEST['mode'])):'index';//判断操作


_ddb::$db = $adb;//数据库


$rs = new roster_do($adb,$smarty,$current_user);
$rs->main($do);//入口
 
class roster_do{ 
private $db, $tpl, $current_user;
function __construct(&$db,&$tpl,&$current_user){
global $adb,$current_user;
$this->db =& $db;
$this->tpl =& $tpl; 
$this->user =& $current_user;
}


public function main($_mod = 'index'){
$mod = "_$_mod"; 
if(method_exists($this,$mod)) $this->$mod();
}


private function _index(){ 
$page = $_REQUEST['page'];
if($page=="")$page=1;
if($page<1) $page=1;
$showNumber=10;       //每页显示的行数
$sql_num = "SELECT 
  t1.hp_name 
FROM
  vtiger_hospital AS t1 
  LEFT JOIN vtiger_hospitalrel AS t2 
    ON t1.hp_no = t2.hp_no 
WHERE t1.hp_status = '激活' 
  AND t2.status = '激活'";
$num_res = $this->db->pquery($sql_num,array());
$totalnums  = $this->db->num_rows($num_res);       //总行数
//如果总数大于每行显示的行数,计算出分页数
if( $totalnums > $showNumber ) {
$totalpage = ceil( $totalnums/$showNumber);
if ($page>$totalpage)  $page=1;
$limitbegin = ($page-1)*$showNumber;
    $limit=" limit ".$limitbegin.",".$showNumber;
}else{
$totalpage = 1;
}

$sql_hospital = "SELECT 
  t1.hp_name,
  t1.hp_lsubject,
  t1.hp_ssubject,
  t2.doctor,
  t2.time,
  t2.surplus_num,
  t2.total_num 
FROM
  vtiger_hospital AS t1 
  LEFT JOIN vtiger_hospitalrel AS t2 
    ON t1.hp_no = t2.hp_no 
WHERE t1.hp_status = 'A' 
  AND t2.status = 'A' $limit";
$process_result = $this->db->run_query_allrecords($sql_hospital);


$this->tpl->assign('showNumber',$showNumber);
$this->tpl->assign('totalnum',$totalnums);
$this->tpl->assign('page',$page);
$this->tpl->assign('total',$totalpage); 
$this->tpl->assign('PROCESS',$process_result);
$this->tpl->display("callpopup/Hospital/Hospital.tpl");
}


//查询
private function _search(){
$hp_name = $_REQUEST['hp_name'];       //医院名称
$hp_lsubject = $_REQUEST['hp_lsubject'];       //科目大类
$hp_ssubject = $_REQUEST['hp_ssubject'];       //科目小类
$doctor = $_REQUEST['doctor'];         //值班医生
$time = $_REQUEST['time'];         //值班时间
$page = $_REQUEST['page'];                     //显示行数

if($page=="")$page=1;
if($page<1) $page=1;
$showNumber=10;       //每页显示的行数

//where条件
if($hp_name != ""){
$where = " AND t1.hp_name like '%".$hp_name."%' ";
}
if($hp_lsubject != ""){
$where = $where." AND t1.hp_lsubject like '%".$hp_lsubject."%' ";
}
if($hp_ssubject != ""){
$where = $where." AND t1.hp_ssubject like '%".$hp_ssubject."%' ";
}
if($doctort != ""){
$where = $where." AND t2.doctort like '%".$doctort."%' ";
}
if($time != ""){
$where = $where." AND t2.time like '%".$time."%' ";
}


$sql_num = "SELECT 
  t1.hp_name 
FROM
  vtiger_hospital AS t1 
  LEFT JOIN vtiger_hospitalrel AS t2 
    ON t1.hp_no = t2.hp_no 
WHERE t1.hp_status = 'A' 
  AND t2.status = 'A' $where ";
$num_res = $this->db->pquery($sql_num,array());
$totalnums  = $this->db->num_rows($num_res);       //总行数

//如果总数大于每行显示的行数,计算出分页数
if( $totalnums > $showNumber ) {
$totalpage = ceil( $totalnums/$showNumber);
if ($page>$totalpage)  $page=1;
$limitbegin = ($page-1)*$showNumber;
    $limit=" limit ".$limitbegin.",".$showNumber;
}else{
$totalpage = 1;
}

$sql_search = "SELECT 
    t1.hp_name,
    t1.hp_lsubject,
    t1.hp_ssubject,
    t2.doctor,
    t2.time,
    t2.surplus_num,
    t2.total_num 
  FROM
    vtiger_hospital AS t1 
    LEFT JOIN vtiger_hospitalrel AS t2 
      ON t1.hp_no = t2.hp_no 
  WHERE t1.hp_status = 'A' 
    AND t2.status = 'A'
  $where  $limit ";
$search_result =$this->db->pquery($sql_search,array());
$out = '

 
 
 
 
 
 
 
 
';
if($totalnums >0){
while($row =  $this->db->fetchByAssoc($search_result)){
$out = $out.'
 
 
 
 
 
 
 
 
';
}
 
   
$out = $out.'
医院名称科目大类科目小类医生名称值班时间剩余挂号数总挂号数操作
'.$row['hp_name'].''.$row['hp_lsubject'].''.$row['hp_ssubject'].''.$row['doctor'].''.$row['time'].''.$row['surplus_num'].''.$row['total_num'].'挂号

 
   
        ';    
}

$out = $out.'

   

   
 
 
';

  if ($totalpage >1){
if ($page >1){              
$out = $out.'
  首页
 
 
  上一页
';
}else{           
$out = $out.' 首页
  上一页';
}
if ($page < $totalpage){
$out = $out.'
  下一页
 
 
  末页
';
}else{
$out = $out.' 下一页 
  末页';
}
$out = $out.'';
  }
$out = $out."总共 $totalnums
 
条记录,当前第 
  $page
 
页,共 
      $totalpage
 
";
  
}
}else{
$out = $out.'
对不起!查询不到该服务项目!
';
echo $out;

}





}
?>



Hospital.tpl











{literal} 

{/literal} 






 
 
 
 
 
 
 
 
 
 
 {if $totalnum >0}
 {foreach item=ROW name=foo from=$PROCESS }
 
 
 
 
 
 
 
 
 
 
 {/foreach}
医院名称科目大类科目小类医生名称值班时间剩余挂号数总挂号数操作
{$ROW.hp_name}{$ROW.hp_lsubject}{$ROW.hp_ssubject}{$ROW.doctor}{$ROW.time}{$ROW.surplus_num}{$ROW.total_num}挂号


 
 
 
  {else}
 
 
 
 {/if}

 

   
   
     
   
   
 
     {if $total >1}
     {if $page >1}              
      首页 
      上一页
     {else}           
      首页
      上一页
     {/if}
     {if $page < $total}
      下一页 
      末页
     {else}
      下一页 
      末页
     {/if}
     
     总共 {$totalnum}
     
条记录,当前第 
     {$page}
     
页,共 
     {$total}
     

     {/if}  
     

 

 
对不起!查询不到该服务项目!







效果图:







阅读(4076) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~