function prt_link($row)
{
    if ($row['type'] == ST_JOURNAL) {
        $trans_type = ST_JOURNAL;
    }
    if ($row['type'] == ST_DISBURSEMENT) {
        $trans_type = ST_DISBURSEMENT;
    }
    return print_document_link($row['type_no'], _("&Print"), true, $trans_type);
}
function prt_link($row)
{
    if (!isset($row['type'])) {
        $row['type'] = $_POST['filterType'];
    }
    if ($row['type'] == ST_PURCHORDER || $row['type'] == ST_SALESORDER || $row['type'] == ST_SALESQUOTE || $row['type'] == ST_WORKORDER) {
        return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT);
    } else {
        return print_document_link($row['trans_no'] . "-" . $row['type'], _("Print"), true, $row['type'], ICON_PRINT);
    }
}
function handle_report()
{
    global $Ajax;
    if (can_process()) {
        $from = $_POST['TransFromDate'];
        $to = $_POST['TransToDate'];
        $typeId = $_POST['typeId'];
        $accountId = $_POST['accountId'];
        display_notification(_('Report successfully generated.'));
        $arr = array($from, $to, $typeId, $accountId);
        $trans_type = ST_SUBSIDIARY;
        display_note(print_document_link($arr, _("&Print Report"), true, $trans_type));
    } else {
        display_notification(_('Report not generated, please contact the administrator.'));
    }
    $Ajax->activate('_page_body');
    return;
}
Exemple #4
0
function prt_link($row)
{
    if ($row['type'] == ST_SUPPAYMENT || $row['type'] == ST_BANKPAYMENT || $row['type'] == ST_SUPPCREDIT) {
        return print_document_link($row['trans_no'] . "-" . $row['type'], _("Print Remittance"), true, ST_SUPPAYMENT, ICON_PRINT);
    }
}
 function submenu_print($title, $type, $number, $id = null, $email = 0, $extra = 0)
 {
     display_note(print_document_link($number, $title, true, $type, false, 'printlink', $id, $email, $extra), 0, 1);
 }
    $credit_no = $_GET['AddedID'];
    $trans_type = ST_CUSTCREDIT;
    display_notification_centered(_("Credit Note has been processed"));
    display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View This Credit Note")), 0, 0);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Print This Credit Note"), true, $trans_type), 1);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Email This Credit Note"), true, $trans_type, false, "printlink", "", 1), 1);
    display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")), 1);
    hyperlink_params("{$path_to_root}/admin/attachments.php", _("Add an Attachment"), "filterType={$trans_type}&trans_no={$credit_no}");
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $credit_no = $_GET['UpdatedID'];
    $trans_type = ST_CUSTCREDIT;
    display_notification_centered(_("Credit Note has been updated"));
    display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View This Credit Note")), 0, 0);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Print This Credit Note"), true, $trans_type), 1);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Email This Credit Note"), true, $trans_type, false, "printlink", "", 1), 1);
    display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")), 1);
    display_footer_exit();
} else {
    check_edit_conflicts();
}
//-----------------------------------------------------------------------------
function can_process()
{
    global $Refs;
    /*===================MOODLEARNING===========================*/
    if (!get_post('custom_num')) {
        display_error(_("You must enter a Credit Memo No."));
        set_focus('custom_num');
        return false;
    }
    $sql = "SELECT trans_type_from, trans_no_from FROM " . TB_PREF . "cust_allocations\n\t\t\tWHERE trans_type_to=" . ST_SALESINVOICE . " AND trans_no_to=" . db_escape($invoice_no);
    $result = db_query($sql, "could not retrieve customer allocation");
    $row = db_fetch($result);
    if ($row === false) {
        hyperlink_params("{$path_to_root}/sales/customer_payments.php", _("Entry &customer payment for this invoice"), "SInvoice=" . $invoice_no);
    }
    hyperlink_params("{$path_to_root}/admin/attachments.php", _("Add an Attachment"), "filterType={$trans_type}&trans_no={$invoice_no}");
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $invoice_no = $_GET['UpdatedID'];
    $trans_type = ST_SALESINVOICE;
    display_notification_centered(sprintf(_('Sales Invoice # %d has been updated.'), $invoice_no));
    display_note(get_trans_view_str(ST_SALESINVOICE, $invoice_no, _("&View This Invoice")));
    echo '<br>';
    display_note(print_document_link($invoice_no . "-" . $trans_type, _("&Print This Invoice"), true, ST_SALESINVOICE));
    display_note(print_document_link($invoice_no . "-" . $trans_type, _("&Email This Invoice"), true, ST_SALESINVOICE, false, "printlink", "", 1), 1);
    hyperlink_no_params($path_to_root . "/sales/inquiry/customer_inquiry.php", _("Select Another &Invoice to Modify"));
    display_footer_exit();
} elseif (isset($_GET['RemoveDN'])) {
    for ($line_no = 0; $line_no < count($_SESSION['Items']->line_items); $line_no++) {
        $line =& $_SESSION['Items']->line_items[$line_no];
        if ($line->src_no == $_GET['RemoveDN']) {
            $line->quantity = $line->qty_done;
            $line->qty_dispatched = 0;
        }
    }
    unset($line);
    // Remove also src_doc delivery note
    $sources =& $_SESSION['Items']->src_docs;
    unset($sources[$_GET['RemoveDN']]);
}
 label_cell($preview_order_str);
 label_cell($myrow["reference"]);
 label_cell($date, "nowrap");
 label_cell($due_date_str, "nowrap");
 if ($_POST['customer_id'] == reserved_words::get_all()) {
     label_cell($myrow["CustName"]);
 }
 label_cell($branch_name);
 if ($_POST['customer_id'] == reserved_words::get_all()) {
     label_cell($myrow["CustCurrCode"]);
 }
 display_debit_or_credit_cells($myrow['type'] == 11 || $myrow['type'] == 12 || $myrow['type'] == 2 ? -$myrow["TotalAmount"] : $myrow["TotalAmount"]);
 echo $gl_trans_str;
 label_cell($edit_page == '' ? '' : "<a href='{$edit_page}'>" . tr('Edit') . '</a>');
 if ($myrow['type'] == 10 || $myrow['type'] == 11) {
     label_cell(print_document_link($myrow['trans_no'], tr("Print"), true, $myrow['type']));
 } else {
     label_cell("");
 }
 if ($credit_me_str != "") {
     label_cell($credit_me_str, "nowrap");
 } else {
     label_cell('');
 }
 end_row();
 $j++;
 if ($j == 12) {
     $j = 1;
     table_header($th);
 }
 //end of page full new headings if
    $invoice_no = $_GET['AddedID'];
    $trans_type = 10;
    print_hidden_script(10);
    display_notification(tr("Selected deliveries has been processed"), true);
    display_note(get_customer_trans_view_str($trans_type, $invoice_no, tr("View This Invoice")), 0, 1);
    display_note(print_document_link($invoice_no, tr("Print This Invoice"), true, 10));
    display_note(get_gl_view_str($trans_type, $invoice_no, tr("View the GL Journal Entries for this Invoice")), 1);
    hyperlink_params("{$path_to_root}/sales/inquiry/sales_deliveries_view.php", tr("Select Another Delivery For Invoicing"), "OutstandingOnly=1");
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $invoice_no = $_GET['UpdatedID'];
    print_hidden_script(10);
    display_notification_centered(sprintf(tr('Sales Invoice # %d has been updated.'), $invoice_no));
    display_note(get_trans_view_str(10, $invoice_no, tr("View This Invoice")));
    echo '<br>';
    display_note(print_document_link($invoice_no, tr("Print This Invoice"), true, 10));
    hyperlink_no_params($path_to_root . "/sales/inquiry/customer_inquiry.php", tr("Select A Different Invoice to Modify"));
    display_footer_exit();
} elseif (isset($_GET['RemoveDN'])) {
    for ($line_no = 0; $line_no < count($_SESSION['Items']->line_items); $line_no++) {
        $line =& $_SESSION['Items']->line_items[$line_no];
        if ($line->src_no == $_GET['RemoveDN']) {
            $line->quantity = $line->qty_done;
            $line->qty_dispatched = 0;
        }
    }
    unset($line);
}
//-----------------------------------------------------------------------------
if (isset($_GET['DeliveryNumber']) && $_GET['DeliveryNumber'] > 0 || isset($_GET['BatchInvoice'])) {
    processing_start();
check_db_has_stock_items(_("There are no items defined in the system."));
check_db_has_customer_branches(_("There are no customers, or there are no customers with branches. Please define customers and customer branches."));
//-----------------------------------------------------------------------------
if (list_updated('branch_id')) {
    // when branch is selected via external editor also customer can change
    $br = get_branch(get_post('branch_id'));
    $_POST['customer_id'] = $br['debtor_no'];
    $Ajax->activate('customer_id');
}
if (isset($_GET['AddedID'])) {
    $credit_no = $_GET['AddedID'];
    $trans_type = ST_CUSTCREDIT;
    display_notification_centered(sprintf(_("Credit Note # %d has been processed"), $credit_no));
    display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View this credit note")), 0, 1);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Print This Credit Invoice"), true, ST_CUSTCREDIT), 0, 1);
    display_note(print_document_link($credit_no . "-" . $trans_type, _("&Email This Credit Invoice"), true, ST_CUSTCREDIT, false, "printlink", "", 1), 0, 1);
    display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")));
    hyperlink_params($_SERVER['PHP_SELF'], _("Enter Another &Credit Note"), "NewCredit=yes");
    hyperlink_params("{$path_to_root}/admin/attachments.php", _("Add an Attachment"), "filterType={$trans_type}&trans_no={$credit_no}");
    display_footer_exit();
} else {
    check_edit_conflicts();
}
//--------------------------------------------------------------------------------
function line_start_focus()
{
    global $Ajax;
    $Ajax->activate('items_table');
    set_focus('_stock_id_edit');
}
//-----------------------------------------------------------------------------
function prt_link($row)
{
    if ($row['type'] == ST_CUSTPAYMENT || $row['type'] == ST_BANKDEPOSIT) {
        return print_document_link($row['trans_no'] . "-" . $row['type'], _("Print Receipt"), true, ST_CUSTPAYMENT, ICON_PRINT);
    } elseif ($row['type'] == ST_BANKPAYMENT) {
        // bank payment printout not defined yet.
        return '';
    } else {
        return print_document_link($row['trans_no'] . "-" . $row['type'], _("Print"), true, $row['type'], ICON_PRINT);
    }
}
    display_note(print_document_link($dispatch_no, _("&Print Delivery Note"), true, ST_CUSTDELIVERY));
    display_note(print_document_link($dispatch_no, _("&Email Delivery Note"), true, ST_CUSTDELIVERY, false, "printlink", "", 1), 1, 1);
    display_note(print_document_link($dispatch_no, _("P&rint as Packing Slip"), true, ST_CUSTDELIVERY, false, "printlink", "", 0, 1));
    display_note(print_document_link($dispatch_no, _("E&mail as Packing Slip"), true, ST_CUSTDELIVERY, false, "printlink", "", 1, 1), 1);
    display_note(get_gl_view_str(13, $dispatch_no, _("View the GL Journal Entries for this Dispatch")), 1);
    hyperlink_params("{$path_to_root}/sales/customer_invoice.php", _("Invoice This Delivery"), "DeliveryNumber={$dispatch_no}");
    hyperlink_params("{$path_to_root}/sales/inquiry/sales_orders_view.php", _("Select Another Order For Dispatch"), "OutstandingOnly=1");
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $delivery_no = $_GET['UpdatedID'];
    display_notification_centered(sprintf(_('Delivery Note # %d has been updated.'), $delivery_no));
    display_note(get_trans_view_str(ST_CUSTDELIVERY, $delivery_no, _("View this delivery")), 0, 1);
    display_note(print_document_link($delivery_no, _("&Print Delivery Note"), true, ST_CUSTDELIVERY));
    display_note(print_document_link($delivery_no, _("&Email Delivery Note"), true, ST_CUSTDELIVERY, false, "printlink", "", 1), 1, 1);
    display_note(print_document_link($delivery_no, _("P&rint as Packing Slip"), true, ST_CUSTDELIVERY, false, "printlink", "", 0, 1));
    display_note(print_document_link($delivery_no, _("E&mail as Packing Slip"), true, ST_CUSTDELIVERY, false, "printlink", "", 1, 1), 1);
    hyperlink_params($path_to_root . "/sales/customer_invoice.php", _("Confirm Delivery and Invoice"), "DeliveryNumber={$delivery_no}");
    hyperlink_params($path_to_root . "/sales/inquiry/sales_deliveries_view.php", _("Select A Different Delivery"), "OutstandingOnly=1");
    display_footer_exit();
}
//-----------------------------------------------------------------------------
if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
    $ord = new Cart(ST_SALESORDER, $_GET['OrderNumber'], true);
    if ($ord->count_items() == 0) {
        hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", _("Select a different sales order to delivery"), "OutstandingOnly=1");
        die("<br><b>" . _("This order has no items. There is nothing to delivery.") . "</b>");
    }
    // Adjust Shipping Charge based upon previous deliveries TAM
    adjust_shipping_charge($ord, $_GET['OrderNumber']);
    $_SESSION['Items'] = $ord;
    copy_from_cart();
if (isset($_GET['AddedID'])) {
    $credit_no = $_GET['AddedID'];
    $trans_type = 11;
    print_hidden_script(11);
    display_notification_centered(tr("Credit Note has been processed"));
    display_note(get_customer_trans_view_str($trans_type, $credit_no, tr("View This Credit Note")), 0, 0);
    display_note(print_document_link($credit_no, tr("Print This Credit Note"), true, 11), 1);
    display_note(get_gl_view_str($trans_type, $credit_no, tr("View the GL Journal Entries for this Credit Note")), 1);
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $credit_no = $_GET['UpdatedID'];
    $trans_type = 11;
    print_hidden_script(11);
    display_notification_centered(tr("Credit Note has been updated"));
    display_note(get_customer_trans_view_str($trans_type, $credit_no, tr("View This Credit Note")), 0, 0);
    display_note(print_document_link($credit_no, tr("Print This Credit Note"), true, 11), 1);
    display_note(get_gl_view_str($trans_type, $credit_no, tr("View the GL Journal Entries for this Credit Note")), 1);
    display_footer_exit();
}
//-----------------------------------------------------------------------------
function can_process()
{
    if (!is_date($_POST['CreditDate'])) {
        display_error(tr("The entered date is invalid."));
        set_focus('CreditDate');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['CreditDate'])) {
        display_error(tr("The entered date is not in fiscal year."));
        set_focus('CreditDate');
        return false;
    }
function prt_link($row)
{
    return print_document_link($row['invoice_no'], _("&Print"), true, ST_VOUCHER);
}
} else {
    $th = array(tr("#"), tr("Reference"), tr("Supplier"), tr("Supplier's Reference"), tr("Order Date"), tr("Currency"), tr("Order Total"), "");
}
table_header($th);
$j = 1;
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    $date = sql2date($myrow["ord_date"]);
    label_cell(get_trans_view_str(systypes::po(), $myrow["order_no"]));
    label_cell($myrow["reference"]);
    label_cell($myrow["supp_name"]);
    if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == reserved_words::get_all()) {
        label_cell($myrow["location_name"]);
    }
    label_cell($myrow["requisition_no"]);
    label_cell($date);
    label_cell($myrow["curr_code"]);
    amount_cell($myrow["OrderValue"]);
    label_cell(print_document_link($myrow['order_no'], tr("Print")));
    end_row();
    $j++;
    if ($j == 12) {
        $j = 1;
        table_header($th);
    }
}
end_table(2);
//---------------------------------------------------------------------------------------------------
end_page();
function handle_search()
{
    global $table_style;
    if (check_valid_entries() == true) {
        $db_info = get_systype_db_info($_POST['filterType']);
        if ($db_info == null) {
            return;
        }
        $table_name = $db_info[0];
        $type_name = $db_info[1];
        $trans_no_name = $db_info[2];
        $trans_ref = $db_info[3];
        $sql = "SELECT DISTINCT {$trans_no_name} ";
        if ($trans_ref) {
            $sql .= " ,{$trans_ref} ";
        }
        $sql .= " FROM {$table_name}\n\t\t\tWHERE {$trans_no_name} >= " . $_POST['FromTransNo'] . "\n\t\t\tAND  {$trans_no_name} <= " . $_POST['ToTransNo'];
        if ($type_name != null) {
            $sql .= " AND {$type_name} = " . $_POST['filterType'];
        }
        $sql .= " ORDER BY {$trans_no_name}";
        $result = db_query($sql, "could not query transactions on {$table_name}");
        if (db_num_rows($result) == 0) {
            echo tr("There are no transactions for the given parameters.");
            return;
        }
        $print_type = $_POST['filterType'];
        $print_out = $print_type == 10 || $print_type == 11 || $print_type == systypes::cust_dispatch() || $print_type == systypes::po() || $print_type == systypes::sales_order();
        if ($print_out) {
            print_hidden_script($print_type);
            if ($trans_ref) {
                $th = array(tr("#"), tr("Reference"), tr("View"), tr("Print"), tr("GL"));
            } else {
                $th = array(tr("#"), tr("View"), tr("Print"), tr("GL"));
            }
        } else {
            if ($trans_ref) {
                $th = array(tr("#"), tr("Reference"), tr("View"), tr("GL"));
            } else {
                $th = array(tr("#"), tr("View"), tr("GL"));
            }
        }
        start_table($table_style);
        table_header($th);
        $k = 0;
        while ($line = db_fetch($result)) {
            alt_table_row_color($k);
            label_cell($line[$trans_no_name]);
            if ($trans_ref) {
                label_cell($line[$trans_ref]);
            }
            label_cell(get_trans_view_str($_POST['filterType'], $line[$trans_no_name], tr("View")));
            if ($print_out) {
                label_cell(print_document_link($line[$trans_no_name], tr("Print"), true, $print_type));
            }
            label_cell(get_gl_view_str($_POST['filterType'], $line[$trans_no_name], tr("View GL")));
            end_row();
        }
        end_table();
    }
}
     label_cell($myrow["curr_code"]);
     if ($_POST['order_view_mode'] == 'OutstandingOnly') {
         $delivery_note = $path_to_root . "/sales/customer_delivery.php?" . SID . "OrderNumber=" . $myrow["order_no"];
         label_cell("<a href='{$delivery_note}'>" . tr("Dispatch") . "</a>");
     } elseif ($_POST['order_view_mode'] == 'InvoiceTemplates') {
         $select_order = $path_to_root . "/sales/sales_order_entry.php?" . SID . "NewInvoice=" . $myrow["order_no"];
         label_cell("<a href='{$select_order}'>" . tr("Invoice") . "</a>");
     } elseif ($_POST['order_view_mode'] == 'DeliveryTemplates') {
         $select_order = $path_to_root . "/sales/sales_order_entry.php?" . SID . "NewDelivery=" . $myrow["order_no"];
         label_cell("<a href='{$select_order}'>" . tr("Delivery") . "</a>");
     } else {
         echo "<td><input " . ($myrow["type"] == 1 ? 'checked' : '') . " type='checkbox' name='chgtpl" . $myrow["order_no"] . "' value='1'\n\t\t   \t\tonclick='this.form.ChangeTmpl.value= this.name.substr(6);\n\t\t   \t\tthis.form.submit();' ></td>";
         $modify_page = $path_to_root . "/sales/sales_order_entry.php?" . SID . "ModifyOrderNumber=" . $myrow["order_no"];
         label_cell("<a href='{$modify_page}'>" . tr("Edit") . "</a>");
         label_cell(print_document_link($myrow['order_no'], tr("Print"), true, 30, 0));
         label_cell(print_document_link($myrow['order_no'], tr("Quote"), true, 30, 1));
     }
     end_row();
     $j++;
     if ($j == 12) {
         $j = 1;
         table_header($th);
     }
     //end of page full new headings if
 }
 //end of while loop
 hidden('ChangeTmpl', 0);
 end_form();
 end_table();
 if ($overdue_items) {
     display_note(tr("Marked items are overdue."), 0, 1, "class='overduefg'");
    $dispatch_no = $_GET['AddedID'];
    print_hidden_script(13);
    display_notification(tr("Dispatch processed:") . ' ' . $_GET['AddedID'], true);
    display_note(get_customer_trans_view_str(13, $dispatch_no, tr("View this dispatch")), 0, 1);
    display_note(print_document_link($dispatch_no, tr("Print this delivery"), true, 13));
    display_note(get_gl_view_str(13, $dispatch_no, tr("View the GL Journal Entries for this Dispatch")), 1);
    hyperlink_params("{$path_to_root}/sales/customer_invoice.php", tr("Invoice This Delivery"), "DeliveryNumber={$dispatch_no}");
    hyperlink_params("{$path_to_root}/sales/inquiry/sales_orders_view.php", tr("Select Another Order For Dispatch"), "OutstandingOnly=1");
    display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
    $delivery_no = $_GET['UpdatedID'];
    print_hidden_script(13);
    display_notification_centered(sprintf(tr('Delivery Note # %d has been updated.'), $delivery_no));
    display_note(get_trans_view_str(13, $delivery_no, tr("View this delivery")));
    echo '<br>';
    display_note(print_document_link($delivery_no, tr("Print this delivery"), true, 13));
    hyperlink_params($path_to_root . "/sales/customer_invoice.php", tr("Confirm Delivery and Invoice"), "DeliveryNumber={$delivery_no}");
    hyperlink_params($path_to_root . "/sales/inquiry/sales_deliveries_view.php", tr("Select A Different Delivery"), "OutstandingOnly=1");
    display_footer_exit();
}
//-----------------------------------------------------------------------------
if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
    $ord = new Cart(30, $_GET['OrderNumber'], true);
    /*read in all the selected order into the Items cart  */
    if ($ord->count_items() == 0) {
        hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", tr("Select a different sales order to delivery"), "OutstandingOnly=1");
        die("<br><b>" . tr("This order has no items. There is nothing to delivery.") . "</b>");
    }
    $ord->trans_type = 13;
    $ord->src_docs = $ord->trans_no;
    $ord->order_no = key($ord->trans_no);
    echo '<br>';
    display_note(print_document_link($delivery, tr("Print Delivery Note"), true, 13));
    hyperlink_params($path_to_root . "/sales/customer_invoice.php", tr("Make Invoice Against This Delivery"), "DeliveryNumber={$delivery}");
    if (isset($_GET['Type']) && $_GET['Type'] == 1) {
        hyperlink_params("inquiry/sales_orders_view.php", tr("Enter a New Template Delivery"), "DeliveryTemplates=Yes");
    } else {
        hyperlink_params($_SERVER['PHP_SELF'], tr("Enter a New Delivery"), "NewDelivery=0");
    }
    display_footer_exit();
} elseif (isset($_GET['AddedDI'])) {
    $invoice = $_GET['AddedDI'];
    print_hidden_script(10);
    display_notification_centered(sprintf(tr("Invoice # %d has been entered."), $invoice));
    display_note(get_trans_view_str(10, $invoice, tr("View This Invoice")));
    echo '<br>';
    display_note(print_document_link($invoice, tr("Print Sales Invoice"), true, 10));
    if (isset($_GET['Type']) && $_GET['Type'] == 1) {
        hyperlink_params("inquiry/sales_orders_view.php", tr("Enter a New Template Invoice"), "InvoiceTemplates=Yes");
    } else {
        hyperlink_params($_SERVER['PHP_SELF'], tr("Enter a New Direct Invoice"), "NewInvoice=0");
    }
    display_footer_exit();
}
//-----------------------------------------------------------------------------
function copy_to_cart()
{
    $cart =& $_SESSION['Items'];
    if ($cart->trans_type != 30) {
        $cart->reference = $_POST['ref'];
    }
    $cart->Comments = $_POST['Comments'];
page($_SESSION['page_title'], false, false, "", $js);
//---------------------------------------------------------------------------------------------------
check_db_has_suppliers(_("There are no suppliers defined in the system."));
check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system."));
//---------------------------------------------------------------------------------------------------------------
if (isset($_GET['AddedID'])) {
    $order_no = $_GET['AddedID'];
    $trans_type = ST_PURCHORDER;
    if (!isset($_GET['Updated'])) {
        display_notification_centered(_("Purchase Order has been entered"));
    } else {
        display_notification_centered(_("Purchase Order has been updated") . " #{$order_no}");
    }
    display_note(get_trans_view_str($trans_type, $order_no, _("&View this order")), 0, 1);
    display_note(print_document_link($order_no, _("&Print This Order"), true, $trans_type), 0, 1);
    display_note(print_document_link($order_no, _("&Email This Order"), true, $trans_type, false, "printlink", "", 1));
    hyperlink_params($path_to_root . "/purchasing/po_receive_items.php", _("&Receive Items on this Purchase Order"), "PONumber={$order_no}");
    hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another Purchase Order"), "NewOrder=yes");
    hyperlink_no_params($path_to_root . "/purchasing/inquiry/po_search.php", _("Select An &Outstanding Purchase Order"));
    display_footer_exit();
} elseif (isset($_GET['AddedGRN'])) {
    $trans_no = $_GET['AddedGRN'];
    $trans_type = ST_SUPPRECEIVE;
    display_notification_centered(_("Direct GRN has been entered"));
    display_note(get_trans_view_str($trans_type, $trans_no, _("&View this GRN")), 0);
    $clearing_act = get_company_pref('grn_clearing_act');
    if ($clearing_act) {
        display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL Journal Entries for this Delivery")), 1);
    }
    // not yet
    //	display_note(print_document_link($trans_no, _("&Print This GRN"), true, $trans_type), 0, 1);
function prt_link($row)
{
    global $trans_type;
    return print_document_link($row['order_no'], _("Print"), true, $trans_type, ICON_PRINT);
}
function prt_link($row)
{
    return print_document_link($row['order_no'], _("Print"), true, 18, ICON_PRINT);
}
function prt_link($row)
{
    return print_document_link($row['trans_no'], _("Print"), true, ST_CUSTDELIVERY, ICON_PRINT);
}
function prt_link($row)
{
    if ($row['type'] == ST_SUPPAYMENT || $row['type'] == ST_BANKPAYMENT || $row['type'] == ST_SUPPCREDIT) {
        return print_document_link($row['trans_no'] . "-" . $row['type'], _("Print Check Voucher"), true, ST_DISBURSEMENT, ICON_PRINT);
    }
}
$js = '';
if ($use_popup_windows) {
    $js .= get_js_open_window(800, 500);
}
if ($use_date_picker) {
    $js .= get_js_date_picker();
}
/*========================================START OF PAGE=========================================*/
page(_($help_context = "Manage Commission"), @$_REQUEST['popup'], false, "", $js);
global $imc;
if (isset($_GET['AddedID'])) {
    $id = $_GET['AddedID'];
    $trans_type = ST_VOUCHER;
    display_notification_centered(sprintf(_("Commission Voucher for Invoice # %d has been entered."), $id));
    submenu_option(_("Create New Commission Voucher"), "/sales/ml/commission_voucher.php");
    display_note(print_document_link($id, _("&Print Voucher"), true, $trans_type));
    display_footer_exit();
}
function clear_data()
{
    unset($_POST['commission']);
}
function computation_1($gross, $tax, $commission)
{
    $sub1 = $gross * ($commission / 100);
    $sub2 = $sub1 * ($tax / 100);
    $totalcommission = $sub1 - $sub2;
    $_POST['total'] = $totalcommission;
    $_POST['tax'] = $sub2;
}
function can_process()