if ($results['active'] == 'N') { failure("Your account has been Inactivated. Please contact JHP for assistance."); } if ($results['username'] != $username) { // try as admin $handle = DB_Query_Select("* FROM `msg_staff` WHERE `username` = '".addslashes($username)."'"); $results = @ $handle[0]; if ($username == $results['username']) { $admin = true; //session_register(username); //session_register(name); //session_register(staffID); $_SESSION['username'] = $username; $_SESSION['name'] = $results['name']; $_SESSION['company'] = $results['company']; $_SESSION['accesslevel'] = $results['level']; $_SESSION['staffID'] = $results['staffID']; $_SESSION['admin'] = $results['admin']; $_SESSION['logintime'] = date("g:ia, D jS F"); $_COOKIE['username'] = $username; //setcookie('username', $username); //reset cooke to more days setcookie('jhplumbing', $username, time()+31536000); redirect("", " "; if ($_SESSION['accesslevel'] == 100) $template .= ""; if (isset($_SESSION['accesslevel'])) $template .= " "; else $template .= " "; $template .= "
Click here to go back to

Click Here To Go Back To Previous Page
Help & Support
$difmsg

Find Word Or Phrase

© 2002 - ".date('Y')." JHP Projects
"; $print_template = " <PAGE TITLE />
Printed on: ".e_date(date("Y-m-d"))." By ".$_SESSION['name']." | ".staffEmail($_SESSION['staffID'], "")." | ".staffSMS($_SESSION['staffID'], "")."
".print_f()." "; $view_template = " <PAGE TITLE />
© 2002 - ".date('Y')." JHP Projects
"; //page view templates if($_REQUEST['template'] == "print") { config_modify("Template_Current", "Template_Normal"); config_modify("Template_Normal", $print_template); config_modify("Fax Number", "02 4991 7875"); print_f(); } else if($_REQUEST['template'] == "log") { config_modify("Template_Current", "Template_Normal"); config_modify("Template_Normal", $log_template); config_modify("Fax Number", "02 4991 7875"); } else if($_REQUEST['template'] == "chart") { config_modify("Template_Current", "Template_Normal"); config_modify("Template_Normal", $chart_template); config_modify("Fax Number", "02 4991 7875"); } else if($_REQUEST['template'] == "view") { config_modify("Template_Current", "Template_Normal"); config_modify("Template_Normal", $view_template); config_modify("Fax Number", "02 4991 7875"); } else { config_modify("Template_Current", "Template_Normal"); config_modify("Template_Normal", $template); config_modify("Fax Number", "02 4991 7875"); } if ($_GET['act'] == NULL) { if($_SESSION['accesslevel'] == 100) { redirect("", "index.php?act=adminjobs&category=o&assign=n&time=a"); // Changed default from New Today to Unassigned // redirect("", "index.php?act=adminjobs&category=o&assign=n&time=n"); } elseif ($_SESSION['accesslevel'] == 50) { auto_main(); } elseif ($_SESSION['accesslevel'] == 10) { auto_customer(); } else { config_Modify("Site Menu Bar", " "); Authenticate_ShowLogin(); die(); } } else if ($_GET['act'] != "authenticate" && $_GET['act'] != "logout") { $path = "Auto_".$_GET['act']; if (function_exists($path)) $path (); else failure("Page is currently under review and evaluation by the administration"); } global $config, $db, $binary_data;; function DocumentFormatter($buffer) { $buffer2 = Config_Get(Config_Get("Template_Current")); $buffer2 = str_replace("", Config_Get("Site Menu Bar"), $buffer2); $buffer2 = str_replace("", Config_Get("Site Name").$siteextra, $buffer2); $buffer2 = str_replace("", Config_Get("Page Title"), $buffer2); $buffer2 = str_replace("", $buffer, $buffer2); $buffer2 = str_replace("
Contact: ".config_get("noty_name")." by
Email: ".config_get("noty_email")." OR
Mobile: ".sendSMSG(skypeNo(config_get("noty_mobile")))." OR
Landline: ".skypeNo(config_get("noty_landline"))." OR
Work: ".skypeNo(config_get("noty_work"))."
for support.
"; return $result; }//end function /* =================================================================== Database Functions =================================================================== */ function DB_Start() { global $db; $db['handle'] = @mysql_connect($db['host'], $db['user'], $db['pass']) or ($db['error'] = mysql_error()); if ($db['handle'] == "") { $response['Error'] = $db['error']; $response[0] = "Failed"; } else { mysql_select_db($db['db']) or ($db['error']=mysql_error()); if ($db['error'] != "") die($db['error']); } } // execute specified query and return the rows found function DB_Query_Select ($query, $strip = true) { global $db; $db['numqueries'] ++; $handle = mysql_query("SELECT ".$query) or die(mysql_error()); $results = array(); do { if (isset($entry)) { foreach ($entry as $key => $value) { if ($strip) $entry[$key] = stripslashes($value); } $results[] = $entry; } } while ($entry = @mysql_fetch_assoc($handle)); return $results; } // execute the insert command and return the appropriate insert ID function DB_Query_Insert ($query) { global $db; $db['numqueries'] ++; $handle = mysql_query("INSERT ".$query) or die(mysql_error().$query); //mysql_query("INSERT INTO `log_query` VALUES ('', '".addslashes("INSERT ".$query)."')"); return @ mysql_insert_id(); } // execute the specified update command function DB_Query_Update ($query) { global $db; $db['numqueries'] ++; $handle = mysql_query("UPDATE ".$query) or die(mysql_error()); //mysql_query("INSERT INTO `log_query` VALUES ('', '".addslashes("UPDATE ".$query)."')") or die(mysql_error()); } function DB_Query_Delete ($query) { global $db; $db['numqueries'] ++; $handle = mysql_query("DELETE FROM ".$query) or die(mysql_error()); //mysql_query("INSERT INTO `log_query` VALUES ('', '".addslashes("UPDATE ".$query)."')") or die(mysql_error()); } /* =================================================================== Customer adding, retrieving and modification routines. All routines should record a transaction with the record transaction function above. =================================================================== */ // get all notes associated with a particular customers. function Customer_GetNotes ($customer_username) { // validate customer exists; $customer = customer_get($customer_username); if ($customer === false) return false; // get notes $notes = DB_Query_Select ("* FROM `customer_notes` WHERE `username` = '".addslashes($customer_username)."'"); // record transaction record_transaction ($customer_username, "Retrieved ".count($notes)." note(s) for this customer"); // return notes return $notes; } // save a note against a customer's account. function Customer_SaveNote ($customer_username, $note) { // validate customer exists $customer = customer_get($customer_username); if ($customer === false) return false; // prepare some data $customer_username = addslashes($customer_username); $current_username = addslashes($_SESSION["current username"]); // put it in the DATABASE $note_id = DB_Query_Insert("`customer_notes` VALUES (DEFAULT, '$customer_username', '$current_username', NOW(), '$note')"); // record transaction record_transaction ($customer_username, "Saved a note on this account:\n\nNote Text: ".substr($note,0,20)."..."); return $note_id; } // retrieve the customer details. function Customer_Get($customer_username) { // get from database $customer = DB_Query_Select ("* FROM `customers` WHERE `username` = '".addslashes($customer_username)."' LIMIT 1"); $customer = $customer[0]; // check record is valid if ($customer[username] != $customer_username) return false; // extract data from userdata field $customer[userdata] = unserialize($customer[userdata]); // return user data selected return $customer; } // make any change to the customer. No changes should be made with direct DB queries, all through this routine. function Customer_Update($customer_username, $fieldname, $new_data) { // retrieve customer details $customer = customer_get($customer_username); if ($customer === false) return false; // store old detail if ($fieldname == "password" || $fieldname == "activestatus") $variable = $customer[$fieldname]; else $variable = $customer[userdata][$fieldname]; $old_data = addslashes($variable); $new_data = addslashes($new_data); // make the change if ($fieldname == "password" || $fieldname == "activestatus") { DB_Query_Update ("`customers` SET `".addslashes($fieldname)."` = '$newdata' WHERE `username` = '$customer_username';"); } else { $customer[userdata][$fieldname] = $new_data; DB_Query_Update ("`customers` SET `userdata` = '".addslashes(serialize($customer[userdata]))."' WHERE `username` = '$customer_username';"); } // record transaction record_transaction ($customer_username, "Updated Customer Record - $fieldname:\n\nOld Value: $olddata\nNew Value: $newdata"); } // Create a new customer record in the database. function Customer_Create ($userdata) { // check array vs current template $template1 = @ unserialize(config("Customer Template - Required")); $template2 = @ unserialize(config("Customer Template - Not Required")); if (!is_array($template1)) failure ("Customer Template Invalid"); if (!is_array($template2)) failure ("Customer Template Invalid"); if (!is_array($userdata)) failure ("New Customer Invalid"); $template_valid = true; foreach ($template as $key => $value) { // check if that key is in the array that was passed if (!isset($userdata[$key])) $template_valid = false; } if (!$template_valid) return false; // generate a username and password // working with any key that has a "name" value in it. $name = ""; foreach ($userdata as $key => $value) { if (stripos($key, "name") !== false) $name.= trim($value); } if (strlen($name) < 6) { foreach ($userdata as $value) { $name .= trim($value); } } $username = strtolower($username); $ok = "abcdefghijklmnopqrstuvwxyz"; $newusername = ""; $tracker = 0; do { if (@ strpos($ok, $username[$tracker]) !== false )$newusername .= $username[$tracker];; //echo "searching for ".$username[$tracker]."
"; $tracker ++; } while ($tracker <= strlen($username)); $username = substr($newusername,0,6); $pin = rand(100000, 1000000); $exist = DB_Query_Select ("`username` FROM `customers` WHERE `username` LIKE '".addslashes($username)."%';"); $usernumber = count($exist) + 1; $username .= $usernumber; // insert customer into database $usernumber = DB_Query_Insert("`customers` VALUES (DEFAULT, '$username', '$pin', '".addslashes(serialize($userdata))."', 'N', NOW());"); // record transaction record_transaction($username, "Created new user:\n\nUsername: $username\nPassword: $pin"); // generate their bpay number $bpaynumber = generatebpay ((config("BPAY Multiplexor")+$usernumber)*$usernumber); // update record with bpay number customer_update($username, "bpay number", $bpaynumber); // return the username that was generated return array("username" => $username, "password" => $pin, "id" => $usernumber); } /* =================================================================== Job Functions =================================================================== */ //get staff card information function jobStaffCard($jobID, $staffID, $starttime) { $job = db_query_select("* FROM `jobs` WHERE `id` = '".$jobID."'"); $job = $job[0]; //get job start time $jjw = db_query_select("* FROM `jobs_workers` WHERE `jobID` = '".$jobID."' AND `staffID` = '".$staffID."'"); $jjw = $jjw[0]; if($starttime != "") $jjw['starttime'] = $starttime; $result = "".timeAMPM($jjw['starttime']).""; $result .= "
"; //get more job details //get client information if($job['internal'] == "n") { $client = db_query_select("* FROM `customers` WHERE `customerID` = '".$job['username']."'"); $client = $client[0]; $client['name'] = $job['who']. " ( ".$client['company']." )"; } //get client information if($job['internal'] == "y") { $client = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$job['username']."'"); $client = $client[0]; $client['company'] = "JHP Internal"; $job['who'] = $client['name']; $client['name'] = $job['who']. " ( ".$client['company']." )"; } $result .= " JOB No: ".$job['id']."
Logged By: ".$client['name']."
Contact: ".$job['contactperson']." - M: ".$job['contactmobile'].", L: ".$job['contactphone'].", W: ".$job['contactwork']."
Description: ".$job['jobdescription']."
Address: ".$job['address'].", ".$job['suburb'].", ".$job['postcode']."
Other Employees Assigned:"; //get staff members attending event $st = db_query_select("* FROM `jobs_workers` WHERE `jobID` = '".$job['id']."' AND `staffID` != '".$staffID."'"); foreach($st AS $temp) { //get staff member details $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$temp['staffID']."'"); $staff = $staff[0]; $result .= "
".$staff['name']."-".$staff['mobile']."-".$staff['email']."
"; }//end for $result .= "
"; return $result; }//end function //job booking confirmation function jobConfirmSchedule($message, $j, $s, $date, $starttime, $direct) { //get job details $job = db_query_select("* FROM `jobs` WHERE `id` = '".$_REQUEST['j']."'"); $job = $job[0]; //compile text message to be sent if there is a mobile number $text = "Jason Higgins Plumbing Job No. ".$j." Scheduled on ".e_date($date)." @ ".timeAMPM($starttime)." If unsuitable call 02 4015 4444 to reschedule."; echo " ".countCharDown('request', 160, 'message', 'count')."
?act=save_schedule&j=".$j."&s=".$s."&date=".$date."&starttime=".$starttime."&direct=".$direct."\" method=\"post\" enctype=\"multipart/form-data\" name=\"confirm\" id=\"confirm\">
Confirm Job Scheduling
".fontColorSize(addslashes(strtoupper($message)), "black", "-1")."
".jobStaffCard($j, $s, $starttime)."
SMS job details to : ".strtoupper($job['contactperson'])." (customer)
Send SMS?
Job Mobile No: ".textFieldNos("mobile", $job['contactmobile'], "20", "10", helpS("Mobile number can be edited & replaced with another number", ""))." Skype Call: ".skypeNo($job['contactmobile'])."
Text Message:  
Characters Left
Contact Landline: ".skypeNo($job['contactphone'])." / Work: ".skypeNo($job['contactwork'])."
".btnSubmit("CLICK HERE TO CONFRIM DATE & TIME")."
"; die(); }//end function /* =================================================================== Customer Functions =================================================================== */ //get staff card information function customerCard($customerID, $color) { $customer = db_query_select("* FROM `customers` WHERE `customerID` = '".$customerID."'"); $customer = $customer[0]; $result = "
?act=clientupdate&client=".$customerID."\">".$customer['company']."
Email: ".$customer['username']."
Phone: ".skypeNo($customer['phone'])."
"; return $result; }//end function /* =================================================================== Global Functions =================================================================== */ function sendSMSG($mobile) { $result = " ".skypeNo($mobile)." "; return $result; }//end function /* =================================================================== Skype Functions =================================================================== */ //this will change the format of the number to a skype format function skypeNo($no) { //check the first 2 digits of the number $no = str_replace(" ","",$no); //remove spaces $dig1 = substr($no, 0 ,2); $dig2 = substr($no, 2 ,15); //mobile number part if($dig1 == 04) { $result = "+614".$dig2; }//end if for mobile else if($dig1 == 02) { $result = "+612".$dig2; } else if($dig1 == 03) { $result = "+613".$dig2; } else if($dig1 == 05) { $result = "+615".$dig2; } else if($dig1 == 06) { $result = "+616".$dig2; } else if($dig1 == 07) { $result = "+6137".$dig2; } else if($dig1 == 08) { $result = "+618".$dig2; } else if($dig1 == 09) { $result = "+619".$dig2; } //consider already country provided else if($dig1 == 61) { $result = "+61".$dig2; } //consider numbers greater than 10 else if($dig1 > 9) { $result = "+612".$no; } //return result if(strlen($result) < 10) $result = $no; else $result = substr($result, 0, 12); return $result; }//end function /* =================================================================== Staff Functions =================================================================== */ //get staff card information function staffCard($staffID, $color) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; $result = "
".$staff['name']."
Email: ".staffEmail($staffID, "".$color."")."
Mobile: ".sendSMSG($staff['mobile'])."
"; return $result; }//end function //staff send email href link function staffEmail($staffID, $color) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; $result = "".$staff['email'].""; return $result; }//end function //staff send sms href link function staffSMS($staffID, $color) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; $result = "".skypeNo($staff['mobile']).""; return $result; }//end function //these functions are for getting the staff information of another staff member //get staff username function getStaffUsername($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['username']; }//end function //get staff name function getStaffName($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['name']; }//end function //get staff email function getStaffEmail($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['email']; }//end function //get staff sms function getStaffMobile($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['mobile']; }//end function //get staff start time function getStaffStartTime($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['starttime']; }//end function //get staff finish time function getStaffFinishTime($staffID) { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$staffID."'"); $staff = $staff[0]; return $staff['finishtime']; }//end function //thses functions are for the staff member logged in //get session staff username function sessionStaffUsername() { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$_SESSION['staffID']."'"); $staff = $staff[0]; return $staff['username']; }//end function //get session staff name function sessionStaffName() { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$_SESSION['staffID']."'"); $staff = $staff[0]; return $staff['name']; }//end function //get session staff email function sessionStaffEmail() { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$_SESSION['staffID']."'"); $staff = $staff[0]; return $staff['email']; }//end function //get session staff sms function sessionStaffMobile() { $staff = db_query_select("* FROM `msg_staff` WHERE `staffID` = '".$_SESSION['staffID']."'"); $staff = $staff[0]; return $staff['mobile']; }//end function //Staff Working Days; Check whether staff member works that day function staffWorkOnDay($staffID, $day) { return count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '".$day."' AND `staffID` = '".$staffID."'")); }//end function //Staff RDO Day; Check whether staff member works that day function staffRDO($month, $day) { return count(db_query_select("* FROM `months` WHERE `id` = '".$month."' AND `day_month` = '".$day."'")); }//end function //Staff Public Holidays function staffPublicH($month, $day) { return count(db_query_select("* FROM `public_holidays` WHERE `day_month` = '".$month."-".$day."'")); }//end function //Staff leave dates c function staffLeave($staffID, $date) { return count(db_query_select("* FROM `leave_staff` WHERE `staffID` = '".$staffID."' AND `commences` <= '".$date."' AND `returns` > '".$date."'")); }//end function //this function calculates the staff member workings hors function staffHours($staffID) { return (1 + getStaffFinishTime($staffID) - getStaffStartTime($staffID)) * 100; }//end function /* =================================================================== Javascript Functions =================================================================== */ //this function will count the number of characters been type with a remainder value function countCharDown($form, $limit, $textfield, $counfield) { $result = " "; return $result; }//end function /* =================================================================== Routines to deal with configuration variables stored in the DB. =================================================================== */ // temporarily overrides one of the config variables for this execution only function Config_Override($var, $value) { global $config; $config[$var] = $value; } // permanantly changes a config variable to the value passed. Creates it if it doesn't exist. function Config_Modify($var, $value) { global $config; $config[$var] = $value; // check if it exists first! $exists = DB_Query_Select("* FROM `configuration` WHERE `key` = '".addslashes($var)."' LIMIT 1"); if (count($exists) < 1) // insert DB_Query_Insert("`configuration` VALUES ('".addslashes($var)."', '".addslashes($value)."')"); else {//update if ($exists[0]['value'] != $value) DB_Query_Update("`configuration` SET `value` = '".addslashes($value)."' WHERE `key` = '".addslashes($var)."' LIMIT 1"); } } // retrieve a config variable form the database. usage: echo config("variable name"); function Config_Get ($var) { global $config; if (!isset($config[$var]) || $config[$var] == "") { $temp = DB_Query_Select("* FROM `configuration` WHERE `key` = '".addslashes($var)."'"); $temp = @ $temp[0]['value']; $config[$var] = $temp; } return $config[$var]; } /* =================================================================== Help & Support =================================================================== */ //default load message function helpSLoad($def) { echo " "; }//end function //this function will generate the help and support for the nominated item function helpS($msg, $def) { // ".helpS("", $def)." $result = "onmouseover=\"changeContent('lyr1', '".$msg."')\" onmouseout=\"changeContent('lyr1', '".$def."')\""; return $result; }//end function /* =================================================================== Checkers to sipt out result =================================================================== */ function chk($result) { echo $result; } function chkDie($result) { echo $result; die; } /* =================================================================== Basic HTML functions =================================================================== */ function Failure($message) { echo "
Warning!
 
".fontColorSize(addslashes($message), "black", "2")."
 
"; die(); } function Bounce($message = "") { //draw a table echo "
Warning!
 
".fontColorSize(addslashes($message), "black", "2")."
 
"; die(); /* echo ""; die(); */ } function Bounce_2($message = "") { echo "
Warning!
 
".fontColorSize(addslashes($message), "black", "2")."
 
"; die(); } function Alert($message = "") { echo ""; } //back function back($no) { echo " "; }//end function function Redirect($message, $newpage) { if ($message != "") echo "
Warning!
 
".fontColorSize(addslashes($message), "black", "2")."
 
"; else echo " "; die(); } //job description mean calculator function mean($id) { //get job description inital duration $temp = db_query_select("* FROM `job_descriptions` WHERE `id` = '".$id."'"); $temp = $temp[0]; //calcualte average duration of job description //get the total that will divide global $total, $totald; $total = 0; $totald = 0; $total = count(db_query_select("* FROM `job_descriptions_duration` WHERE `f_id` = '".$id."'")); //get the total duration to be divided $dt = db_query_select("* FROM `job_descriptions_duration` WHERE `f_id` = '".$id."'"); foreach($dt AS $dtt) { $totald = $totald + $dtt['value']; } $totald = $totald + $temp['duration']; $total = $total + 1; return round($totald / $total, 2); } //job description true hours and minutes function mean_true($mean) { $true = explode(".", $mean); $h = $true[0]."Hr(s)"; //put back the decimal comma $k = "0.".$true[1]; $m = round($k * 60, 0); //0 decimal place $m = $m."mins"; return $h." ".$m; } //this function closes the current window and refreshse the parent windows function close_refresh($msg) { if($msg == "") echo " "; else echo "
Warning!
 
".fontColorSize(addslashes($msg), "black", "2")."
 
"; die(); }//end function //this function just closes the open window without refreshing the parent window function close($msg) { if($msg == "") echo " "; else echo "
Warning!
 
".fontColorSize(addslashes($msg), "black", "2")."
 
"; die(); }//end function //print function function print_f() { $result = " "; return $result; } //this function asks user to confirm any action function confirmOnNewWindow($msg, $url) { //javascript to ask to confirm echo" "; } //end function //this function asks user to confirm the delete action function confirm_delete($msg, $url) { //javascript to ask to confirm echo" "; } //end function //this function will drop a text field that will only take numbers function textFieldNos($name, $value, $size, $length, $headers) { $result = " "; return $result; }//end function //this function will drop a text field that will only take numbers & commas function textFieldNosCom($name, $value, $size, $length, $headers) { $result = " "; return $result; }//end function //this function will chage the text color and size to the required function fontColorSize($text, $color, $size) { $result = "".$text.""; return $result; }//end function //colour picker function pickColor($frm, $field, $value) { $result = "
?act=pickcolor&frm=".$frm."&field=".$field."&template=view', '', 'width=400,height=300,top=120,left=120' ))\">
"; return $result; } /* =================================================================== Time & Date Functions =================================================================== */ //this function will drop the claendar and the date field function drop_date($frm, $field, $value) { $result = "
"; return $result; } //format date to australian date format function american_date($date) { $expo = explode("-", $date); $y = $expo[0]; $m = $expo[1]; $d = $expo[2]; return $m."/".$d."/".$y; } //format date to australian date format function aussie_date($date) { $expo = explode("-", $date); $y = $expo[0]; $m = $expo[1]; $d = $expo[2]; return $d."/".$m."/".$y; } //expand date function e_date($date) { $expo = explode("-", $date); $y = $expo[0]; $m = $expo[1]; $d = $expo[2]; return date("D jS F Y", mktime(0,0,0, (int)$m, (int)$d, (int)$y)); } //this function returns todays date function today() { return date("Y-m-d", time()); }//end function //this function return the current time function get_time() { return date("H:i:s", time()); }//end function //this gunction will conver the 24hr to am/pm function timeAMPM($time) { //split the time $st = explode(":", $time); $h = $st[0]; $m = $st[1]; //AM OR PM if($h >= 0 AND $h < 12) $result = $h.":".$m." a.m."; else if($h >= 12 AND $h < 24) { if($h > 12) $h = $h - 12; $result = $h.":".$m." p.m."; } return $result; }//end function //this gunction will conver the 24hr to am/pm function timeAMPMCaps($time) { //split the time $st = explode(":", $time); $h = $st[0]; $m = $st[1]; $s = $st[2]; //AM OR PM if($h >= 0 AND $h < 12) $result = $h.":".$m.":AM"; else if($h >= 12 AND $h < 24) { if($h > 12) $h = $h - 12; $result = $h.":".$m.":".$s.":PM"; } return $result; }//end function //this function will add the number of hours or minutes and return the future time in minutes function futureTime($time, $sec) { //split the time $st = explode(":", $time); $h = $st[0]; $m = $st[1]; $s = $st[2]; //check for how many hours to add $hr_r = $min / 3600; $min_r = $min / 60; //add the minutes $min_add = $m + $min_r; if($min_add > 59) { $m = 0; $hr_add = $h + $hr_r; if($hr_add > 23) $h = 0; } $result = $h.":".$m; return $result; }//end function //return number of days between 2 dates function date_diffs($date1, $date2) { $s = strtotime($date2)-strtotime($date1); $d = intval($s/86400); //if($d <= 0) $d = 0; return $d; }//end function //show the AMPM hour selection function selectAMPM($hour, $minutes, $am_pm) { if($am_pm == "AM") $sel_a = "SELECTED"; else if($am_pm == "PM") $sel_p = "SELECTED"; $result = "
".dropDownNos("hour", "1", "12", $hour, "")." : ".dropDownNos("minutes", "0", "60", $minutes, "")."
"; return $result; } //show the AMPM hour selection function selectDates($n1, $n2, $n3, $day, $month, $year) { $result = "
".dropDownNos($n1, "1", "31", $day, "")." ".dropDownNos($n2, "1", "12", $month, "")." ".dropDownNos($n3, date("Y", time()), (date("Y", time()) + 5), $year, "")." (dd/mm/yyyy)
"; return $result; } //convert the time to 24 hour function time24($hour, $min, $am_pm) { //chkdie($hour." ".$min." ".$am_pm); if($am_pm == "PM") $hour = $hour + 12; if($hour == 24) $hour = "00"; $result = $hour.":".$min.":00"; return $result; } //this gunction will conver the 24hr to am/pm function time12($time) { //split the time $st = explode(":", $time); $h = $st[0]; $m = $st[1]; //AM OR PM if($h >= 0 AND $h < 12) $result = $h.":".$m.":AM"; else if($h >= 12 AND $h < 24) { if($h > 12) $h = $h - 12; $result = $h.":".$m.":PM"; } return $result; }//end function //select time sone function selectTimeZone($value) { //get timezones from db $gzones = db_query_select("* FROM `gmt_zones` ORDER BY `gmt_id` ASC"); $r = " "; return $r; } function getGMTHrMin($gmt_id) { $gmt_zone = db_query_select("* FROM `gmt_zones` WHERE `gmt_id` = '".$gmt_id."'"); $gmt_zone = $gmt_zone[0]; $r = $gmt_zone['adj_hours'].":".$gmt_zone['adj_minutes'].":00"; return $r; } //get user email function userDST() { if(Config_Get("Daylight Savings") == "y") $r = 1; else $r = 0; return $r; }//end function //server time zone function serverTimeZone() { return getGMTHrMin(config_get("Server Time Zone")); }//end fucntion //user time zone function userTimerZone() { return getGMTHrMin(Config_Get("Site Time GMT Zone")); } //server user timer function serverUserTimeDif() { //split the values //user slip $user = explode(":", userTimerZone()); $server = explode(":", serverTimeZone()); //first check minutes $chk_min = $user[1] - $server[1]; if($chk_min < 0) { $min = $chk_min + 60; $adj_hr = -1; } else { $min = $chk_min; $adj_hr = 0; } //check hours $chk_hr = $user[0] - $server[0] + $adj_hr; return $chk_hr.":".$min.":00"; } //user actual time function userActualTime($userTime) { $user_time = explode(":", $userTime); $user_hr = $user_time[0]; $user_min = $user_time[1]; $server_dif = explode(":", serverUserTimeDif()); $server_hr = $server_dif[0]; $server_min = $server_dif[1]; $chk_min = $user_min + $server_min; if($chk_min >= 60) { $min = $chk_min - 60; $adj_hr = 1; } else { $min = $chk_min; $adj_hr = -1; } //check hours $chk_hr = $user_hr + $server_hr + $adj_hr + userDST(); if($chk_hr < 0) $chk_hr = 24 + $chk_hr; else if($chk_hr >= 24) $chk_hr = $chk_hr - 24; if(strlen($chk_hr) == 1) $chk_hr = "0".$chk_hr; if(strlen($min) == 1) $min = "0".$min; return $chk_hr.":".$min.":00"; }//end function //user actual date function userActualDate($userDate) { $server_date = today(); $server_time = get_time(); $user_time = userActualTime($server_time); //the difference between user & server $sut = explode(":", serverUserTimeDif()); $sut_hr = $sut[0]; $sut_min = $sut[1]; $server = explode(":", $server_time); $server_hr = $server[0]; $server_min = $server[1]; //check whether to increamate day od decrease //if user time zone is greater than server if(userTimerZone() <= serverTimeZone()) { //make adjustsments to the minutes $mindif = $sut_min - $server_min; if($mindif < 0) { $min = $mindif + 60; $adj_hr = -1; }//end if else { $min = $mindif; $adj_hr = 0; } //check hours $hr = $sut_hr + $adj_hr; $steps_catchup = -($hr) - $server_hr; if($steps_catchup > 0) //reduce day by 1 $r = dateAdjustments("-1", $userDate); else $r = $userDate; }//end if //if user time zone is greater than server time zone else if(userTimerZone() > serverTimeZone()) { //make adjustsments to the minutes $mindif = $server_min - $sut_min; if($mindif < 0) { $min = $mindif + 60; $adj_hr = 1; }//end if else { $min = $mindif; $adj_hr = 0; } //check hours $hr = $sut_hr + $adj_hr; $steps_server_catchup = 24 - $server_hr; $steps_done = $hr - $steps_server_catchup; //echo $hr; //die(); if($steps_done >= 0) //reduce day by 1 $r = dateAdjustments("1", $userDate); else $r = $userDate; }//endif return $r; } //days in month function daysInMonth($month) { // How many days in the month? if (($month == "4") || ($month == "6") || ($month == "9") || ($month == "11")) { $days = 30; } elseif ($month == "2") { if (is_int($year / 4)) { $days = 29; } else { $days = 28; } } else { $days = 31; } return $days; }//end function //function to adjust date and return year, month from the given date function dateAdjustments($day_adj, $date) { $da = explode("-", $date); $year = $da[0]; $month = $da[1]; $day = $da[2]; $days_diff = $day + $day_adj; //if negative if($days_diff <= 0) { $month = $month - 1; if($month <= 0) { $month = 12; $year = $year - 1; $day = daysInMonth($month) + $days_diff; } else $day = daysInMonth($month); }//end if //if positive else if($days_diff > daysInMonth($month)) { $month = $month + 1; if($month > 12) { $month = 1; $year = $year + 1; $day = $days_diff - daysInMonth($month); } else $day = 1; } else $day = $days_diff; return $year."-".$month."-".$day; }//end function /* =================================================================== Page functions for data provided =================================================================== */ //this will list pages according numbers function pages($query, $url) { //get the list of all the records $records = count(db_query_select($query)); //divide record count by 20 $pg = $records / 20; //explode the value and get the whole number $pg_e = explode(".", $pg); $pg_n = $pg_e[0]; //get the modulous or remainder $pg_r = $records % 20; $addpg = 0; if($pg_r > 0) $addpg = 1; $pages = $pg_n + $addpg; $last = ($pages * 20) - 20; if($last < 0) $last = 0; $result = "
"; if($_REQUEST['st'] == 0) $result .= "FIRST"; else $result .= "?act=".$url."&st=0<t=20\">FIRST"; //this back way if(($_REQUEST['st'] - 20) < 0) $result .= " BACK"; else $result .= "?act=".$url."&st=".($_REQUEST['st'] - 20)."<t=20\"> BACK"; //do a for loop to list number of pages $p = 0; for($i = 1; $i < $pages + 1; $i++) { $st = $p * 20; if($_REQUEST['st'] == $st) $result .= " ".$i." "; else $result .= "?act=".$url."&st=".$st."<t=20\"> ".$i." "; $p = $p + 1; }//end for loop //this next way if(($_REQUEST['st'] + 20) > $last) $result .= " NEXT"; else $result .= "?act=".$url."&st=".($_REQUEST['st'] + 20)."<t=20\"> NEXT"; if($_REQUEST['st'] == $last) $result .= " LAST"; else $result .= "?act=".$url."&st=".$last."<t=20\"> LAST"; $result .="
"; return $result; }//nd function //this will list pages according to the avaliable letters in the database function pagesAlpha($query, $name, $url, $next) { $result = "
"; $records = db_query_select($query." GROUP BY `".$name."`"); //save variable of last letter $lt = ""; foreach($records AS $temp) { if($lt != strtoupper(substr($temp[$name], 0, 1))) { $result .= "?act=".$url."&letter=".strtoupper(substr($temp[$name], 0, 1))."\">".strtoupper(substr($temp[$name], 0, 1))."".$next.""; $lt = strtoupper(substr($temp[$name], 0, 1)); } else $result .= ""; }//end foreach $result .="?act=".$url."&letter=all\"> [ All ]
"; return $result; }//nd function /* =================================================================== Button Functions =================================================================== */ //button for general onclick event function btnButton($name, $value, $url) { $result = ""; return $result; }//end function //delete button alt and link function btnDelete($alt, $url) { $result = "\"".$alt."\""; return $result; }//end function //this function will goto the next page using javascript function onclick_go($url) { $result = "OnClick=\"Javascript:go('".$url."');\""; return $result; }//end function //this function submit a form function btnSubmit($value) { $result = ""; return $result; }//end function /* =================================================================== Duration calculator for jobs for staff member =================================================================== */ function durationLastJob($staffID, $weekstart_date) { $gsst = getStaffStartTime($staffID); $gsft = getStaffFinishTime($staffID) + 1; if(strlen($gsst) == 1) $gsst = "0".$gsst; if(strlen($gsft) == 1) $gsft = "0".$gsft; $gsst = $gsst.":00:00"; $gsft = $gsft.":00:00"; //get the latest job according to date and start tome, less than nominated date. //the TO_DAYS function returns day number since year 0 //also consdier that the job falls into the interval the staff member starts $pre_chk = db_query_select("* FROM `jobs_workers` WHERE `staffID` = '".$staffID."' AND TO_DAYS(date) < TO_DAYS('".$weekstart_date."') AND `starttime` >= '".$gsst."' AND `starttime` < '".$gsft."' ORDER BY `date` DESC, `starttime` DESC"); $pre_chk = $pre_chk[0]; //echo $pre_chk['jobID']." - ".e_date($pre_chk['date'])."
"; //get job duration $pre_job = db_query_select("* FROM `jobs` WHERE `id` = '".$pre_chk['jobID']."'"); $pre_job = $pre_job[0]; //----------------hours left from starttime until shift finishes //split the start time $pre_st = explode(":", $pre_chk['starttime']); $p_min = ($pre_st[1] / 60) * 100; $p_hr = $pre_st[0] * 100; $f_hr = getStaffFinishTime($staffID) * 100; //increase finish time to true to finish time 100 = 1 hr $pre_hrs = ($f_hr + 100) - ($p_hr + $p_min); //count how many staff members are doing the job $cnt_jw = count(db_query_select("* FROM `jobs_workers` WHERE `jobID` = '".$pre_chk['jobID']."'")); //no division by zero if($cnt_jw == 0) $cnt_jw = 1; //check whether duration is greater than shift hours left to work on $pre_du = ($pre_job['duration'] * 100) / $cnt_jw; //convert to 100 //if duration left is greater than shift hors left for the day if($pre_du > $pre_hrs) { //how may are left then $pre_left = $pre_du - $pre_hrs; //split week start date of the weeek $wk = explode("-", $pre_chk['date']); $wk_y = $wk[0]; $wk_m = $wk[1]; $wk_d = $wk[2]; //check how many days in the current month if (("$wk_m" == 4) || ("$wk_m" == 6) || ("$wk_m" == 9) || ("$wk_m" == 11)) { $days = 30; } elseif ("$wk_m" == 2) { if (is_int($wk_y / 4)) { $days = 29; } else { $days = 28; } } else { $days = 31; } //duration of shift per day $shift_day = ((getStaffFinishTime($staffID) + 1) - getStaffStartTime($staffID)) * 100; //required loops to add days, months, year $times = $pre_left / $shift_day; $e_times = explode(".", $times); //remaining duration after loop $dur_left = $pre_left - ($shift_day * $e_times[0]); //insatantiate date when dates will start from //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days //now loop for($i = 1; $i < $e_times[0] + 1; $i++) { if(strlen($wk_m) == 1) $wk_m = "0".$wk_m; if(strlen($wk_d) == 1) $wk_d = "0".$wk_d; //new date generated $new_date = $wk_y."-".$wk_m."-".$wk_d; //check to see whether staff member works that day of the week $new_day = date("D", mktime(0, 0, 0, $wk_m, $wk_d, $wk_y)); $wsdNew_mon = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '1' AND `staffID` = '".$staffID."'")); $wsdNew_tue = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '2' AND `staffID` = '".$staffID."'")); $wsdNew_wed = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '3' AND `staffID` = '".$staffID."'")); $wsdNew_thu = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '4' AND `staffID` = '".$staffID."'")); $wsdNew_fir = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '5' AND `staffID` = '".$staffID."'")); $wsdNew_sat = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '6' AND `staffID` = '".$staffID."'")); $wsdNew_sun = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '7' AND `staffID` = '".$staffID."'")); //rdo days $rdoNew = count(db_query_select("* FROM `months` WHERE `id` = '".$wk_m."' AND `day_month` = '".$wk_d."'")); //public holidays $pubNew = count(db_query_select("* FROM `public_holidays` WHERE `day_month` = '".$wk_m."-".$wk_d."'")); //leave dates $levNew = count(db_query_select("* FROM `leave_staff` WHERE `staffID` = '".$staffID."' AND `commences` <= '".$new_date."' AND `returns` > '".$new_date."'")); //--------------------------------- MONDAY if($new_day == "Mon" AND $wsdNew_mon == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end MONDAY //--------------------------------- TUESDAY else if($new_day == "Tue" AND $wsdNew_tue == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- WEDNESDAY else if($new_day == "Wed" AND $wsdNew_wed == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- THURSDAY else if($new_day == "Thu" AND $wsdNew_thu == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- FRIDAY else if($new_day == "Fri" AND $wsdNew_fri == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- SATURDAY else if($new_day == "Sat" AND $wsdNew_sat == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- SUNDAY else if($new_day == "Sun" AND $wsdNew_sun == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end else { //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end for loop }// end else //check whther there are any remaining hours on the job if($dur_left > 0) { //loop through the seven days of the week until you finnd the right date to drop the job for($i = 0; $i < 7; $i++) { //new date generated if(strlen($wk_m) == 1) $wk_m = "0".$wk_m; if(strlen($wk_d) == 1) $wk_d = "0".$wk_d; $new_date = $wk_y."-".$wk_m."-".$wk_d; //check to see whether staff member works that day of the week $new_day = date("D", mktime(0, 0, 0, $wk_m, $wk_d, $wk_y)); //--------------------------------- MONDAY if($new_day == "Mon" AND staffWorkOnDay($staffID, 1) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $mon_passon = $dur_left; break; } }//end //--------------------------------- TUESDAY else if($new_day == "Tue" AND staffWorkOnDay($staffID, 2) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $tue_passon = $dur_left; break; } }//end //--------------------------------- WEDNESDAY else if($new_day == "Wed" AND staffWorkOnDay($staffID, 3) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $wed_passon = $dur_left; break; } }//end //--------------------------------- THURSDAY else if($new_day == "Thu" AND staffWorkOnDay($staffID, 4) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $thu_passon = $dur_left; break; } }//end //--------------------------------- FRIDAY else if($new_day == "Fri" AND staffWorkOnDay($staffID, 5) == 1) { //rdo days //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $fri_passon = $dur_left; break; } }//end //--------------------------------- SATURDAY else if($new_day == "Sat" AND staffWorkOnDay($staffID, 6) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $sat_passon = $dur_left; break; } }//end //--------------------------------- SUNDAY else if($new_day == "Sun" AND staffWorkOnDay($staffID, 7) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else { $sun_passon = $dur_left; break; } }//end else { //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end else }//end for }//end if for the remaining time }//end if //now return the finish date and duration left on that date to be done and the job ID $value = $new_date.":".$dur_left.":".$pre_chk['jobID']; return $value; }//end function //=========================================== Show the Job Finish Date & Time function jobFinishDate($staffID, $jobID, $startDate, $startTime) { //get job information $pre_job = db_query_select("* FROM `jobs` WHERE `id` = '".$jobID."'"); $pre_job = $pre_job[0]; //count to check for other scheduled members to do the job $count_jw = count(db_query_select("* FROM `jobs_workers` WHERE `jobID` = '".$jobID."'")); //division by zero not allowed if($count_jw == 0) $count_jw = 1; //$pre_chk = db_query_select("* FROM `jobs_workers` WHERE `staffID` = '".$staffID."' AND `jobID` = '".$jobID."'"); //$pre_chk = $pre_chk[0]; //echo e_date($startDate)."
"; //----------------hours left from starttime until shift finishes //split the start time $pre_st = explode(":", $startTime); $p_min = ($pre_st[1] / 60) * 100; $p_hr = $pre_st[0] * 100; $f_hr = getStaffFinishTime($staffID) * 100; //increase finish time to true to finish time 100 = 1 hr $pre_hrs = ($f_hr + 100) - ($p_hr + $p_min); //check whether duration is greater than shift hours left to work on $pre_du = ($pre_job['duration'] * 100) / $count_jw; //convert to 100 and divide by the nymber of staff members assigned to the job //if duration left is greater than shift hours left for the day if($pre_du > $pre_hrs) { //how may are left then $pre_left = $pre_du - $pre_hrs; //split week start date of the weeek $wk = explode("-", $startDate); $wk_y = $wk[0]; $wk_m = $wk[1]; $wk_d = $wk[2]; //check how many days in the current month if (("$wk_m" == 4) || ("$wk_m" == 6) || ("$wk_m" == 9) || ("$wk_m" == 11)) { $days = 30; } elseif ("$wk_m" == 2) { if (is_int($wk_y / 4)) { $days = 29; } else { $days = 28; } } else { $days = 31; } //duration of shift per day $shift_day = ((getStaffFinishTime($staffID) + 1) - getStaffStartTime($staffID)) * 100; //required loops to add days, months, year $times = $pre_left / $shift_day; $e_times = explode(".", $times); //remaining duration after loop $dur_left = $pre_left - ($shift_day * $e_times[0]); //insatantiate date when dates will start from //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days if($e_times[0] > 0) { //now loop for($i = 1; $i < $e_times[0] + 1; $i++) { if(strlen($wk_m) == 1) $wk_m = "0".$wk_m; if(strlen($wk_d) == 1) $wk_d = "0".$wk_d; //new date generated $new_date = $wk_y."-".$wk_m."-".$wk_d; //check to see whether staff member works that day of the week $new_day = date("D", mktime(0, 0, 0, $wk_m, $wk_d, $wk_y)); $wsdNew_mon = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '1' AND `staffID` = '".$staffID."'")); $wsdNew_tue = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '2' AND `staffID` = '".$staffID."'")); $wsdNew_wed = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '3' AND `staffID` = '".$staffID."'")); $wsdNew_thu = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '4' AND `staffID` = '".$staffID."'")); $wsdNew_fir = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '5' AND `staffID` = '".$staffID."'")); $wsdNew_sat = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '6' AND `staffID` = '".$staffID."'")); $wsdNew_sun = count(db_query_select("* FROM `staff_working_days` WHERE `f_id` = '7' AND `staffID` = '".$staffID."'")); //rdo days $rdoNew = count(db_query_select("* FROM `months` WHERE `id` = '".$wk_m."' AND `day_month` = '".$wk_d."'")); //public holidays $pubNew = count(db_query_select("* FROM `public_holidays` WHERE `day_month` = '".$wk_m."-".$wk_d."'")); //leave dates $levNew = count(db_query_select("* FROM `leave_staff` WHERE `staffID` = '".$staffID."' AND `commences` <= '".$new_date."' AND `returns` > '".$new_date."'")); //--------------------------------- MONDAY if($new_day == "Mon" AND $wsdNew_mon == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end MONDAY //--------------------------------- TUESDAY else if($new_day == "Tue" AND $wsdNew_tue == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- WEDNESDAY else if($new_day == "Wed" AND $wsdNew_wed == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- THURSDAY else if($new_day == "Thu" AND $wsdNew_thu == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- FRIDAY else if($new_day == "Fri" AND $wsdNew_fri == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- SATURDAY else if($new_day == "Sat" AND $wsdNew_sat == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //--------------------------------- SUNDAY else if($new_day == "Sun" AND $wsdNew_sun == 1) { //check to see whether any of the 3 options apply if($rdoNew == 1 || $pubNew == 1 || $levNew > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else //descrese loop by one $pre_left = $pre_left - $shift_day; }//end //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end for loop }//end if if($dur_left > 0) { //if duration left is less than than shift hours left for the day //loop through the seven days of the week until you finnd the right date to drop the job /* $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days */ for($i = 0; $i < 7; $i++) { //new date generated if(strlen($wk_m) == 1) $wk_m = "0".$wk_m; if(strlen($wk_d) == 1) $wk_d = "0".$wk_d; $new_date = $wk_y."-".$wk_m."-".$wk_d; //check to see whether staff member works that day of the week $new_day = date("D", mktime(0, 0, 0, $wk_m, $wk_d, $wk_y)); //--------------------------------- MONDAY if($new_day == "Mon" AND staffWorkOnDay($staffID, 1) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- TUESDAY else if($new_day == "Tue" AND staffWorkOnDay($staffID, 2) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- WEDNESDAY else if($new_day == "Wed" AND staffWorkOnDay($staffID, 3) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- THURSDAY else if($new_day == "Thu" AND staffWorkOnDay($staffID, 4) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- FRIDAY else if($new_day == "Fri" AND staffWorkOnDay($staffID, 5) == 1) { //rdo days //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- SATURDAY else if($new_day == "Sat" AND staffWorkOnDay($staffID, 6) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end //--------------------------------- SUNDAY else if($new_day == "Sun" AND staffWorkOnDay($staffID, 7) == 1) { //check to see whether any of the 3 options apply if(staffRDO($wk_m, $wk_d) == 1 || staffPublicH($wk_m, $wk_d) == 1 || staffLeave($staffID, $new_date) > 0) { $i = $i - 1; $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end if else break; }//end else { //create date the next duration of job should fall in to $wk_d = $wk_d + 1; if($wk_d > $days) { //reset day to start $wk_d = 1; //increase month $wk_m = $wk_m + 1; if($wk_m > 12) { $wk_d = 1; //reset month to start $wk_m = 1; $wk_y = $wk_y + 1; }//end for month }//end if for days }//end else }//end for }//end if for the remaining time //now return the finish date and duration left on that date to be done and the job ID $value = $new_date.":".$dur_left; return $value; //return $value; }//end if //===================================== this caters for duration for that day if the job can be done that day else if($pre_du <= $pre_hrs) { //how may are left then //$pre_left = $pre_du - $pre_hrs; $dur_left = $pre_du; //split week start date of the weeek $wk = explode("-", $startDate); $wk_y = $wk[0]; $wk_m = $wk[1]; $wk_d = $wk[2]; //check how many days in the current month if (("$wk_m" == 4) || ("$wk_m" == 6) || ("$wk_m" == 9) || ("$wk_m" == 11)) { $days = 30; } elseif ("$wk_m" == 2) { if (is_int($wk_y / 4)) { $days = 29; } else { $days = 28; } } else { $days = 31; } //duration of shift per day $shift_day = ((getStaffFinishTime($staffID) + 1) - getStaffStartTime($staffID)) * 100; //required loops to add days, months, year $times = $pre_left / $shift_day; $e_times = explode(".", $times); //now return the finish date and duration left on that date to be done and the job ID $value = $startDate.":".$dur_left; return $value; }//end else }//end function /* =================================================================== Form Routines =================================================================== */ function Form_Draw($newform, $action="index.php", $method="POST") { // expects an array with 3 values. // 1. Form Name // 2. Submit Button Text // 3. Array of fields // >> each field is an array - "description", "name", "type", "value" echo "\n "; $tracker = 0; foreach ($newform[2] as $row) { foreach ($row as $field => $value) { if (!is_array($field)) $row[$field] = (str_replace("\"", """,$value)); } if ($row[1] != "hidden") { $tracker ++; if ($tracker % 2 == 1) $class="class=form1"; else $class="class=form2"; $type = strtolower($row[2]); if ($type == "text") $input = ""; else if ($type == "check") $input = ""; else if ($type == "radio") $input = ""; else if ($type == "select") { $input = "\n";; } else $input = ""; echo "\n"; } else { // draw hidden field echo "\n"; } } echo "
".$newform[0]."
".$row[0]."$input
"; } /* =================================================================== Authentication Validation =================================================================== */ function Authenticate_Validate () { // checks the username and password in the database mentioned below //conver all to small caps //$_POST['username'] = strtolower($_POST['username']); //$_POST['password'] = strtolower($_POST['password']); //trim $_POST['username'] = trim ($_POST['username']); $_POST['password'] = trim ($_POST['password']); if($_POST['username'] == "" AND $_POST['password'] == "") { Authenticate_Showlogin("Fill in your login details"); exit();} $admin=false; if ($_POST['username'] != "") { $handle = DB_Query_Select("* FROM `customers` WHERE `username` = '".addslashes($_POST['username'])."' AND `password` = '".addslashes($_POST['password'])."';"); $results = @ $handle[0]; } else { $_POST['username'] = 'invalid'; } //check whether account is active
if ($results['active'] == 'N') { failure("Your account has been Inactivated. Please contact JHP for assistance."); } if ($results['username'] != $_POST['username']) { // try as admin $handle = DB_Query_Select("* FROM `msg_staff` WHERE `username` = '".($_POST['username'])."' AND `password` = '".addslashes($_POST['password'])."';"); $results = @ $handle[0]; if ($_POST['username'] == $results['username']) { $admin = true; //session_register(username); //session_register(name); //session_register(staffID); $_SESSION['username'] = $_POST['username']; $_SESSION['name'] = $results['name']; $_SESSION['company'] = $results['company']; $_SESSION['accesslevel'] = $results['level']; $_SESSION['staffID'] = $results['staffID']; $_SESSION['admin'] = $results['admin']; $_SESSION['logintime'] = date("g:ia, D jS F", time()); $_COOKIE['username'] = $_POST['username']; //setcookie('username', $_POST['username']); setcookie('jhplumbing', $_POST['username'], time()+31536000); redirect("", " ".$_SESSION['name']." $unreadD [ ?act=logout class=menu>Log Out ] "; //menu option for add staff $staff = ""; $log = ""; $con = ""; if($_SESSION['admin'] == "y") { $staff = " Staff |"; $log = " Log |"; $con = " ?act=settings class=menu>Configurations"; } //
?act=search>
$menubar .= " $staff $log $con
?act=adminjobs&category=o&assign=n&time=n class=menu>Jobs | ?act=events class=menu>Events | ?act=msgtodays class=menu>Messages | Send SMS | Send Email | ?act=search2 class=menu>Search | ?act=statusreport class=menu>Clients | ?act=downloads class=menu>Downloads |
";} // elseif ($_SESSION['accesslevel'] == 10) /* if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === false) {// just use PNG as god intended them. $menubar= "\n?act=>\"New ?act=options> \"Site ?act=logout> \"Log"; ; } else { //its IE... do the stupid work around $menubar="?act= style=\"cursor:pointer;\">
\"New
?act=options style=\"cursor:pointer;\">
\"Site
?act=logout style=\"cursor:pointer;\">
\"Log
"; }*/ //else $menubar = NULL; config_override ("Site Menu Bar", $menubar); } //message menues function msgMenu() { $today = userActualDate(date("Y-m-d", time())); //delete messages 12 months old and all related replies and follow up notes $messages = db_query_select("* FROM `messages` WHERE date <= DATE_SUB('$today', INTERVAL 12 MONTH) AND status='T'"); foreach ($messages as $temp) { mysql_query("DELETE FROM messages WHERE messageID='".$temp['messageID']."'"); //delete related notes mysql_query("DELETE FROM message_note WHERE messageID='".$temp['messageID']."'"); //delete replies mysql_query("DELETE FROM message_reply WHERE messageID='".$temp['messageID']."'"); //delete files $messages2 = db_query_select("* FROM `message_files` WHERE messageID = '".$temp['messageID']."'"); //delete anyfiles that might exist for that message foreach ($messages2 as $temp2) { mysql_query("DELETE FROM message_files WHERE fileID = '".$temp2['fileID']."'"); //delete file from server $file = "messagefiles/".$temp['messageID']."/".$temp2['filename'].""; unlink($file); } //if folder is empty get rid of it $att = count(db_query_select("* FROM `message_files` WHERE messageID = '".$temp['messageID']."'")); $folder = "messagefiles/".$temp['messageID']."/"; if($att == 0) rmdir($folder); } //if(!err) echo("".mysql_error.""); /* $searchqueryt = mysql_query("SELECT * FROM messages WHERE date <= DATE_SUB('$today', INTERVAL 12 MONTH)"); $numRows = mysql_num_rows($searchqueryt); echo("$numRows"); for ($i=0; $i < $numRows; $i++) { $resultt = mysql_fetch_array($searchqueryt); echo("
".$resultt[date]." ".$resultt[from]."

"); } $searchquery77 = mysql_query("SELECT * FROM messages"); $numRows = mysql_num_rows($searchquery77); for ($i=0; $i < $numRows; $i++) { $result = mysql_fetch_array($searchquery77); $day = $result['date']; $curdate = substr("$day", 6, 4); $curdate .= "-"; $curdate .= substr("$day", 3, 2); $curdate .= "-"; $curdate .= substr("$day", 0, 2); mysql_query("UPDATE messages SET date = '$curdate' WHERE messageID = ".$result[messageID].""); // echo("$curdate
"); }//end for*/ //count todays new messages $searchquery = mysql_query("SELECT * FROM messages WHERE date = '$today' AND status= 'N' AND `to` = '".$_SESSION['staffID']."'"); $todaysNo = mysql_num_rows($searchquery); if($todaysNo > 0) $stat = "Todays ($todaysNo)"; else $stat = "Todays ($todaysNo)"; //count yesterdays new messages $searchqueryY = mysql_query("SELECT * FROM messages WHERE date = DATE_SUB('$today', INTERVAL 1 DAY) AND status='N' AND `to` = '".$_SESSION['staffID']."'"); $todaysNoY = mysql_num_rows($searchqueryY); if($todaysNoY > 0) $yest = "Yesterdays ($todaysNoY)"; else $yest = "Yesterdays ($todaysNoY)"; //count all messages new messages $searchquery2 = mysql_query("SELECT * FROM messages WHERE status= 'N' AND `to` = '".$_SESSION['staffID']."'"); $allnewNo = mysql_num_rows($searchquery2); if($allnewNo > 0) $stat2 = "All New ($allnewNo)"; else $stat2 = "All New ($allnewNo)"; //count all read messages $searchquery4 = mysql_query("SELECT * FROM messages WHERE status= 'Y' AND `to` = '".$_SESSION['staffID']."'"); $read = mysql_num_rows($searchquery4); if($read > 0) $stat4 = "Read ($read)"; else $stat4 = "Read ($read)"; //count all done messages $searchquery5 = mysql_query("SELECT * FROM messages WHERE status= 'D' AND `to` = '".$_SESSION['staffID']."'"); $done = mysql_num_rows($searchquery5); if($done > 0) $stat5 = "Done ($done)"; else $stat5 = "Done ($done)"; //count all sent messages $searchqueryS = mysql_query("SELECT * FROM message_sent WHERE `staffID` = '".$_SESSION['staffID']."'"); $sent = mysql_num_rows($searchqueryS); $sent1 = "Sent Items($sent)"; //count all trash can messages $searchquery6 = mysql_query("SELECT * FROM messages WHERE status= 'T' AND `to` = '".$_SESSION['staffID']."'"); $trash = mysql_num_rows($searchquery6); global $difmsg; $difmsg = ""; if($trash > 0) { $stat6 = " Trash Can ($trash)
"; } else $stat6 = "Trash Can ($trash)"; //count all staff members $searchquery7 = mysql_query("SELECT * FROM msg_staff"); $staff2 = mysql_num_rows($searchquery7); if($staff2 > 0) $staff1 = "Staff ($staff2)"; else $staff1 = "Staff ($staff2)"; echo("
Message Menu
Folders
Search Messages
?act=searchmsg>
"); } //process action to be done selected from the pages function chooseAction() { echo" Check All/Uncheck All
"; }//end function for choose action //process action to be done selected from the pages function chooseTrashAction() { echo" Check All/Uncheck All
"; }//end function for choose action //---------------------------------------------------sent function choose action function chooseActionSent() { echo"
"; }//end function for choose action //----------------------------------------------------------------------------Staff Menu function staffMenu() { //count active staff members $searchquery = mysql_query("SELECT * FROM msg_staff WHERE active = 'Y'"); $activeNo = mysql_num_rows($searchquery); if($activeNo > 0) $active = "Active ($activeNo)"; else $active = "Active ($activeNo)"; //count inactive staff members $searchquery2 = mysql_query("SELECT * FROM msg_staff WHERE active = 'N'"); $inactiveNo = mysql_num_rows($searchquery2); if($inactiveNo > 0) $inactive = "Inactive ($inactiveNo)"; else $inactive = "Inactive ($inactiveNo)"; echo("
Staff Menu
"); } //authentic admn functions function Authenticate_admin($level) { if ($level != $_SESSION['admin']) failure("You are not authorized to view this page."); } //-------------------------------- Jobs menu //--------------------------------------------------- Job function choose action function chooseJobAction() { global $difmsg; $difmsg = ""; echo"  Check All/Uncheck All
".btnSubmit("GO")." "; }//end function for choose action //----------------------------------------------------------------------------Staff Menu function jobMenu() { $today = userActualDate(date("Y-m-d", time())); //count todays new jobs that have not been assigned $searchqueryN = mysql_query("SELECT * FROM jobs WHERE timestamp = '$today' AND status = 'o' AND assign = 'n'"); $jobsNew = mysql_num_rows($searchqueryN); if($jobsNew > 0) $jobNew = "Todays New ($jobsNew)"; else $jobNew = "Todays New ($jobsNew)"; //count all other jobs that are unscheduled $searchqueryUS = mysql_query("SELECT * FROM pending_schedules WHERE done = 'n'"); $jobsUS = mysql_num_rows($searchqueryUS); if($jobsUS > 0) $jobUS = "Unscheduled ($jobsUS)"; else $jobUS = "Unscheduled ($jobsUS)"; //count all scheduled jobs $cc = mysql_query("SELECT * FROM jobs_workers jw, jobs j WHERE jw.jobID = j.id AND j.status = 'o' AND j.assign = 'y'"); $numRows = mysql_num_rows($cc); if($numRows > 0) $sj = "Scheduled Jobs ($numRows)"; else $sj = "Scheduled Jobs ($numRows)"; //count all other jobs that are unassigned $searchqueryU = mysql_query("SELECT * FROM jobs WHERE status = 'o' AND assign = 'n'"); $jobsU = mysql_num_rows($searchqueryU); if($jobsU > 0) $jobU = "Unassigned ($jobsU)"; else $jobU = "Unassigned ($jobsU)"; //jobs that need to be reassigned $searchqueryR = mysql_query("SELECT * FROM jobs WHERE status = 'r'"); $jobsRea = mysql_num_rows($searchqueryR); if($jobsRea > 0) $jobRea = "Re-Assign ($jobsRea)"; else $jobRea = "Re-Assign ($jobsRea)"; //count all jobs $searchquery = mysql_query("SELECT * FROM jobs WHERE status != 'c' AND `status` != 'q'"); $jobsNo = mysql_num_rows($searchquery); if($jobsNo > 0) $job1 = "All ($jobsNo)"; else $job1 = "All ($jobsNo)"; //count all left a note jobs $searchquery2 = mysql_query("SELECT * FROM jobs WHERE status = 't'"); $jobsNo2 = mysql_num_rows($searchquery2); if($jobsNo2 > 0) $job2 = "Left a Note ($jobsNo2)"; else $job2 = "Left a Note ($jobsNo2)"; //count all complete jobs $searchquery3 = mysql_query("SELECT * FROM jobs WHERE status = 'c'"); $jobsNo3 = mysql_num_rows($searchquery3); if($jobsNo3 > 0) $job3 = "Complete ($jobsNo3)"; else $job3 = "Complete ($jobsNo3)"; //count all follouw up jobs $searchquery4 = mysql_query("SELECT * FROM jobs WHERE status = 'a'"); $jobsNo4 = mysql_num_rows($searchquery4); $job4 = "Follow-up ($jobsNo4)"; //count all unreachable jobs $searchquery5 = mysql_query("SELECT * FROM jobs WHERE status = 'u'"); $jobsNo5 = mysql_num_rows($searchquery5); $job5 = "Unreachable ($jobsNo5)"; //count all left a message jobs $searchquery6 = mysql_query("SELECT * FROM jobs WHERE status = 'l'"); $jobsNo6 = mysql_num_rows($searchquery6); $job6 = "Left a Message ($jobsNo6)"; //count all Active Jobs $searchquery7 = mysql_query("SELECT * FROM jobs WHERE status = 'o' AND assign = 'y'"); $jobsNo7 = mysql_num_rows($searchquery7); if($jobsNo7 > 0) $job7 = "Assigned ($jobsNo7)"; else $job7 = "Assigned ($jobsNo7)"; //count all to be invoiced jobs $searchqueryI = mysql_query("SELECT * FROM jobs WHERE status = 'i'"); $jobsNoI = mysql_num_rows($searchqueryI); if($jobsNoI > 0) $jobI = "To be invoiced ($jobsNoI)"; else $jobI = "To be invoiced ($jobsNoI)"; //count all quote only jobs $searchquery8 = mysql_query("SELECT * FROM jobs WHERE status = 'q'"); $jobsNo8 = mysql_num_rows($searchquery8); if($jobsNo8 > 0) $job8 = "Quotes Only ($jobsNo8)"; else $job8 = "Quotes Only ($jobsNo8)"; global $difmsg; $difmsg = ""; //
//
echo("
Jobs Menu
Job Folders
Search Jobs

"); } //---------------------------------------------------------------------------- Client Menu function clientMenu() { //count active clients $searchquery = mysql_query("SELECT * FROM customers WHERE active = 'Y'"); $activeNo = mysql_num_rows($searchquery); if($activeNo > 0) $active = "Active ($activeNo)"; else $active = "Active ($activeNo)"; //count inactive clients $searchquery2 = mysql_query("SELECT * FROM customers WHERE active = 'N'"); $inactiveNo = mysql_num_rows($searchquery2); if($inactiveNo > 0) $inactive = "Inactive ($inactiveNo)"; else $inactive = "Inactive ($inactiveNo)"; global $difmsg; $difmsg = ""; echo("
Client Menu
"); } //customer menu //----------------------------------------------------------------------------Client Menu function customerMenu() { //count all wip in progress jobs $searchquery4 = mysql_query("SELECT * FROM jobs WHERE status != 'c' AND status != 'i' AND status != 'q' AND `username` = '".addslashes($_SESSION['customerID'])."' AND `internal` = 'n'"); $jobsNo4 = mysql_num_rows($searchquery4); $job1 = "Work In Progess ($jobsNo4)"; //count all to be invoiced job $searchquery5 = mysql_query("SELECT * FROM jobs WHERE status= 'i' AND `username` = '".addslashes($_SESSION['customerID'])."' AND `internal` = 'n'"); $jobsNo5 = mysql_num_rows($searchquery5); $job2 = "Invoice Pending ($jobsNo5)"; //count all complete jobs $searchquery3 = mysql_query("SELECT * FROM jobs WHERE status= 'c' AND `username` = '".addslashes($_SESSION['customerID'])."' AND `internal` = 'n'"); $jobsNo3 = mysql_num_rows($searchquery3); if($jobsNo3 > 0) $job3 = "Complete ($jobsNo3)"; else $job3 = "Complete ($jobsNo3)"; //count all quote only jobs $searchquery8 = mysql_query("SELECT * FROM jobs WHERE status= 'q' AND `username` = '".addslashes($_SESSION['customerID'])."' AND `internal` = 'n'"); $jobsNo8 = mysql_num_rows($searchquery8); $job4 = "Quote Only ($jobsNo8)"; //count all staff users $searchquery9 = mysql_query("SELECT * FROM `staff` WHERE `company` = '".addslashes($_SESSION['customerID'])."'"); $users = mysql_num_rows($searchquery9); $staff9 = "Staff Members ($users)"; global $difmsg; $difmsg = ""; echo("
".$_SESSION['company']."

Customer Options

Job Log Folders


Search Jobs
?act=searchcusmsg>
"); } //---------------------------------------------------------------------------- Configurations menu function configurationsMenu() { $difmsg = "Website configurations & adjustments and made here."; echo("
Configurations Menu
"); } //---------------------------------------------------------------------------- LOG MENU function logMenu() { echo("
Log Menu
"); } /* =================================================================== PayPal fee calculator =================================================================== */ //format number to decimal places function formatNumber($no) { $n = explode(".", $no); if(strlen($n[1]) == 1) $n[1] = $n[1]."0"; else if(strlen($n[1]) == 0) $n[1] = "00"; return $n[0].".".$n[1]; }//end function function paypalFee($amount, $currency) { $constant = 0.30; if($currency == "au") //if australia { // if($amount > 0 && $amount <= 5000) $rate = 0.024; // else if($amount > 5000 && $amount <= 15000) $rate = 0.02; // else if($amount > 15000 && $amount <= 150000) $rate = 0.015; // else if($amount > 150000) $rate = 0.011; // else $rate = 0.024; // Rate is now a flat 3%. $rate = 0.03; } $fee = ($amount * $rate) + $constant; $fee = round($fee, 2); $total = round(($amount + $fee), 2); //echo $total; die(); return formatNumber($total).":".formatNumber($fee); }//end function // END OF FILE ?>