Topic: New Copy of Sales Order

I want to make a new copy of the sales order to use.   I do not want to lose the current sales order.

i.e new report rep109b.php which will have less columns and data in the body.  I do not want to list prices as well as other things.

I can remove the columns I don't want from doctext.inc but then I lose them for ALL sales order reports.   

Can I make a doctext3.inc, a header3.inc etc and make the changes there?  Or is there a way to put my new headers in rep109b.php and override the default headers?

Thanks for your help!

Re: New Copy of Sales Order

You can do it very well, Create a new Type with different number, sales order is 30 and sales quotation is 32 as of FA standard.  You can see other reserved type numbers here at /includes/types.inc

And necessary functions inside, sales_order_ui.inc and sales_order_entry.php  to utilize your new type number and make a duplicate of it with you can reduce the fields. Even you can go with separate files to reduce the complexity.

Ofcourse, you can make doctext3.inc. But header3.inc  is already programmed to use.so go with different number.

Subscription service based on FA
HRM CRM POS batch Themes

Re: New Copy of Sales Order

Alternatively, make an extension for it, overwriting the variables that hold the output of the said include files.

4 (edited by jfirestone 09/27/2018 12:56:19 pm)

Re: New Copy of Sales Order

I appreciate both of your suggestions but not much of this makes sense.  I am not a programmer at all, so I don't really know much about what I am doing.   I am able to find things and change basics, but creating new programming is beyond me.

I was able to do this, change column names and even add a column to this display list, but getting a new icon or even a text link to that "Factory Order" field is something I haven't even come near figuring out.  sad

http://www.egreene.com/tmp/saleslist.png

Post's attachments

saleslist.png 41.1 kb, file has never been downloaded. 

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

5 (edited by poncho1234 09/27/2018 02:32:35 pm)

Re: New Copy of Sales Order

@jfirestone, apmuthu's answer is probably the easiest, have a look at the report extensions on his github acc. to see how they are constructed, look for the code that appears in all the extensions. Don't worry about the _init directory thats used for auto install, you can install it manually.

Then use reporting/rep109.php as the basis for your new extension, just rename it first, when you get it running then modify it to what you need and write your new header code

Also an ext does not modify the core FA files, so upgrades are not compromised

If you figured out you need to modify doctext and header2 you should be able to do it.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

By "factory order" do you mean "works order", an internal order for your manufacturing dept to start manufacturing something?

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

7 (edited by jfirestone 10/01/2018 11:34:57 am)

Re: New Copy of Sales Order

Thanks poncho, that was a good suggestion.   I am making a little bit of headway using those report extensions as a basis.  Still struggling adding things, but I've gotten a little bit of redesign done and made space for the things I want.

I am referring to a "sales order" which is what we will give to the factory to produce the order.  We don't need to be so official as to have a two step process here.

IN addition to making this new report, which is accessible from the Reports screen - can I add this as a link or icon to the "sales_orders_view.php" page?

Re: New Copy of Sales Order

Works orders are produced in the manufacturing module.

Please read the wiki, and set up a training company.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

Thank you, but I think we are getting mixed up.  I am ONLY using sales order, so let's just think about it as Sales Order and Sales Order BY ME.   

can I add this as a link or icon to the "sales_orders_view.php" page?     There is already an icon to edit the sales order AND Print the sales order, but now I want a new icon OR text link to Print Sales order BY ME.

Re: New Copy of Sales Order

Of course you can add it, but you will be modifying core files, which is not best practice, and you will have to change the code everytime you update the core software.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

11 (edited by jfirestone 10/01/2018 03:41:15 pm)

Re: New Copy of Sales Order

I'm ok with that.   I can make a record of what I did and redo those changes each time.   I know it's not ideal, but streamlining the process makes much more sense to me than forcing the user to go through several extra steps.

Do you know how I would go about creating this new link?  I attempted to follow the trail of included files to see where the link was created, but I was not able to.

Re: New Copy of Sales Order

Follow the function calls

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

Getting closer, little by little.   Thanks for sticking with me.

I have the default Print link duplicated in a new spot.   Both icon links call report 109.  I can't seem to figure out how to get the new icon ink I added to call report 127 instead.   I have report 127 in my reports area and can view and use it.  Just not here.

14 (edited by poncho1234 10/01/2018 07:37:56 pm)

Re: New Copy of Sales Order

I've had  a brief look, maybe you need to create a new function similar to order_link or invoice_link

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

That's exactly what I did to make my new icon link show up, BUT I can't seem to figure out the part where that link is given it's report ID#.   I'll begin my search again today.

Re: New Copy of Sales Order

Ok... I have effectively made some sort of new link, but it's not firing my Report.  Any idea how I need to change this?

function print_factory_link($link_text, $rep, $pars = array(), $dir = '', 
    $icon=false, $class='printlink', $id='')
{
    global $path_to_root, $SysPrefs;

    $url = $dir == '' ?  $path_to_root.'/reporting/prn_redirect.php?' : $dir;

    $id = default_focus($id);
    foreach($pars as $par => $val) {
        $pars[$par] = "$par=".urlencode($val);
    }
    $pars[] = 'REP_ID='.urlencode($rep);
    $url .= implode ('&', $pars);

    if ($class != '')
        $class = $SysPrefs->pdf_debug ? '' : " class='$class'";
    if ($id != '')
        $id = " id='$id'";
    $pars = access_string($link_text);
    if (user_graphic_links() && $icon)
        $pars[0] = set_icon($icon, $pars[0]);
    return "<a target='_blank' href='$url'$id$class $pars[1]>$pars[0]</a>";
}

it's creating THIS link

http://testing.egreene.com/sales/inquiry/30

but I need it to create THIS link

http://testing.egreene.com/reporting/prn_redirect.php?PARAM_0=3&PARAM_1=3&PARAM_2=&PARAM_3=0&PARAM_4=0&PARAM_5=&PARAM_6=0&REP_ID=127

When the system creates the current Print Order link, it comes from this.  You can see my addition of Rep. 127, But since this checks what the screen is (ST_SALESORDER) it only uses Rep. 109.  I CAN permanently change this page to show ONLY rep. 127, but I want a link for both reports since I'll use both.

function print_document_link($doc_no, $link_text, $link=true, $type_no, 
    $icon=false, $class='printlink', $id='', $email=0, $extra=0)
{
    global $path_to_root;
    include_once($path_to_root . "/includes/types.inc");

    $url = $path_to_root.'/reporting/prn_redirect.php?';
    $def_orientation = (user_def_print_orientation() == 1 ? 1 : 0);

    switch ($type_no)
    {
        case ST_SALESQUOTE :
            $rep = 111;
            // from, to, currency, email, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => '',
                'PARAM_5' => $def_orientation);
            break;
        case ST_SALESORDER :
            $rep = 109;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;
        
        case ST_SALESORDER :
            $rep = 127;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;

        case ST_CUSTDELIVERY :
            $rep = 110;
            // from, to, email, packing slip, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => $email,
                'PARAM_3' => $extra,
                'PARAM_4' => '',
                'PARAM_5' => $def_orientation);
            break;
        case ST_SALESINVOICE : // Sales Invoice
        case ST_CUSTCREDIT : // Customer Credit Note
            $rep = $type_no==ST_CUSTCREDIT ? 113 : 107;
            // from, to, currency, email, paylink, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => '',
                'PARAM_5' => '', 
                'PARAM_6' => $rep == 107 ? '' : $def_orientation);
            if ($rep == 107)
                $ar['PARAM_7'] = $def_orientation;
            break;
        case ST_PURCHORDER :
            $rep = 209;
            // from, to, currency, email, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => '',
                'PARAM_5' => $def_orientation);
            break;
        case ST_CUSTPAYMENT :
            $rep = 112;
            // from, to, currency, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => '',
                'PARAM_4' => $def_orientation);
            break;
        case ST_SUPPAYMENT :
            $rep = 210;
            // from, to, currency, email, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => '',
                'PARAM_5' => $def_orientation);
            break;
        case ST_WORKORDER :
            $rep = 409;
            // from, to, email, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => $email, 
                'PARAM_3' => '', 
                'PARAM_4' => $def_orientation);
            break;
        default:
            return null;
    }

    return print_link($link_text, $rep, $ar, "", $icon, $class, $id);
}

Re: New Copy of Sales Order

Study the code to print rep109... copy and rename

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

I think that part was already completed in the last section of code above...

       case ST_SALESORDER :
            $rep = 109;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;
        
        case ST_SALESORDER :
            $rep = 127;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;

But, that doesn't put the link where I need it.   Some how I need to use this sections

function print_factory_link($link_text, $rep, $pars = array(), $dir = '', 
    $icon=false, $class='printlink', $id='')
{
    global $path_to_root, $SysPrefs;

    $url = $dir == '' ?  $path_to_root.'/reporting/prn_redirect.php?' : $dir;

    $id = default_focus($id);
    foreach($pars as $par => $val) {
        $pars[$par] = "$par=".urlencode($val);
    }
    $pars[] = 'REP_ID='.urlencode($rep);
    $url .= implode ('&', $pars);

    if ($class != '')
        $class = $SysPrefs->pdf_debug ? '' : " class='$class'";
    if ($id != '')
        $id = " id='$id'";
    $pars = access_string($link_text);
    if (user_graphic_links() && $icon)
        $pars[0] = set_icon($icon, $pars[0]);
    return "<a target='_blank' href='$url'$id$class $pars[1]>$pars[0]</a>";
}

but shove this into it...  which I am not able to figure out.

     case ST_SALESORDER :
            $rep = 127;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;

19 (edited by poncho1234 10/02/2018 05:51:04 pm)

Re: New Copy of Sales Order

What errors are showing?
Have you set:-

33:     $debug             = 1;    // show sql on database errors
34: 
35:     $show_sql         = 1;    // show all sql queries in page footer for debugging purposes
36:     $go_debug         = 2;    // set to 1 for basic debugging, or 2 to see also backtrace after failure.

In File: \config.php

Don't forget to change them back when you have completed your changes

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

No, sure don't have that those set.  I'll try them and see what happens when I try to make the edits that break the file.

Thanks big_smile

Re: New Copy of Sales Order

Well...  here's where I am.   I tried to mimic and make this new function, but it's not creating the link as expected...

function print_factory_link($doc_no, $link_text, $link=true, $type_no, 
    $icon=false, $class='printlink', $id='', $email=0, $extra=0)
{
    global $path_to_root;
    include_once($path_to_root . "/includes/types.inc");

    $url = $path_to_root.'/reporting/prn_redirect.php?';
    $def_orientation = (user_def_print_orientation() == 1 ? 1 : 0);

    switch ($type_no)
    {
                case ST_FACTORYORDER :
            $rep = 127;
            // from, to, currency, email, quote, comments, orientation
            $ar = array(
                'PARAM_0' => $doc_no, 
                'PARAM_1' => $doc_no, 
                'PARAM_2' => '', 
                'PARAM_3' => $email, 
                'PARAM_4' => 0, 
                'PARAM_5' => '',
                'PARAM_6' => $def_orientation);
            break;
        default:
            return null;
    }

    return print_factory_link($link_text, $rep, $ar, "", $icon, $class, $id);
}

and these are my errors.

Missing argument 4 for print_factory_link(), called in .../includes/ui/db_pager_view.inc on line 107 and defined in file: .../reporting/includes/reporting.inc at line 167
...includes/ui/db_pager_view.inc:107:     print_factory_link((Array[20]),'')
.../sales/inquiry/sales_orders_view.php:321:     display_db_pager((db_pager Object))


Use of undefined constant ST_FACTORYORDER - assumed 'ST_FACTORYORDER' in file: .../reporting/includes/reporting.inc at line 178
.../includes/ui/db_pager_view.inc:107:     print_factory_link((Array[20]),'')
.../sales/inquiry/sales_orders_view.php:321:     display_db_pager((db_pager Object))


Undefined variable: type_no in file: .../reporting/includes/reporting.inc at line 178
.../includes/ui/db_pager_view.inc:107:     print_factory_link((Array[20]),'')
.../sales/inquiry/sales_orders_view.php:321:     display_db_pager((db_pager Object))

Re: New Copy of Sales Order

??? you do want to modify /sales/inquiry/sales_orders_view.php don't you?
1st you need a new type as given in post 2 above by kvvaradha
Then add you new type, and change the code in sales_orders_view.php -
Study the existing code for a sales order - add similar for the new type you have defined.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: New Copy of Sales Order

After a brief look into extension. Returned back to the basic things I told first. Glad if it helps you

Subscription service based on FA
HRM CRM POS batch Themes

Re: New Copy of Sales Order

I will give that a shot.  Thanks!

Re: New Copy of Sales Order

Ok... so far I have now gotten it to show up on my order confirmation page. So, After I have put in my order and I get my list of options, my new link and report are there and available.  That's 1/2 way...