init
This commit is contained in:
131
modules/EcmProducts/javascript/ProductionCopyElements.js
Normal file
131
modules/EcmProducts/javascript/ProductionCopyElements.js
Normal file
@@ -0,0 +1,131 @@
|
||||
getCopyElements = function() {
|
||||
PTABLE = new EcmJsTable(pcolumns, $('#copyProduct'), 'EditView');
|
||||
|
||||
PTABLE.customQuickSearch = function(search) {
|
||||
// clear previous data
|
||||
this.items = new Array();
|
||||
// AJAX call
|
||||
var a = jQuery
|
||||
.ajax({
|
||||
type : 'POST',
|
||||
url : 'index.php?module=EcmProducts&action=ProductionTablesHelper&to_pdf=1',
|
||||
data : {
|
||||
job : 'searchProduct',
|
||||
searchText : search,
|
||||
},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
});
|
||||
return $.parseJSON(a.responseText);
|
||||
}
|
||||
|
||||
PTABLE.setItems(new Array());
|
||||
PTABLE.getHeaders();
|
||||
PTABLE.fillTable();
|
||||
|
||||
// create butons
|
||||
var b = $('<input></input>');
|
||||
b.addClass('button');
|
||||
b.attr('type', 'button');
|
||||
b.css('width', '100%');
|
||||
b.val('Komponenty');
|
||||
b
|
||||
.click(function() {
|
||||
var prod = PTABLE.getItems();
|
||||
if (prod.length == 0 || !prod[0].product_id
|
||||
|| prod[0].product_id == "") {
|
||||
alert('Wybierz produkt źródłowy');
|
||||
return;
|
||||
}
|
||||
if (CTABLE.getItemsCount() > 0)
|
||||
var keepitems = confirm("Zachować aktualne komponenty?");
|
||||
var i = jQuery
|
||||
.ajax({
|
||||
type : 'POST',
|
||||
url : 'index.php?module=EcmProducts&action=ProductionTablesHelper&to_pdf=1',
|
||||
data : {
|
||||
job : 'getItemsComponents',
|
||||
prod_id : prod[0].product_id,
|
||||
},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
});
|
||||
var response = $.parseJSON(i.responseText);
|
||||
if (response.length==0) {alert('Brak komponentów dla '+prod[0].product_code); return;}
|
||||
if (keepitems) {
|
||||
var items = CTABLE.getItems();
|
||||
$.each(response, function(c, i) {
|
||||
items.push(i)
|
||||
});
|
||||
} else
|
||||
var items = response;
|
||||
CTABLE.setItems(items);
|
||||
CTABLE.fillTable();
|
||||
});
|
||||
$('#copyButtons').append(b);
|
||||
|
||||
$('#copyButtons').append('<br>');
|
||||
//czynności
|
||||
var b = $('<input></input>');
|
||||
b.addClass('button');
|
||||
b.attr('type', 'button');
|
||||
b.css('width', '100%');
|
||||
b.val('Czynności');
|
||||
b
|
||||
.click(function() {
|
||||
var prod = PTABLE.getItems();
|
||||
if (prod.length == 0 || !prod[0].product_id
|
||||
|| prod[0].product_id == "") {
|
||||
alert('Wybierz produkt źródłowy');
|
||||
return;
|
||||
}
|
||||
if (ATABLE.getItemsCount() > 0)
|
||||
var keepitems = confirm("Zachować aktualne komponenty?");
|
||||
var i = jQuery
|
||||
.ajax({
|
||||
type : 'POST',
|
||||
url : 'index.php?module=EcmProducts&action=ProductionTablesHelper&to_pdf=1',
|
||||
data : {
|
||||
job : 'getItemsActions',
|
||||
prod_id : prod[0].product_id,
|
||||
},
|
||||
dataType : 'json',
|
||||
async : false,
|
||||
});
|
||||
var response = $.parseJSON(i.responseText);
|
||||
if (response.length==0) {alert('Brak czynności dla '+prod[0].product_code); return;}
|
||||
if (keepitems) {
|
||||
var items = ATABLE.getItems();
|
||||
$.each(response, function(c, i) {
|
||||
items.push(i)
|
||||
});
|
||||
} else
|
||||
var items = response;
|
||||
ATABLE.setItems(items);
|
||||
ATABLE.fillTable();
|
||||
});
|
||||
$('#copyButtons').append(b);
|
||||
}
|
||||
|
||||
var pcolumns = new Array();
|
||||
// end: number
|
||||
// begin: code
|
||||
pcolumns[0] = {
|
||||
'name' : 'product_',
|
||||
'label' : 'Kopiuj elementy z: ',
|
||||
'searchTrigger' : true,
|
||||
'width' : 100, // %
|
||||
'content' : new Array(),
|
||||
};
|
||||
pcolumns[0]['content'][0] = {
|
||||
'name' : 'id',
|
||||
'attr' : {
|
||||
'type' : 'hidden',
|
||||
}
|
||||
};
|
||||
pcolumns[0]['content'][1] = {
|
||||
'name' : 'code',
|
||||
'css' : {
|
||||
'text-align' : 'left',
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user