diff --git a/admin/docs.php b/admin/docs.php
index 70500a5..0d9141b 100644
--- a/admin/docs.php
+++ b/admin/docs.php
@@ -318,5 +318,17 @@
$AVE_Document->documentPosition();
}
break;
+
+ case 'publish':
+ if (check_permission_acp('document_view')) {
+ $AVE_Document->documentPublish();
+ }
+ break;
+
+ case 'recycle':
+ if (check_permission_acp('document_view')) {
+ $AVE_Document->documentRecycle();
+ }
+ break;
}
?>
\ No newline at end of file
diff --git a/admin/lang/ru/docs.txt b/admin/lang/ru/docs.txt
index 76e117d..b9b4362 100755
--- a/admin/lang/ru/docs.txt
+++ b/admin/lang/ru/docs.txt
@@ -315,3 +315,12 @@ DOC_SEARCH_PARAM_SELECT = "Выберите параметр"
DOC_SEARCH_PARAM_LIKE = "Содержит"
DOC_SEARCH_PARAM_EQ = "Равно"
DOC_SEARCH_PARAM_TEXT = "Значение"
+
+DOC_STATUS_SUCCESS = "Выполнено"
+DOC_STATUS_ERROR = "Ошибка"
+
+DOC_STATUS_ON = "Документ опубликован"
+DOC_STATUS_OFF = "Документ снят с публикации"
+
+DOC_RECYCLE_ON = "Документ восстановлен"
+DOC_RECYCLE_OFF = "Документ помещен в корзину"
\ No newline at end of file
diff --git a/admin/templates/css/main.css b/admin/templates/css/main.css
index 4459bef..20db152 100644
--- a/admin/templates/css/main.css
+++ b/admin/templates/css/main.css
@@ -120,7 +120,7 @@ p { padding: 12px 0 0 0; }
.first { margin-top: 22px!important; }
.inactive { margin-top: 0px; color: #656565; }
.btext { font-weight: bold; }
-.hidden { display: none;}
+.hidden { display: none !important;}
.rounded { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;}
select { overflow: auto; }
.bordLeft { border-top-left-radius: 3px; -moz-border-radius-topleft: 3px; -webkit-border-top-left-radius: 3px; }
diff --git a/admin/templates/documents/doc_search.tpl b/admin/templates/documents/doc_search.tpl
index 917f4f3..d99a445 100644
--- a/admin/templates/documents/doc_search.tpl
+++ b/admin/templates/documents/doc_search.tpl
@@ -1,79 +1,3 @@
-
-
-
@@ -143,15 +152,31 @@
{if $docs}
- |
- {#DOC_ID#} |
+
+
+
+
+ |
+
+ {#DOC_ID#}
+ |
{#DOC_TITLE#} | {#DOC_URL_RUB#}
|
- {#DOC_IN_RUBRIK#} |
- {#DOC_POSITION#} |
- {#DOC_CREATED#} | {#DOC_EDIT#} |
- {if !$smarty.const.ADMIN_EDITMENU}{#DOC_ACTIONS#} | {/if}
+
+ {#DOC_IN_RUBRIK#}
+ |
+
+ {#DOC_POSITION#}
+ |
+
+ {#DOC_CREATED#} | {#DOC_EDIT#}
+ |
+ {if !$smarty.const.ADMIN_EDITMENU}
+
+ {#DOC_ACTIONS#}
+ |
+ {/if}
{/if}
@@ -220,30 +245,29 @@
{/if}
- {if $item->document_deleted!=1}
- {if $item->document_status==1}
- {if $item->canOpenClose==1 && $item->Id != 1 && $item->Id != $PAGE_NOT_FOUND_ID}
-
-
-
- {/if}
- {else}
- {if $item->canOpenClose==1}
-
-
-
- {/if}
+ {if $item->document_status==1}
+ {if $item->canOpenClose==1 && $item->Id != 1 && $item->Id != $PAGE_NOT_FOUND_ID}
+
+
+
+ {/if}
+ {else}
+ {if $item->canOpenClose==1}
+
+
+
{/if}
{/if}
+
{if $item->document_deleted==1}
-
+
{else}
{if $item->canDelete==1}
-
+
{/if}
@@ -312,11 +336,12 @@
-
{if $item->ist_remark!='0'}
-
+
{/if}
@@ -417,7 +442,7 @@
{#DOC_IN_RUBRIK#} |
{#DOC_POSITION#} |
{#DOC_CREATED#} | {#DOC_EDIT#} |
- {if !$smarty.const.ADMIN_EDITMENU} {#DOC_ACTIONS#} | {/if}
+ {if !$smarty.const.ADMIN_EDITMENU} {#DOC_ACTIONS#} | {/if}
{/if}
@@ -451,115 +476,13 @@
{/if}
-
+
\ No newline at end of file
diff --git a/admin/templates/js/docs.js b/admin/templates/js/docs.js
new file mode 100644
index 0000000..0888230
--- /dev/null
+++ b/admin/templates/js/docs.js
@@ -0,0 +1,270 @@
+var AveDocs = {
+
+ initialized: false,
+
+ init: function () {
+
+ if (this.initialized)
+ return;
+
+ this.initialized = true;
+ },
+
+
+ //
+ list: function () {
+ this.addDocument();
+ this.selectAllDocuments();
+ this.documentAction();
+ this.documentPublish();
+ this.documentRecycle();
+ },
+
+
+ //
+ edit: function () {
+
+ },
+
+
+ //
+ search: function () {
+ this.searchDateTime();
+ this.searchCollapsible();
+ },
+
+
+ //
+ addDocument: function () {
+ $(".AddDocument").on('click', function (event) {
+ event.preventDefault();
+
+ let rubricId = $('#addDocRub #rubricId').fieldValue();
+
+ if (rubricId == '') {
+ jAlert(add_doc_text, add_doc_title);
+ } else {
+ $.alerts._overlay('show');
+ $("#addDocRub").submit();
+ }
+ });
+ },
+
+
+ //
+ selectAllDocuments: function () {
+ $('#selectAll').on('change', function (event) {
+ event.preventDefault();
+
+ if ($('#selectAll').is(':checked')) {
+ $('#docs .checkbox').attr('checked', 'checked').addClass('jqTransformChecked');
+ $("#docs a.jqTransformCheckbox").addClass("jqTransformChecked");
+ } else {
+ $('#docs .checkbox').removeClass('jqTransformChecked').removeAttr('checked');
+ $("#docs a.jqTransformCheckbox").removeClass("jqTransformChecked");
+ }
+ });
+ },
+
+
+ //
+ documentPublish: function () {
+ $(".documentPublish").on('click', function (event) {
+ event.preventDefault();
+
+ let link = $(this);
+ let doc_id = link.data('id');
+
+ $.ajax({
+ type: 'POST',
+ url: 'http://ave327.loc/admin/index.php?do=docs&action=publish&cp=' + sess,
+ data: {
+ 'doc_id': doc_id
+ },
+ dataType: 'JSON',
+ beforeSend: function () {
+ $.alerts._overlay('show');
+ },
+ success: function (data) {
+ $.alerts._overlay('hide');
+
+ if (data.success) {
+
+ (data.status != 1)
+ ? link.closest('tr').addClass('yellow')
+ : link.closest('tr').removeClass('yellow');
+
+ (data.status != 1)
+ ? link.addClass('public')
+ : link.removeClass('public');
+
+ link.attr('title', data.text);
+
+ AveAdmin.tooltip();
+ }
+
+ $.jGrowl(data['message'], {
+ header: data['header'],
+ theme: data['theme']
+ });
+ }
+ });
+ });
+ },
+
+
+ //
+ documentRecycle: function () {
+ $(".documentRecycle").on('click', function (event) {
+ event.preventDefault();
+
+ let link = $(this);
+ let doc_id = link.data('id');
+
+ $.ajax({
+ type: 'POST',
+ url: 'http://ave327.loc/admin/index.php?do=docs&action=recycle&cp=' + sess,
+ data: {
+ 'doc_id': doc_id
+ },
+ dataType: 'JSON',
+ beforeSend: function () {
+ $.alerts._overlay('show');
+ },
+ success: function (data) {
+ $.alerts._overlay('hide');
+
+ if (data.success) {
+
+ (data.status == 1)
+ ? link.closest('tr').addClass('red')
+ : link.closest('tr').removeClass('red');
+
+ (data.status == 1)
+ ? link.addClass('recylce')
+ : link.removeClass('recylce');
+
+ (data.status == 1)
+ ? link.closest('tr').find('.documentPublish').addClass('hidden')
+ : link.closest('tr').find('.documentPublish').removeClass('hidden');
+
+ link.attr('title', data.text);
+
+ AveAdmin.tooltip();
+ }
+
+ $.jGrowl(data['message'], {
+ header: data['header'],
+ theme: data['theme']
+ });
+ }
+ });
+ });
+ },
+
+
+ //
+ documentCopy: function () {
+ $(".CopyDocs").on('click', function (event) {
+ event.preventDefault();
+
+ let href = $(this).attr('href');
+
+ jPrompt(copy_doc_text, '', copy_doc_title, function (data) {
+ if (data) {
+ $.alerts._overlay('show');
+ window.location = href + '&document_title=' + data;
+ } else {
+ $.jGrowl(copy_doc_no, {theme: 'error'});
+ }
+ }
+ );
+ });
+ },
+
+
+ //
+ documentAction: function () {
+ $(".docaction").hover(
+ function () { $(this).children(".actions").show("fade", 10); },
+ function() { $(this).children(".actions").hide("fade", 10); }
+ );
+ },
+
+
+ //
+ searchDateTime: function () {
+ $('#document_published').datepicker({
+ changeMonth: true,
+ changeYear: true,
+
+ onClose: function (dateText, inst) {
+ var endDateTextBox = $('#document_expire');
+ if (endDateTextBox.val() != '') {
+ var testStartDate = new Date(dateText);
+ var testEndDate = new Date(endDateTextBox.val());
+ if (testStartDate > testEndDate)
+ endDateTextBox.val(dateText);
+ }
+ else {
+ endDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime) {
+ var start = $(this).datetimepicker('getDate');
+ $('#document_expire').datetimepicker('option', 'minDate', new Date(start.getTime()));
+ }
+ });
+
+ $('#document_expire').datepicker({
+ changeMonth: true,
+ changeYear: true,
+
+ onClose: function (dateText, inst) {
+ var startDateTextBox = $('#document_published');
+ if (startDateTextBox.val() != '') {
+ var testStartDate = new Date(startDateTextBox.val());
+ var testEndDate = new Date(dateText);
+ if (testStartDate > testEndDate)
+ startDateTextBox.val(dateText);
+ }
+ else {
+ startDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime) {
+ var end = $(this).datetimepicker('getDate');
+ $('#document_published').datetimepicker('option', 'maxDate', new Date(end.getTime()));
+ }
+ });
+ },
+
+
+ //
+ searchCollapsible: function () {
+ $('.collapsible').collapsible({
+ defaultOpen: 'opened',
+ cssOpen: 'inactive',
+ cssClose: 'normal',
+ cookieName: 'collaps_doc',
+ cookieOptions: {
+ expires: 7,
+ domain: ''
+ },
+ speed: 5,
+ loadOpen: function (elem, opts) {
+ elem.next().show();
+ },
+ loadClose: function (elem, opts) {
+ elem.next().hide();
+ }
+ });
+
+ $('.collapsible').on('click', function () {
+ setTimeout(function () {
+ AveAdmin.sticky_panel_refresh();
+ AveAdmin.select_form();
+ }, 10);
+ });
+ },
+};
\ No newline at end of file
diff --git a/class/class.docs.php b/class/class.docs.php
index 8928af7..8a6f95c 100755
--- a/class/class.docs.php
+++ b/class/class.docs.php
@@ -132,7 +132,7 @@
$stamp['day'] = explode(".", $data[0]);
$stamp['time'] = explode(":", $data[1]);
- if (!empty($stamp))
+ if (! empty($stamp))
{
$timestamp = mktime(
$stamp['time'][0],
@@ -4377,5 +4377,116 @@
exit;
}
+
+ function documentPublish ()
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $doc_id = (int)$_REQUEST['doc_id'];
+
+ if (! $doc_id)
+ {
+ $return = [
+ 'success' => false,
+ 'header' => $AVE_Template->get_config_vars('DOC_STATUS_ERROR'),
+ 'message' => '',
+ 'theme' => 'error'
+ ];
+
+ _json($return, true);
+ }
+
+ $sql = "
+ SELECT
+ document_status
+ FROM
+ " . PREFIX . "_documents
+ WHERE
+ Id = '" . $doc_id . "'
+ ";
+
+ $status = $AVE_DB->Query($sql)->GetCell();
+
+ $sql = "
+ UPDATE
+ " . PREFIX . "_documents
+ SET
+ document_status = '" . ($status == 1 ? 0 : 1) . "'
+ WHERE
+ Id = '" . $doc_id . "'
+ ";
+
+ $AVE_DB->Query($sql);
+
+ $return = [
+ 'success' => true,
+ 'status' => ($status == 1 ? '0' : '1'),
+ 'text' => ($status == 1 ? $AVE_Template->get_config_vars('DOC_ENABLE_TITLE') : $AVE_Template->get_config_vars('DOC_DISABLE_TITLE')),
+ 'header' => $AVE_Template->get_config_vars('DOC_STATUS_SUCCESS'),
+ 'message' => ($status == 1 ? $AVE_Template->get_config_vars('DOC_STATUS_OFF') : $AVE_Template->get_config_vars('DOC_STATUS_ON')),
+ 'theme' => 'accept'
+ ];
+
+ $AVE_DB->clearDocument($doc_id);
+
+ reportLog($_SESSION['user_name'] . ' - ' . (($status == 1) ? $AVE_Template->get_config_vars('DOC_STATUS_OFF') : $AVE_Template->get_config_vars('DOC_STATUS_ON')) . ' (' . $doc_id . ')', 2, 2);
+
+ _json($return, true);
+ }
+
+ function documentRecycle ()
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $doc_id = (int) $_REQUEST['doc_id'];
+
+ if (!$doc_id) {
+ $return = [
+ 'success' => false,
+ 'header' => $AVE_Template->get_config_vars('DOC_STATUS_ERROR'),
+ 'message' => '',
+ 'theme' => 'error'
+ ];
+
+ _json($return, true);
+ }
+
+ $sql = "
+ SELECT
+ document_deleted
+ FROM
+ " . PREFIX . "_documents
+ WHERE
+ Id = '" . $doc_id . "'
+ ";
+
+ $status = $AVE_DB->Query($sql)->GetCell();
+
+ $sql = "
+ UPDATE
+ " . PREFIX . "_documents
+ SET
+ document_deleted = '" . ($status == 0 ? 1 : 0) . "'
+ WHERE
+ Id = '" . $doc_id . "'
+ ";
+
+ $AVE_DB->Query($sql);
+
+ $return = [
+ 'success' => true,
+ 'status' => ($status == 1 ? '0' : '1'),
+ 'text' => ($status == 1 ? $AVE_Template->get_config_vars('DOC_TEMPORARY_DELETE') : $AVE_Template->get_config_vars('DOC_RESTORE_DELETE')),
+ 'header' => $AVE_Template->get_config_vars('DOC_STATUS_SUCCESS'),
+ 'message' => ($status == 1 ? $AVE_Template->get_config_vars('DOC_RECYCLE_ON') : $AVE_Template->get_config_vars('DOC_RECYCLE_OFF')),
+ 'theme' => 'accept'
+ ];
+
+ $AVE_DB->clearDocument($doc_id);
+
+ reportLog($_SESSION['user_name'] . ' - ' . (($status == 1) ? $AVE_Template->get_config_vars('DOC_RECYCLE_ON') : $AVE_Template->get_config_vars('DOC_RECYCLE_OFF')) . ' (' . $doc_id . ')', 2, 2);
+
+ _json($return, true);
+ }
}
?>
\ No newline at end of file
|