mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
move methods for updating, deleting transmittal item into trait, makes it work in bootstrap4
This commit is contained in:
parent
b88e05fe22
commit
b65d940259
|
@ -26,6 +26,9 @@ include("../inc/inc.DBInit.php");
|
|||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
require_once("../views/".$theme."/trait.TransmittalUpdateButton.php");
|
||||
require_once("../views/".$theme."/trait.TransmittalDeleteButton.php");
|
||||
|
||||
/**
|
||||
* Include class to preview documents
|
||||
*/
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
*/
|
||||
class SeedDMS_View_TransmittalMgr extends SeedDMS_Theme_Style {
|
||||
|
||||
use TransmittalDeleteButton;
|
||||
use TransmittalUpdateButton;
|
||||
|
||||
function js() { /* {{{ */
|
||||
$showtree = $this->params['showtree'];
|
||||
$onepage = $this->params['onepage'];
|
||||
|
@ -65,157 +68,6 @@ $(document).ready( function() {
|
|||
<?php
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Print button for updating the transmittal item to the newest version
|
||||
*
|
||||
* @param object $item
|
||||
* @param string $msg message shown in case of successful update
|
||||
*/
|
||||
protected function printUpdateItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$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="fa fa-refresh"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
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')."';
|
||||
bootbox.dialog(confirmmsg, [{
|
||||
\"label\" : \"<i class='fa fa-refresh'></i> ".getMLText("update_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.ajax('../op/op.TransmittalMgr.php', {
|
||||
type:'POST',
|
||||
async:true,
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: 'updatetransmittalitem',
|
||||
id: id,
|
||||
formtoken: formtoken
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
$('div.ajax').trigger('update', {transmittalid: transmittalid});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"class\" : \"btn-cancel\",
|
||||
\"callback\": function() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Print button with link for deleting a transmittal item
|
||||
*
|
||||
* This button works just like the printDeleteDocumentButton()
|
||||
*
|
||||
* @param object $item transmittal item to be deleted
|
||||
* @param string $msg message shown in case of successful deletion
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
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="fa fa-remove"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
protected function printDeleteItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.delete-transmittalitem-btn', function(ev){
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('removetransmittalitem')."';
|
||||
bootbox.dialog(confirmmsg, [{
|
||||
\"label\" : \"<i class='fa fa-remove'></i> ".getMLText("rm_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.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-transmittalitem-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"class\" : \"btn-cancel\",
|
||||
\"callback\": function() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
protected function showTransmittalForm($transmittal) { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
|
|
81
views/bootstrap/trait.TransmittalDeleteButton.php
Normal file
81
views/bootstrap/trait.TransmittalDeleteButton.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
trait TransmittalDeleteButton {
|
||||
/**
|
||||
* Print button with link for deleting a transmittal item
|
||||
*
|
||||
* This button works just like the printDeleteDocumentButton()
|
||||
*
|
||||
* @param object $item transmittal item to be deleted
|
||||
* @param string $msg message shown in case of successful deletion
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
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="fa fa-remove"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
protected function printDeleteItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.delete-transmittalitem-btn', function(ev){
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('removetransmittalitem')."';
|
||||
bootbox.dialog(confirmmsg, [{
|
||||
\"label\" : \"<i class='fa fa-remove'></i> ".getMLText("rm_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.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-transmittalitem-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"class\" : \"btn-cancel\",
|
||||
\"callback\": function() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
}
|
79
views/bootstrap/trait.TransmittalUpdateButton.php
Normal file
79
views/bootstrap/trait.TransmittalUpdateButton.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
trait TransmittalUpdateButton {
|
||||
/**
|
||||
* Print button for updating the transmittal item to the newest version
|
||||
*
|
||||
* @param object $item
|
||||
* @param string $msg message shown in case of successful update
|
||||
*/
|
||||
protected function printUpdateItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$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="fa fa-refresh"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
protected function printUpdateItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.update-transmittalitem-btn', function(ev){
|
||||
ev.stopPropagation();
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
transmittalid = $(ev.currentTarget).attr('transmittal');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('updatetransmittalitem')."';
|
||||
bootbox.dialog(confirmmsg, [{
|
||||
\"label\" : \"<i class='fa fa-refresh'></i> ".getMLText("update_transmittalitem")."\",
|
||||
\"class\" : \"btn-danger\",
|
||||
\"callback\": function() {
|
||||
$.ajax('../op/op.TransmittalMgr.php', {
|
||||
type:'POST',
|
||||
async:true,
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: 'updatetransmittalitem',
|
||||
id: id,
|
||||
formtoken: formtoken
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
$('div.ajax').trigger('update', {transmittalid: transmittalid});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"class\" : \"btn-cancel\",
|
||||
\"callback\": function() {
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
}
|
90
views/bootstrap4/trait.TransmittalDeleteButton.php
Normal file
90
views/bootstrap4/trait.TransmittalDeleteButton.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
trait TransmittalDeleteButton {
|
||||
/**
|
||||
* Print button with link for deleting a transmittal item
|
||||
*
|
||||
* This button works just like the printDeleteDocumentButton()
|
||||
*
|
||||
* @param object $item transmittal item to be deleted
|
||||
* @param string $msg message shown in case of successful deletion
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
protected function printDeleteItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$content .= '<a class="delete-transmittalitem-btn" transmittal="'.$item->getTransmittal()->getID().'" rel="'.$itemid.'" msg="'.htmlspecialchars($msg, ENT_QUOTES).'" confirmmsg="'.htmlspecialchars(getMLText("confirm_rm_transmittalitem"), ENT_QUOTES).'"><i class="fa fa-remove"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
protected function printDeleteItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.delete-transmittalitem-btn', function(ev){
|
||||
ev.stopPropagation();
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
transmittalid = $(ev.currentTarget).attr('transmittal');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('removetransmittalitem')."';
|
||||
bootbox.confirm({
|
||||
\"message\": confirmmsg,
|
||||
\"buttons\": {
|
||||
\"confirm\": {
|
||||
\"label\" : \"<i class='fa fa-remove'></i> ".getMLText("rm_transmittalitem")."\",
|
||||
\"className\" : \"btn-danger\",
|
||||
},
|
||||
\"cancel\": {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"className\" : \"btn-secondary\",
|
||||
}
|
||||
},
|
||||
\"callback\": function(result) {
|
||||
if(result) {
|
||||
$.ajax('".$this->params['settings']->_httpRoot."../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-transmittalitem-'+id).hide('slow');
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
$('div.ajax').trigger('update', {transmittalid: transmittalid});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
}
|
86
views/bootstrap4/trait.TransmittalUpdateButton.php
Normal file
86
views/bootstrap4/trait.TransmittalUpdateButton.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
trait TransmittalUpdateButton {
|
||||
/**
|
||||
* Print button for updating the transmittal item to the newest version
|
||||
*
|
||||
* @param object $item
|
||||
* @param string $msg message shown in case of successful update
|
||||
*/
|
||||
protected function printUpdateItemButton($item, $msg, $return=false){ /* {{{ */
|
||||
$itemid = $item->getID();
|
||||
$content = '';
|
||||
$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="fa fa-refresh"></i></a>';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
protected function printUpdateItemButtonJs(){ /* {{{ */
|
||||
echo "
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'a.update-transmittalitem-btn', function(ev){
|
||||
ev.stopPropagation();
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
transmittalid = $(ev.currentTarget).attr('transmittal');
|
||||
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
|
||||
msg = $(ev.currentTarget).attr('msg');
|
||||
formtoken = '".createFormKey('updatetransmittalitem')."';
|
||||
bootbox.dialog({
|
||||
\"message\": confirmmsg,
|
||||
\"buttons\": {
|
||||
\"confirm\": {
|
||||
\"label\" : \"<i class='fa fa-remove'></i> ".getMLText("update_transmittalitem")."\",
|
||||
\"className\" : \"btn-danger\",
|
||||
},
|
||||
\"cancel\": {
|
||||
\"label\" : \"".getMLText("cancel")."\",
|
||||
\"className\" : \"btn-secondary\",
|
||||
}
|
||||
},
|
||||
\"callback\": function(result) {
|
||||
if(result) {
|
||||
$.ajax('".$this->params['settings']->_httpRoot."../op/op.TransmittalMgr.php', {
|
||||
type:'POST',
|
||||
async:true,
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: 'updatetransmittalitem',
|
||||
id: id,
|
||||
formtoken: formtoken
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
noty({
|
||||
text: msg,
|
||||
type: 'success',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
$('div.ajax').trigger('update', {transmittalid: transmittalid});
|
||||
} else {
|
||||
noty({
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user