1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
|
window.onbeforeunload = function() {
removeDocumentReservations(document.getElementById("temp_id").value);
alert('Wprowadzone zmiany nie zostały zapisane');
}
function removeDocumentReservations(temp_id, operation) {
//alert(operation);
url='index.php?module=EcmStockOperations&action=deleteDocumentReservations&temp_doc_id='+temp_id+'&to_pdf=1';
var req=mint.Request();
req.OnSuccess = function() {
if (operation) {
if (operation=='cancel')
window.location="index.php?module=EcmInvoiceOuts&action=index";
if (operation=='list')
window.location="index.php?module=EcmInvoiceOuts&action=index";
}
}
req.Send(url);
}
function getProductQuantity(input,product_id, stock_id,old_qty, row)
{
url='index.php?module=EcmStockStates&action=getProductQuantity&stock_id='+stock_id+'&product_id='+product_id+'&to_pdf=1';
var req=mint.Request();
req.OnLoading=function()
{
input.innerHTML='loading';
}
req.OnSuccess = function()
{
console.log(old_qty);
if (row) {
if (parseFloat(this.responseText) != old_qty) {
row.className='orangeRow';
setTimeout(function() {row.className='selectedRow';}, 1500);
}
}
input.value=this.responseText;
}
req.Send(url);
}
function saveReservation(stock_id,product_id,quantity,temp_doc_id,temp_item_id,date, row){
url='index.php?module=EcmStockOperations&action=saveReservation&stock_id='+stock_id+'&product_id='+product_id+'&temp_doc_id='+temp_doc_id+'&temp_item_id='+temp_item_id+'&date='+date+'&quantity='+quantity+'&to_pdf=1';
var req=mint.Request();
req.OnSuccess = function(){
row.className='greenRow';
setTimeout(function() {row.className='selectedRow';}, 1500);
}
req.Send(url);
}
function removeReservation(cell) {
var temp_item_id = cell.parentNode.getData().temp_item_id;
url='index.php?module=EcmStockOperations&action=deleteReservation&temp_item_id='+temp_item_id+'&to_pdf=1';
var req=mint.Request();
req.OnSuccess = function(){}
req.Send(url);
}
function createEcmInvoiceOut() {
var selected_prod = false;
for(var i=0; i<N.rowCount(); i++) {
if (N.row(i).getData().checked ==1) selected_prod=true;
}
if (selected_prod==false) {alert('Musisz wybrać przynajmniej jeden produkt'); return; }
post = 'temp_id='+document.getElementById("temp_id").value+"&module=EcmServices&action=realizationListSetSession&to_pdf=1";
doRequest('index.php',post+ItemListSave(true),function(result){
window.onbeforeunload = '';
window.location="index.php?module=EcmInvoiceOuts&action=EditView&to_pdf=0&parent_doc_type=EcmServices&temp_id="+document.getElementById("temp_id").value;
}
);
}
function addEvent(object,eventName,do_function) {
if(typeof(object) == "string") object = document.getElementById(object);
if(!object) { alert('No object in function addEvent!'); return; }
if(object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on'+eventName, do_function);
}
}
function doRequest(where,post,doFunction,error) {
this.Display = function(result) { doFunction(result.responseText); }
this.Fail = function(result){ if(error) alert(error);}
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
ItemListSave = function(json) {
var data = '';
for(var i=0; i<N.rowCount(); i++) {
if (N.row(i).getData().checked ==1)
data = data + '&p_' + i.toString() + '=' + JSON.stringifyNoSecurity(N.row(i).getData());
}
return data;
}
var ERROR = false;
function ItemListClear() {
while(N.rowCount()>0) N.row(0).deleteRow();
}
var parentFL;
var productFL;
var contactFL;
addEvent(
window,
'load',
function () {
//initialize table
N = new MyTable('itemsTable');
N.divParent = document.getElementById('itemsTableDIV');
N.onCreateRow = function(row) {
row.newPos = false;
row.onSelect = function() {
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).style.height = OPT['row_item_height_selected'];
this.cells.item(i).change(
|