mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 17:05:46 +00:00
use ajax for loading parts of page
This commit is contained in:
parent
cf6f8b952d
commit
2d199cae8d
|
@ -36,6 +36,14 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
$this->printDeleteDocumentButtonJs();
|
||||
$this->printDeleteItemButtonJs();
|
||||
$this->printUpdateItemButtonJs();
|
||||
?>
|
||||
$(document).ready( function() {
|
||||
$('body').on('click', '.selecttransmittal', function(ev){
|
||||
ev.preventDefault();
|
||||
$('div.ajax').trigger('update', {transmittalid: $(ev.currentTarget).data('transmittalid')});
|
||||
});
|
||||
});
|
||||
<?php
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
@ -44,10 +52,10 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
* @param object $item
|
||||
* @param string $msg message shown in case of successful update
|
||||
*/
|
||||
function printUpdateItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
protected function printUpdateItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$content .= '<a class="update-transmittalitem-btn" rel="'.$itemid.'" msg="'.htmlspecialchars($msg, ENT_QUOTES).'" confirmmsg="'.htmlspecialchars(getMLText("confirm_update_transmittalitem"), ENT_QUOTES).'"><i class="icon-refresh"></i></a>';
|
||||
$content .= '<a class="update-transmittalitem-btn" transmittal="'.$item->getTransmittal()->getID().'" rel="'.$itemid.'" msg="'.htmlspecialchars($msg, ENT_QUOTES).'" confirmmsg="'.htmlspecialchars(getMLText("confirm_update_transmittalitem"), ENT_QUOTES).'"><i class="icon-refresh"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
|
@ -55,11 +63,12 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
return '';
|
||||
} /* }}} */
|
||||
|
||||
function printUpdateItemButtonJs(){ /* {{{ */
|
||||
protected function printUpdateItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.update-transmittalitem-btn', function(ev){
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
transmittalid = $(ev.currentTarget).attr('transmittal');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('updatetransmittalitem')."';
|
||||
|
@ -67,11 +76,17 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
\"label\" : \"<i class='icon-refresh'></i> ".getMLText("update_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.get('../op/op.Ajax.php',
|
||||
{ command: 'updatetransmittalitem', id: id, formtoken: formtoken },
|
||||
function(data) {
|
||||
$.ajax('../op/op.TransmittalMgr.php', {
|
||||
type:'POST',
|
||||
async:true,
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: 'updatetransmittalitem',
|
||||
id: id,
|
||||
formtoken: formtoken
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
$('#table-row-document-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
|
@ -80,6 +95,7 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
$('div.ajax').trigger('update', {transmittalid: transmittalid});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
|
@ -90,9 +106,8 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
|
@ -115,7 +130,7 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
function printDeleteItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
protected function printDeleteItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$content .= '<a class="delete-transmittalitem-btn" rel="'.$itemid.'" msg="'.htmlspecialchars($msg, ENT_QUOTES).'" confirmmsg="'.htmlspecialchars(getMLText("confirm_rm_transmittalitem"), ENT_QUOTES).'"><i class="icon-remove"></i></a>';
|
||||
|
@ -126,7 +141,7 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
return '';
|
||||
} /* }}} */
|
||||
|
||||
function printDeleteItemButtonJs(){ /* {{{ */
|
||||
protected function printDeleteItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.delete-transmittalitem-btn', function(ev){
|
||||
|
@ -138,11 +153,18 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
\"label\" : \"<i class='icon-remove'></i> ".getMLText("rm_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.get('../op/op.Ajax.php',
|
||||
{ command: 'removetransmittalitem', id: id, formtoken: formtoken },
|
||||
function(data) {
|
||||
$.ajax('../op/op.TransmittalMgr.php', {
|
||||
type:'POST',
|
||||
async:true,
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: 'removetransmittalitem',
|
||||
id: id,
|
||||
formtoken: formtoken
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
$('#table-row-document-'+id).hide('slow');
|
||||
$('#table-row-transmittalitem-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
|
@ -162,8 +184,7 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
});
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
|
@ -176,9 +197,10 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
";
|
||||
} /* }}} */
|
||||
|
||||
function showTransmittalForm($transmittal) { /* {{{ */
|
||||
protected function showTransmittalForm($transmittal) { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$accessop = $this->params['accessobject'];
|
||||
?>
|
||||
<form action="../op/op.TransmittalMgr.php" method="post" enctype="multipart/form-data" name="form<?php print $transmittal ? $transmittal->getID() : '0';?>">
|
||||
<?php
|
||||
|
@ -197,7 +219,7 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
?>
|
||||
<table class="table-condensed">
|
||||
<?php
|
||||
if($transmittal) {
|
||||
if($transmittal && $accessop->check_controller_access('TransmittalMgr', array('action'=>'removetransmittal'))) {
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
|
@ -214,75 +236,44 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
<td><?php printMLText("transmittal_comment");?>:</td>
|
||||
<td><input type="text" name="comment" value="<?php print $transmittal ? htmlspecialchars($transmittal->getComment()) : "";?>"></td>
|
||||
</tr>
|
||||
<?php
|
||||
if($currRole && $accessop->check_controller_access('TransmittalMgr', array('action'=>'edittransmittal')) || !$currRole && $accessop->check_controller_access('TransmittalMgr', array('action'=>'addtransmittal'))) {
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText($transmittal ? "save" : "add_transmittal")?></button></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
function removeitem() { /* {{{ */
|
||||
$seltransmittal = $this->params['seltransmittal'];
|
||||
|
||||
$this->showTransmittalForm($seltransmittal);
|
||||
} /* }}} */
|
||||
|
||||
function form() { /* {{{ */
|
||||
$seltransmittal = $this->params['seltransmittal'];
|
||||
|
||||
$this->showTransmittalForm($seltransmittal);
|
||||
} /* }}} */
|
||||
|
||||
protected function showTransmittalItems($seltransmittal) { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$seltransmittal = $this->params['seltransmittal'];
|
||||
$accessop = $this->params['accessobject'];
|
||||
$cachedir = $this->params['cachedir'];
|
||||
$previewwidth = $this->params['previewWidthList'];
|
||||
$previewconverters = $this->params['previewconverters'];
|
||||
$timeout = $this->params['timeout'];
|
||||
|
||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout);
|
||||
$previewer->setConverters($previewconverters);
|
||||
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
||||
|
||||
$this->htmlStartPage(getMLText("my_transmittals"));
|
||||
$this->globalNavigation();
|
||||
$this->contentStart();
|
||||
$this->pageNavigation(getMLText("my_transmittals"), "my_documents");
|
||||
$this->contentHeading(getMLText("my_transmittals"));
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<?php
|
||||
$this->contentContainerStart();
|
||||
|
||||
$transmittals = $dms->getAllTransmittals($user);
|
||||
|
||||
if ($transmittals){
|
||||
print "<table class=\"table table-condensed\">";
|
||||
print "<thead>\n<tr>\n";
|
||||
print "<th>".getMLText("name")."</th>\n";
|
||||
print "<th>".getMLText("comment")."</th>\n";
|
||||
print "<th>".getMLText("transmittal_size")."</th>\n";
|
||||
print "<th></th>\n";
|
||||
print "</tr>\n</thead>\n<tbody>\n";
|
||||
foreach($transmittals as $transmittal) {
|
||||
print "<tr>\n";
|
||||
print "<td>".$transmittal->getName()."</td>";
|
||||
print "<td>".$transmittal->getComment()."</td>";
|
||||
$items = $transmittal->getItems();
|
||||
print "<td>".count($items)." <em>(".SeedDMS_Core_File::format_filesize($transmittal->getSize()).")</em></td>";
|
||||
print "<td>";
|
||||
print "<div class=\"list-action\">";
|
||||
print "<a href=\"../out/out.TransmittalMgr.php?transmittalid=".$transmittal->getID()."\" title=\"".getMLText("edit_transmittal_props")."\"><i class=\"icon-edit\"></i></a>";
|
||||
print "</div>";
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
$this->contentContainerEnd();
|
||||
?>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<?php
|
||||
$this->contentContainerStart();
|
||||
$this->showTransmittalForm($seltransmittal);
|
||||
$this->contentContainerEnd();
|
||||
|
||||
if($seltransmittal) {
|
||||
$items = $seltransmittal->getItems();
|
||||
if($items) {
|
||||
|
@ -318,6 +309,78 @@ class SeedDMS_View_TransmittalMgr extends SeedDMS_Bootstrap_Style {
|
|||
print "<a class=\"btn btn-default\" href=\"../op/op.TransmittalDownload.php?transmittalid=".$seltransmittal->getID()."\">".getMLText('download')."</a>";
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function items() { /* {{{ */
|
||||
$seltransmittal = $this->params['seltransmittal'];
|
||||
|
||||
$this->showTransmittalItems($seltransmittal);
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$accessop = $this->params['accessobject'];
|
||||
$seltransmittal = $this->params['seltransmittal'];
|
||||
$cachedir = $this->params['cachedir'];
|
||||
$timeout = $this->params['timeout'];
|
||||
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
||||
|
||||
$this->htmlStartPage(getMLText("my_transmittals"));
|
||||
$this->globalNavigation();
|
||||
$this->contentStart();
|
||||
$this->pageNavigation(getMLText("my_transmittals"), "my_documents");
|
||||
$this->contentHeading(getMLText("my_transmittals"));
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<?php
|
||||
$this->contentContainerStart();
|
||||
|
||||
$transmittals = $dms->getAllTransmittals($user);
|
||||
|
||||
if ($transmittals){
|
||||
print "<table class=\"table table-condensed\">";
|
||||
print "<thead>\n<tr>\n";
|
||||
print "<th>".getMLText("name")."</th>\n";
|
||||
print "<th>".getMLText("comment")."</th>\n";
|
||||
print "<th>".getMLText("transmittal_size")."</th>\n";
|
||||
print "<th></th>\n";
|
||||
print "</tr>\n</thead>\n<tbody>\n";
|
||||
foreach($transmittals as $transmittal) {
|
||||
print "<tr>\n";
|
||||
print "<td>".$transmittal->getName()."</td>";
|
||||
print "<td>".$transmittal->getComment()."</td>";
|
||||
$items = $transmittal->getItems();
|
||||
print "<td>".count($items)." <em>(".SeedDMS_Core_File::format_filesize($transmittal->getSize()).")</em></td>";
|
||||
print "<td>";
|
||||
print "<div class=\"list-action\">";
|
||||
print "<a class=\"selecttransmittal\" data-transmittalid=\"".$transmittal->getID()."\" href=\"../out/out.TransmittalMgr.php?transmittalid=".$transmittal->getID()."\" title=\"".getMLText("edit_transmittal_props")."\"><i class=\"icon-edit\"></i></a>";
|
||||
print "</div>";
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
$this->contentContainerEnd();
|
||||
?>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<?php
|
||||
if($accessop->check_view_access($this, array('action'=>'form'))) {
|
||||
$this->contentContainerStart();
|
||||
?>
|
||||
<div class="ajax" data-view="TransmittalMgr" data-action="form" <?php echo ($seltransmittal ? "data-query=\"transmittalid=".$seltransmittal->getID()."\"" : "") ?>></div>
|
||||
<?php
|
||||
$this->contentContainerEnd();
|
||||
}
|
||||
if($accessop->check_view_access($this, array('action'=>'items'))) {
|
||||
?>
|
||||
<div class="ajax" data-view="TransmittalMgr" data-action="items" <?php echo ($seltransmittal ? "data-query=\"transmittalid=".$seltransmittal->getID()."\"" : "") ?>></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user