Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var totalSection = '0';
- var controller = 'purchasing_system/order';
- var base_url = 'http://www.enumaelise.com/tulip/index.php';
- var order_type_price;
- function getStock(id_branch){
- $.ajax({
- 'url' : base_url + '/' + controller + '/getStock',
- 'type' : 'POST',
- 'data' : {'id_branch' : id_branch},
- 'success' : function(data){
- var container = $('#stock');
- container.html(data);
- }
- });
- }
- function setTypePrice(id_branch){
- $.ajax({
- 'url' : base_url + '/' + controller + '/setTypePrice',
- 'type' : 'POST',
- 'data' : {'id_branch' : id_branch},
- 'success' : function(data){
- order_type_price = data;
- document.getElementsByName('orderList[type_price]')[0].value = data;
- }
- });
- }
- function generateMemberOption(id_unit){
- $.ajax({
- 'url' : base_url + '/' + controller + '/generateMemberOption',
- 'type' : 'POST',
- 'data' : {'id_unit' : id_unit},
- 'success' : function(data){
- var container = $('.memberOption');
- container.html(data);
- $('#content').html('');
- }
- });
- }
- function generateMemberDetails(id_user){
- $.ajax({
- 'url' : base_url + '/' + controller + '/generateMemberDetails',
- 'type' : 'POST',
- 'data' : {'id_user' : id_user},
- 'success' : function(data){
- var container = $('.memberDetails');
- container.html(data);
- order_id_user = id_user;
- $('#content').html('');
- totalSection = '0';
- var orderMain = document.createElement('article');
- orderMain.setAttribute('id', 'orderMain');
- var firstSection = document.createElement('section');
- firstSection.setAttribute('id', 'section'+totalSection);
- var result = document.createElement('article');
- result.setAttribute('class', 'right');
- result.setAttribute('id', 'result');
- orderMain.appendChild(firstSection);
- $('#content').append(orderMain);
- $('#content').append(result);
- generateOrderSection(totalSection).done(function() { });
- }
- });
- }
- function generateOrderSection(section_number)
- {
- return $.ajax({
- 'url' : base_url + '/' + controller + '/generateOrderSection',
- 'type' : 'POST',
- 'data' : {'section_number' : section_number},
- 'dataType' : 'json',
- 'success' : function(data){
- document.getElementById('section'+section_number).innerHTML = data[0];
- generatePurchaseTypeList(section_number);
- }
- });
- }
- function generatePurchaseTypeList(section_number)
- {
- $.ajax({
- 'url' : base_url + '/' + controller + '/generatePurchaseTypeList',
- 'type' : 'POST',
- 'data' : {'section_number' : section_number},
- 'success' : function(data){
- document.getElementById('purchaseType_' + section_number).innerHTML = data;
- var input = 'purchaseType' + section_number;
- var datalist = 'purchaseTypeList' + section_number;
- document.getElementById(input).addEventListener('input', function()
- {
- var id_purchaseType = $('#'+datalist).find('option[value="'+this.value+'"]').attr('id');
- var id_promo = 0;
- generatePromoList(section_number, id_purchaseType);
- document.getElementById('product_' + section_number).innerHTML = '<input type="hidden" id="lineNumber'+section_number+'" value="0">';
- generateProductList(section_number, id_purchaseType, id_promo);
- document.getElementById('total_' + section_number).innerHTML = '';
- document.getElementsByName('orderList['+section_number+'][purchaseType]')[0].value = id_purchaseType;
- if(parseInt(section_number) == totalSection)
- {
- totalSection = parseInt(totalSection) + 1;
- var section = document.createElement('section');
- section.setAttribute('id', 'section'+totalSection);
- $('#orderMain').append(section);
- generateOrderSection(totalSection).done(function() { });
- }
- showStock();
- });
- }
- });
- }
- function generatePromoList(section_number, type_purchase)
- {
- var form_data = {
- section_number: section_number,
- type_purchase: type_purchase
- };
- $.ajax({
- 'url' : base_url + '/' + controller + '/generatePromoList',
- 'type' : 'POST',
- 'data' : form_data,
- 'success' : function(data){
- document.getElementById('promo_' + section_number).innerHTML = data;
- var input = 'promo' + section_number;
- var datalist = 'promoList' + section_number;
- document.getElementById(input).addEventListener('input', function()
- {
- var id_purchaseType = 0;
- var id_promo = $('#'+datalist).find('option[value="'+this.value+'"]').attr('id');
- generateProductList(section_number, id_purchaseType, id_promo);
- document.getElementsByName('orderList['+section_number+'][promo]')[0].value = id_promo;
- document.getElementById('product_' + section_number).innerHTML = '<input type="hidden" id="lineNumber'+section_number+'" value="0">';
- showStock();
- });
- }
- });
- }
- function generateProductList(section_number, type_purchase, id_promo)
- {
- var form_data = {
- section_number: section_number,
- type_purchase: type_purchase,
- id_promo: id_promo,
- type_price: order_type_price
- };
- $.ajax({
- 'url' : base_url + '/' + controller + '/generateProductList',
- 'type' : 'POST',
- 'data' : form_data,
- 'success' : function(data){
- addProductLine(section_number, data);
- }
- });
- }
- function addProductLine(section_number, data)
- {
- var lineNumber = parseInt($('#lineNumber' + section_number).val());
- var label = 'product'+section_number+lineNumber;
- var input = 'product'+section_number+lineNumber;
- var datalist = 'productList'+section_number+lineNumber;
- var cover = document.createElement('div');
- cover.setAttribute('id', 'productLine'+section_number+lineNumber);
- var productLabel = document.createElement('label');
- productLabel.setAttribute('for', label);
- productLabel.innerHTML = 'Product: ';
- var productInput = document.createElement('input');
- productInput.type = 'text';
- productInput.setAttribute('id', input);
- productInput.setAttribute('list', datalist);
- var productDatalist = document.createElement('datalist');
- productDatalist.setAttribute('id', datalist);
- productDatalist.innerHTML = data;
- var idProduct = document.createElement('input');
- idProduct.type = 'hidden';
- idProduct.setAttribute('name', 'orderList['+section_number+'][idProduct]['+lineNumber+']');
- var price = document.createElement('input');
- price.type = 'hidden';
- price.setAttribute('name', 'orderList['+section_number+'][price]['+lineNumber+']');
- var pv = document.createElement('input');
- pv.type = 'hidden';
- pv.setAttribute('name', 'orderList['+section_number+'][pv]['+lineNumber+']');
- var omset = document.createElement('input');
- omset.type = 'hidden';
- omset.setAttribute('name', 'orderList['+section_number+'][omset]['+lineNumber+']');
- var komisi = document.createElement('input');
- komisi.type = 'hidden';
- komisi.setAttribute('name', 'orderList['+section_number+'][komisi]['+lineNumber+']');
- label = 'qty'+section_number+lineNumber;
- input = 'qty'+section_number+lineNumber;
- width = 'width: 6em;';
- var qtyLabel = document.createElement('label');
- qtyLabel.setAttribute('for', label);
- qtyLabel.innerHTML = 'Qty: ';
- var qtyInput = document.createElement('input');
- qtyInput.type = 'number';
- qtyInput.setAttribute('id', input);
- qtyInput.setAttribute('name', 'orderList['+section_number+'][qty]['+lineNumber+']');
- qtyInput.setAttribute('style', width);
- label = 'qtyGiven'+section_number+lineNumber;
- input = 'qtyGiven'+section_number+lineNumber;
- var qtyGivenLabel = document.createElement('label');
- qtyGivenLabel.setAttribute('for', label);
- qtyGivenLabel.innerHTML = 'Qty Given: ';
- var qtyGivenInput = document.createElement('input');
- qtyGivenInput.type = 'number';
- qtyGivenInput.setAttribute('id', input);
- qtyGivenInput.setAttribute('name', 'orderList['+section_number+'][qtyGiven]['+lineNumber+']');
- qtyGivenInput.setAttribute('style', width);
- cover.appendChild(productLabel);
- cover.appendChild(productInput);
- cover.appendChild(productDatalist);
- cover.appendChild(idProduct);
- cover.appendChild(price);
- cover.appendChild(pv);
- cover.appendChild(omset);
- cover.appendChild(komisi);
- cover.appendChild(qtyLabel);
- cover.appendChild(qtyInput);
- cover.appendChild(qtyGivenLabel);
- cover.appendChild(qtyGivenInput);
- var details = document.createElement('span');
- details.setAttribute('id', 'details'+section_number+lineNumber);
- label = 'price'+section_number+lineNumber;
- input = 'price'+section_number+lineNumber;
- var priceLabel = document.createElement('label');
- priceLabel.setAttribute('for', label);
- priceLabel.innerHTML = 'Price: ';
- var priceInput = document.createElement('input');
- priceInput.type = 'text';
- priceInput.setAttribute('id', input);
- priceInput.setAttribute('disabled', 'disabled');
- priceInput.setAttribute('style', width);
- label = 'pv'+section_number+lineNumber;
- input = 'pv'+section_number+lineNumber;
- var pvLabel = document.createElement('label');
- pvLabel.setAttribute('for', label);
- pvLabel.innerHTML = 'PV: ';
- var pvInput = document.createElement('input');
- pvInput.type = 'text';
- pvInput.setAttribute('id', input);
- pvInput.setAttribute('disabled', 'disabled');
- pvInput.setAttribute('style', width);
- label = 'omset'+section_number+lineNumber;
- input = 'omset'+section_number+lineNumber;
- var omsetLabel = document.createElement('label');
- omsetLabel.setAttribute('for', label);
- omsetLabel.innerHTML = 'Omset: ';
- var omsetInput = document.createElement('input');
- omsetInput.type = 'text';
- omsetInput.setAttribute('id', input);
- omsetInput.setAttribute('disabled', 'disabled');
- omsetInput.setAttribute('style', width);
- label = 'komisi'+section_number+lineNumber;
- input = 'komisi'+section_number+lineNumber;
- var komisiLabel = document.createElement('label');
- komisiLabel.setAttribute('for', label);
- komisiLabel.innerHTML = 'Komisi: ';
- var komisiInput = document.createElement('input');
- komisiInput.type = 'text';
- komisiInput.setAttribute('id', input);
- komisiInput.setAttribute('disabled', 'disabled');
- komisiInput.setAttribute('style', width);
- details.appendChild(priceLabel);
- details.appendChild(priceInput);
- details.appendChild(pvLabel);
- details.appendChild(pvInput);
- details.appendChild(omsetLabel);
- details.appendChild(omsetInput);
- details.appendChild(komisiLabel);
- details.appendChild(komisiInput);
- cover.appendChild(details);
- $('#product_'+section_number).append(cover);
- var input = 'product' + section_number + lineNumber;
- var datalist = 'productList' + section_number + lineNumber;
- document.getElementById(input).addEventListener('input', function()
- {
- var id_product = $('#'+datalist).find('option[value="'+this.value+'"]').attr('id');
- var purchaseType = document.getElementsByName('orderList['+section_number+'][purchaseType]')[0].value;
- var promo = document.getElementsByName('orderList['+section_number+'][promo]')[0].value;
- document.getElementsByName('orderList['+section_number+'][idProduct]['+lineNumber+']')[0].value = id_product;
- generateProductDetails(section_number, lineNumber, purchaseType, promo, id_product, order_type_price);
- showStock();
- });
- var input = 'qty' + section_number + lineNumber;
- var datalist = 'productList' + section_number + lineNumber;
- document.getElementById(input).addEventListener('input', function()
- {
- var id_product = document.getElementsByName('orderList['+section_number+'][idProduct]['+lineNumber+']')[0];
- if(id_product && id_product.value && id_product.value != 0)
- {
- id_product = document.getElementsByName('orderList['+section_number+'][idProduct]['+lineNumber+']')[0].value;
- document.getElementsByName('orderList['+section_number+'][qtyGiven]['+lineNumber+']')[0].value = this.value;
- var totalLine = parseInt($('#lineNumber' + section_number).val());
- $('#lineNumber' + section_number).val(lineNumber + 1);
- var purchaseType = document.getElementsByName('orderList['+section_number+'][purchaseType]')[0].value;
- var promo = document.getElementsByName('orderList['+section_number+'][promo]')[0].value;
- generateProductList(section_number, purchaseType, promo);
- if(parseInt(lineNumber) < totalLine)
- {
- for(i=parseInt(lineNumber)+1; i<totalLine+1; i++)
- {
- document.getElementById('productLine' + section_number + i).remove();
- }
- }
- total();
- showStock();
- }
- });
- var input = 'qtyGiven' + section_number + lineNumber;
- document.getElementById(input).addEventListener('input', function()
- {
- var qty = document.getElementsByName('orderList['+section_number+'][qty]['+lineNumber+']')[0].value;
- if(this.value >= qty)
- {
- this.value = qty;
- }
- showStock();
- });
- }
- function generateProductDetails(section_number, line_number, type_purchase, id_promo, id_product, type_price)
- {
- var form_data = {
- type_purchase: type_purchase,
- id_promo: id_promo,
- id_product: id_product,
- type_price: type_price
- };
- $.ajax({
- 'url' : base_url + '/' + controller + '/generateProductDetails',
- 'type' : 'POST',
- 'data' : form_data,
- 'dataType' : 'json',
- 'success' : function(data){
- addDetails(section_number, line_number, data);
- }
- });
- }
- function addDetails(section_number, line_number, data)
- {
- document.getElementsByName('orderList['+section_number+'][price]['+line_number+']')[0].value = data['price'];
- document.getElementsByName('orderList['+section_number+'][pv]['+line_number+']')[0].value = toFixed(data['pv'], 2);
- document.getElementsByName('orderList['+section_number+'][omset]['+line_number+']')[0].value = data['omset'];
- document.getElementsByName('orderList['+section_number+'][komisi]['+line_number+']')[0].value = data['komisi'];
- }
- function showStock()
- {
- //hide semua stock dan reset semua outStock value
- var nodes = document.getElementById('stockContent').childNodes;
- for(var i=0; i<nodes.length; i++) {
- if (nodes[i].nodeName.toLowerCase() == 'div') {
- nodes[i].style.display = 'none';
- $("[id^=outStock_]")[i].innerHTML = 0;
- }
- }
- //munculin stock barang yg ada di nota
- for(i=0; i<totalSection; i++)
- {
- for(j=0; j<=document.getElementById('lineNumber'+i).value; j++)
- {
- var idProduct = document.getElementsByName('orderList['+i+'][idProduct]['+j+']')[0];
- if(idProduct && idProduct.value)
- {
- idProduct = document.getElementsByName('orderList['+i+'][idProduct]['+j+']')[0].value;
- var outStock = parseInt(document.getElementById('outStock_'+idProduct).innerHTML);
- var qtyGiven = parseInt(document.getElementsByName('orderList['+i+'][qtyGiven]['+j+']')[0].value);
- var docOut = document.getElementById('outStock_'+idProduct);
- var docFinal = document.getElementById('finalStock_'+idProduct);
- var docCurrent = document.getElementById('currentStock_'+idProduct);
- docCurrent.parentNode.style.display = 'inline';
- if(qtyGiven >= 0)
- {
- docOut.innerHTML = outStock + qtyGiven;
- }
- docFinal.innerHTML = parseInt(docCurrent.innerHTML) - parseInt(docOut.innerHTML);
- }
- }
- }
- }
- function total()
- {
- var totalPrice = 0;
- var totalPv = 0;
- var totalOmset = 0;
- var totalKomisi = 0;
- var arrayPurchase = new Array();
- for(i=0; i<totalSection; i++)
- {
- var temporaryPrice = 0;
- var temporaryPv = 0;
- var temporaryOmset = 0;
- var temporaryKomisi = 0;
- var totalLine = document.getElementById('lineNumber'+i).value;
- for(j=0; j<totalLine; j++)
- {
- var qty = parseInt(document.getElementsByName('orderList['+i+'][qty]['+j+']')[0].value);
- var price = parseInt(document.getElementsByName('orderList['+i+'][price]['+j+']')[0].value);
- var pv = parseFloat(document.getElementsByName('orderList['+i+'][pv]['+j+']')[0].value);
- var omset = parseInt(document.getElementsByName('orderList['+i+'][omset]['+j+']')[0].value);
- var komisi = parseInt(document.getElementsByName('orderList['+i+'][komisi]['+j+']')[0].value);
- document.getElementById('price'+i+j).value = qty * price;
- document.getElementById('pv'+i+j).value = toFixed((qty * pv), 2);
- document.getElementById('omset'+i+j).value = qty * omset;
- document.getElementById('komisi'+i+j).value = qty * komisi;
- temporaryPrice += price * qty;
- temporaryPv = toFixed(parseFloat(temporaryPv) + parseFloat(qty * pv), 2);
- temporaryOmset += omset * qty;
- temporaryKomisi += komisi * qty;
- }
- var total = document.getElementById('total_'+i);
- var label = 'totalPrice'+i;
- var input = 'totalPrice'+i;
- var priceLabel = document.createElement('label');
- priceLabel.setAttribute('for', label);
- priceLabel.innerHTML = 'Total Price: ';
- var priceInput = document.createElement('input');
- priceInput.type = 'text';
- priceInput.setAttribute('id', input);
- priceInput.setAttribute('disabled', 'disabled');
- priceInput.setAttribute('style', width);
- priceInput.setAttribute('value', temporaryPrice);
- label = 'totalPv'+i;
- input = 'totalPv'+i;
- var pvLabel = document.createElement('label');
- pvLabel.setAttribute('for', label);
- pvLabel.innerHTML = 'Total PV: ';
- var pvInput = document.createElement('input');
- pvInput.type = 'text';
- pvInput.setAttribute('id', input);
- pvInput.setAttribute('disabled', 'disabled');
- pvInput.setAttribute('style', width);
- pvInput.setAttribute('value', temporaryPv);
- label = 'totalOmset'+i;
- input = 'totalOmset'+i;
- var omsetLabel = document.createElement('label');
- omsetLabel.setAttribute('for', label);
- omsetLabel.innerHTML = 'Total Omset: ';
- var omsetInput = document.createElement('input');
- omsetInput.type = 'text';
- omsetInput.setAttribute('id', input);
- omsetInput.setAttribute('disabled', 'disabled');
- omsetInput.setAttribute('style', width);
- omsetInput.setAttribute('value', temporaryOmset);
- label = 'totalKomisi'+i;
- input = 'totalKomisi'+i;
- var komisiLabel = document.createElement('label');
- komisiLabel.setAttribute('for', label);
- komisiLabel.innerHTML = 'Total Komisi: ';
- var komisiInput = document.createElement('input');
- komisiInput.type = 'text';
- komisiInput.setAttribute('id', input);
- komisiInput.setAttribute('disabled', 'disabled');
- komisiInput.setAttribute('style', width);
- komisiInput.setAttribute('value', temporaryKomisi);
- total.innerHTML = '';
- total.appendChild(priceLabel);
- total.appendChild(priceInput);
- total.appendChild(pvLabel);
- total.appendChild(pvInput);
- total.appendChild(omsetLabel);
- total.appendChild(omsetInput);
- total.appendChild(komisiLabel);
- total.appendChild(komisiInput);
- totalPrice += temporaryPrice;
- totalPv = toFixed(parseFloat(totalPv) + parseFloat(temporaryPv), 2);
- totalOmset += temporaryOmset;
- totalKomisi += temporaryKomisi;
- var newType = true;
- if(i>0)
- {
- for(m=0; m<arrayPurchase.length; m++)
- {
- if(arrayPurchase[m]['typePurchase'] == document.getElementsByName('orderList['+i+'][purchaseType]')[0].value)
- {
- newType = false;
- arrayPurchase[m]['temporaryPrice'] = parseInt(arrayPurchase[m]['temporaryPrice']) + parseInt(temporaryPrice);
- arrayPurchase[m]['temporaryPv'] = toFixed(parseFloat(arrayPurchase[m]['temporaryPv']) + parseFloat(temporaryPv), 2);
- arrayPurchase[m]['temporaryOmset'] = parseInt(arrayPurchase[m]['temporaryOmset']) + parseInt(temporaryOmset);
- arrayPurchase[m]['temporaryKomisi'] = parseInt(arrayPurchase[m]['temporaryKomisi']) + parseInt(temporaryKomisi);
- }
- }
- }
- if(i == 0 || newType == true)
- {
- var length = arrayPurchase.length;
- arrayPurchase[length] = [];
- arrayPurchase[length]['typePurchase'] = document.getElementsByName('orderList['+i+'][purchaseType]')[0].value;
- arrayPurchase[length]['purchaseTypeName'] = document.getElementById('purchaseType'+i).value;
- arrayPurchase[length]['temporaryPrice'] = temporaryPrice;
- arrayPurchase[length]['temporaryPv'] = temporaryPv;
- arrayPurchase[length]['temporaryOmset'] = temporaryOmset;
- arrayPurchase[length]['temporaryKomisi'] = temporaryKomisi;
- }
- }
- var arr = new Array();
- arr['totalPrice'] = totalPrice;
- arr['totalPv'] = totalPv;
- arr['totalOmset'] = totalOmset;
- arr['totalKomisi'] = totalKomisi;
- document.getElementById('result').innerHTML = '';
- resultPurchaseType(arrayPurchase);
- result(arr);
- }
- function resultPurchaseType(array)
- {
- var total = document.getElementById('result');
- for(p=0; p<array.length; p++)
- {
- var type = document.createElement('div');
- type.setAttribute('style', 'float:left;');
- var sectionLabel = document.createElement('p');
- sectionLabel.setAttribute('style', 'font-size:30px; font-weight:bold; margin-right:1em');
- sectionLabel.innerHTML = array[p]['purchaseTypeName'];
- var label = 'totalSectionPrice'+p;
- var input = 'totalSectionPrice'+p;
- var priceLabel = document.createElement('label');
- priceLabel.setAttribute('for', label);
- priceLabel.innerHTML = 'Total Price: ';
- var priceInput = document.createElement('input');
- priceInput.type = 'text';
- priceInput.setAttribute('id', input);
- priceInput.setAttribute('disabled', 'disabled');
- priceInput.setAttribute('style', width);
- priceInput.setAttribute('value', array[p]['temporaryPrice']);
- label = 'totalSectionPv'+p;
- input = 'totalSectionPv'+p;
- var pvLabel = document.createElement('label');
- pvLabel.setAttribute('for', label);
- pvLabel.innerHTML = 'Total PV: ';
- var pvInput = document.createElement('input');
- pvInput.type = 'text';
- pvInput.setAttribute('id', input);
- pvInput.setAttribute('disabled', 'disabled');
- pvInput.setAttribute('style', width);
- pvInput.setAttribute('value', array[p]['temporaryPv']);
- label = 'totalSectionOmset'+p;
- input = 'totalSectionOmset'+p;
- var omsetLabel = document.createElement('label');
- omsetLabel.setAttribute('for', label);
- omsetLabel.innerHTML = 'Total Omset: ';
- var omsetInput = document.createElement('input');
- omsetInput.type = 'text';
- omsetInput.setAttribute('id', input);
- omsetInput.setAttribute('disabled', 'disabled');
- omsetInput.setAttribute('style', width);
- omsetInput.setAttribute('value', array[p]['temporaryOmset']);
- label = 'totalSectionKomisi'+p;
- input = 'totalSectionKomisi'+p;
- var komisiLabel = document.createElement('label');
- komisiLabel.setAttribute('for', label);
- komisiLabel.innerHTML = 'Total Komisi: ';
- var komisiInput = document.createElement('input');
- komisiInput.type = 'text';
- komisiInput.setAttribute('id', input);
- komisiInput.setAttribute('disabled', 'disabled');
- komisiInput.setAttribute('style', width);
- komisiInput.setAttribute('value', array[p]['temporaryKomisi']);
- type.appendChild(sectionLabel);
- type.appendChild(priceLabel);
- type.appendChild(priceInput);
- type.appendChild(document.createElement('br'));
- type.appendChild(pvLabel);
- type.appendChild(pvInput);
- type.appendChild(document.createElement('br'));
- type.appendChild(omsetLabel);
- type.appendChild(omsetInput);
- type.appendChild(document.createElement('br'));
- type.appendChild(komisiLabel);
- type.appendChild(komisiInput);
- type.appendChild(document.createElement('br'));
- total.appendChild(type);
- }
- }
- function result(array)
- {
- var result = document.getElementById('result');
- var totalLabel = document.createElement('p');
- totalLabel.setAttribute('style', 'font-size:30px; font-weight:bold; margin-right:1em');
- totalLabel.innerHTML = 'Total';
- var label = 'totalPrice';
- var input = 'totalPrice';
- var width = 'width: 12em;';
- var priceLabel = document.createElement('label');
- priceLabel.setAttribute('for', label);
- priceLabel.innerHTML = 'Total Price: ';
- var priceInput = document.createElement('input');
- priceInput.type = 'text';
- priceInput.setAttribute('id', input);
- priceInput.setAttribute('readonly', 'readonly');
- priceInput.setAttribute('name', 'orderList[totalCost]');
- priceInput.setAttribute('style', width);
- priceInput.setAttribute('value', array['totalPrice']);
- label = 'totalPv';
- input = 'totalPv';
- var pvLabel = document.createElement('label');
- pvLabel.setAttribute('for', label);
- pvLabel.innerHTML = 'Total PV: ';
- var pvInput = document.createElement('input');
- pvInput.type = 'text';
- pvInput.setAttribute('id', input);
- pvInput.setAttribute('disabled', 'disabled');
- pvInput.setAttribute('style', width);
- pvInput.setAttribute('value', array['totalPv']);
- label = 'totalOmset';
- input = 'totalOmset';
- var omsetLabel = document.createElement('label');
- omsetLabel.setAttribute('for', label);
- omsetLabel.innerHTML = 'Total Omset: ';
- var omsetInput = document.createElement('input');
- omsetInput.type = 'text';
- omsetInput.setAttribute('id', input);
- omsetInput.setAttribute('disabled', 'disabled');
- omsetInput.setAttribute('style', width);
- omsetInput.setAttribute('value', array['totalOmset']);
- label = 'totalKomisi';
- input = 'totalKomisi';
- var komisiLabel = document.createElement('label');
- komisiLabel.setAttribute('for', label);
- komisiLabel.innerHTML = 'Total Komisi: ';
- var komisiInput = document.createElement('input');
- komisiInput.type = 'text';
- komisiInput.setAttribute('id', input);
- komisiInput.setAttribute('disabled', 'disabled');
- komisiInput.setAttribute('style', width);
- komisiInput.setAttribute('value', array['totalKomisi']);
- label = 'cash';
- input = 'cash';
- var cashLabel = document.createElement('label');
- cashLabel.setAttribute('for', label);
- cashLabel.innerHTML = 'Cash: ';
- var cashInput = document.createElement('input');
- cashInput.type = 'text';
- cashInput.setAttribute('id', input);
- cashInput.setAttribute('name', 'orderList[cash]');
- cashInput.setAttribute('style', width);
- cashInput.setAttribute('required', 'required');
- label = 'debit';
- input = 'debit';
- var debitLabel = document.createElement('label');
- debitLabel.setAttribute('for', label);
- debitLabel.innerHTML = 'Debit: ';
- var debitInput = document.createElement('input');
- debitInput.type = 'text';
- debitInput.setAttribute('id', input);
- debitInput.setAttribute('name', 'orderList[debit]');
- debitInput.setAttribute('style', width);
- debitInput.setAttribute('required', 'required');
- label = 'credit';
- input = 'credit';
- var creditLabel = document.createElement('label');
- creditLabel.setAttribute('for', label);
- creditLabel.innerHTML = 'Credit: ';
- var creditInput = document.createElement('input');
- creditInput.type = 'text';
- creditInput.setAttribute('id', input);
- creditInput.setAttribute('name', 'orderList[credit]');
- creditInput.setAttribute('style', width);
- creditInput.setAttribute('required', 'required');
- var submitDisabled = document.createElement('input');
- submitDisabled.type = 'button';
- submitDisabled.setAttribute('id', 'submitDisabled');
- submitDisabled.setAttribute('value', 'Submitting');
- submitDisabled.setAttribute('disabled', 'disabled');
- submitDisabled.setAttribute('style', 'display: none;');
- var submit = document.createElement('input');
- submit.type = 'submit';
- submit.setAttribute('value', 'Submit');
- submit.setAttribute('onclick', "disableSubmit(this);");
- result.appendChild(totalLabel);
- result.appendChild(priceLabel);
- result.appendChild(priceInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(pvLabel);
- result.appendChild(pvInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(omsetLabel);
- result.appendChild(omsetInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(komisiLabel);
- result.appendChild(komisiInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(cashLabel);
- result.appendChild(cashInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(debitLabel);
- result.appendChild(debitInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(creditLabel);
- result.appendChild(creditInput);
- result.appendChild(document.createElement('br'));
- result.appendChild(submitDisabled);
- result.appendChild(submit);
- }
- function disableSubmit(input)
- {
- if(document.getElementById('cash').value != 0
- && document.getElementById('debit').value != 0
- && document.getElementById('credit').value != 0)
- {
- input.style.display='none';
- document.getElementById('submitDisabled').style.display='inline';
- }
- }
- $("form").submit(function() {
- $(this).submit(function() {
- return false;
- });
- return true;
- });
- function toFixed(value, precision) {
- var precision = precision || 0,
- neg = value < 0,
- power = Math.pow(10, precision),
- value = Math.round(value * power),
- integral = String((neg ? Math.ceil : Math.floor)(value / power)),
- fraction = String((neg ? -value : value) % power),
- padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
- return precision ? integral + '.' + padding + fraction : integral;
- }
- </script>
- <section>
- <header>Order</header>
- <article id="stock" style="position: absolute;">
- </article>
- <form action="http://www.enumaelise.com/tulip/index.php/purchasing_system/order/purchase" method="post" accept-charset="utf-8"> <article class="right">
- <header>
- <div><label for="branches">Branch: </label><input type="text" id="branches" list="branch">
- <datalist id="branch"><option id="1" value="Wastu"><option id="2" value="Cimahi"></datalist>
- <input type="hidden" name="orderList[branch]">
- <input type="hidden" name="orderList[type_price]"><script>document.getElementById('branches').addEventListener('input', function () {
- var id_branch = $('#branch').find('option[value="'+this.value+'"]').attr('id');
- document.getElementsByName('orderList[branch]')[0].value = id_branch;
- getStock(id_branch);
- setTypePrice(id_branch);
- });</script></div>
- <div><label for="units">Unit: </label><input type="text" id="units" list="unit">
- <datalist id="unit"><option id="1" value="Test Unit"></datalist>
- <input type="hidden" name="orderList[unit]"><script>document.getElementById('units').addEventListener('input', function () {
- $('.memberDetails').html('');
- var id_unit = $('#unit').find('option[value="'+this.value+'"]').attr('id');
- document.getElementsByName('orderList[unit]')[0].value = id_unit;
- generateMemberOption(id_unit);
- });</script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement