<?php
|
//--------------------------常用字符转义---------------------begin
|
function strSql($str) {
|
$str=addslashes($str);
|
$str=str_replace("'","''",$str);
|
$str=str_replace("--","- -",$str);
|
$str=str_replace("exec","",$str);
|
$str=str_replace("DECLARE","",$str);
|
//$str=str_replace("\"","''",$str);
|
return $str;
|
}
|
//--------------------------常用字符转义---------------------end
|
|
//--------------------------用户查找---------------------begin
|
function OAUser($adminID,$DataID) {
|
$OAUser="";
|
if (isset($adminID)){
|
global $conn;
|
$sql = "select OA_User_ID,OA_User,OA_Name,OA_weixinAvatar,OA_mobile,OA_DepartmentID from OA_User where OA_User_ID=".$adminID;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($rsDt = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
$ADMINuserID = $rsDt['OA_User_ID'];
|
$ADMINuser = $rsDt['OA_User'];
|
$ADMINName = $rsDt['OA_Name'];
|
$ADMINMobile = $rsDt['OA_mobile'];
|
$ADMINAvatar = $rsDt['OA_weixinAvatar'];
|
$ADMINDepartmentID = $rsDt['OA_DepartmentID'];
|
If ($ADMINAvatar=="") {$ADMINAvatar="/resources/images/icon_avatar_default.png";}
|
}
|
}
|
else{
|
$DataID="adminID";
|
}
|
switch ($DataID) {
|
case "userID":
|
$OAUser .= $ADMINuserID;
|
break;
|
case "UserName":
|
$OAUser .= $ADMINName;
|
break;
|
case "UserPhone":
|
$OAUser .= $ADMINMobile;
|
break;
|
case "adminID":
|
$OAUser .= $adminID;
|
break;
|
case "Avatar":
|
$OAUser .= $ADMINAvatar;
|
break;
|
case "DepartmentID":
|
$OAUser .= $ADMINDepartmentID;
|
break;
|
case "DepartmentName":
|
$sql = "select vtext from dictionary where vtitle='OA_Department' and vID=".$ADMINDepartmentID;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($rsDt = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
$OAUser = $rsDt['vtext'];
|
}
|
}
|
break;
|
default:
|
$OAUser .= $adminID;
|
}
|
}
|
return $OAUser;
|
}
|
//--------------------------用户查找---------------------end
|
|
//--------------------------企业用户查找---------------------begin
|
Function UnitIntroducer($ServiceOrdIntroducer,$DataID){
|
$IntroducerName="";
|
if (isset($ServiceOrdIntroducer)){
|
If (is_numeric($ServiceOrdIntroducer)){
|
global $conn;
|
$sql = "select IntroducerID,IntroducerName,IntroducerUnitID from IntroducerData where IntroducerID=".$ServiceOrdIntroducer;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($rsDt = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
$IntroducerID = $rsDt['IntroducerID'];
|
$IntroducerName = $rsDt['IntroducerName'];
|
$IntroducerUnitID = $rsDt['IntroducerUnitID'];
|
}
|
}Else{
|
$DataID="TXT";
|
}
|
}Else{
|
$DataID="TXT";
|
}
|
}else{
|
$DataID="TXT";
|
}
|
|
switch ($DataID) {
|
case "TXT";
|
$UnitIntroducer = $ServiceOrdIntroducer;
|
break;
|
case "UnitName";
|
$UnitIntroducer = $IntroducerName;
|
break;
|
case "UnitID";
|
$UnitIntroducer = $IntroducerUnitID;
|
break;
|
default:
|
$UnitIntroducer = $ServiceOrdIntroducer;
|
}
|
return $UnitIntroducer;
|
}
|
//--------------------------企业用户查找---------------------end
|
|
//--------------------------数字转字母(用于Excel列标)---------------------begin
|
/**
|
* 数字转字母 (类似于Excel列标)
|
* @param Int $index 索引值
|
* @param Int $start 字母起始值
|
* @return String 返回字母
|
echo IntToChr(27);
|
*/
|
function IntToChr($index, $start = 65) {
|
$str = '';
|
if (floor($index / 26) > 0) {
|
$str .= IntToChr(floor($index / 26)-1);
|
}
|
return $str . chr($index % 26 + $start);
|
}
|
//--------------------------数字转字母---------------------end
|
|
//--------------------------文本日期转实际时间---------------------begin
|
function TXTDateToDate($TXTDate) {
|
$str = '';
|
switch ($TXTDate) {
|
case "当天":
|
$str = date("Y-m-d");
|
break;
|
case "昨天":
|
$str = date("Y-m-d",strtotime('-1 day'));
|
break;
|
case "前天":
|
$str = date("Y-m-d",strtotime('-2 day'));
|
break;
|
case "本周":
|
$str = date("Y-m-d",strtotime('last day this week'))."至".date("Y-m-d",strtotime('last day this week +6 days'));
|
break;
|
case "上周":
|
$str = date("Y-m-d",strtotime('last day this week -1 week'))."至".date("Y-m-d",strtotime('last day this week -1 days'));
|
break;
|
case "本月":
|
$str = date("Y年m月");
|
break;
|
case "上月":
|
$str = date("Y年m月",strtotime("last month"));
|
break;
|
case "本年":
|
$str = date("Y年");
|
break;
|
case "本结算月":
|
$str = date("Y-m-",strtotime("last month"))."25"."至".date("Y-m-")."24";
|
/*
|
if(date("d")<=24) {
|
$str = date("Y-m-",strtotime("last month"))."25"."至".date("Y-m-")."24";
|
}else{
|
$str = date("Y-m-")."25"."至".date("Y-m-",strtotime("+1 month"))."24";
|
}
|
*/
|
break;
|
default:
|
$str = $TXTDate;
|
}
|
return $str;
|
}
|
//--------------------------文本日期转实际时间---------------------end
|
|
//--------------------------无限级菜单排序算法---------------------begin
|
//组成多级数组
|
function MultiLevelConvert1($arr,$id){
|
$res = array();
|
foreach ($arr as $key => $value) {
|
if ($value["pid"] == $id) {
|
$value["child"]=MultiLevelConvert1($arr,$value["id"]);
|
array_push($res,$value);
|
}
|
}
|
return $res;
|
}
|
//重新整理成一维数组
|
function MultiLevelConvert2($arr,$level){
|
$res = array();
|
foreach ($arr as $key => $value) {
|
if (count($value)>0) {
|
$value["level"]=$level;
|
if (count($value['child'])>0) {
|
$res2=MultiLevelConvert2($value['child'],$level+1);
|
array_pop($value);array_push($res,$value);
|
foreach ($res2 as $key => $value) {array_push($res,$value);}
|
}
|
else {array_pop($value);array_push($res,$value);}
|
}
|
}
|
return $res;
|
}
|
//--------------------------无限级菜单排序算法---------------------end
|
|
//--------------------------调度单跟随人员---------------------begin
|
function EntourageOANameA($EntourageID,$DispatchOrdID,$DataID){
|
$res = $EntourageID;
|
if (empty($EntourageID)==false and empty($DispatchOrdID)==false) {
|
global $conn;
|
$sql = "select OA_User_ID,OA_User,OA_Name,OA_weixinAvatar,EntourageLead,EntourageState,EntourageMileageFactor,EntourageDKP,EntourageDKPScale,EntourageOT_is,EntourageLong_is,EntourageBetimesHH,EntourageEnd_Time,EntourageState_Time,Stretcher_is from DispatchOrd_Entourage,OA_User where OA_User_ID=EntourageOAid and EntourageState<>4 and DispatchOrdIDDt=".$DispatchOrdID." and EntourageID=".$EntourageID;
|
//echo $sql;exit;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($EntourageOArs = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
$EntourageOAuserID = $EntourageOArs['OA_User_ID'];
|
$EntourageOAuser = $EntourageOArs['OA_User'];
|
$EntourageOAName = $EntourageOArs['OA_Name'];
|
$EntourageOAAvatar=empty($EntourageOArs['OA_weixinAvatar'])!=false ? "/resources/images/icon_avatar_default.png" : $EntourageOArs['OA_weixinAvatar'];
|
$EntourageLead = $EntourageOArs['EntourageLead'];
|
$EntourageState = $EntourageOArs['EntourageState'];
|
$EntourageMileageFactor = $EntourageOArs['EntourageMileageFactor'];
|
$EntourageOT_is = $EntourageOArs['EntourageOT_is'];
|
$EntourageLong_is = $EntourageOArs['EntourageLong_is'];
|
$EntourageBetimesHH = $EntourageOArs['EntourageBetimesHH'];
|
$EntourageDKP = $EntourageOArs['EntourageDKP'];
|
$EntourageDKPScale = $EntourageOArs['EntourageDKPScale'];
|
$EntourageEnd_Time = $EntourageOArs['EntourageEnd_Time'];
|
$EntourageState_Time = $EntourageOArs['EntourageState_Time'];
|
$Stretcher_is = $EntourageOArs['Stretcher_is'];
|
}
|
}Else{
|
$DataID="userID";
|
$EntourageOAuserID=$EntourageID;
|
}
|
|
if (isset($EntourageOAuserID)) {
|
switch ($DataID)
|
{
|
case "userID":
|
$res= $EntourageOAuserID;
|
break;
|
case "UserName":
|
$res= $EntourageOAName;
|
If ($EntourageOAState==3) {
|
$res = "<font color='#6699ff'>".$res."</font>";
|
}
|
ElseIf ($EntourageOAState==2) {
|
$res = "<font color='#C3C3C3'>".$res."</font>";
|
}
|
If ($EntourageOALead==1) { $res = "<img src='/resources/images/2016020401.png'>".$res;}
|
break;
|
case "UserNameReport":
|
$res= $EntourageOAName;
|
If ($EntourageMileageFactor!=1) {
|
$res = $res."/".floatval(number_format($EntourageMileageFactor,2,".",""));
|
}
|
If ($EntourageID==5 Or $EntourageID==6 Or $EntourageID==2) {
|
$res=",".$res;
|
}
|
break;
|
default:
|
$res="";
|
}
|
} else {
|
$res="";
|
}
|
|
}
|
return $res;
|
}
|
//--------------------------调度单跟随人员---------------------end
|
|
|
//--------------------------服务单类型---------------------begin
|
Function ServiceOrdTypeA($ServiceOrdType) {
|
global $conn;
|
$sql = "select vtext from dictionary where vtitle='ServiceOrderType' and vID=".$ServiceOrdType;
|
//echo $sql;exit;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($ServiceOrdTypers = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
return $ServiceOrdTypers['vtext'];
|
}
|
}Else{
|
return $ServiceOrdType;
|
}
|
}
|
//--------------------------服务单类型---------------------end
|
|
|
//--------------------------单据状态---------------------begin
|
function OrdState_A($ServiceOrdState,$DispatchOrdState) {
|
$OrdState="";
|
if ($ServiceOrdState==1) {
|
$OrdState="咨询";
|
}
|
elseif ($ServiceOrdState==4) {
|
$OrdState="取消";
|
}
|
else {
|
if ($DispatchOrdState==4 or $DispatchOrdState==5) {
|
$OrdState="已出车";
|
}
|
elseif ($DispatchOrdState==6) {
|
$OrdState="转运途中";
|
}
|
elseif ($DispatchOrdState==8 or $DispatchOrdState==7) {
|
$OrdState="已完成";
|
}
|
elseif ($DispatchOrdState==9 or $DispatchOrdState==10) {
|
$OrdState="已取消";
|
}
|
else {
|
$OrdState="处理中";
|
}
|
}
|
return $OrdState;
|
|
}
|
//--------------------------单据状态---------------------end
|
|
//--------------------------科室---------------------begin
|
Function PtServices_A($ServiceOrdPtServicesID) {
|
global $conn;
|
$sql = "select vId,vtext from dictionary where vType=1 and vtitle='HospitalDepartment' and vId=".$ServiceOrdPtServicesID;
|
//echo $sql;exit;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($PtServicesrs = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
return $PtServicesrs['vtext'];
|
}
|
}Else{
|
return $ServiceOrdPtServicesID;
|
}
|
}
|
//--------------------------科室---------------------end
|
|
//--------------------------车牌信息---------------------begin
|
Function CarDataA($CarID) {
|
global $conn;
|
$sql = "select * from CarData where CarID=".$CarID;
|
//echo $sql;exit;
|
$dataDt = sqlsrv_query($conn,$sql);
|
if($dataDt == true){
|
while($CarDatars = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
|
return $CarDatars['CarLicense'];
|
}
|
}Else{
|
return $CarID;
|
}
|
}
|
//--------------------------车牌信息---------------------end
|
|
//--------------------------处理带有中文URL的方法---------------------begin
|
function urlencode_ch($url) {
|
$uri = '';
|
$cs = unpack('C*', $url);
|
$len = count($cs);
|
for ($i=1; $i<=$len; $i++) {
|
$uri .= $cs[$i] > 127 ? '%'.strtoupper(dechex($cs[$i])) : $url{$i-1};
|
}
|
if ($uri=='') {$uri=$url;}
|
return $uri;
|
}
|
//--------------------------处理带有中文URL的方法---------------------end
|
?>
|