Pessoal,
Estou customizando o módulo OpenSales, mas sei muito pouco de programação.
Consegui avançar até certo ponto, mas faltou conhecimento para terminar.
Preciso concluir o cálculo de um pedido de Venda. Não estou conseguindo fazer a soma do custo total do pedido, conforme a imagem anexa.
Sem quere abusar, segue o código do arquivo quote.js. Se alguém se dispuser a me dar uma ajuda...
Agradeço desde já.
JorgePHP Code:function calculateProductLineTotal()
{
var length = document.getElementById('productLine').getElementsByTagName('tr').length;
var row = document.getElementById('productLine').getElementsByTagName('tr');
var subtotal = 0;
for (i=1; i < length; i++) {
var qty = 0;
var price = 0;
var deleted = 0;
var input = row[i].getElementsByTagName('input');
for (j=0; j < input.length; j++) {
if (input[j].id.indexOf('product_qty') != -1) {qty = input[j].value;}
if (input[j].id.indexOf('product_unit_price') != -1) {price = input[j].value;}
if (input[j].id.indexOf('deleted') != -1) {deleted = input[j].value;}}
if (qty != 0 && price != 0 && deleted != 1) {subtotal += price * qty;}}
document.getElementById('subtotal_amount').value = subtotal.toFixed(2);
calculateGrandTotal();}
function calculateGrandTotal()
{
var subtotal = Number(document.getElementById('subtotal_amount').value);
//var discount = Number(document.getElementById('discount_amount').value);
var tax = Number(document.getElementById('tax_amount').value);
var shipping = Number(document.getElementById('shipping_amount').value);
//var total = (subtotal - discount) + tax + shipping;
var total = (subtotal) + tax + shipping;
document.getElementById('total_amount').value = total.toFixed(2);
function calculateProductLineTotal()
{
var length = document.getElementById('productLine').getElementsByTagName('tr').length;
var row = document.getElementById('productLine').getElementsByTagName('tr');
var subtotalcost = 0;
for (i=1; i < length; i++) {
var qty = 0;
var cost = 0;
var deleted = 0;
var input = row[i].getElementsByTagName('input');
for (j=0; j < input.length; j++) {
if (input[j].id.indexOf('product_qty') != -1) {qty = input[j].value;}
if (input[j].id.indexOf('product_cost_price') != -1) {cost = input[j].value;}
if (input[j].id.indexOf('deleted') != -1) {deleted = input[j].value;}}
if (qty != 0 && cost != 0 && deleted != 1) {subtotalcost += cost * qty;}}
document.getElementById('subtotal_cost').value = subtotalcost.toFixed(2);
calculateGrandCost();
function calculateGrandCost()
{
// var subtotal = Number(document.getElementById('subtotal_amount').value);
var subtotalcost = Number(document.getElementById('subtotal_cost').value);
//var discount = Number(document.getElementById('discount_amount').value);
// var tax = Number(document.getElementById('tax_amount').value);
// var shipping = Number(document.getElementById('shipping_amount').value);
//var total = (subtotal - discount) + tax + shipping;
var totalcost = subtotalcost;
document.getElementById('total_cost').value = totalcost.toFixed(2);
}
}
}
Sugar CE version 5.1.0c
langpack-pt_br-5.1-CE-Lampada
PHP Version 5.2.5
MySQL Version: 5.0.45
Windows Server 2003


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks