/
var
/
www
/
barefootlaw.org
/
bios2
/
manager
/
Upload File
HOME
<?php require_once('../Connections/fleetMan.php'); ?> <?php require_once("functions.php"); $api = new fleet(); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; if(isset($_SESSION['MM_UserGroup']) && !isset($access)) { $access = array(); foreach($_SESSION['MM_UserGroup'] as $item) { $access[] = $item['permission']; } } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "signin.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "signin.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php mysql_select_db($database_fleetMan, $fleetMan); $data = $api->message_log($_GET['id']); $data2 = array(); foreach($data as $item) { $data2[substr($item['date'],0,10)][] = $item; } $data = $data2; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!--<link rel="shortcut icon" href="../images/favicon.png" type="image/png">--> <title>Conversation Timeline</title> <link rel="stylesheet" href="../lib/fontawesome/css/font-awesome.css"> <link rel="stylesheet" href="../lib/weather-icons/css/weather-icons.css"> <link rel="stylesheet" href="../lib/jquery-toggles/toggles-full.css"> <link rel="stylesheet" href="../css/quirk.css"> <script src="../lib/modernizr/modernizr.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="../lib/html5shiv/html5shiv.js"></script> <script src="../lib/respond/respond.src.js"></script> <![endif]--> </head> <body> <section><!-- leftpanel --> <div class="contentpanel"> <span><strong>Conversation between <?php echo $api->get_record("bios_user","concat(fname,' ',lname)","where id = '".$_GET['id']."'"); ?> and BarefootLaw</strong></span> <hr class="darken"> <div id="log"> <?php $keys = array_keys($data); foreach($keys as $item) { if($data[$item] == null) { continue; } ?> <div class="row"> <div class="col-sm-8 col-md-9 col-lg-10"> <div class="timeline-wrapper"> <div class="timeline-date"><?php echo date("l, F j, Y", strtotime($item)); ?></div> <?php foreach($data[$item] as $message) { ?> <div class="panel panel-post-item status"> <div class="panel-heading"> Posted by <?php echo substr($message['message_source'],0,strlen('user-')) == 'user-' ? 'User' : $api->get_record("bios_sys_user","name","where id = '".$message['who_posted']."'"); ?> Date: <a href=""><?php echo date("g:ia", strtotime($message['date'])); ?></a> <?php if(substr($message['message_source'],0,5) == "user-") { ?> <p>Category: <select id="cat<?php echo $message['message_id'] ?>" onChange="set_issue_cat('<?php echo $message['message_id'] ?>', this.value)"> <option value="">Please select category:</option> <?php $list = $api->get_records("bios_category",array("id","short_name","long_name","parent_id"),"where _status = '1'"); foreach($list as $as) { ?> <option value="<?php echo $as['id'] ?>" <?php echo $message['category'] == $as['id'] ? "selected" : ""; ?>><?php echo $as['short_name'].(trim($as['parent_id']) == "" ? "" : " - ".$as['short_name']); ?></option> <?php } ?> </select></p> <?php } ?> </div><!-- panel-heading --> <div class="panel-body"> <?php echo $message['message']; ?> </div> <div class="panel-footer"> <ul class="list-inline"> <li>Message Source: <?php echo strtoupper($message['channel']); ?> - <?php echo $message['recipient']; ?></li> </ul> </div> </div> <!-- panel panel-post --><!-- panel panel-post --><!-- panel panel-post --><!-- panel panel-post --><!-- panel panel-post --> <?php } ?> <!-- panel panel-post --> </div><!-- timeline-wrapper --> </div> </div> <?php } ?> </div> <!-- row --> <a name="user_response"></a> <div class="timeline-date" align="center"><strong>New Message</strong></div> <div class="form-group" align="center"> <textarea class="form-control" placeholder="Write response here:" name="user_response" id="user_response" style="height:100px;width:50%"></textarea> <br><br> <input type="file" name="response_upload" id="response_upload" /> <input name="uploaded_file_name" id="uploaded_file_name" type="hidden" value=""> <br><br> <select id="send_via" style="height: 40px"> <option value="">Auto Select</option> <option value="sms">Send via SMS</option> <option value="barefootlaw_fb_page" selected="true">Send via BarefootLaw Page</option> <option value="msmegarage_fb_page">Send via mSME Garage Page</option> <option value="ask@barefootlaw.org">Send via ask@barefootlaw</option> <option value="admin@msmegarage.com">Send via admin@msmegarage</option> </select> <button class="btn btn-info" type="button" name="send_msg" id="send_msg" onclick="send_msg()">Send Message</button> </div> </div> </section> <script src="../lib/jquery/jquery.js"></script> <script src="../lib/jquery-ui/jquery-ui.js"></script> <script src="../lib/bootstrap/js/bootstrap.js"></script> <script src="../lib/jquery-toggles/toggles.js"></script> <script src="../js/quirk.js"></script> <script type="text/javascript"> //Document Ready $(document).ready(function(){ location.hash = "#user_response"; $('input[type=file]').on('change', upload_attachment); }); function upload_attachment(event=null) { if(event != null) { var data = new FormData(); var files = event.target.files; if(files[0].size <= <?php echo preg_replace("/^[0-9]/","",ini_get('upload_max_filesize'))*1024*1024; ?>) { $("#send_msg").html("Uploading File "+files[0].name); $("#send_msg").attr("disabled","disabled"); data.append("bios_attachment", files[0], "bios_attachment_"+files[0].name); var xhr = new XMLHttpRequest(); xhr.open('POST', '../json_api.php', true); xhr.send(data); xhr.onload = function () { if (xhr.status === 200) { alert("File has succesfully been uploaded."); $("#uploaded_file_name").val(xhr.response); $("#send_msg").html("Send Message"); $("#send_msg").removeAttr("disabled","disabled"); //$("#uploaded_file").html("<a href=\"../uploads/tc_report_<?php echo $_GET['id']; ?>_"+files[0].name+"\" target=\"_blank\"><strong>tc_report_<?php echo $_GET['id']; ?>_"+files[0].name+"</strong></a>"); } else { alert("File upload error."); } } } else { alert("File size is too big."); } } } function set_issue_cat(message_id, category) { var a = confirm("Please note that all uncategorized messages that were sent\nafter this message will be set to the selected category. You can optionally go and categorize individual messages accordingly."); if(a) { $.getJSON( "../json_api.php?action=categorize_message&message_id="+message_id+"&category="+category, function( data ) { if(data.status == 1) { alert(data.message); } else { $("#cat"+message_id).val(""); alert(data.message); } }); } else { //Set Value to Default $("#cat"+message_id).val(""); } } function send_msg() { $("#send_msg").html("Please wait . . ."); $("#send_msg").attr("disabled","disabled"); console.log($("#uploaded_file_name").val()+" Checking.\n"); $.getJSON( "../json_api.php?action=user_response&user=<?php echo $_GET['id'] ?>&response="+$("#user_response").val()+"&file_name="+$("#uploaded_file_name").val()+"&channel="+$("#send_via").val(), function( data ) { if(data.status == 1) { $("#user_response").val(""); $("#response_upload").val(""); message_log(); } else { alert("Post was unsuccesful. Please try again later."); } $("#send_msg").html("Send Message"); $("#send_msg").removeAttr("disabled","disabled"); }); } function message_log() { $.getJSON( "../json_api.php?action=user_log&user=<?php echo $_GET['id'] ?>&max_time=<?php echo date("Y-m-d H:i:s"); ?>", function( data ) { if(data.length > 0) { for (var i = data.length - 1; i >= 0; i--) { if(data[i].message_id != null) { $("#log").prepend('<div class="row"><div class="col-sm-8 col-md-9 col-lg-10"><div class="timeline-wrapper"><div class="timeline-date">{date}</div><div class="panel panel-post-item status"><div class="panel-heading">Posted by {who_posted} | Date: {when_posted}</a></div><!-- panel-heading --><div class="panel-body">{message}</div><div class="panel-footer"><ul class="list-inline"><li><a href="">Category: {category}</a> | {agent_assigned}</li></ul></div></div></div></div></div>'); } } } }); } </script> </body> </html>