update PHP Excel
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<link type="image/x-icon" href="images/favicon.ico" rel="shortcut icon" />
|
||||
<link type="image/png" href="images/favicon_32.png" rel="icon" sizes="32x32" />
|
||||
<link type="text/css" href="style/jsgrid.css" rel="stylesheet" media="all" />
|
||||
<link type="text/css" href="style/jsgrid-theme.css" rel="stylesheet" media="all" />
|
||||
<link type="text/css" href="style/pedidor.css" rel="stylesheet" media="all" />
|
||||
<script type="text/javascript" src="script/jquery.js"></script>
|
||||
<script type="text/javascript" src="script/jquery.mods.js"></script>
|
||||
@@ -13,7 +14,7 @@
|
||||
var oPedidor = new Pedidor(asGlobalVars);
|
||||
$(document).ready(oPedidor.init);
|
||||
</script>
|
||||
<title>Pedidor</title>
|
||||
<title>Gestion de Pedidos</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
@@ -12,15 +12,13 @@
|
||||
<script type="text/javascript">
|
||||
oPedidor.pageInit = function(asHash, bFirstPage)
|
||||
{
|
||||
//$('#header, #menu, #footer').hide();
|
||||
$('#header, #menu, #footer').hide();
|
||||
|
||||
$('#login').addDefaultValue('Nombre');
|
||||
$('#pass').addDefaultValue('Codigo');
|
||||
|
||||
$(window).keyup(function(e){if(e.which==13) logMeIn();});
|
||||
$('#validate').addButton('enter', 'Entrar', logMeIn);
|
||||
|
||||
//$('#logon').fadeIn('slow');
|
||||
oSubmitButton = $('#validate').addButton('enter', 'Entrar', logMeIn/*, '', '', false, true*/);
|
||||
};
|
||||
|
||||
//oPedidor.onFeedback = function(sType, sMsg){feedback('.credentials', sType, sMsg)};
|
||||
@@ -34,11 +32,19 @@ function logMeIn()
|
||||
getInfo
|
||||
(
|
||||
'logmein',
|
||||
function(){oPedidor.setHash(oPedidor.consts.default_page);},
|
||||
self.loadHome,
|
||||
{token:md5(sLogin)+oPedidor.consts.token_sep+getLoginToken(sPass)},
|
||||
function(sDesc){self.onFeedback('error', sDesc);}
|
||||
function(sDesc){
|
||||
//oSubmitButton.stopProcess();
|
||||
self.onFeedback('error', sDesc);
|
||||
},
|
||||
oSubmitButton
|
||||
);
|
||||
}
|
||||
else self.onFeedback('warning', 'Formulario incompleto');
|
||||
else
|
||||
{
|
||||
//oSubmitButton.stopProcess();
|
||||
self.onFeedback('warning', 'Formulario incompleto');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,88 +1,135 @@
|
||||
<div id="products"></div>
|
||||
<div id="products">
|
||||
<div id="product_menu"></div>
|
||||
<div id="progress">
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<input id="uploader" type="file" multiple="" name="files[]" style="display:none;" />
|
||||
<div id="product_list"></div>
|
||||
<div id="product_list">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
oPedidor.pageInit = function(asHash, bFirstPage)
|
||||
{
|
||||
//Upload Excel File
|
||||
$('#product_menu').addButton('upload', 'cargar excel', function(){$('#uploader').click();}, '', 'fileupload', true);
|
||||
//Export button
|
||||
$('#product_menu')
|
||||
.addButton('excel', 'Descargar en Excel', oPedidor.getActionLink('dl_products'), '')
|
||||
.addButton('search', 'Buscar por un producto', function(){switchToMode('search');}, '')
|
||||
.addButton('add', 'Añadir un producto', function(){switchToMode('insert');}, '');
|
||||
|
||||
self.tmp('file_count', 0);
|
||||
$(function ()
|
||||
function switchToMode(sMode)
|
||||
{
|
||||
$('#uploader').fileupload(
|
||||
{
|
||||
url: self.getActionLink('upload_excel'),
|
||||
dropZone: $('#fileupload'),
|
||||
sequentialUploads: true,
|
||||
formData: {script:true},
|
||||
acceptFileTypes:'/(\.|\/)(xlsx?|ods)$/i',
|
||||
dataType: 'json',
|
||||
autoUpload: true,
|
||||
start: function(e)
|
||||
{
|
||||
$('#progress .bar').width('0%').parent().slideDown('fast');
|
||||
},
|
||||
stop: function(e)
|
||||
{
|
||||
if(self.tmp('file_count')>0) self.onFeedback('success', '¡Terminado!');
|
||||
},
|
||||
/*done: function(e, data)
|
||||
{
|
||||
$.each(data.files, function (index, file)
|
||||
{
|
||||
self.tmp('file_count', self.tmp('file_count') + 1);
|
||||
$('#upload_log').find('.success').text('¡Terminado!');
|
||||
});
|
||||
},*/
|
||||
fail: function(e, data)
|
||||
{
|
||||
$.each(data.files, function (index, file)
|
||||
{
|
||||
self.onFeedback('error', 'Error con "'+file.name+'"');
|
||||
});
|
||||
console.log(e);
|
||||
},
|
||||
progressall: function(e, data)
|
||||
{
|
||||
var progress = parseInt(data.loaded / data.total * 100, 10);
|
||||
$('#progress .bar').stop().animate({width:progress+'%'}, 'fast', function(){if(progress==100) $('#progress').delay(1000).slideUp('slow');});
|
||||
},
|
||||
/*drop: function (e, data)
|
||||
{
|
||||
$.each(data.files, function(index, file){debug('Dropped file: '+file.name);});
|
||||
},
|
||||
change: function (e, data)
|
||||
{
|
||||
$.each(data.files, function (index, file){debug('Selected file: '+file.name);});
|
||||
}*/
|
||||
});
|
||||
});
|
||||
var $SwitchBtn = $('.jsgrid-mode-button');
|
||||
if($SwitchBtn.hasClass('jsgrid-'+sMode+'-mode-button')) $SwitchBtn.click();
|
||||
$('.jsgrid-'+sMode+'-row').find('td').eq(1).find('input').focus();
|
||||
}
|
||||
|
||||
$(document).bind('drop dragover', function(e){e.preventDefault();});
|
||||
$(document).bind('dragover', function(e)
|
||||
{
|
||||
var dropZone = $('#fileupload'), timeout = window.dropZoneTimeout;
|
||||
var found = false, node = e.target;
|
||||
do
|
||||
{
|
||||
if(node === dropZone[0])
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
} while(node != null);
|
||||
getInfo('products', function(asData){
|
||||
|
||||
dropZone.toggleClass('hover', found);
|
||||
});
|
||||
//Adding null values
|
||||
asData.mat_types.unshift({'id':0, 'text':'Todos'});
|
||||
|
||||
//Building controller
|
||||
var oController = {
|
||||
|
||||
modifyProduct: function(sActionType, oProduct, sSuccessMsg)
|
||||
{
|
||||
var d = $.Deferred();
|
||||
getInfo('product',
|
||||
function(asItem){d.resolve(asItem); oPedidor.onFeedback('success', asItem.Producto+' '+sSuccessMsg)},
|
||||
{t:sActionType, item:oProduct},
|
||||
function(sMsg){oPedidor.onFeedback('error', sMsg);d.resolve({});});
|
||||
|
||||
return d.promise();
|
||||
},
|
||||
|
||||
loadData: function(filter) { //search
|
||||
return $.grep(this.products, function(product) {
|
||||
|
||||
var bValidProducto = (!filter.Producto || removeDiacritics(product.Producto).toLowerCase().indexOf(removeDiacritics(filter.Producto).toLowerCase()) > -1);
|
||||
var bValidCat = (!filter.Categoria || product.Categoria == filter.Categoria);
|
||||
var bValidZeta = (!filter['Codigo Zeta'] || product['Codigo Zeta'].indexOf(filter['Codigo Zeta']) > -1);
|
||||
var bValidPrice = (!filter.Precio || product.Precio >= filter.Precio);
|
||||
|
||||
return bValidProducto && bValidCat && bValidZeta && bValidPrice;
|
||||
});
|
||||
},
|
||||
|
||||
insertItem: function(oProduct) {
|
||||
//Add to search
|
||||
this.products.push(oProduct);
|
||||
|
||||
return this.modifyProduct(self.consts.rest.insert, oProduct, 'añadido');
|
||||
},
|
||||
|
||||
updateItem: function(oProduct) {
|
||||
console.log(oProduct);
|
||||
return this.modifyProduct(self.consts.rest.update, oProduct, 'modificado');
|
||||
},
|
||||
|
||||
deleteItem: function(oProduct) {
|
||||
//remove from search
|
||||
var productIndex = $.inArray(oProduct, this.products);
|
||||
this.products.splice(productIndex, 1);
|
||||
|
||||
return this.modifyProduct(self.consts.rest.remove, oProduct, 'borrado');
|
||||
}
|
||||
};
|
||||
window.oController = oController;
|
||||
oController.products = asData.products;
|
||||
oController.mat_types = asData.mat_types;
|
||||
|
||||
$("#product_list").jsGrid({
|
||||
width: "100%",
|
||||
height: "calc(100% - 3em)",
|
||||
filtering: true,
|
||||
selecting:true,
|
||||
inserting:true,
|
||||
editing: true,
|
||||
sorting: true,
|
||||
paging: false,
|
||||
autoload: true,
|
||||
controller: oController,
|
||||
noDataContent: 'No hay resultados (lo siento)',
|
||||
confirmDeleting:true,
|
||||
deleteConfirm: function(oItem){return '¿Está seguro que quiere borrar permanentemente el producto "'+oItem.Producto+'"?';},
|
||||
fields: [
|
||||
{name: 'Categoria', type: 'select', width:80, items: oController.mat_types, valueField:'id', textField:'text'},
|
||||
{name: 'Codigo Zeta', type: 'text', width: 50},
|
||||
{name: 'Producto', type:'text', width:200},
|
||||
{name: 'Precio', type:'money', width:50},
|
||||
{
|
||||
type: 'control',
|
||||
editButton: true,
|
||||
deleteButton:true,
|
||||
inserting:true,
|
||||
modeSwitchButton:true,
|
||||
searchModeButtonTooltip: "Cambiar a Buscar",
|
||||
insertModeButtonTooltip: "Cambiar a añadir",
|
||||
editButtonTooltip: "Editar",
|
||||
deleteButtonTooltip: "Borrar",
|
||||
searchButtonTooltip: "Buscar",
|
||||
clearFilterButtonTooltip: "Borrar filtros",
|
||||
insertButtonTooltip: "Insertar",
|
||||
updateButtonTooltip: "Actualisar",
|
||||
cancelEditButtonTooltip: "Cancelar"
|
||||
}
|
||||
],
|
||||
onItemInserting: function(args) {
|
||||
args.cancel = true;
|
||||
if(args.item.Categoria == '0') oPedidor.onFeedback('warning', 'Eligir una categoria');
|
||||
else if(args.item.Producto == '') oPedidor.onFeedback('warning', 'No hay ningun descricion por este producto');
|
||||
else if(args.item.Precio <= 0) oPedidor.onFeedback('warning', 'Un producto gratis, uhm?');
|
||||
else args.cancel = false;
|
||||
},
|
||||
onRefreshed:function(){
|
||||
// $('.jsgrid-search-button').buildClone();
|
||||
}
|
||||
});
|
||||
}, {}, function(msg){feedback('error', msg);});
|
||||
};
|
||||
|
||||
function uploadExcel()
|
||||
{
|
||||
}
|
||||
</script>
|
||||
|
||||
$.prototype.buildClone = function() {
|
||||
var $This = $(this);
|
||||
|
||||
|
||||
return $This;
|
||||
};
|
||||
</script>
|
||||
@@ -2,11 +2,11 @@
|
||||
<div id="menu">
|
||||
<ul>
|
||||
<li><a href="#crear_pedido"><i class="fa add-order"></i> crear pedido</a></li>
|
||||
<li><a href="#pedidos"><i class="fa search"></i> busqueda pedidos</a></li>
|
||||
<li><a href="#pedidos"><i class="fa followup"></i> Seguimiento pedidos</a></li>
|
||||
<li><a href="#productos"><i class="fa list"></i> listado productos</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="main"></div>
|
||||
<div id="footer">
|
||||
Designed and powered by Franzz & Clarita. Proyecto Gestion de Pedidos bajo licencia <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GPLv3</a>.
|
||||
Designed and powered by Franzz & Clarita. Proyecto Micro Negrin bajo licencia <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GPLv3</a>
|
||||
</div>
|
||||
Reference in New Issue
Block a user