芝麻web文件管理V1.00
编辑当前文件:/home/jambtst2015/public_html/giraffeng.com/admin/functions.php
='".$wkfirst."' AND `open_date`<='".$wklast."' AND `status`='".$status."'"; } elseif($status=='Close' && $wkfirst!='' && $wklast!=''){ $sql = "SELECT count(req_id) FROM `abs_requirement` WHERE `close_date`>='".$wkfirst."' AND `close_date`<='".$wklast."' AND `status`='".$status."'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $todayReq = $getCount['count(req_id)']; return $todayReq; } function requirementsNew($firstdate='',$lastdate=''){ if($firstdate!='' && $lastdate!=''){ $sql = "SELECT count(req_id) FROM `abs_requirement` WHERE `post_date` >= '".$firstdate."' AND `post_date` <= '".$lastdate."'"; }else{ $sql = "SELECT count(req_id) FROM `abs_requirement` WHERE `post_date` = '".$firstdate."'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $newReq = $getCount['count(req_id)']; return $newReq; } function submissions($firstdate,$lastdate){ if($firstdate!='' && $lastdate!=''){ $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` >= '".$firstdate."' AND `submit_date` <= '".$lastdate."'"; }else{ $currentDate = date('Y-m-d'); $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` = '".$currentDate."'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $newSub = $getCount['count(submit_id)']; return $newSub; } function candidates($firstdate='',$lastdate=''){ if($firstdate!='' && $lastdate==''){ $sql = "SELECT count(candidate_id) FROM `abs_candidate` WHERE add_date='".$firstdate."'"; }else{ $sql = "SELECT count(candidate_id) FROM `abs_candidate` WHERE `add_date` >= '".$firstdate."' AND `add_date` <= '".$lastdate."'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $newCan = $getCount['count(candidate_id)']; return $newCan; } function interview($firstdate,$lastdate){ if($firstdate!='' && $lastdate!=''){ $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` >= '".$firstdate."' AND `submit_date` <= '".$lastdate."' AND `interview`='Y'"; }else{ $currentDate = date('Y-m-d'); $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` = '".$currentDate."' AND `interview`='Y'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $newInterview = $getCount['count(submit_id)']; return $newInterview; } function placements($firstdate,$lastdate){ if($firstdate!='' && $lastdate!=''){ $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` >= '".$firstdate."' AND `submit_date` <= '".$lastdate."' AND `status`='Confirmation' AND dup_status!=2"; //exit(); } else{ $currentDate = date('Y-m-d'); $sql = "SELECT count(submit_id) FROM `abs_submit` WHERE `submit_date` = '".$currentDate."' AND `status`='Confirmation'"; } $qry = mysql_query($sql); $getCount = mysql_fetch_assoc($qry); $newSub = $getCount['count(submit_id)']; return $newSub; } function getTime(){ //date_default_timezone_set('US/Eastern'); //date_default_timezone_set('UTC'); // date_default_timezone_get(); $currenttime = date('h:i:s:a'); list($hrs,$mins,$secs,$msecs) = split(':',$currenttime); //echo " => $hrs:$mins:$secs:$msecs\n"; $usTime = $hrs.":".$mins." $msecs"; return $usTime; } function getUserlevel($id){ $sql = "select userclass from sat_users where user_id='".$id."'"; $qry = mysql_query($sql); $arr = mysql_fetch_assoc($qry); $level = $arr['userclass']; return $level; } //Pagination Function function pagination($per_page = 10, $page = 1, $url = '', $total){ $adjacents = "2"; $page = ($page == 0 ? 1 : $page); $start = ($page - 1) * $per_page; $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total/$per_page); $lpm1 = $lastpage - 1; $pagination = ""; if($lastpage > 1) { $pagination .= "
"; $pagination .= "
Page $page of $lastpage
"; if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "
$counter
"; else $pagination.= "
$counter
"; } } elseif($lastpage > 5 + ($adjacents * 2)) { if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "
$counter
"; else $pagination.= "
$counter
"; } $pagination.= "
...
"; $pagination.= "
$lpm1
"; $pagination.= "
$lastpage
"; } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "
1
"; $pagination.= "
2
"; $pagination.= "
...
"; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "
$counter
"; else $pagination.= "
$counter
"; } $pagination.= "
..
"; $pagination.= "
$lpm1
"; $pagination.= "
$lastpage
"; } else { $pagination.= "
1
"; $pagination.= "
2
"; $pagination.= "
..
"; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "
$counter
"; else $pagination.= "
$counter
"; } } } if ($page < $counter - 1){ $pagination.= "
Next
"; $pagination.= "
Last
"; }else{ $pagination.= "
Next
"; $pagination.= "
Last
"; } $pagination.= "
\n"; } return $pagination; } function nullCheck($value=''){ if($value!=''){ return $value; }else{ return "N/A"; } } function check_null($value){ if($value!=''){ if($value=='N'){ return 'No'; }elseif($value=='Y'){ return 'Yes'; }else{ return $value; } } else{ return "N/A"; } } function check_null_value($field1='',$table='',$id='',$value='',$field2=''){ if($value!=''){ $field = ''; if($field2!=''){ $field = $field1.', '.$field2; }else{ $field = $field1; } $sql_title = "select ".$field." from ".$table." where ".$id."='".$value."'"; $qry_title = mysql_query($sql_title); $qry_num = mysql_num_rows($qry_title); $arr_title = mysql_fetch_assoc($qry_title); if($field2!=''){ $val = $arr_title[$field1].' '.$arr_title[$field2]; }else{ $val = $arr_title[$field]; } if($qry_num>0){ //echo $val; //echo $qry_num; return $val; }else{ return "N/A"; } } else{ return "N/A"; } } function check_null_value_array($field,$table,$id,$value){ if($value!=''){ $array = explode(',', $value); //print_r($array); $separate=""; foreach($array as $array_primary){ $sql_title = "select ".$field." from ".$table." where ".$id."='".$array_primary."'"; $qry_title = mysql_query($sql_title); $qry_num = mysql_num_rows($qry_title); $arr_title = mysql_fetch_assoc($qry_title); $val .= $separate.$arr_title[$field]; $separate=","; } return $val; //echo $val; //exit(); /*if($qry_num>0){ return $val; }else{ return "N/A"; }*/ } else{ return "N/A"; } } function check_null_date($value){ if($value=='0000-00-00'){ return "N/A"; } else{ return date('m/d/Y',strtotime($value)); } } function dupcheck($table,$field,$value){ $sql=mysql_query("SELECT * FROM ".$table." WHERE ".$field."='".$value."'"); $sql_num=mysql_num_rows($sql); return $sql_num; } function getUsers(){ $sql_title = "select * from sat_users where title in (1,2,3) and status = 'Active' order by name"; $qry_title = mysql_query($sql_title); //$arr_title = mysql_fetch_array($qry_title); return $qry_title; } function getClass($value){ if($value==1){ $value = 'Admin'; } if($value==2){ $value = 'Manager'; } if($value==3){ $value = 'User'; } return $value; } /*%%%%%%%%%%%%%%%%%%%%% Number to word convert start %%%%%%%%%%%%%%%%%%%%%%%*/ function addOrdinalNumberSuffix($num) { if (!in_array(($num % 100),array(11,12,13))){ switch ($num % 10) { // Handle 1st, 2nd, 3rd case 1: return $num.'st'; case 2: return $num.'nd'; case 3: return $num.'rd'; } } return $num.'th'; } /*%%%%%%%%%%%%%%%%%%%%% Number to word convert end %%%%%%%%%%%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%%%%%%%%% Client isactive start %%%%%%%%%%%%%%%%%%%%%%%*/ function getClient(){ $sql_title = "select * from abs_client where 1 and record_status='Active' order by name"; $qry_title = mysql_query($sql_title); //$arr_title = mysql_fetch_array($qry_title); return $qry_title; } /*%%%%%%%%%%%%%%%%%%%%% Client isactive end %%%%%%%%%%%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%%%%%%%%% Candidate isactive start %%%%%%%%%%%%%%%%%%%%%%%*/ function getCandidate(){ $sql_title = "select * from abs_candidate where 1 and record_status='Active' order by name"; $qry_title = mysql_query($sql_title); return $qry_title; } /*%%%%%%%%%%%%%%%%%%%%% Candidate isactive end %%%%%%%%%%%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%%%%%%%%% Candidate isactive start %%%%%%%%%%%%%%%%%%%%%%%*/ function getVendor(){ $sql_title = "select * from abs_vendor where 1 and record_status='Active' order by vendor_id"; $qry_title = mysql_query($sql_title); return $qry_title; } /*%%%%%%%%%%%%%%%%%%%%% Candidate isactive end %%%%%%%%%%%%%%%%%%%%%%%*/ //page permission /*function getPermission($pageName){ if($pageName!='changepassword.php'){ $sqlpage = "select page_id from sat_page_name where page_name='".$pageName."'"; $qrypage = mysql_query($sqlpage); $arrpage = mysql_fetch_array($qrypage); $pageId = $arrpage['page_id']; //echo "
"; $sqluser = "select userclass from sat_users where user_id='".$_SESSION['sat_login_id']."'"; $qryuser = mysql_query($sqluser); $arruser = mysql_fetch_array($qryuser); $user_level = $arruser['userclass']; $qryaut = mysql_query("select id from sat_permition where page_id='".$pageId."' and user_level='".$user_level."'"); $perRow = mysql_num_rows($qryaut); return $perRow; } }*/ //email template function emailTempalte($heading='',$body=''){ $content = '
American Business Solutions Inc - SAT
'.$heading.'
##EMAIL_BODY##
© '.date('Y').'
American Business Solutions Inc
. All rights reserved.
'; $email_body = str_replace(array("##EMAIL_BODY##"),array($body),$content); return $email_body; } function get_perticuler_value($table , $field , $field_name , $value){ $query = mysql_query("SELECT ".$field." FROM ".$table." WHERE ".$field_name." ='".$value."'"); $result= mysql_fetch_array($query); return $result; } function staff_code_gen() { $staff_code_rand = rand(10000,99999); $check = mysql_num_rows(mysql_query("SELECT staff_id FROM sat_staff WHERE staff_code = '".$staff_code_rand."'")); if($check == 0) { return $staff_code_rand; } else { staff_code_gen(); } } function getNameTable($table,$col,$field='',$value='',$field1='',$value1='',$field2='',$value2='') { $query="SELECT ".$col." FROM ".$table." where 1 "; if($field!='' && $value!='') { $query.="AND ".$field."='".$value."' "; } if($field1!='' && $value1!='') { $query.="AND ".$field1."='".$value1."' "; } if($field2!='' && $value2!='') { $query.="AND ".$field2."='".$value2."' "; } //echo $query; $recordSet = mysql_query($query); if(mysql_num_rows($recordSet) > 0) { $row = mysql_fetch_array($recordSet); return $row[$col]; } else { return ""; } } ?>