set_filenames(array("body" => $html_file)) ; $template->assign_vars(array( "USERID" =>$_SESSION['user_id'], )); $base_left_menu = 'left_menu.htm'; $base_top_menu = 'header.htm'; $template->set_filenames(array( 'left_menu' => $base_left_menu, 'top_banner' => $base_top_menu, )) ; $template->assign_var_from_handle('LEFT_MENU','left_menu'); $template->assign_var_from_handle('TOP_BANNER','top_banner'); $find[] = "\""; $replace[] = "'"; $datein=date("d/m/y"); $dateout=date("d/m/y",mktime(0, 0, 0, date("m")+1, date("d"), date("Y"))); $table_hopdong ='tbl_hopdong'; $table_kh ='tbl_khachhang'; $table_nv ='tbl_nhanvien'; $table_dv ='tbl_dichvu'; $table_xl ='tbl_xuly'; $table_gt ='tbl_gtkt'; $table_giayto ='tbl_giayto'; //Kiem tra quyen truy cap /*if($_SESSION['group_id']!=1) Gologin("access.php");*/ if(@isset($_POST['search'])) { $template->assign_block_vars("searchhopdong", array()); // Lay hop dong $sql_hd="select * from ".$table_hopdong." where mahopdong='".$_POST['mahd']."'"; $result_hd = $db->sql_query($sql_hd) or $db->sql_error("Khong the truy cap data"); $row_hd = $db->sql_fetchrowset($result_hd) ; if (count($row_hd)>0) { // so nguoi xem $songuoixem=$row_hd[0]['songuoixem']+1; $sql="update ".$table_hopdong." set "; $sql.=" songuoixem='".$songuoixem."'"; $sql.=" where mahopdong='".$_POST['mahd']."'"; $result = $db->sql_query($sql) or $db->sql_error("Loi: Khong the cap nhat so nguoi xem"); //end cap nhat so nguoi xem // Ten khach hang $sql_kh="select hoten from ".$table_kh." where id_kh='".$row_hd[0]['id_khachhang']."'"; $result_kh = $db->sql_query($sql_kh) or $db->sql_error("Khong the truy cap data"); $row_kh = $db->sql_fetchrowset($result_kh) ; // Ten nhan vien $sql_nv="select name,phone from ".$table_nv." where id_member='".$row_hd[0]['id_nvthuchien']."'"; $result_nv = $db->sql_query($sql_nv) or $db->sql_error("Khong the truy cap data"); $row_nv = $db->sql_fetchrowset($result_nv) ; // Ten dich vu $sql_dv="select tendichvu from ".$table_dv." where id_dv='".$row_hd[0]['id_dichvu']."'"; $result_dv = $db->sql_query($sql_dv) or $db->sql_error("Khong the truy cap data"); $row_dv = $db->sql_fetchrowset($result_dv) ; //Xu ly : hien trang va thong tin bo sung $sql_xl="select * from ".$table_xl." where id_hopdong='".$row_hd[0]['id_hopdong']."' order by id_xuly desc limit 0,1"; $result_xl = $db->sql_query($sql_xl) or $db->sql_error("Khong the truy cap data"); $row_xl = $db->sql_fetchrowset($result_xl) ; $sql_xl2="SELECT DATEDIFF(STR_TO_DATE('".$row_hd[0]['ngaybangiao']."','%d/%m/%Y'),STR_TO_DATE('".$datein."','%d/%m/%Y')) as temp" ; $result_xl2 = $db->sql_query($sql_xl2) or $db->sql_error("Khong the truy cap data"); $row_xl2 = $db->sql_fetchrowset($result_xl2) ; $songay = $row_xl2[0]['temp']; if($songay<10){ $temp_colour ='text_red';} else if($songay>10 && $songay<20){ $temp_colour ='text_yellow';} else{ $temp_colour ='text_blue';} $template->assign_block_vars("view", array( "NGAYNHAN" => $row_hd[0]['thoigiannhan'], "DATE_HT" => $row_hd[0]['ngaybangiao'], "MAHD" => $row_hd[0]['mahopdong'], "DIACHI" => $row_hd[0]['diachibds'], "LUOTXEM" => $row_hd[0]['songuoixem']+1, "SONGAY" => $songay, "KHACHHANG" => $row_kh[0]['hoten'], "NHANVIEN" => $row_nv[0]['name'].' - '.$row_nv[0]['phone'], "DICHVU" => $row_dv[0]['tendichvu'], "HIENTRANG" => $row_xl[0]['hientrang'], "THONGTIN" => $row_xl[0]['thongtinbosung'], "CONTENT" => $row_hd[0]['noidung'], "CSS_SN" => $temp_colour, )); $sql_cat="select * from ".$table_xl." where id_hopdong='".$row_hd[0]['id_hopdong']."' order by id_xuly asc"; $result_cat = mysql_query($sql_cat) or die("Khong the truy xuat Tinh/Thanh"); $row_cat = $db->sql_fetchrowset($result_cat) ; for ($i=0 ; $iassign_block_vars("view.cat", array( "ID" => $row_cat[$i]['id_xuly'], "HIENTRANG" => $row_cat[$i]['hientrang'], "THONGTIN" => $row_cat[$i]['thongtinbosung'], "NGAY" => $row_cat[$i]['ngay'], "BGCOLOR" => ($i%2==0)?"#E6F2FF":"#FFFFFF", )); } // Cac giay to kem theo $sql_gt="select id_giayto from ".$table_gt." where id_hopdong='".$row_hd[0]['id_hopdong']."' order by id_giayto desc"; $result_gt = mysql_query($sql_gt) or die("Khong the truy xuat Tinh/Thanh"); $row_gt = $db->sql_fetchrowset($result_gt) ; for ($i=0 ; $isql_fetchrowset($result_giayto) ; for ($j=0 ; $jassign_block_vars("view.giayto", array( "GIAYTO" => $row_giayto[$j]['ten'] ? '  '.$row_giayto[$j]['ten'].'  ;
' : '', )); } } } else { $template->assign_block_vars("noview", array()); } } else { $template->assign_block_vars("search", array()); } $template->assign_vars(array( "PHP_FILE" => $php_file, "QUANLYNOIDUNG" => $admin_quanlynoidung, "ID" => $_SESSION['user_id'], )); ///////////////////////////////////////////////////////////////////////////////////////// $template->pparse("body") ; include('include/page_footer.php') ; ?>