mirror of https://github.com/itflow-org/itflow
Changed notes to documents DB Structure updated
This commit is contained in:
parent
4fec4dd36b
commit
6aebe260f5
|
|
@ -1,8 +1,8 @@
|
|||
<div class="modal" id="addNoteModal" tabindex="-1">
|
||||
<div class="modal" id="addDocumentModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header text-white">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-edit mr-2"></i>New Note</h5>
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-file-alt mr-2"></i>New Document</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
|
@ -11,15 +11,15 @@
|
|||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="subject" placeholder="Title" required autofocus>
|
||||
<input type="text" class="form-control" name="name" placeholder="Name" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<textarea class="form-control summernote" name="note" id="addClientNote"></textarea>
|
||||
<textarea class="form-control summernote" name="details"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_note" class="btn btn-primary">Save</button>
|
||||
<button type="submit" name="add_document" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -100,8 +100,8 @@ if(isset($_GET['client_id'])){
|
|||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('file_id') AS num FROM files WHERE client_id = $client_id"));
|
||||
$num_files = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('note_id') AS num FROM notes WHERE client_id = $client_id"));
|
||||
$num_notes = $row['num'];
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('document_id') AS num FROM documents WHERE client_id = $client_id"));
|
||||
$num_documents = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('event_id') AS num FROM events WHERE client_id = $client_id"));
|
||||
$num_events = $row['num'];
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if(isset($_GET['q'])){
|
|||
if(!empty($_GET['sb'])){
|
||||
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
|
||||
}else{
|
||||
$sb = "note_subject";
|
||||
$sb = "document_name";
|
||||
}
|
||||
|
||||
if(isset($_GET['o'])){
|
||||
|
|
@ -40,10 +40,10 @@ if(isset($_GET['o'])){
|
|||
$disp = "DESC";
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM notes
|
||||
WHERE notes.client_id = $client_id
|
||||
AND notes.company_id = $session_company_id
|
||||
AND (note_subject LIKE '%$q%')
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM documents
|
||||
WHERE documents.client_id = $client_id
|
||||
AND documents.company_id = $session_company_id
|
||||
AND (document_name LIKE '%$q%' OR document_details LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||
|
|
@ -54,8 +54,8 @@ $total_pages = ceil($total_found_rows / 10);
|
|||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-edit"></i> Notes</h6>
|
||||
<button class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addNoteModal"><i class="fa fa-plus"></i></button>
|
||||
<h6 class="float-left mt-1"><i class="fa fa-file-alt"></i> Documents</h6>
|
||||
<button class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addDocumentModal"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form autocomplete="off">
|
||||
|
|
@ -69,19 +69,19 @@ $total_pages = ceil($total_found_rows / 10);
|
|||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<?php echo $_SESSION['bean']; ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=note_subject&o=<?php echo $disp; ?>">Note</a>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=document_name&o=<?php echo $disp; ?>">Name</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=note_created_at&o=<?php echo $disp; ?>">Created</a>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=document_created_at&o=<?php echo $disp; ?>">Created</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=note_updated_at&o=<?php echo $disp; ?>">Updated</a>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=document_updated_at&o=<?php echo $disp; ?>">Updated</a>
|
||||
</th>
|
||||
<th class="text-center">
|
||||
Action
|
||||
|
|
@ -92,34 +92,34 @@ $total_pages = ceil($total_found_rows / 10);
|
|||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$note_id = $row['note_id'];
|
||||
$note_subject = $row['note_subject'];
|
||||
$note_body = $row['note_body'];
|
||||
$note_created_at = $row['note_created_at'];
|
||||
$note_updated_at = $row['note_updated_at'];
|
||||
$document_id = $row['document_id'];
|
||||
$document_name = $row['document_name'];
|
||||
$document_details = $row['document_details'];
|
||||
$document_created_at = $row['document_created_at'];
|
||||
$document_updated_at = $row['document_updated_at'];
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#" data-toggle="modal" data-target="#viewNoteModal<?php echo $note_id; ?>"><?php echo $note_subject; ?></a>
|
||||
<a href="#" data-toggle="modal" data-target="#viewDocumentModal<?php echo $document_id; ?>"><?php echo $document_name; ?></a>
|
||||
</td>
|
||||
<td><?php echo $note_created_at; ?></td>
|
||||
<td><?php echo $note_updated_at; ?></td>
|
||||
<td><?php echo $document_created_at; ?></td>
|
||||
<td><?php echo $document_updated_at; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editNoteModal<?php echo $note_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editDocumentModal<?php echo $document_id; ?>">Edit</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?delete_note=<?php echo $note_id; ?>">Delete</a>
|
||||
<a class="dropdown-item" href="post.php?delete_document=<?php echo $document_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
include("edit_note_modal.php");
|
||||
include("view_note_modal.php");
|
||||
include("edit_document_modal.php");
|
||||
include("view_document_modal.php");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -139,4 +139,4 @@ $total_pages = ceil($total_found_rows / 10);
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_note_modal.php"); ?>
|
||||
<?php include("add_document_modal.php"); ?>
|
||||
|
|
@ -52,8 +52,8 @@ if(isset($_GET['tab'])){
|
|||
elseif($_GET['tab'] == "files"){
|
||||
include("client_files.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "notes"){
|
||||
include("client_notes.php");
|
||||
elseif($_GET['tab'] == "documents"){
|
||||
include("client_documents.php");
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -176,13 +176,13 @@
|
|||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="?client_id=<?php echo $client_id; ?>&tab=notes" class="nav-link <?php if($_GET['tab'] == "notes") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-edit"></i>
|
||||
<a href="?client_id=<?php echo $client_id; ?>&tab=documents" class="nav-link <?php if($_GET['tab'] == "documents") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-file-alt"></i>
|
||||
<p>
|
||||
Notes
|
||||
Documents
|
||||
<?php
|
||||
if($num_notes > 0){ ?>
|
||||
<span class="right badge badge-light"><?php echo $num_notes; ?></span>
|
||||
if($num_documents > 0){ ?>
|
||||
<span class="right badge badge-light"><?php echo $num_documents; ?></span>
|
||||
<?php } ?>
|
||||
</p>
|
||||
</a>
|
||||
|
|
|
|||
40
db.sql
40
db.sql
|
|
@ -221,6 +221,25 @@ CREATE TABLE `contacts` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `documents`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `documents`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `documents` (
|
||||
`document_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`document_name` varchar(200) NOT NULL,
|
||||
`document_details` text NOT NULL,
|
||||
`document_created_at` datetime NOT NULL,
|
||||
`document_updated_at` datetime DEFAULT NULL,
|
||||
`client_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`document_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `domains`
|
||||
--
|
||||
|
|
@ -486,25 +505,6 @@ CREATE TABLE `networks` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `notes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `notes`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `notes` (
|
||||
`note_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`note_subject` varchar(200) NOT NULL,
|
||||
`note_body` text NOT NULL,
|
||||
`note_created_at` datetime NOT NULL,
|
||||
`note_updated_at` datetime DEFAULT NULL,
|
||||
`client_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`note_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `payments`
|
||||
--
|
||||
|
|
@ -920,4 +920,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2021-01-26 16:07:08
|
||||
-- Dump completed on 2021-01-26 19:16:25
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
<div class="modal" id="editNoteModal<?php echo $note_id; ?>" tabindex="-1">
|
||||
<div class="modal" id="editDocumentModal<?php echo $document_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-edit mr-2"></i><?php echo $note_subject; ?></h5>
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-file-alt mr-2"></i><?php echo $document_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="note_id" value="<?php echo $note_id; ?>">
|
||||
<input type="hidden" name="document_id" value="<?php echo $document_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="subject" value="<?php echo $note_subject; ?>" placeholder="Subject" required>
|
||||
<input type="text" class="form-control" name="name" value="<?php echo $document_name; ?>" placeholder="Name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<textarea class="form-control summernote" name="note"><?php echo $note_body; ?></textarea>
|
||||
<textarea class="form-control summernote" name="details"><?php echo $document_details; ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_note" class="btn btn-primary">Save</button>
|
||||
<button type="submit" name="edit_document" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
45
post.php
45
post.php
|
|
@ -3395,58 +3395,49 @@ if(isset($_GET['delete_file'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_note'])){
|
||||
if(isset($_POST['add_document'])){
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']));
|
||||
$note = mysqli_real_escape_string($mysqli,$_POST['note']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$details = mysqli_real_escape_string($mysqli,$_POST['details']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO notes SET note_subject = '$subject', note_body = '$note', note_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_details = '$details', document_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Note', log_action = 'Created', log_description = '$subject', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Created', log_description = '$details', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
//$_SESSION['alert_message'] = "Note added";
|
||||
|
||||
$_SESSION['bean'] = "
|
||||
|
||||
<div class='toast'>
|
||||
<div class='toast-body'>
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
";
|
||||
$_SESSION['alert_message'] = "Document added";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_note'])){
|
||||
if(isset($_POST['edit_document'])){
|
||||
|
||||
$note_id = intval($_POST['note_id']);
|
||||
$subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']));
|
||||
$note = mysqli_real_escape_string($mysqli,$_POST['note']);
|
||||
$document_id = intval($_POST['document_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$details = mysqli_real_escape_string($mysqli,$_POST['details']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE notes SET note_subject = '$subject', note_body = '$note', note_updated_at = NOW() WHERE note_id = $note_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_details = '$details', document_updated_at = NOW() WHERE document_id = $document_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Note', log_action = 'Modified', log_description = '$subject', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Note', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Note updated";
|
||||
$_SESSION['alert_message'] = "Document updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_note'])){
|
||||
$note_id = intval($_GET['delete_note']);
|
||||
if(isset($_GET['delete_document'])){
|
||||
$document_id = intval($_GET['delete_document']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM notes WHERE note_id = $note_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"DELETE FROM documents WHERE document_id = $document_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Note', log_action = 'Deleted', log_description = '$note_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Deleted', log_description = '$document_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Note deleted";
|
||||
$_SESSION['alert_message'] = "Document deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-edit"></i><?php echo $note_subject; ?></h6>
|
||||
<button class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#editNoteModal"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text("$note_body");
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
<div class="modal" id="viewNoteModal<?php echo $note_id; ?>" tabindex="-1">
|
||||
<div class="modal" id="viewDocumentModal<?php echo $document_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-edit mr-2"></i><?php echo $note_subject; ?></h5>
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-file-alt mr-2"></i><?php echo $document_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body bg-white">
|
||||
<?php echo $note_body; ?>
|
||||
<?php echo $document_details; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue