Skip to content

Commit

Permalink
Modified: Chat engine with Log
Browse files Browse the repository at this point in the history
Modified: Default template
Modified: Less file
  • Loading branch information
mucill committed Sep 20, 2015
1 parent a4953e4 commit a5f10b0
Show file tree
Hide file tree
Showing 19 changed files with 2,760 additions and 229 deletions.
13 changes: 9 additions & 4 deletions admin/admin_template/default/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "bootstrap.min.css";
@import "bootstrap.min.css";
@import "font-awesome.min.css";
@import "animate.css";
@font-face {
Expand Down Expand Up @@ -234,7 +234,9 @@ a:hover {
font-size: 10px;
}
/*----------------*/

/* User Account */

/*----------------*/

.s-header {
Expand Down Expand Up @@ -358,7 +360,9 @@ a:hover {
}
}
/*-----------*/

/* Content */

/*-----------*/

.s-content.active,
Expand Down Expand Up @@ -1365,6 +1369,7 @@ tr.dataListHeader > td > a {
padding: 15px;
margin: 15px 10px;
}

.errorBox:before,
.message:before {
font-family: 'FontAwesome';
Expand All @@ -1379,6 +1384,7 @@ tr.dataListHeader > td > a {
overflow: hidden;
color: rgba(255, 255, 255, 0.25);
}

.message ul {
list-style: none;
padding: 0;
Expand Down Expand Up @@ -2205,7 +2211,6 @@ table {

/* Chat
================================ */

#pchat-toggle {
background-color: #fff;
border-radius: 50px;
Expand Down Expand Up @@ -2325,7 +2330,7 @@ table {
}

.s-minimize {
bottom: -355px;
bottom: -379px;
-webkit-transition: all 150ms ease;
transition: all 150ms ease;
}
Expand All @@ -2334,4 +2339,4 @@ table {
bottom: 0px;
-webkit-transition: all 150ms ease;
transition: all 150ms ease;
}
}
72 changes: 2 additions & 70 deletions admin/admin_template/default/index_template.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/**
* Template for Backend
*
* Copyright (C) 2015 Arie Nugraha ([email protected])
* Create by Eddy Subratha ([email protected])
* Copyright (C) 2015 Arie Nugraha ([email protected]), Eddy Subratha ([email protected])
*
* Slims 8 (Akasia)
*
Expand Down Expand Up @@ -121,73 +120,6 @@
</footer>
</main>

<?php
// Chat
// =============================================
if($sysconf['chat_system']['enabled'] && $sysconf['chat_system']['librarian']) : ?>
<aside class="s-chat s-maximize">
<a href="#" id="pchat-hide" class="s-chat-header"><?php echo __('Chat With Members'); ?></a>
<div class="s-chat-content">
<div id="log"></div>
<label for="message">Message</label>
<input type="text" id="message" name="message" />
</div>
<footer><?php echo __('Please type and hit Enter button to send your messages'); ?></footer>
</aside>

<script>
var Server;
function log( text ) {
$log = $('#log');
//Add text to log
$log.append(($log.html()?'<br>':'') + text);
//Autoscroll
$log[0].scrollTop = $log[0].scrollHeight - $log[0].clientHeight;
}

function send( text ) {
Server.send( 'message', text );
}

$(document).ready(function() {
log('Connecting...');
Server = new FancyWebSocket('ws://<?php echo $sysconf['chat_system']['server'] ?>:<?php echo $sysconf['chat_system']['server_port'] ?>');
$('#message').keypress(function(e) {
if ( e.keyCode == 13 && this.value ) {
log( 'You: ' + this.value );
send( '<?php echo $_SESSION["realname"]?>|'+this.value);
$(this).val('');
}
});

//Let the user know we're connected
Server.bind('open', function() {
log( "Connected." );
});

//OH NOES! Disconnection occurred.
Server.bind('close', function( data ) {
log( "Disconnected." );
});

//Log any messages sent from server
Server.bind('message', function( payload ) {
log( payload );
});

Server.connect();
});

// Show or hide chat
// ============================================
$('.s-chat').toggleClass('s-minimize s-maximize');
$('#pchat-hide').on('click', function(){
$('.s-chat').toggleClass('s-minimize s-maximize ');
});

</script>
<?php endif; ?>

<!-- fake submit iframe for search form, DONT REMOVE THIS! -->
<iframe name="blindSubmit" style="visibility: hidden; width: 0; height: 0;"></iframe>
<!-- fake submit iframe -->
Expand Down Expand Up @@ -260,6 +192,6 @@ function send( text ) {
);
});
</script>
<?php if (isset($chat)) { echo $chat; } ?>
<?php include "chat.php" ?>
</body>
</html>
76 changes: 76 additions & 0 deletions admin/chat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
// Chat
// =============================================
if($sysconf['chat_system']['enabled'] && $sysconf['chat_system']['librarian']) : ?>
<aside class="s-chat s-maximize">
<a href="#" id="hide-pchat" class="s-chat-header"><?php echo __('Chat With Members'); ?></a>
<div class="s-chat-content">
<div id="log"></div>
<label for="message">Message</label>
<input type="text" id="message" name="message" />
</div>
<footer>
<p>
<?php echo __('Please type and hit Enter button to send your messages'); ?><br>
[M] <?php echo __('Members') ?> - [L] <?php echo __('Librarian') ?>
</p>
</footer>
</aside>

<script>
var Server;
function log( text ) {
$log = $('#log');
//Add text to log
$log.append(($log.html()?'<br>':'') + text);
//Autoscroll
$log[0].scrollTop = $log[0].scrollHeight - $log[0].clientHeight;
}

function send( text ) {
Server.send( 'message', text );
}

$(document).ready(function() {
log('Connecting...');
Server = new FancyWebSocket('ws://<?php echo $sysconf['chat_system']['server'] ?>:<?php echo $sysconf['chat_system']['server_port'] ?>?u=<?php echo $_SESSION["realname"] ?>');
$('#message').keypress(function(e) {
if ( e.keyCode == 13 && this.value ) {
log( 'You: ' + this.value );
send( '[L] <?php echo $_SESSION["realname"]?>|'+this.value);
$.ajax({
type: 'POST',
url: '../index.php?p=chat',
data: {msg: '<?php echo date("Y.m.d H:i:s") ?> [L] <?php echo $_SESSION["realname"] ?> - ' + this.value}
});
$(this).val('');
}
});

//Let the user know we're connected
Server.bind('open', function() {
log( "Connected." );
});

//OH NOES! Disconnection occurred.
Server.bind('close', function( data ) {
log( "Disconnected." );
});

//Log any messages sent from server
Server.bind('message', function( payload ) {
log( payload );
});

Server.connect();
});

// Show or hide chat
// ============================================
$('.s-chat').toggleClass('s-minimize s-maximize');
$('#hide-pchat').on('click', function(){
$('.s-chat').toggleClass('s-minimize s-maximize ');
});

</script>
<?php endif; ?>
66 changes: 43 additions & 23 deletions admin/default/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
?>
<fieldset class="menuBox adminHome">
<div class="menuBoxInner">
<div class="per_title">
<h2><?php echo __('Library Administration'); ?></h2>
</div>
<div class="per_title">
<h2><?php echo __('Library Administration'); ?></h2>
</div>
</div>
</fieldset>
<?php
Expand Down Expand Up @@ -79,10 +79,11 @@


// check need to be repaired mysql database
$query_of_tables = $dbs->query('SHOW TABLES');
$num_of_tables = $query_of_tables->num_rows;
$prevtable = '';
$is_repaired = false;
$query_of_tables = $dbs->query('SHOW TABLES');
$num_of_tables = $query_of_tables->num_rows;
$prevtable = '';
$repair = '';
$is_repaired = false;

if (isset ($_POST['do_repair'])) {
if ($_POST['do_repair'] == 1) {
Expand All @@ -98,27 +99,35 @@
while ($rowcheck = $query_of_check->fetch_assoc()) {
if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) {
if ($row[0] != $prevtable) {
echo '<li class="warning">Table '.$row[0].' might need to be repaired.</li>';
$repair .= '<li>Table '.$row[0].' might need to be repaired.</li>';
}
$prevtable = $row[0];
$is_repaired = true;
}
}
}
if (($is_repaired) && !isset($_POST['do_repair'])) {
echo '<li class="warning"><form method="POST"><input type="hidden" name="do_repair" value="1"><input value="Repaire Tables" type="submit"></form></li>';
echo '<div class="message">';
echo '<ul>';
echo $repair;
echo '</ul>';
echo '</div>';
echo ' <form method="POST" style="margin:0 10px;">
<input type="hidden" name="do_repair" value="1">
<input type="submit" value="'.__('Click Here To Repaire The Tables').'" class="button btn btn-block btn-default">
</form>';
}
echo '<div class="message">';
echo '<ul>';

// if there any warnings
if ($warnings) {
echo '<div class="message">';
echo '<ul>';
foreach ($warnings as $warning_msg) {
echo '<li class="warning">'.$warning_msg.'</li>';
echo '<li>'.$warning_msg.'</li>';
}
echo '</ul>';
echo '</div>';
}
echo '</ul>';
echo '</div>';

// admin page content
if($sysconf['admin_home']['mode'] == 'default') {
Expand Down Expand Up @@ -171,9 +180,13 @@
GROUP BY
loan_date";

$set_loan = $dbs->query($sql_loan);
$transc_loan = $set_loan->fetch_object();
$get_loan .= $transc_loan->countloan.',';
$set_loan = $dbs->query($sql_loan);
if($set_loan->num_rows > 0) {
$transc_loan = $set_loan->fetch_object();
$get_loan .= $transc_loan->countloan.',';
} else {
$get_loan = 0;
}

// get latest return
$sql_return =
Expand All @@ -190,8 +203,12 @@
loan_date";

$set_return = $dbs->query($sql_return);
$transc_return = $set_return->fetch_object();
$get_return .= $transc_return->countloan.',';
if($set_return->num_rows > 0) {
$transc_return = $set_return->fetch_object();
$get_return .= $transc_return->countloan.',';
} else {
$get_return = 0;
}

// get latest extends
$sql_extends =
Expand All @@ -205,10 +222,13 @@
AND renewed = 1
GROUP BY
loan_date";

$set_extends = $dbs->query($sql_extends);
$transc_extends = $set_extends->fetch_object();
$get_extends .= $transc_extends->countloan.',';
$set_extends = $dbs->query($sql_extends);
if($set_extends->num_rows > 0) {
$transc_extends = $set_extends->fetch_object();
$get_extends .= $transc_extends->countloan.',';
} else {
$get_extends = 0;
}
}
// return transaction date
$get_date = substr($get_date,0,-1);
Expand Down
22 changes: 3 additions & 19 deletions admin/modules/bibliography/dl_print.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,10 @@
$html_str .= '<div class="labelStyle" valign="top">';
if ($sysconf['print']['label']['include_header_text']) { $html_str .= '<div class="labelHeaderStyle">'.($sysconf['print']['label']['header_text']?$sysconf['print']['label']['header_text']:$sysconf['library_name']).'</div>'; }
// explode label data by space
$sliced_label = explode(' ', $label);
//Modified By Eddy Subratha
//Need to check of the classification is has another space between each number
//Ex. 123 123 12 SIL m
if(count($sliced_label) > 4) {
$html_str .= $sliced_label[0].' '.$sliced_label[1].' '.$sliced_label[2].'<br/>';
$html_str .= $sliced_label[3].'<br/>';
$html_str .= $sliced_label[4].'<br/>';
$html_str .= $sliced_label[5];
} elseif(count($sliced_label) > 3) {
$html_str .= $sliced_label[0].' '.$sliced_label[1].'<br/>';
$html_str .= $sliced_label[2].'<br/>';
$html_str .= $sliced_label[3].'<br/>';
$html_str .= $sliced_label[4];
} else {
foreach ($sliced_label as $slice_label_item) {
$html_str .= $slice_label_item.'<br />';
}
$sliced_label = explode(' ', $label, 5);
foreach ($sliced_label as $slice_label_item) {
$html_str .= $slice_label_item.'<br />';
}
//End modified
$html_str .= '</div>';
$html_str .= '</td>';
}
Expand Down
Loading

0 comments on commit a5f10b0

Please sign in to comment.