Chọn thời gian
Từ Tháng buildMonthSelect('BCKD_Thang',$search_thang,'cbo width_100');?> Năm buildYearSelect('BCKD_Nam',date('Y')-2,date('Y'),$search_nam,'cbo width_100');?>
 
fetchRow($rs_chinhanh)){ ?> getMultiValue(array('TSCN_THOIDIEMBAOCAONGAY','TSCN_CACHTINHPHUTHUTHEMNGUOI','TSCN_GOPNOTHANGTRUOC','TSCN_BCNGAY_TACHTRANOTHE'), $chinhanh_id); $thoidiembaocao = $arr_ts_cnh['TSCN_THOIDIEMBAOCAONGAY']; $t = strtotime($search_tu_ngay_db." ".$arr_ts['TS_GIOTRAPHONG'].":00:00"); $t2 = strtotime($search_den_ngay_db." ".$arr_ts['TS_GIOTRAPHONG'].":00:00")+86400; $ngay_bd_cf = $search_tu_ngay_db." 00:00:00"; $ngay_kt_cf = $search_den_ngay_db." 23:59:59"; $ngay_bd_ks = $search_tu_ngay_db." ".$arr_ts['TS_GIOTRAPHONG'].":00:00"; $ngay_kt_ks = date('Y-m-d H:i:s',$t2); $tienphong_chuagiam[$chinhanh_id] = 0; $tiengiamgia_congdon[$chinhanh_id] = 0; $thukhac_congdon[$chinhanh_id] = 0; $trukhac_congdon[$chinhanh_id] = 0; $tiendichvu_congdon[$chinhanh_id] = 0; $tienvondichvu_congdon[$chinhanh_id] = 0; $arr_doanhthu_chinhanh[$chinhanh_id]=0; if($rw_cnh['CNH_LOAI']==TYPE_IS_HOTEL){ while($t<$t2){ $ngay_thu++; $from = date('Y-m-d H:i:s',$t); $end = date('Y-m-d H:i:s',$t+86400); $rs = $mBC->getDoanhThuNgay_Apollo($chinhanh_id,$from,$end); $lamtrongio = $arr_ts['TS_LAMTRONGIO']*60; while($rw = $conn->fetchRow($rs)){ $klt_id = $rw['KLT_ID']; $ph_id = $rw['PH_ID']; $giam_gia ="" ; $tien_giamgia = 0; if($rw['KLT_THOIDIEMTRAPHONG']!=NULL){ $arrfromjson = json_decode($rw['KLT_PRICE_INFO'],true); $arr_price_add = $arrfromjson['ARR_PRICE_ADD']; $arr_ts = $arrfromjson['ARR_TS']; $arr_price_early = $arrfromjson['ARR_PRICE_EARLY']; $arr_giatheonguoi = $arrfromjson['ARR_ADD_PERSON']; $cachtinhphuthuthemnguoi = $arrfromjson['ARR_OTHER']['cachtinh_pttn']; }else{ $arr_price_early = $model->getPhuThuVaoSom($klt_id); if(empty($arr_price_early)){ $arr_price_early = $mVaoSomPhong->getToArray($ph_id); } //Tra tre $arr_price_add = $model->getPhuThuTraTre($klt_id); if(empty($arr_price_add)){ $arr_price_add = $mTraTrePhong->getToArray($ph_id); } } if($rw['CACHTINH']=='TINHTIENCHECKOUT'){ $tienphong = $rw['KLT_TIENPHONG']; $tienphong_chuagiam[$chinhanh_id]+=$tienphong; if($rw['KLT_KHUYENMAI']>0 && $rw['KLT_KHUYENMAI']<=100){ $tienphong = $tienphong - $rw['KLT_TIENPHONG']*$rw['KLT_KHUYENMAI']/100; }elseif($rw['KLT_KHUYENMAI']>100){ $tienphong = $tienphong - $rw['KLT_KHUYENMAI']; } if($rw['KLT_KHUYENMAI']>100){ $giam_gia = WebHelper::format_vn_number($rw['KLT_KHUYENMAI']); $tien_giamgia = $rw['KLT_KHUYENMAI']; }elseif($rw['KLT_KHUYENMAI']>0){ $giam_gia = WebHelper::format_vn_number($rw['KLT_KHUYENMAI'])."%"; $tien_giamgia = $rw['KLT_TIENPHONG']*$rw['KLT_KHUYENMAI']/100; } }elseif($rw['CACHTINH']=='TINHPHUTHUTRE'){ $giam_gia = 0; if($rw['KLT_KPTTRATRE']==0){ $staying = strtotime($rw['KLT_THOIDIEMTRAPHONG'])-$t; $h = intval($staying/3600); if($staying%3600>$lamtrongio){ $h++; } if($h>0){ $price_add = $model->getPriceByHour($h,$arr_price_add); if(empty($price_add)){ $tienphong = $rw['GIANGAY']; }else{ if($price_add['GIATRI']>100){ $tienphong = $price_add['GIATRI']; }else{ $tienphong = $rw['GIANGAY']*$price_add['GIATRI']/100; } } }else{ $tienphong = 0; } }else{ $tienphong = 0; } $tienphong_chuagiam[$chinhanh_id]+=$tienphong; }elseif($rw['CACHTINH']=='TINHPHUTHUSOM'){ $giam_gia = 0; if($rw['KLT_KPTVAOSOM']==0){ $staying = $t - strtotime($rw['KLT_THOIDIEMNHANPHONG']); $h = intval($staying/3600); if($staying%3600>$lamtrongio){ $h++; } if($h>0){ $price_early = $model->getPriceByHour($h,$arr_price_early); if(empty($price_early)){ $tienphong = $rw['GIANGAY']; }else{ if($price_early['GIATRI']>100){ $tienphong = $price_early['GIATRI']; }else{ $tienphong = $rw['GIANGAY']*$price_early['GIATRI']/100; } } }else{ $tienphong = 0; } }else{ $tienphong = 0; } $tienphong_chuagiam[$chinhanh_id]+=$tienphong; }else{ $tienphong = $rw['GIANGAY']; $tienphong_chuagiam[$chinhanh_id]+=$tienphong; if($rw['KLT_KHUYENMAI']>100){ $tienphong = $tienphong - $rw['KLT_KHUYENMAI']; $giam_gia = WebHelper::format_vn_number($rw['KLT_KHUYENMAI']); $tien_giamgia = $rw['KLT_KHUYENMAI']; }elseif($rw['KLT_KHUYENMAI']>0){ $tienphong = $rw['GIANGAY']*(1 - $rw['KLT_KHUYENMAI']/100); $giam_gia = WebHelper::format_vn_number($rw['KLT_KHUYENMAI'])."%"; $tien_giamgia = $rw['GIANGAY']*$rw['KLT_KHUYENMAI']/100; } } $thukhac = $rw['KLT_THUKHAC']; $trukhac = $rw['KLT_TRUKHAC']; $tienphong += $rw['KLT_THUKHAC']; $tienphong -= $rw['KLT_TRUKHAC']; $tiengiamgia_congdon[$chinhanh_id] += $tien_giamgia; $thukhac_congdon[$chinhanh_id] += $thukhac; $trukhac_congdon[$chinhanh_id] += $trukhac; $tiendichvu_congdon[$chinhanh_id] += $rw['TIENDICHVU']; if($cty_id==151){ $tienvondichvu_congdon[$chinhanh_id] += $rw['TIENVON_DICHVU']; }else{ $tienvondichvu_congdon[$chinhanh_id] = 0; } } $t+=86400; } $arr_doanhthu_chinhanh[$chinhanh_id] = $tienphong_chuagiam[$chinhanh_id] - $tiengiamgia_congdon[$chinhanh_id] + $tiendichvu_congdon[$chinhanh_id]; }else{ $doanhthu_cf[$chinhanh_id] = $mBC->getTongHopKinhDoanhDichVu($chinhanh_id,$ngay_bd_cf,$ngay_kt_cf); $arr_doanhthu_chinhanh[$chinhanh_id] = $doanhthu_cf[$chinhanh_id]['DOANHTHUCHUAGIAM'] + $doanhthu_cf[$chinhanh_id]['TONGTHUKHAC'] - $doanhthu_cf[$chinhanh_id]['TIENGIAMGIA']; } // //Doanh thu cafe $quy_nganhang = 0; $quy_ck = 0; if($cty_id==151){ $doanhthu_cf[$chinhanh_id]['TONGTIENVON'] = 0; } // $doanhthu_khac = $mBC->getTongThuKhacCongTy($cty_id,$ngay_bd_cf,$ngay_kt_cf); $chiphi_kpb[$chinhanh_id] = $mChi->getTongChiNgay_KhongPhanBo($chinhanh_id,$ngay_bd_cf,$ngay_kt_cf,true); $chiphi_khac[$chinhanh_id] = 0;//$mChi->getTongChiNgay(182,$ngay_bd_ks,$ngay_kt_ks); } //Tính chi phí có phân bổ $html_chitietphanbo = '
'; $html_chitietphanbo.=""; $html_chitietphanbo.=""; $html_chitietphanbo.=""; $rs_pb = $mChi->getChiPhi_PhanBo($cty_id,$ngay_bd_cf,$ngay_kt_cf,true); while($rwcppb = $conn->fetchRow($rs_pb)){ $loai_pb = $rwcppb['LCP_PHANBO']; $html_chitietphanbo.=""; $html_chitietphanbo.=""; $html_chitietphanbo.=""; } $html_chitietphanbo .="
Phân loại chiSố tiềnPhân bổ
". WebHelper::decodeSpecialChar($rwcppb['LCP_TEN'])."". WebHelper::format_vn_number($rwcppb['TONGCHI']).""; $sql_1 = "SELECT * FROM ".PRE."tylephanbochiphi WHERE PHANBOCHI_IDLCP=".$rwcppb['CP_IDLCP']; $rs_1 = $conn->execute($sql_1); if($loai_pb==1){//Theo % while($rw_1 = $conn->fetchRow($rs_1)){ $cp_chiu = round($rwcppb['TONGCHI']*$rw_1['PHANBOCHI_PHANTRAM']/100); $chiphi_pb[$rw_1['PHANBOCHI_IDCNH']] += $cp_chiu; $html_chitietphanbo.="
".$arr_chinhanh_name[$rw_1['PHANBOCHI_IDCNH']]."
"; $html_chitietphanbo.="
".round($rw_1['PHANBOCHI_PHANTRAM'])."%
"; $html_chitietphanbo.="
".WebHelper::format_vn_number($cp_chiu)."
"; $html_chitietphanbo.="
"; } }else{ $arr_cnh_pb = array(); $tong_doanhthu_cnh_tv = 0; while($rw_1 = $conn->fetchRow($rs_1)){ $tong_doanhthu_cnh_tv += $arr_doanhthu_chinhanh[$rw_1['PHANBOCHI_IDCNH']]; $arr_cnh_pb[] = $rw_1['PHANBOCHI_IDCNH']; } for($ig=0;$ig0){ $tle_pb = $arr_doanhthu_chinhanh[$idcnh_ig]/$tong_doanhthu_cnh_tv; }else{ $tle_pb = 0; } $cp_chiu = round($rwcppb['TONGCHI']*$tle_pb); $chiphi_pb[$idcnh_ig] += $cp_chiu; $html_chitietphanbo.="
".$arr_chinhanh_name[$idcnh_ig]."
"; $html_chitietphanbo.="
".round($tle_pb*100)."%
"; $html_chitietphanbo.="
".WebHelper::format_vn_number($cp_chiu)."
"; $html_chitietphanbo.="
"; } } $html_chitietphanbo .="
"; ?> Nội dung Số tiền Diễn giải getTongThuNgay_TinhDoanhThu($chinhanh_id,$ngaythu_bd,$ngaythu_kt); // $congno = $model->congNoCongTy($cty_id); if($rw_cnh['CNH_LOAI']==TYPE_IS_HOTEL){ ?> Doanh Thu Tiền phòng Giảm giá phòng Trừ khác Tiền phòng đã giảm Thu khác Doanh thu dịch vụ Doanh thu thuần Giá vốn dịch vụ Lại gộp Tổng chi phí riêng Tổng chi phí chịu phân bổ Lãi ròng Doanh Thu Doanh thu chưa giảm Giảm giá Trừ khác Thu khác Doanh thu thuần Giá vốn hàng bán Lãi gộp Chi phí riêng Chi phí chịu phân bổ Lãi ròng
TỔNG HỢP TỔNG DOANH THU THUẦN
TỔNG THU KHÁC Đã tính vào doanh thu thuần
TỔNG GIÁ VỐN HÀNG BÁN
TỔNG LẠI GỘP
TỔNG CHI PHÍ
TÔNG LÃI RÒNG