Results 1 to 1 of 1

Thread: Módulo OpenSales - Quotes - arquivo js

  1. #1
    jorgeluiz is offline Sugar Community Member
    Join Date
    Apr 2008
    Location
    Brasil - Porto Alegre - RS
    Posts
    74

    Default Módulo OpenSales - Quotes - arquivo js

    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á.

    PHP Code:
      function calculateProductLineTotal()
    {
        var 
    length document.getElementById('productLine').getElementsByTagName('tr').length;
        var 
    row document.getElementById('productLine').getElementsByTagName('tr');
        var 
    subtotal 0;
        for (
    i=1lengthi++) {
            var 
    qty 0;
            var 
    price 0;
            var 
    deleted 0;
            var 
    input row[i].getElementsByTagName('input');
            for (
    j=0input.lengthj++) {
                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 != && price != && 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=1lengthi++) {
            var 
    qty 0;
            var 
    cost 0;
            var 
    deleted 0;
            var 
    input row[i].getElementsByTagName('input');
            for (
    j=0input.lengthj++) {
                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 != && cost != && 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);

    }
    }

    Jorge
    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
    Attached Images Attached Images  

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sugar OpenSales - Products, Quotes, & Contracts
    By rustinp77 in forum Downloads
    Replies: 280
    Last Post: 2012-01-28, 12:09 AM
  2. Replies: 1
    Last Post: 2011-01-12, 01:05 PM
  3. Studio no Módulo OpenSales
    By jorgeluiz in forum Portugese
    Replies: 2
    Last Post: 2008-12-18, 06:42 PM
  4. Problems with Quotes / Opensales
    By wolfcon in forum Help
    Replies: 4
    Last Post: 2008-01-19, 06:27 PM
  5. C3 OpenSales - Products, Quotes, & Contracts
    By rustinp77 in forum Downloads
    Replies: 2
    Last Post: 2007-06-19, 03:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •