mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-29 21:17:22 +00:00
folders and docs can be marked for batch operation
This commit is contained in:
parent
9f34304a41
commit
d271dfbf1f
|
@ -61,16 +61,39 @@ class SeedDMS_View_Search extends SeedDMS_Theme_Style {
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
$('#export').on('click', function(e) {
|
$('#export').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
|
var url = "";
|
||||||
|
url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
|
||||||
|
|
||||||
|
var inputs = $('input[name^=\"marks\"]');
|
||||||
|
var values = {};
|
||||||
|
inputs.each(function() {
|
||||||
|
console.log(this.name+'='+this.checked);
|
||||||
|
if(this.checked)
|
||||||
|
values[this.name] = 1;
|
||||||
|
});
|
||||||
|
url += '&'+$.param(values);
|
||||||
|
window.location.href = url;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#changeowner').on('click', function(e) {
|
$('#changeowner').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.location.href = $(this).attr('href')+'&newowner='+($('#newowner').val());
|
var url = "";
|
||||||
|
url = $(this).attr('href')+'&newowner='+($('#newowner').val());
|
||||||
|
var inputs = $('input[name^=\"marks\"]');
|
||||||
|
var values = {};
|
||||||
|
inputs.each(function() {
|
||||||
|
console.log(this.name+'='+this.checked);
|
||||||
|
if(this.checked)
|
||||||
|
values[this.name] = 1;
|
||||||
|
});
|
||||||
|
url += '&'+$.param(values);
|
||||||
|
window.location.href = url;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
// $this->printFolderChooserJs("form1");
|
// $this->printFolderChooserJs("form1");
|
||||||
$this->printDeleteFolderButtonJs();
|
$this->printDeleteFolderButtonJs();
|
||||||
|
$this->printMarkDocumentButtonJs();
|
||||||
$this->printDeleteDocumentButtonJs();
|
$this->printDeleteDocumentButtonJs();
|
||||||
/* Add js for catching click on document in one page mode */
|
/* Add js for catching click on document in one page mode */
|
||||||
$this->printClickDocumentJs();
|
$this->printClickDocumentJs();
|
||||||
|
@ -83,11 +106,64 @@ $(document).ready(function() {
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print button with icon for marking a document
|
||||||
|
*
|
||||||
|
* @param object $document document to be marked
|
||||||
|
* @param boolean $return return html instead of printing it
|
||||||
|
* @return string html content if $return is true, otherwise an empty string
|
||||||
|
*/
|
||||||
|
function printMarkDocumentButton($document, $return=false){ /* {{{ */
|
||||||
|
$docid = $document->getID();
|
||||||
|
$content = '';
|
||||||
|
$content .= '<br /><span class="mark-btn document-unmarked" title="'.getMLText('mark_document').'" rel="D'.$docid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_D'.$docid.'" name="marks[D'.$docid.']" value="1" style="display: none;">';
|
||||||
|
if($return)
|
||||||
|
return $content;
|
||||||
|
else
|
||||||
|
echo $content;
|
||||||
|
return '';
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print button with icon for marking a folder
|
||||||
|
*
|
||||||
|
* @param object $folder folder to be marked
|
||||||
|
* @param boolean $return return html instead of printing it
|
||||||
|
* @return string html content if $return is true, otherwise an empty string
|
||||||
|
*/
|
||||||
|
function printMarkFolderButton($folder, $return=false){ /* {{{ */
|
||||||
|
$folderid = $folder->getID();
|
||||||
|
$content = '';
|
||||||
|
$content .= '<br /><span class="mark-btn folder-unmarked" title="'.getMLText('mark_folder').'" rel="F'.$folderid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_F'.$folderid.'" name="marks[F'.$folderid.']" value="1" style="display: none;">';
|
||||||
|
if($return)
|
||||||
|
return $content;
|
||||||
|
else
|
||||||
|
echo $content;
|
||||||
|
return '';
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function printMarkDocumentButtonJs(){ /* {{{ */
|
||||||
|
$url = $this->html_url('Search', array_merge($_GET, array('action'=>null)));
|
||||||
|
echo "
|
||||||
|
// ".$url."
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('body').on('click', 'span.mark-btn', function(ev){
|
||||||
|
ev.stopPropagation();
|
||||||
|
id = $(ev.currentTarget).attr('rel');
|
||||||
|
$('#marks_'+id).each(function () { this.checked = !this.checked; });
|
||||||
|
$(this).parents('tr').toggleClass('table-info');
|
||||||
|
$(this).find('i').toggleClass('fa-square-o fa-check-square-o')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
";
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function export() { /* {{{ */
|
function export() { /* {{{ */
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$entries = $this->params['searchhits'];
|
$entries = $this->params['searchhits'];
|
||||||
$includecontent = $this->params['includecontent'];
|
$includecontent = $this->params['includecontent'];
|
||||||
|
$marks = $this->params['marks'];
|
||||||
|
|
||||||
include("../inc/inc.ClassDownloadMgr.php");
|
include("../inc/inc.ClassDownloadMgr.php");
|
||||||
$downmgr = new SeedDMS_Download_Mgr();
|
$downmgr = new SeedDMS_Download_Mgr();
|
||||||
|
@ -95,12 +171,14 @@ $(document).ready(function() {
|
||||||
$downmgr->addHeader($extraheader);
|
$downmgr->addHeader($extraheader);
|
||||||
foreach($entries as $entry) {
|
foreach($entries as $entry) {
|
||||||
if($entry->isType('document')) {
|
if($entry->isType('document')) {
|
||||||
$extracols = $this->callHook('extraDownloadColumns', $entry);
|
if(empty($marks) || !empty($marks['D'.$entry->getId()])) {
|
||||||
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
|
$extracols = $this->callHook('extraDownloadColumns', $entry);
|
||||||
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
|
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
|
||||||
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
|
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
|
||||||
} else
|
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
|
||||||
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
|
} else
|
||||||
|
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$filename = tempnam(sys_get_temp_dir(), '');
|
$filename = tempnam(sys_get_temp_dir(), '');
|
||||||
|
@ -129,16 +207,18 @@ $(document).ready(function() {
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$entries = $this->params['searchhits'];
|
$entries = $this->params['searchhits'];
|
||||||
$newowner = $this->params['newowner'];
|
$newowner = $this->params['newowner'];
|
||||||
|
$marks = $this->params['marks'];
|
||||||
|
|
||||||
if($newowner && $user->isAdmin()) {
|
if($newowner && $user->isAdmin()) {
|
||||||
$j = $i = 0;
|
$j = $i = 0;
|
||||||
foreach($entries as $entry) {
|
foreach($entries as $entry) {
|
||||||
// if($entry->isType('document')) {
|
$prefix = $entry->isType('document') ? 'D' : 'F';
|
||||||
|
if(empty($marks) || !empty($marks[$prefix.$entry->getId()])) {
|
||||||
if($entry->getOwner()->getId() != $newowner->getId()) {
|
if($entry->getOwner()->getId() != $newowner->getId()) {
|
||||||
$entry->setOwner($newowner);
|
$entry->setOwner($newowner);
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
$this->setParam('batchmsg', getMLText('batch_new_owner_msg', ['count'=>$j]));
|
$this->setParam('batchmsg', getMLText('batch_new_owner_msg', ['count'=>$j]));
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +290,7 @@ function typeahead() { /* {{{ */
|
||||||
$tmp['orderby'] = ($orderby=="d"||$orderby=="da") ? "dd" : "d";
|
$tmp['orderby'] = ($orderby=="d"||$orderby=="da") ? "dd" : "d";
|
||||||
$headcol .= " <a href=\"../out/out.Search.php?".http_build_query($tmp)."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="fa fa-sort-amount-asc selected"></i>':($orderby=="dd"?' <i class="fa fa-sort-amount-desc selected"></i>':' <i class="fa fa-sort-amount-asc"></i>'))."</a>";
|
$headcol .= " <a href=\"../out/out.Search.php?".http_build_query($tmp)."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="fa fa-sort-amount-asc selected"></i>':($orderby=="dd"?' <i class="fa fa-sort-amount-desc selected"></i>':' <i class="fa fa-sort-amount-asc"></i>'))."</a>";
|
||||||
}
|
}
|
||||||
return $headcol;
|
return $headcol;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function show() { /* {{{ */
|
function show() { /* {{{ */
|
||||||
|
@ -271,7 +351,7 @@ function typeahead() { /* {{{ */
|
||||||
//$this->contentHeading("<button class=\"btn btn-primary\" id=\"searchform-toggle\" data-toggle=\"collapse\" href=\"#searchform\"><i class=\"fa fa-exchange\"></i></button> ".getMLText('search'), true);
|
//$this->contentHeading("<button class=\"btn btn-primary\" id=\"searchform-toggle\" data-toggle=\"collapse\" href=\"#searchform\"><i class=\"fa fa-exchange\"></i></button> ".getMLText('search'), true);
|
||||||
$this->contentHeading(getMLText('search'), true);
|
$this->contentHeading(getMLText('search'), true);
|
||||||
if($this->query) {
|
if($this->query) {
|
||||||
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
|
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<ul class="nav nav-pills" id="searchtab">
|
<ul class="nav nav-pills" id="searchtab">
|
||||||
|
@ -858,6 +938,7 @@ function typeahead() { /* {{{ */
|
||||||
$extracontent['below_title'] = $this->getListRowPath($document);
|
$extracontent['below_title'] = $this->getListRowPath($document);
|
||||||
if($attrstr)
|
if($attrstr)
|
||||||
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
||||||
|
$extracontent['end_action_list'] = $this->printMarkDocumentButton($document, true);
|
||||||
|
|
||||||
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search', $extracontent);
|
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search', $extracontent);
|
||||||
if(is_string($txt))
|
if(is_string($txt))
|
||||||
|
@ -887,6 +968,7 @@ function typeahead() { /* {{{ */
|
||||||
$extracontent['below_title'] = $this->getListRowPath($folder);
|
$extracontent['below_title'] = $this->getListRowPath($folder);
|
||||||
if($attrstr)
|
if($attrstr)
|
||||||
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
||||||
|
$extracontent['end_action_list'] = $this->printMarkFolderButton($folder, true);
|
||||||
print $this->folderListRow($folder, false, $extracontent);
|
print $this->folderListRow($folder, false, $extracontent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user