mirror of https://github.com/itflow-org/itflow
Merged table Document and Document Template and just added a new field to differentiate, can save a document as a template now more to come, also added folder selection not quite ready yet
This commit is contained in:
parent
bb5abba882
commit
e6167ffaa3
|
|
@ -51,8 +51,35 @@
|
|||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
|
||||
<div class="form-group mr-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info-circle"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="template">
|
||||
<option value="0">Document</option>
|
||||
<option value="1">Template</option>
|
||||
<option value="3">Global Template</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group ml-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="folder">
|
||||
<option value="">- Select Folder -
|
||||
<option value="">/</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_document" class="btn btn-primary">Save</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,32 @@
|
|||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
|
||||
<div class="form-group mr-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-info-circle"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="template">
|
||||
<option value="0">Document</option>
|
||||
<option value="1">Template</option>
|
||||
<option value="3">Global Template</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group ml-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="folder">
|
||||
<option value="">- Select Folder -
|
||||
<option value="">/</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_document" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -55,12 +55,14 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
|
|||
$sql_no_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
|
||||
WHERE document_client_id = $client_id
|
||||
AND documents.company_id = $session_company_id
|
||||
AND document_template = 0
|
||||
AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to";
|
||||
|
||||
$sql_with_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
|
||||
LEFT JOIN documents_tagged ON documents.document_id = documents_tagged.document_id
|
||||
WHERE document_client_id = $client_id
|
||||
AND document_template = 0
|
||||
AND documents.company_id = $session_company_id
|
||||
AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
|
||||
AND documents_tagged.tag_id LIKE '%$tag%'
|
||||
|
|
@ -81,9 +83,20 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-file-alt"></i> Documents</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addDocumentModal"><i class="fas fa-fw fa-plus"></i> New Document</button>
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#manageTagsModal"><i class="fas fa-fw fa-tags"></i> Tags</button>
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"><i class="fas fa-fw fa-plus"></i> New Document</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addDocumentModal">New Document</a>
|
||||
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addDocumentFromTemplateModal">From Template</a>
|
||||
<div class="dropdown-divider text-dark"></div>
|
||||
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#manageTagsModal"><i class="fas fa-fw fa-tags"></i> Tags</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
|
|
|
|||
25
db.sql
25
db.sql
|
|
@ -398,26 +398,6 @@ CREATE TABLE `document_tags` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `document_templates`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `document_templates`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `document_templates` (
|
||||
`document_template_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`document_template_name` varchar(200) NOT NULL,
|
||||
`document_template_content` longtext NOT NULL,
|
||||
`document_template_created_at` datetime NOT NULL,
|
||||
`document_template_updated_at` datetime DEFAULT NULL,
|
||||
`document_template_archived_at` datetime DEFAULT NULL,
|
||||
`document_template_category_id` int(11) DEFAULT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`document_template_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `documents`
|
||||
--
|
||||
|
|
@ -432,6 +412,7 @@ CREATE TABLE `documents` (
|
|||
`document_created_at` datetime NOT NULL,
|
||||
`document_updated_at` datetime DEFAULT NULL,
|
||||
`document_archived_at` datetime DEFAULT NULL,
|
||||
`document_template` tinyint(1) NOT NULL,
|
||||
`document_folder_id` int(11) DEFAULT NULL,
|
||||
`document_client_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
|
|
@ -1139,7 +1120,7 @@ CREATE TABLE `settings` (
|
|||
DROP TABLE IF EXISTS `shared_items`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE IF NOT EXISTS `shared_items` (
|
||||
CREATE TABLE `shared_items` (
|
||||
`item_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`item_active` int(1) NOT NULL,
|
||||
`item_key` varchar(255) NOT NULL,
|
||||
|
|
@ -1464,4 +1445,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-02-18 18:02:48
|
||||
-- Dump completed on 2022-02-20 17:01:28
|
||||
|
|
|
|||
|
|
@ -894,4 +894,10 @@ $license_types_array = array(
|
|||
'User'
|
||||
);
|
||||
|
||||
$document_types_array = array(
|
||||
'0'=>'Document',
|
||||
'1'=>'Template',
|
||||
'2'=>'Global Template'
|
||||
);
|
||||
|
||||
?>
|
||||
12
post.php
12
post.php
|
|
@ -6065,17 +6065,19 @@ if(isset($_POST['add_document'])){
|
|||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$tags_ids = $_POST['tags_ids'];
|
||||
$content = trim(mysqli_real_escape_string($mysqli,$purifier->purify(html_entity_decode($_POST['content']))));
|
||||
$template = intval($_POST['template']);
|
||||
$folder = intval($_POST['folder']);
|
||||
|
||||
// Document add query
|
||||
$add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_content = '$content', document_created_at = NOW(), document_client_id = $client_id, company_id = $session_company_id");
|
||||
$add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_content = '$content', document_created_at = NOW(), document_template = $template, document_folder_id = $folder, document_client_id = $client_id, company_id = $session_company_id");
|
||||
$document_id = $mysqli->insert_id;
|
||||
|
||||
// Logging
|
||||
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, log_user_id = $session_user_id");
|
||||
|
||||
// Add tags
|
||||
foreach($tags_ids as $tag_id) {
|
||||
if (intval($tag_id)) {
|
||||
foreach($tags_ids as $tag_id){
|
||||
if(intval($tag_id)){
|
||||
mysqli_query($mysqli, "INSERT INTO documents_tagged SET document_id = '$document_id', tag_id = '$tag_id'");
|
||||
}
|
||||
}
|
||||
|
|
@ -6097,9 +6099,11 @@ if(isset($_POST['edit_document'])){
|
|||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$tags_ids = $_POST['tags_ids'];
|
||||
$content = trim(mysqli_real_escape_string($mysqli,$purifier->purify(html_entity_decode($_POST['content']))));
|
||||
$template = intval($_POST['template']);
|
||||
$folder = intval($_POST['folder']);
|
||||
|
||||
// Document edit query
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_content = '$content', document_updated_at = NOW() WHERE document_id = $document_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_content = '$content', document_updated_at = NOW(), document_template = $template, document_folder_id = $folder 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 = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
||||
|
|
|
|||
Loading…
Reference in New Issue