Add TPL files
This commit is contained in:
336
include/SugarFields/Fields/File/EditView.tpl
Executable file
336
include/SugarFields/Fields/File/EditView.tpl
Executable file
@@ -0,0 +1,336 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
<link rel="stylesheet" type="text/css" href="include/SugarFields/Fields/File/BarCss.css"/>
|
||||
<div id="dialogScanner1"></div>
|
||||
<div id="uploadFormDiv">
|
||||
</div>
|
||||
<div class="progress" id="progressBar" style="display:none;">
|
||||
<div class="bar"></div>
|
||||
<div class="percent">0%</div>
|
||||
</div>
|
||||
<div id="statusReturnPlace">
|
||||
{assign var='existUploadedFiles' value=";"|explode:{{sugarvar key='value' string=true}} }
|
||||
|
||||
{foreach from=$existUploadedFiles item=key}
|
||||
{assign var='values' value=":"|explode:$key }
|
||||
{if $values[0]!=''}
|
||||
<p id='picker_{$values[1]}'>Plik {$values[0]} wgrany.
|
||||
<input type='hidden' name='{{sugarvar key='name'}}_newname[]' value='{$values[1]}'/>
|
||||
<input type="hidden" name='{{sugarvar key='name'}}_orginal[]' value='{$values[0]}'/>
|
||||
<input type="hidden" name='{{sugarvar key='name'}}_type[]' value='{$values[2]}'/>
|
||||
<input class="button" type="button" value="Usuń" name="button" onclick="{literal}removeFile('{/literal}{$values[1]}{literal}');{/literal}">
|
||||
</p>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
{literal}
|
||||
|
||||
function addScanFile(){
|
||||
var html='';
|
||||
if($('#scannerPage').val()=='0'){
|
||||
html+="<p id='picker_"+$('#hiddenFileId').val()+"'>Dodano nowy skan "+$('#newScanfilename').val()+".jpeg<input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_newname[]' value='"+$('#hiddenFileId').val()+"'/>";
|
||||
html+="<input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_orginal[]' value='"+$('#newScanfilename').val()+".jpeg'/>";
|
||||
html+=" <input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_type[]' value='image/jpeg'/>";
|
||||
onclick='removeFile("'+$('#hiddenFileId').val()+'");';
|
||||
html+=" <input class='button' type='button' value='Usuń' name='button' onclick='"+onclick+"');'></p>";
|
||||
$("#statusReturnPlace").append(html);
|
||||
$( "#dialogScanner1").dialog( "close" );
|
||||
} else {
|
||||
html+="<p id='picker_"+$('#hiddenFileId').val()+"'>Dodano nowy skan "+$('#newScanfilename').val()+".pdf<input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_newname[]' value='"+$('#hiddenFileId').val()+"'/>";
|
||||
html+="<input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_orginal[]' value='"+$('#newScanfilename').val()+".pdf'/>";
|
||||
html+=" <input type='hidden' name='{/literal}{{sugarvar key='name'}}{literal}_type[]' value='application/pdf'/>";
|
||||
onclick='removeFile("'+$('#hiddenFileId').val()+'");';
|
||||
html+=" <input class='button' type='button' value='Usuń' name='button' onclick='"+onclick+"');'></p>";
|
||||
$("#statusReturnPlace").append(html);
|
||||
$( "#dialogScanner1").dialog( "close" );
|
||||
}
|
||||
}
|
||||
|
||||
function justScan(){
|
||||
var params = {
|
||||
job : 'justScanCheck',
|
||||
scanner : $('#scannerId').val(),
|
||||
nameField : '{/literal}{{sugarvar key='name'}}{literal}',
|
||||
check : '0',
|
||||
type : $('#scannerPage').val(),
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : 'index.php?entryPoint=uploadAjaxFile',
|
||||
dataType : "html",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data == 'false') {
|
||||
$('#ajaxScannerStatus').html('Nie można zeskanować dokumentu!');
|
||||
|
||||
} else {
|
||||
if($('#scannerPage').val()=='0'){
|
||||
$('#ajaxScannerStatus').html('<img width="800px" src="upload/'+data+'"><input type="hidden" id="hiddenFileId" value="'+data+'">');
|
||||
$( "#dialogScanner1").dialog( "option", "width", 1000 );
|
||||
} else {
|
||||
|
||||
$('#ajaxScannerStatus').html('Dodano zbiorczy skan.<input type="hidden" id="hiddenFileId" value="'+data+'">');
|
||||
window.open('upload/'+data);
|
||||
}
|
||||
|
||||
}
|
||||
console.log(data);
|
||||
//$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data : params
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function tmpName(){
|
||||
var fullDate = new Date();
|
||||
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1);
|
||||
|
||||
var currentDate = 'skan_'+fullDate.getDate() + "_" + twoDigitMonth + "_" + fullDate.getFullYear()+'_'+fullDate.getHours()+'_'+fullDate.getMinutes();
|
||||
return currentDate;
|
||||
}
|
||||
|
||||
function drawScannerDialog(data){
|
||||
var html="<table><tr><td>Urządzenie: </td><td><select id='scannerId' name='scannerId'>"
|
||||
$.each( data, function( key, value ) {
|
||||
html+="<option value='"+value.id+"'>"+value.name+'</option>';
|
||||
console.log( key + ": " + value );
|
||||
});
|
||||
html+="</select></td></tr><tr><td>Źródło:</td><td><select id='scannerPage' name='scannerPage'><option value='0' selected>Tafla</option><option value='1'>Podajnik</option></select></td></tr>";
|
||||
html+="<tr><td>Nazwa pliku:</td><td><input type='text' id='newScanfilename' value='"+tmpName()+"'></td></tr>";
|
||||
html+="<tr><td><input type='button' name='letsScan' onClick='DoScanCheck();' value='Skanuj'></td>";
|
||||
html+="<td><input type='button' name='addScanFile' onClick='addScanFile()' value='Dodaj'></td></tr></table><div id='ajaxScannerStatus'></div>";
|
||||
|
||||
$( "#dialogScanner1").html(html);
|
||||
$( "#dialogScanner1").dialog({
|
||||
title: "Wybierz skaner",
|
||||
open: function() { // open event handler
|
||||
$(this) // the element being dialogged
|
||||
.parent() // get the dialog widget element
|
||||
.find(".ui-dialog-titlebar-close") // find the close button for this dialog
|
||||
.hide(); // hide it
|
||||
},
|
||||
width: 300,
|
||||
modal: true,
|
||||
buttons: {
|
||||
'Zamknij': function() {
|
||||
$( this ).dialog( "close" );
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function DoScanCheck(){
|
||||
$('#ajaxScannerStatus').html('Sprawdzam skaner...<img src="include/SugarFields/Fields/File/gif-load.gif">');
|
||||
|
||||
var params = {
|
||||
job : 'justScanCheck',
|
||||
scanner : $('#scannerId').val(),
|
||||
nameField : '{/literal}{{sugarvar key='name'}}{literal}',
|
||||
check : '1'
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : 'index.php?entryPoint=uploadAjaxFile',
|
||||
dataType : "html",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data == 'false') {
|
||||
$('#ajaxScannerStatus').html('Sprawdz czy skaner jest włączony lub konfigurację!');
|
||||
|
||||
} else {
|
||||
$('#ajaxScannerStatus').html('Trwa skanowanie dokumentu...<img src="include/SugarFields/Fields/File/gif-load.gif">');
|
||||
justScan();
|
||||
|
||||
}
|
||||
//$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
|
||||
function DrawScannerList(data){
|
||||
var html="Urządzenie: <select id='scannerId' name='scannerId'>"
|
||||
$.each( data, function( key, value ) {
|
||||
html+="<option value='"+value.id+"'>"+value.name+'</option>';
|
||||
console.log( key + ": " + value );
|
||||
});
|
||||
html+="</select><br><input type='button' name='letsScan' onClick='DoScan();' value='Start'>";
|
||||
return html;
|
||||
}
|
||||
|
||||
function getScannerList(){
|
||||
|
||||
var params = {
|
||||
job : 'getScannerList',
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : 'index.php?entryPoint=uploadAjaxFile',
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data != '-1') {
|
||||
|
||||
drawScannerDialog(data);
|
||||
|
||||
|
||||
}
|
||||
//$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data : params
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function removeFile(id){
|
||||
var params = {
|
||||
delete : 'delete',
|
||||
record : id,
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : 'index.php?entryPoint=uploadAjaxFile',
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data != '-1') {
|
||||
|
||||
console.log('dziala');
|
||||
$( "#picker_"+id ).remove();
|
||||
|
||||
|
||||
}
|
||||
//$(".loading_panel").css("display", "none");
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
|
||||
$("div#uploadFormDiv")
|
||||
.append(
|
||||
// Creating Form Div and Adding <h2> and <p> Paragraph Tag in it.
|
||||
$("<form/>", {
|
||||
action : 'index.php?entryPoint=uploadAjaxFile',
|
||||
method : 'POST',
|
||||
enctype : "multipart/form-data",
|
||||
id : 'UploadFormAjax'
|
||||
}).append(
|
||||
// Create <form> Tag and Appending in HTML Div form1.
|
||||
|
||||
$("<input/>", {
|
||||
type : 'button',
|
||||
id : 'loadImage',
|
||||
value : 'Skanuj',
|
||||
onClick :"getScannerList();",
|
||||
}),
|
||||
$("<input/>", {
|
||||
type : 'hidden',
|
||||
id : 'uploadFieldName',
|
||||
value : '{/literal}{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}{literal}',
|
||||
name : 'uploadFieldName',
|
||||
}), // Creating Input Element With Attribute.
|
||||
$("<span/>",{
|
||||
html:'lub'
|
||||
}), $("<input/>", {
|
||||
type : 'file',
|
||||
id : '{/literal}{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}{literal}',
|
||||
name : '{/literal}{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}[]{literal}',
|
||||
onChange : "{/literal}$('#UploadFormAjax').submit();{literal}",
|
||||
multiple : ''
|
||||
}), // Creating Input Element With Attribute.
|
||||
$("<div/>",{
|
||||
style: "border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;",
|
||||
id: 'deviceDiv'
|
||||
}),
|
||||
|
||||
$("<br/>"), $("<input/>", {
|
||||
type : 'submit',
|
||||
id : 'submit',
|
||||
value : 'Załaduj pliki',
|
||||
style :'display:none',
|
||||
})
|
||||
|
||||
));
|
||||
|
||||
|
||||
$(document)
|
||||
.ready(
|
||||
function() {
|
||||
|
||||
(function() {
|
||||
|
||||
var bar = $('.bar');
|
||||
var percent = $('.percent');
|
||||
var status = $('#statusReturnPlace');
|
||||
|
||||
|
||||
$('#UploadFormAjax').ajaxForm(
|
||||
{
|
||||
beforeSend : function() {
|
||||
$('#progressBar').show();
|
||||
//status.empty();
|
||||
var percentVal = '0%';
|
||||
bar.width(percentVal)
|
||||
percent.html(percentVal);
|
||||
},
|
||||
uploadProgress : function(event, position, total,
|
||||
percentComplete) {
|
||||
var percentVal = percentComplete + '%';
|
||||
bar.width(percentVal)
|
||||
percent.html(percentVal);
|
||||
//console.log(percentVal, position, total);
|
||||
},
|
||||
success : function() {
|
||||
var percentVal = '100%';
|
||||
bar.width(percentVal)
|
||||
percent.html(percentVal);
|
||||
},
|
||||
complete : function(xhr) {
|
||||
status.append(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
});
|
||||
{/literal}
|
||||
</script>
|
||||
Reference in New Issue
Block a user