Topic: How to Add Column in Direct Invoice

I have spent several hours trying to look through all the files for this program to find the way the program decides how many cells to put in each row in the invoice form and I have been unable to do so.

So far, I've figured out that the sales_order_entry.php has some link to the form design but there is no place in that file which talks about form fields. I want to add two new columns. I was able to edit sales_order_ui.inc and have all the headers I want displayed. So now the Direct Sales Invoice form has  Confirmation, Source, Avg Rate, Stay, Gross,    Our Price, GDS, Discount %, and Total across the top.

Now I want to align the rows below to match those headings. I looked in the database and found `0_sales_order_details` where I added the columns to that table. The first two are just fine (Confirmation and Source) because the display is the same as what I need it to display. It's after that that the whole thing gets jumbled. Where do I edit the design? The .css file had nothing except for font color and spacing, and all the .php files just have the website's logic. But none of the logic denotes the form! I'm sure I'm missing a very small detail but I don't think that what I'm trying to do should be that difficult. If anyone has some suggestions, please give me some direction with this issue.

Thank you,
all the best.

Re: How to Add Column in Direct Invoice

Update: I have found potential in view_invoice.php...
start_table(TABLESTYLE, "width=95%");

if (db_num_rows($result) > 0)
{
    $th = array(_("Confirmation"), _("Source"), _("Avg Rate"), _("Stay"),
        _("Gross"), _("Our Charge"), _("GDS"), _("Total"));
    table_header($th);

    $k = 0;    //row colour counter
    $sub_total = 0;
    while ($myrow2 = db_fetch($result))
    {
        if($myrow2["quantity"]==0) continue;
        alt_table_row_color($k);

        $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
           user_price_dec());
        $sub_total += $value;

        if ($myrow2["discount_percent"] == 0)
        {
              $display_discount = "";
        }
        else
        {
              $display_discount = percent_format($myrow2["discount_percent"]*100) . "%";
        }

        label_cell($myrow2["stock_id"]);
        label_cell($myrow2["StockDescription"]);
        qty_cell($myrow2["quantity"], false, get_qty_dec($myrow2["stock_id"]));
        label_cell($myrow2["units"], "align=right");
        amount_cell($myrow2["unit_price"]);
        label_cell($display_discount, "nowrap align=right");
        amount_cell($value);
        end_row();

I will try to see if I can make the changes I need here.

3 (edited by apmuthu 12/15/2012 12:53:43 am)

Re: How to Add Column in Direct Invoice

It would be better to create a separate plugin for it - that way you will be able to upgrade painlessly. Alternatively, look at the SimpleAPI for FA and build a form that posts directly into the FA db tables.

The plugin system (modified Debian Repo) and the API for the repo are not public - they need to be culled out from the includes folder's files: archive,inc, packages.inc and main.inc besides the hooks files and their classes.

You have modified - sales/view/view_invoice.php and sales/includes/ui/sales_order_ui.inc - changing only the heading lines at lines 113-114 (line 107 has the SQL and details content in lines 137-143)  in the former and lines 144-146 in the latter . The content comes from sales/includes/db/sales_order_db.inc and is processed in sales/includes/db/sales_invoice_db.inc.

Re: How to Add Column in Direct Invoice

With regards to creating a separate plugin, can you go into detail about how I would do that or point me to some other threads on the forum that might help me out?

Thanks for your reply!

5 (edited by reservhotel 12/17/2012 10:12:55 pm)

Re: How to Add Column in Direct Invoice

Update:
Ok so I went ahead and started making some edits to the files you mentioned apmuthu. However, now the site is coming up as a blank page, so I think I may have broken something in the code of one of the *_db files. Here is a rundown of all the edits I've made.

sales_order_db.inc
Changed lines 82-90 to include gross and gds
        $sql = "INSERT INTO ".TB_PREF."sales_order_details (order_no, trans_type, stk_code, description, unit_price, quantity, gross, discount_percent, gds) VALUES (";
        $sql .= $order_no . ",".$order->trans_type .
                ",".db_escape($line->stock_id).", "
                .db_escape($line->item_description).", $line->price,
                $line->quantity,
                $line->gross,
                $line->discount_percent,
                $line->gds");
        db_query($sql, "order Details Cannot be Added");

Changed lines 234-247 to include gross and gds
        $sql = "INSERT INTO ".TB_PREF."sales_order_details
         (id, order_no, trans_type, stk_code, description, unit_price, quantity, gross,
          discount_percent, gds, qty_sent)
         VALUES (";
        $sql .= db_escape($line->id ? $line->id : 0) . ","
          .$order_no . ",".$order->trans_type.","
          .db_escape($line->stock_id) . ","
          .db_escape($line->item_description) . ", "
          .db_escape($line->price) . ", "
          .db_escape($line->quantity) . ", "
          .db_escape($line->gross) . ", "
          .db_escape($line->discount_percent) . ", "
          .db_escape($line->gds) . ", "
          .db_escape($line->qty_done) ." )";

        db_query($sql, "Old order Cannot be Inserted");

    } /* inserted line items into sales order details */

Changed lines 327-343 to include gross and gds
function get_sales_order_details($order_no, $trans_type) {
    $sql = "SELECT id, stk_code, unit_price, "
        .TB_PREF."sales_order_details.description,"
        .TB_PREF."sales_order_details.quantity, gross,
          discount_percent, gds,
          qty_sent as qty_done, "
        .TB_PREF."stock_master.units,"
        .TB_PREF."stock_master.mb_flag,"
        .TB_PREF."stock_master.material_cost + "
            .TB_PREF."stock_master.labour_cost + "
            .TB_PREF."stock_master.overhead_cost AS standard_cost
    FROM ".TB_PREF."sales_order_details, ".TB_PREF."stock_master
    WHERE ".TB_PREF."sales_order_details.stk_code = ".TB_PREF."stock_master.stock_id
    AND order_no =" . db_escape($order_no)
        ." AND trans_type = " . db_escape($trans_type) . " ORDER BY id";

    return db_query($sql, "Retreive order Line Items");
}

Changed lines 383-390 to include gross and gds
    $result = get_sales_order_details($order_no, $order->trans_type);
    if (db_num_rows($result) > 0)
    {
        $line_no=0;
        while ($myrow = db_fetch($result))
        {
            $order->add_to_cart($line_no,$myrow["stk_code"],$myrow["quantity"],
                $myrow["unit_price"], $myrow["discount_percent"], $myrow["gds"], $myrow["gross"],
                $myrow["qty_done"], $myrow["standard_cost"], $myrow["description"], $myrow["id"] );
        $line_no++;
        }
    }

    return true;
}

sales/view/view_invoice.php
Changed lines 107-145
-Edited $th array to show Confirmation, Source, Avg Rate, Stay, Gross, Our Charge, GDS, and Total for the table headings.
-Added lines 141 to reflect math for Gross cell.
        amount_cell($myrow2["unit_price"] * $myrow2["quantity"]);
-Added line 143 for GDS.
        amount_cell($myrow2["gds"]);

sales/includes/ui/sales_order_ui.inc
Edited lines 144-145
    $th = array(_("Confirmation"), _("Source"), _("Avg Rate"), _("Stay"), _("Gross"), $order->tax_included ? _("Our Charge") : _("Price before Tax"), _("GDS"), _("Total"),);

Changed lines 163-218. Not sure if my additions are valid or not though.
        $line_total = round($stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent),
           user_price_dec());

        $qoh_msg = '';
        if (!$editable_items || $id != $line_no)
        {
            if (!$SysPrefs->allow_negative_stock() && is_inventory_item($stock_item->stock_id) &&
                $order->trans_type != ST_SALESORDER && $order->trans_type!=ST_SALESQUOTE) {
                $qoh = get_qoh_on_date($stock_item->stock_id,
                    $_POST['Location'], $_POST['delivery_date']);
                if (($stock_item->qty_dispatched -$stock_item->qty_done) > $qoh)
                {
                    // oops, we don't have enough of one of the component items
                    start_row("class='stockmankobg'");
                    $qoh_msg .= $stock_item->stock_id . " - " . $stock_item->item_description . ": " .
                    _("Quantity On Hand") . " = "
                    . number_format2($qoh, get_qty_dec($stock_item->stock_id)) . '<br>';
                    $has_marked = true;
                 } else
                    alt_table_row_color($k);
            } else {
                alt_table_row_color($k);
            }

            view_stock_status_cell($stock_item->stock_id);

            //label_cell($stock_item->item_description, "nowrap" );
            label_cell($stock_item->item_description );
            amount_cell($stock_item->price);
            $dec = get_qty_dec($stock_item->stock_id);
            qty_cell($stock_item->qty_dispatched, false, $dec);

            if ($order->trans_no!=0)
                qty_cell($stock_item->qty_done, false, $dec);

            //label_cell($stock_item->units);

                    amount_cell($stock_item->price * $stock_item->qty_dispatched);
            percent_cell($stock_item->discount_percent * 100);
                amount_cell($stock_item->gds);
            amount_cell($line_total);
            if ($editable_items)
            {
                edit_button_cell("Edit$line_no", _("Edit"),
                _('Edit document line'));
                delete_button_cell("Delete$line_no", _("Delete"),
                _('Remove line from document'));
            }
            end_row();
        }
        else
        {
            sales_order_item_controls($order, $k,  $line_no);
        }

        $total += $line_total;
    }

I know I need to edit/change lines 489-572 but I don't know what or how to do so (unsure of syntax, looking for any help!)
function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1)
{
    global $Ajax;

    alt_table_row_color($rowcounter);

    $id = find_submit('Edit');
    if ($line_no!=-1 && $line_no == $id) // edit old line
    {
        $_POST['stock_id'] = $order->line_items[$id]->stock_id;
        $dec = get_qty_dec($_POST['stock_id']);
        $_POST['qty'] = number_format2($order->line_items[$id]->qty_dispatched, $dec);
        $_POST['price'] = price_format($order->line_items[$id]->price);
        $_POST['Disc'] = percent_format($order->line_items[$id]->discount_percent*100);
        $units = $order->line_items[$id]->units;
        $_POST['item_description'] = $order->line_items[$id]->item_description;
        hidden('stock_id', $_POST['stock_id']);
        label_cell($_POST['stock_id']);
        if ($order->line_items[$id]->descr_editable)
            text_cells(null,'item_description', null, 45, 150);
        else {
            hidden('item_description', $_POST['item_description']);
            label_cell($_POST['item_description']);
        }
//        } else {
//            sales_items_list_cells(null,'item_description', null, false, true);
//        }
        //label_cell($order->line_items[$line_no]->item_description, "nowrap");
        $Ajax->activate('items_table');
    }
    else    // prepare new line
    {
        sales_items_list_cells(null,'stock_id', null, false, true);
        if (list_updated('stock_id')) {
                $Ajax->activate('price');
                $Ajax->activate('units');
                $Ajax->activate('qty');
                $Ajax->activate('line_total');
        }

        $item_info = get_item_edit_info($_POST['stock_id']);
        $units = $item_info["units"];
        $dec = $item_info['decimals'];
        $_POST['qty'] = number_format2(1, $dec);
        $price = get_kit_price($_POST['stock_id'],
            $order->customer_currency, $order->sales_type,
            $order->price_factor, get_post('OrderDate'));
        $_POST['price'] = price_format($price);
        // default to the customer's discount %
        $_POST['Disc'] = percent_format($order->default_discount * 100);
    }

    qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);

    if ($order->trans_no!=0) {
        qty_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done, false, $dec);
    }

    label_cell($units, '', 'units');

    amount_cells(null, 'price');

    small_amount_cells(null, 'Disc', percent_format($_POST['Disc']), null, null, user_percent_dec());

    $line_total = input_num('qty') * input_num('price') * (1 - input_num('Disc') / 100);

    amount_cell($line_total, false, '','line_total');

    if ($id!=-1)
    {
        button_cell('UpdateItem', _("Update"),
                _('Confirm changes'), ICON_UPDATE);
        button_cell('CancelItemChanges', _("Cancel"),
                _('Cancel changes'), ICON_CANCEL);
        hidden('LineNo', $line_no);
        set_focus('qty');
    }
    else
    {
        submit_cells('AddItem', _("Add Item"), "colspan=2 align='center'",
            _('Add new item to document'), true);
    }

    end_row();
}

I have looked at sales/includes/db/sales_invoice_db.inc but I don't really know what or how to change the values there to include the two new values I want. Any thoughts, advice, tips, etc are greatly appreciated.

As I said before, right now I'm getting a blank page whenever I try to access any pages on the site, I can't even log in. I think it's related to the sales_order_db.inc file that I edited, but I'm not sure. If it is, does anyone have any ideas why this might be? Thanks for all your help!

I wish you all a great holiday.

6 (edited by reservhotel 12/17/2012 11:24:27 pm)

Re: How to Add Column in Direct Invoice

Update: fixed blank page, realized I added a ")" where it shouldn't be.

Onward to try and fix the invoice table...

Re: How to Add Column in Direct Invoice

check apache error logs for issues and hints to where typos may exist.

Re: How to Add Column in Direct Invoice

apmuthu wrote:

check apache error logs for issues and hints to where typos may exist.

I already fixed the blank screen issue. I'm still trying to change the invoice table though. Any thoughts on what I'd need to change in order to fix that?

Re: How to Add Column in Direct Invoice

Some screenshots on your current invoice table can show what needs to be done - see that the arguments to the insert sql and the output of the form post variables match.

Re: How to Add Column in Direct Invoice

Okay, here is an annotated screenshot. Hope this helps!
[img]http://i49.tinypic.com/34e8a3c.jpg[/img]

Re: How to Add Column in Direct Invoice

Okay, here is an annotated screenshot. Thank you for your help!
http://tinypic.com/r/34e8a3c/6

12 (edited by apmuthu 12/19/2012 04:44:13 am)

Re: How to Add Column in Direct Invoice

On your annotations, let us address them one at a time:

Need to address Row Alignment:

You have missed out a blank array element at the last:

Lines 144-146 in sales/includes/ui/sales_order_ui.inc

    $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
        _("Delivered"),
        _("Unit"), $order->tax_included ? _("Price after Tax") : _("Price before Tax"), _("Discount %"), _("Total"), "");

For you should be:

$th = array(_("Confirmation"), _("Source"), _("Avg Rate"), 
        _("Stay"), 
        _("Gross"), $order->tax_included ? _("Our Charge") : _("Price before Tax"), _("GDS"), _("Total"),"");

Check if you also need to increase the col span for the other rows at line 225 (of the original file):

    $colspan = 6;

to be

    $colspan = 7;

Re: How to Add Column in Direct Invoice

Ah, thank you, that was helpful.

Now how would I tell FA that I want another cell in the second row or how would I change the coding that affects the content of each cell in the item row?

14 (edited by apmuthu 12/20/2012 04:05:14 am)

Re: How to Add Column in Direct Invoice

Lines 490-574 in sales/includes/ui/sales_order_ui.inc - function sales_order_item_controls() dictates what goes into each row and it's columns.

Re: How to Add Column in Direct Invoice

can someone pls help me also on similar kind of prob,

i have tried to update almost everything.. but now i think i am facing an prob in
sales\include\ui\sales_order_ui.inc

---------------------------------------------------------------------
Line no: 168 - 183~~
-----------------------------------------------------------------------

            view_stock_status_cell($stock_item->stock_id);

            //label_cell($stock_item->item_description, "nowrap" );
            label_cell($stock_item->item_description );
            $dec = get_qty_dec($stock_item->stock_id);
            qty_cell($stock_item->qty_dispatched, false, $dec);

            if ($order->trans_no!=0)
                qty_cell($stock_item->qty_done, false, $dec);
            amount_cell($stock_item->price);
            amount_cell($stock_item->price);
            amount_cell($stock_item->price);
            label_cell($stock_item->units);
            amount_cell($stock_item->price);
            percent_cell($stock_item->discount_percent * 100);
            amount_cell($line_total);

            if ($editable_items)
            {
                edit_button_cell("Edit$line_no", _("Edit"),
                _('Edit document line'));
                delete_button_cell("Delete$line_no", _("Delete"),
                _('Remove line from document'));
            }
            end_row();
        }
        else
        {
            sales_order_item_controls($order, $k,  $line_no);
        }

        $total += $line_total;
    }

    if ($id==-1 && $editable_items)
        sales_order_item_controls($order, $k);

    $colspan = 10;
    if ($order->trans_no!=0)
        ++$colspan;
    start_row();
    label_cell(_("Shipping Charge"), "colspan=$colspan align=right");
    small_amount_cells(null, 'freight_cost', price_format(get_post('freight_cost',0)));
    label_cell('', 'colspan=2');
    end_row();
    $display_sub_total = price_format($total + input_num('freight_cost'));
    label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right", 2);
    $taxes = $order->get_taxes(input_num('freight_cost'));
    $tax_total = display_edit_tax_items($taxes, $colspan, $order->tax_included, 2);

    $display_total = price_format(($total + input_num('freight_cost') + $tax_total));

    start_row();
    label_cells(_("Amount Total"), $display_total, "colspan=$colspan align=right","align=right");
    submit_cells('update', _("Update"), "colspan=2 align='center'", _("Refresh"), true);
    end_row();

    end_table();
    if ($has_marked) {
        display_note(_("Marked items have insufficient quantities in stock as on day of delivery."), 0, 1, "class='stockmankofg'");
        if ($order->trans_type!=30 && !$SysPrefs->allow_negative_stock())
            display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:")
                . '<br>'. $qoh_msg);
    }
    div_end();
}


somthing is worng in the above code..
the data is not getting entred,

you can try my demo
www.ptsvee.com/simplykool.com/test/1/
user: admin
pass:admin
company: sunrise


Please help of the same

Re: How to Add Column in Direct Invoice

Copy paste the full code in:
http://phpcodechecker.com/
and you might find syntax errors.

Re: How to Add Column in Direct Invoice

hm.. i checked that.. no errors sad

Re: How to Add Column in Direct Invoice

Thanks #reservhotel. is topic can use reference how to remove line Column in Sales Invoice / Sales Order

Best Regard
/Jujuk

ING NGARSO SUNG TULODO, ING MADYO MANGUN KARSO, TUT WURI HANDAYANI

Re: How to Add Column in Direct Invoice

I know this topic is kind of old, but I am trying to do something similar.  I need to add 2 fields, ship_to and shipper_address.  I have added the fields into the db table already, _sales_orders.  And I was able to get the fields to show up on the sales order page.  What I can't figure out is how to get the information I type into those fields to be saved in the db.  That is far beyond my skills.  I would appreciate as much help as possible.

The reason for doing this is because of trying to use the batch invoice function.  I have one customer that I bill to, but I pick up and delivery from different locations.  So when I use the branch to set up each pick up location and then I manually get to type in the delivery address and deliver to instead of using the branch billing address so I can track where something was picked up from and delivered to.

Since batch can only be used with the same branch, I can't batch invoice to the customer like I need to for all the loads that were run during that period.   That is why I am trying to create the extra 2 fields so I can add the ship from and shipper address.  Once I can get it to save in the DB I have figured how to pull the information from the DB in the reports or invoices.  I just need to get the information into the DB.

Thanks for the help!

Re: How to Add Column in Direct Invoice

Add the necessary fields values into the function add_sales_order() in sales/includes/db/sales_order_db.inc.

21 (edited by myhandgunpursedotcom 12/10/2016 05:37:12 am)

Re: How to Add Column in Direct Invoice

apmuthu wrote:

Add the necessary fields values into the function add_sales_order() in sales/includes/db/sales_order_db.inc.

Ok, I attempted to do what you suggested and it still won't write anything to the db.  Here is what I edited.  Maybe you can tell me what I did wrong.  Thanks

I am adding "shipper_address" and "ship_from".  Those are the two fields I am adding to the db and to the sales order.  Below is the add sales order function from the sales/includes/db/sales_order_db.inc that I am trying to modify.

function add_sales_order(&$order)
{
    global $loc_notification, $path_to_root, $Refs;

    begin_transaction();
    hook_db_prewrite($order, $order->trans_type);
    $order_no = get_next_trans_no($order->trans_type);
    $del_date = date2sql($order->due_date);
    $order_type = 0; // this is default on new order
    $total = $order->get_trans_total();
    $sql = "INSERT INTO ".TB_PREF."sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date,
        order_type, ship_via, deliver_to, delivery_address, contact_phone, shipper_address, ship_from,
        freight_cost, from_stk_loc, delivery_date, payment_terms, total)
        VALUES (" .db_escape($order_no) . "," .db_escape($order_type) . "," . db_escape($order->customer_id) .
         ", " .db_escape($order->trans_type) . "," .db_escape($order->Branch) . ", ".
            db_escape($order->cust_ref) .",".
            db_escape($order->reference) .",".
            db_escape($order->Comments) .",'" .
            date2sql($order->document_date) . "', " .
            db_escape($order->sales_type) . ", " .
            db_escape($order->ship_via)."," .
            db_escape($order->deliver_to) . "," .
            db_escape($order->delivery_address) . ", " .
            db_escape($order->shipper_address) . ", ".
              db_escape($order->ship_from) . ", ".

            db_escape($order->phone) . ", " .
            db_escape($order->freight_cost) .", " .
            db_escape($order->Location) .", " .
            db_escape($del_date) . "," .
            db_escape($order->payment) . "," .
            db_escape($total). ")";

    db_query($sql, "order Cannot be Added");

    $order->trans_no = array($order_no=>0);

    if ($loc_notification == 1)
    {
        include_once($path_to_root . "/inventory/includes/inventory_db.inc");
        $st_ids = array();
        $st_names = array();
        $st_num = array();
        $st_reorder = array();
    }
    foreach ($order->line_items as $line)
    {
        if ($loc_notification == 1 && is_inventory_item($line->stock_id))
            $loc = calculate_reorder_level($order->Location, $line, $st_ids, $st_names, $st_num, $st_reorder);

        $sql = "INSERT INTO ".TB_PREF."sales_order_details (order_no, trans_type, stk_code, description, unit_price, quantity, discount_percent) VALUES (";
        $sql .= $order_no . ",".$order->trans_type .
                ",".db_escape($line->stock_id).", "
                .db_escape($line->item_description).", $line->price,
                $line->quantity,
                $line->discount_percent)";
        db_query($sql, "order Details Cannot be Added");

    // Now mark quotation line as processed
        if ($order->trans_type == ST_SALESORDER && $line->src_id)
            update_parent_line(ST_SALESORDER, $line->src_id, $line->qty_dispatched); // clear all the quote despite all or the part was ordered
    } /* inserted line items into sales order details */
    add_audit_trail($order->trans_type, $order_no, $order->document_date);
    $Refs->save($order->trans_type, $order_no, $order->reference);

    hook_db_postwrite($order, $order->trans_type);
    commit_transaction();

    if ($loc_notification == 1 && count($st_ids) > 0)
        send_reorder_email($loc, $st_ids, $st_names, $st_num, $st_reorder);
    return $order_no;
}

Here is the sales/include/ui/sales_order_ui.inc that I modified as well.  I bolded the section that I added below.

function display_delivery_details(&$order)
{
    global $Ajax;

    div_start('delivery');   


    if ($order->payment_terms['cash_sale']) {    // Direct payment sale
        $Ajax->activate('items_table');
        display_heading(_('Cash payment'));
        start_table(TABLESTYLE2, "width='60%'");

        locations_list_row(_("Deliver from Location:"), 'Location', null, false, true);
        if (list_updated('Location'))
            $Ajax->activate('items_table');
        label_row(_("Cash account:"), $order->pos['bank_account_name']);
        textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
        end_table();
        hidden('delivery_date', $order->due_date);
    } else {
        if ($order->trans_type==ST_SALESINVOICE)
        {
            $title = _("Delivery Details");
            $delname = _("Due Date").':';
        }
        elseif ($order->trans_type==ST_CUSTDELIVERY)
        {
            $title = _("Invoice Delivery Details");
            $delname = _("Invoice before").':';
        }
        elseif ($order->trans_type==ST_SALESQUOTE)
        {
            $title = _("Quotation Delivery Details");
            $delname = _("Valid until").':';
        }
        else
        {
            $title = _("Order Delivery Details");
            $delname = _("Required Delivery Date").':';
        }
        display_heading($title);
        start_outer_table(TABLESTYLE2, "width='100%'");
        table_section(1);
       
        text_row(_("Ship From:"), 'ship_from', $order->ship_from, 40, 40,
            _('Additional identifier for delivery e.g. name of receiving person'));

        textarea_row(_("Address:"), 'shipper_address', $order->shipper_address, 35, 5,
            _('Shipper address.'));

           
        table_section(2);

        locations_list_row(_("Deliver from Location:"), 'Location', null, false, true);
        if (list_updated('Location'))
            $Ajax->activate('items_table');


        date_row($delname, 'delivery_date',
            $order->trans_type==ST_SALESORDER ?  _('Enter requested day of delivery')
                : $order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : '');
        text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40,
            _('Additional identifier for delivery e.g. name of receiving person'));

        textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5,
            _('Delivery address. Default is address of customer branch'));

        table_section(3);

        text_row(_("Contact Phone Number:"), 'phone', $order->phone, 25, 25,
            _('Phone number of ordering person. Defaults to branch phone number'));
        text_row(_("Customer Reference:"), 'cust_ref', $order->cust_ref, 25, 25,
          _('Customer reference number for this order (if any)'));
        textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);

        shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via);

        end_outer_table(1);
    }
    div_end();

And finally here is the sales/sales_order_entry.php that I modified in the function copy_from_cart()

function copy_from_cart()
{
    $cart = &$_SESSION['Items'];
    $_POST['ref'] = $cart->reference;
    $_POST['Comments'] = $cart->Comments;

    $_POST['OrderDate'] = $cart->document_date;
    $_POST['delivery_date'] = $cart->due_date;
    $_POST['cust_ref'] = $cart->cust_ref;
    $_POST['freight_cost'] = price_format($cart->freight_cost);

    $_POST['ship_from'] = $cart->ship_from;
    $_POST['shipper_address'] = $cart->shipper_address;

    $_POST['deliver_to'] = $cart->deliver_to;
    $_POST['delivery_address'] = $cart->delivery_address;
    $_POST['phone'] = $cart->phone;
    $_POST['Location'] = $cart->Location;
    $_POST['ship_via'] = $cart->ship_via;

    $_POST['customer_id'] = $cart->customer_id;

    $_POST['branch_id'] = $cart->Branch;
    $_POST['sales_type'] = $cart->sales_type;
    // POS
    $_POST['payment'] = $cart->payment;
    if ($cart->trans_type!=ST_SALESORDER && $cart->trans_type!=ST_SALESQUOTE) { // 2008-11-12 Joe Hunt
        $_POST['dimension_id'] = $cart->dimension_id;
        $_POST['dimension2_id'] = $cart->dimension2_id;
    }
    $_POST['cart_id'] = $cart->cart_id;
    $_POST['_ex_rate'] = $cart->ex_rate;
}

Re: How to Add Column in Direct Invoice

So I turned some of the debug options on in the config.php file and when I entered a new sales order here is the error I got.

Undefined index: Ship_from in file: /hermes/bosnaweb03a/b240/dom.abintra2012/james/accounting/sales/sales_order_entry.php at line 277
/hermes/bosnaweb03a/b240/dom.abintra2012/james/accounting/sales/sales_order_entry.php:352:    copy_to_cart()
/hermes/bosnaweb03a/b240/dom.abintra2012/james/accounting/sales/sales_order_entry.php:458:    can_process()

not sure what any of this means now, but I hope it helps.

Re: How to Add Column in Direct Invoice

The order of the inserted fields must match the order of the values to be inserted in them.
Your first bold SQL code entry:

        order_type, ship_via, deliver_to, delivery_address, contact_phone, shipper_address, ship_from,

should be:

        order_type, ship_via, deliver_to, delivery_address, shipper_address, ship_from, contact_phone,

Re: How to Add Column in Direct Invoice

apmuthu wrote:

The order of the inserted fields must match the order of the values to be inserted in them.
Your first bold SQL code entry:

        order_type, ship_via, deliver_to, delivery_address, contact_phone, shipper_address, ship_from,

should be:

        order_type, ship_via, deliver_to, delivery_address, shipper_address, ship_from, contact_phone,

Thank you so much.  I knew I was missing something really really simple.  That was all that was wrong.  Thank you again!!!!

Re: How to Add Column in Direct Invoice

Wiki-ed it.