Topic: How to Add Column Undefined property ?

i followed the wiki on how to  How to Add Column why can't i add just one simple input text in this page ?

Undefined property: Cart::$From in file: C:\xampp\htdocs\erp-1\sales\sales_order_entry.php at line 322

Undefined property: Cart::$From in file: C:\xampp\htdocs\erp-1\sales\includes\ui\sales_order_ui.inc at line 585

sales/sales_order_entry.php

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['From'] = $cart->From;
   

    $_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;
}

sales_order_db.inc

function add_sales_order(&$order)
{
    global $SysPrefs, $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, From, contact_phone,
        freight_cost, from_stk_loc, delivery_date, payment_terms, total, prep_amount)
        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->From) . "," .
            db_escape($order->delivery_address) . ", " .
            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_escape($order->prep_amount).")";
                        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;
}

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='90%'");
        table_section(1);

        locations_list_row(_("Deliver from Location:"), 'Location', null, false, true, $order->fixed_asset);
        if ($order->payment_terms['days_before_due'] == -1)
        {
            $Ajax->addUpdate('items_table', 'prep_amount', price_format($order->get_trans_total())); // bind to items_table update
            if (!$order->is_started())
                amount_row(_("Pre-Payment Required:"), 'prep_amount');
            else
                label_row(_("Pre-Payment Required:"), price_format($order->prep_amount), "class='label'");
        }
        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, 50, 60,
            _('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'));

        text_row(_("From:"), 'From', $order->From, 40, 40);
   
        table_section(2);

        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();
}

https://imgur.com/a/IsXd1iL

tried adding custom input field request by but keep getting errors what did i do wrong ?

Post's attachments

Extra_SO_Field_error.png 35 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: How to Add Column Undefined property ?

First you need to input the from variable inside the cart class . There after extend to use it in other object files. Its simple php class variable creation

Subscription service based on FA
HRM CRM POS batch Themes

3 (edited by kalmav1 02/27/2019 12:26:16 am)

Re: How to Add Column Undefined property ?

Where do i find the cart class been looking for it everywhere ? already added but still shows blank on the database why ?.

Re: How to Add Column Undefined property ?

It is in sales/includes/cart_class.inc.