} else {
    if (!empty($_REQUEST['record'])) {
        $xtpl->assign("RETURN_ID", $_REQUEST['record']);
    }
}
//when create without save, click save.
if (empty($_REQUEST['return_id'])) {
    $xtpl->assign("RETURN_ACTION", 'index');
}
if (!empty($xtpl_data['STATUS']) && $xtpl_data['STATUS'] > 0) {
    $xtpl_data['STATUS_CHECKED'] = 'checked';
}
$xtpl->assign("JAVASCRIPT", get_set_focus_js() . get_validate_record_js());
$xtpl->assign("JAVASCRIPT_PRODUCT", get_product_js());
$xtpl->assign("THEME", $theme);
$xtpl_data = $focus->get_xtemplate_data();
if (!$focus->num_pref && !$focus->num) {
    $ppref = 'POR';
    $pnumber = $focus->generate_number();
    $xtpl->assign('num_pref', $ppref);
    $xtpl->assign('num_suf', $pnumber);
} else {
    $xtpl->assign('num_pref', $focus->num_pref);
    $xtpl->assign('num_suf', $focus->num_suf);
}
global $current_user;
$xtpl->assign("PAYMENT_TERM", get_select_options_with_id($app_list_strings['payment_terms'], $focus->payment_term));
$productrows = $focus->getProductRows();
if (count($productrows) == 0) {
    $xtpl->assign("PRODUCTROWS", $focus->getProductRow(new PurchaseOrderLine(), 0, true));
    $xtpl->parse("main.row1");