$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");
}
for ($i = 0; $i < count($productrows); $i++) {
    $fieldcount = count($productrows[$i]);
    $xtpl->assign("PRODUCTROWS", $focus->getProductRow($productrows[$i], $i, true));
    $xtpl->parse("main.row1");
}
$xtpl->assign('PRODUCTCOUNT', count($productrows));
$xtpl->assign('PurchaseOrder', $xtpl_data);
$timedate = new TimeDate();
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
$xtpl->assign("USER_DATE_FORMAT", $timedate->get_user_date_format());
if (empty($focus->id)) {