<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
$_SESSION['cuPages']='blank_page.php';   
$cuPage='blank_page.php';    
$aid=$_SESSION['uid'];
$uty=$_SESSION['utype'];    
$brid=$_SESSION['abrid'];     
}else{
header('Location:../index.php');
exit;    
}
$mhead='personal';
$menuh='Personal';
$phead='note';
$page='Personal Note';
$pcss='note';
$dtnow = date("Y-m-d h:i:s", time());
$today = strftime("%Y-%m-%d", time());
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>
<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">
<div class="app-note-container">

<div class="app-note-overlay"></div>

<div class="tab-title">
<div class="row">
<div class="col-md-12 col-sm-12 col-12 text-center">
<a id="btn-add-notes" class="btn btn-primary" href="javascript:void(0);">Add</a>
</div>
<div class="col-md-12 col-sm-12 col-12 mt-5">
<ul class="nav nav-pills d-block" id="pills-tab3" role="tablist">
<li class="nav-item">
<a class="nav-link list-actions active" id="all-notes"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg> All Notes</a>
</li>
<li class="nav-item">
<a class="nav-link list-actions" id="note-fav"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg> Favourites</a>
</li>
</ul>

<hr/>

<p class="group-section"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg> Tags</p>

<ul class="nav nav-pills d-block group-list" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link list-actions g-dot-primary" id="note-personal">Personal</a>
</li>
<li class="nav-item">
<a class="nav-link list-actions g-dot-warning" id="note-work">Work</a>
</li>
<li class="nav-item">
<a class="nav-link list-actions g-dot-success" id="note-social">Social</a>
</li>
<li class="nav-item">
<a class="nav-link list-actions g-dot-danger" id="note-important">Important</a>
</li>
</ul>
</div>
</div>
</div>


<div id="ct" class="note-container note-grid">

</div>

</div>

<!-- Modal -->
<div class="modal fade" id="notesMailModal" tabindex="-1" role="dialog" aria-labelledby="notesMailModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x close" data-dismiss="modal"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<div class="notes-box">
<div class="notes-content">                                                                        

<div class="row">
<div class="col-md-12">
<div class="d-flex note-title">
<input type="text" id="n-title" name="title" class="form-control" maxlength="35" placeholder="Title">
</div>
<span class="validation-text"></span>
</div>
<br><br><br>   
<div class="col-md-12">
<div class="d-flex note-description">
<textarea id="n-description" name="note" class="form-control" maxlength="250" placeholder="Description" rows="3"></textarea>
</div>
<span class="validation-text"></span>
</div>
</div>

</div>
</div>
</div>
<div class="modal-footer">
<button id="btn-n-save" class="float-left btn">Save</button>
<button class="btn" data-dismiss="modal"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg> Discard</button>
<button id="btn-n-add" class="btn">Add</button>
</div>
</div>
</div>
</div>    
    
<?php include('../layout/quick.php');?>    
</section>
<!-- /.main content -->    
</div>
<?php
include('../layout/footer.php');
?>
<!-- page script -->
<script type="text/javascript">
ReadItem();    
function ReadItem() {
$.ajax({
url: "axe_ncart.php",
method: "POST",
data:{note:1},    
success: function(data) {
$('#ct').html(data);   
}
})
}
    

function deleteNote() {
$(".delete-note").off('click').on('click', function(event) {
event.stopPropagation();
id_arr = $(this).attr('id');
id = id_arr.split("_");
var ids=id[1];
$.ajax({
url: "axe_ncart.php",
method: "POST",
data:{delnt:1, ids: ids},
dataType: 'json',    
success: function(data) {
if(data.status === "success"){
ReadItem();
toastr.success(data.message);        
}else{
toastr.error(data.message);      
}    
}
})
})
}

function favNote() {
$(".fav-note").off('click').on('click', function(event) {
event.stopPropagation();
id_arr = $(this).attr('id');
id = id_arr.split("_");
var ids=id[1];
$.ajax({
url: "axe_ncart.php",
method: "POST",
data:{upfav:1, ids: ids},
dataType: 'json',    
success: function(data) {
if(data.status === "success"){
ReadItem();    
}else{    
}    
}
})    
})
}

function addLabelGroups() {
$('.tags-selector .label-group-item').off('click').on('click', function(event) {
event.preventDefault();
/* Act on the event */
id_arr = $(this).attr('id');
id = id_arr.split("_");
var ids=id[1];    
var typ=0;    
var getclass = this.className;
var getSplitclass = getclass.split(' ')[0];
if ($(this).hasClass('label-personal')) {
typ=1;
} else if ($(this).hasClass('label-work')) {
typ=2;
} else if ($(this).hasClass('label-social')) {
typ=3;
} else if ($(this).hasClass('label-important')) {
typ=4;
}
$.ajax({
url: "axe_ncart.php",
method: "POST",
data:{uplab:1, ids: ids, typ: typ},
dataType: 'json',    
success: function(data) {
if(data.status === "success"){
ReadItem();    
}else{    
}    
}
})    
});
}

$('.hamburger').on('click', function(event) {
$('.app-note-container').find('.tab-title').toggleClass('note-menu-show')
$('.app-note-container').find('.app-note-overlay').toggleClass('app-note-overlay-show')
})
$('.app-note-overlay').on('click', function(e){
$(this).parents('.app-note-container').children('.tab-title').removeClass('note-menu-show')
$(this).removeClass('app-note-overlay-show')
})
$('.tab-title .nav-pills a.nav-link').on('click', function(event) {
$(this).parents('.app-note-container').find('.tab-title').removeClass('note-menu-show')
$(this).parents('.app-note-container').find('.app-note-overlay').removeClass('app-note-overlay-show')
})

var $btns = $('.list-actions').click(function() {
if (this.id == 'all-notes') {
var $el = $('.' + this.id).fadeIn();
$('#ct > div').not($el).hide();
} if (this.id == 'important') {
var $el = $('.' + this.id).fadeIn();
$('#ct > div').not($el).hide();
} else {
var $el = $('.' + this.id).fadeIn();
$('#ct > div').not($el).hide();
}
$btns.removeClass('active');
$(this).addClass('active');  
})

$('#btn-add-notes').on('click', function(event) {
$('#notesMailModal').modal('show');
$('#btn-n-save').hide();
$('#btn-n-add').show();
})

// Button add
$("#btn-n-add").on('click', function(event) {
event.preventDefault();
/* Act on the event */
var title=$('#n-title').val();
var note=$('#n-description').val();
        
if(title.length <2 ){
Snackbar.show({
text: "Title can't empty!!!",
actionTextColor: '#fff',
backgroundColor: '#e2a03f',    
pos: 'top-center'
});
return;    
}
        
if(note.length <2 ){
toastr.info("Description can't empty!!!");     
return;    
}
        
$.ajax({
url: "axe_ncart.php",
method: "POST",
data:{savent:1, title: title, note:note},
dataType: 'json',    
success: function(data) {
if(data.status === "success"){
ReadItem();
toastr.success(data.message);    
}else{
toastr.error(data.message);    
}    
}
})    
$('#notesMailModal').modal('hide');
});

$('#notesMailModal').on('hidden.bs.modal', function (event) {
event.preventDefault();
document.getElementById('n-title').value = '';
document.getElementById('n-description').value = '';
})   
</script>    
<!-- /page script -->
</html>    