$list[] = $data;
}
//HTML2FPDF contains the functions - headerPDF, footerPDF, createHeading, createTr
$pdf = new HTML2FPDF();
//these are some shortcut variables
$created_by = $current_user;
$created_by->retrieve($focus->created_by);
$dateModified = $focus->date_modified . "," . $app_strings["LBL_BY"] . "," . $created_by->user_name;
$modified_by = $current_user;
$modified_by->retrieve($focus->modified_user_id);
$dateEntered = $focus->date_entered . "," . $app_strings["LBL_BY"] . "," . $modified_by->user_name;
$periodic = $app_list_strings['clientrequest_samples_options'][$focus->periodic];
$samples = $app_list_strings['clientrequest_samples_options'][$focus->samples];
$description = nl2br(url2html($focus->description));
//begin the Body's html creation (the Header and Footer are called later)
$bodyHtml .= $pdf->sectionHeading($mod_strings["LBL_MODULE_NAME"], $focus->name, $focus->number);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_PRODUCT_INFORMATION"]);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_CODE"], $product->pnum, $mod_strings["LBL_ACCOUNT_NAME"], $product->account_name);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_NAME"], $product->name, $mod_strings["LBL_CONTACT_NAME"], $product->contact_name);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_REQUEST_INFORMATION"]);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_ASSIGNED_USER_ID"], $focus->assigned_user_name, $mod_strings["LBL_DUE_DATE"], $focus->due_date);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_DATE_ENTERED"], $dateEntered, $mod_strings["LBL_DATE_MODIFIED"], $dateModified);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_GENERAL"]);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_QUANTITY"], $focus->quantity, $mod_strings["LBL_PERIODIC"], $periodic);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_FILES"], $focus->files, $mod_strings["LBL_SAMPLES"], $samples);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_SPECIAL_REQUIREMENTS"], $focus->special_requirements, null, null, true);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_DESCRIPTION"], $description, null, null, true);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_OPERATIONS"]);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_OPERATIONS_DESCRIPTION"], $focus->operation_description, null, null, true);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_OTHERS"]);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_TRANSPORT"], $focus->transport, $mod_strings["LBL_PACK"], $focus->pack);
    }
    $focus = $result;
} else {
    header("Location: index.php?module=Accounts&action=index");
}
//HTML2FPDF contains the functions - headerPDF, footerPDF, createHeading, createTr
$pdf = new HTML2FPDF();
//Shortcuts
$total = $focus->total_paper + $focus->total_prepress + $focus->total_press + $focus->total_operations . " " . $mod_strings["LBL_UNITS"];
$total_paper = $focus->total_paper . " " . $mod_strings["LBL_UNITS"];
$total_prepress = $focus->total_prepress . " " . $mod_strings["LBL_UNITS"];
$total_press = $focus->total_press . " " . $mod_strings["LBL_UNITS"];
$total_operations = $focus->total_operations . " " . $mod_strings["LBL_UNITS"];
$status = $app_list_strings['componentestimatecalc_status_dom'][$focus->status];
//begin the Body's html creation (the Header and Footer are called later)
$bodyHtml .= $pdf->sectionHeading($mod_strings["LBL_MODULE_NAME"], $focus->name);
$bodyHtml .= $pdf->createHeading();
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_NAME"], $focus->name, $mod_strings["LBL_ASSIGNED_USER_ID"], $focus->assigned_user_name);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_COMPONENT_NAME"], $focus->component_name, $mod_strings["LBL_ESTIMATE_NAME"], $focus->estimate_name);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_TOTAL"], $total, $mod_strings["LBL_DESCRIPTION"], nl2br(url2html($focus->description)));
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_PAPER_TOTAL"], $total_paper, $mod_strings["LBL_PREPRESS_TOTAL"], $total_prepress);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_PRESS_TOTAL"], $total_press, $mod_strings["LBL_OPERATIONS_TOTAL"], $total_operations);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_STATUS"], $status);
//$bodyHtml .= "<newpage>";
$paperEst = $focus->paperEstimate($focus->component_id, null, false, true);
$pressEst = $focus->pressEstimate($focus->component_id, null, false, true);
$operationsEst = $focus->operationsEstimate($focus->component_id, false, true);
$prepressEst = $focus->prepressEstimate($focus->component_id, false, true);
$compsHtml = "";
$compsHtml .= $pdf->sectionHeading($mod_strings["LBL_DETAILED_INFO"]);
//shortcuts
$fields = array('name', 'type', 'number', 'paper', 'fsize_h', 'fsize_w');
$query = "SELECT name, type, number, paper, fsize_h, fsize_w  FROM `estimates_components` WHERE parent_id='" . $focus->id . "' AND deleted=0";
$result = $focus->db->query($query, true, "Error filling layout fields: ");
while (($row = $focus->db->fetchByAssoc($result)) != null) {
    foreach ($fields as $field) {
        $data[$field] = $row[$field];
    }
    $list[] = $data;
}
//HTML2FPDF contains the functions - headerPDF, footerPDF, createHeading, createTr
$pdf = new HTML2FPDF();
//Shortcuts
$status = $app_list_strings['estimate_component_status'][$focus->sub_status];
//begin the Body's html creation (the Header and Footer are called later)
$bodyHtml = "";
$bodyHtml .= $pdf->sectionHeading($mod_strings["LBL_MODULE_NAME"], $focus->name, $focus->number);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_PRODUCT_INFORMATION"]);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_CODE"], $focus->number, $mod_strings["LBL_ACCOUNT_NAME"], $focus->account_name);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_NAME"], $focus->name, $mod_strings["LBL_CONTACT_NAME"], $focus->contact_name);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_STATUS"], $status);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_ESTIMATE_QTY"]);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_QUANTITY"], $focus->quantity, $mod_strings["LBL_SAMPLES"], $focus->samples);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_DEADLINE"], $focus->deadline, $mod_strings["LBL_FILE"], $focus->file);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_COMPONENTS_LIST"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_NAME"], true, true, false);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_TYPE"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_NUMBER"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_PAPER"], false, false, false, "25%");
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_FSIZE_H"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COMP_FSIZE_W"], false, false, true);
$bodyHtml .= $pdf->CompRows($list);
$payment_term = $app_list_strings['payment_terms'][$focus->payment_term];
$shipping_term = $app_list_strings['shipping_term_dom'][$focus->shipping_term];
$payment_method = $app_list_strings['payment_method_dom'][$focus->payment_method];
$address = $focus->billtocity . ", " . $focus->billpostalcode . ", " . $focus->billtostate . ", " . $focus->billtocountry;
if (isset($focus->currency_id) && !empty($focus->currency_id)) {
    $currency->retrieve($focus->currency_id);
    if ($currency->deleted != 1) {
        $curr = $currency->name;
    } else {
        $curr = $currency->getDefaultCurrencyName();
    }
} else {
    ${$curr} = $currency->getDefaultCurrencyName();
}
//begin the Body's html creation (the Header and Footer are called later)
$bodyHtml .= $pdf->sectionHeading($mod_strings["LBL_MODULE_NAME"], $focus->name, $focus->quotenum);
$bodyHtml .= $pdf->createHeading();
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_NAME"], $focus->name, $mod_strings["LBL_QUOTENUM"], $focus->quotenum);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_OPPORTUNITY_NAME"], $focus->opportunity_name, $mod_strings["LBL_STAGE"], $stage);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_ACCOUNT_NAME"], $focus->account_name, $mod_strings["LBL_BILLTOCONTACTNAME"], $focus->billtocontactname);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_CURRENCY"], $curr, $mod_strings["LBL_PAYMENT_METHOD"], $payment_method);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_PAYMENT_TERM"], $payment_term, $mod_strings["LBL_SHIPPING_TERM"], $shipping_term);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_ASSIGNEDUSER"], $focus->assigned_user_name, $mod_strings["LBL_VALIDUNTIL"], $focus->validuntil);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_BILLTOADDRESS"], $address);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_LINEITEMS"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_PRODUCT"], true, true, false, "20%");
$bodyHtml .= $pdf->genCells($mod_strings["LBL_PRODUCT_NUMBER"], false, false, false, "20%");
$bodyHtml .= $pdf->genCells($mod_strings["LBL_TOTAL_PAPER"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_TOTAL_PREPRESS"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_TOTAL_PRESS"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_TOTAL_OPERATIONS"]);
        sugar_die($app_strings['ERROR_NO_RECORD']);
    }
    $focus = $result;
} else {
    header("Location: index.php?module=Accounts&action=index");
}
//HTML2FPDF contains the functions - headerPDF, footerPDF, createHeading, createTr
$pdf = new HTML2FPDF();
//Shortcuts
$total = $focus->total_paper + $focus->total_prepress + $focus->total_press + $focus->total_operations . " " . $mod_strings["LBL_UNITS"];
$total_paper = $focus->total_paper . " " . $mod_strings["LBL_UNITS"];
$total_prepress = $focus->total_prepress . " " . $mod_strings["LBL_UNITS"];
$total_press = $focus->total_press . " " . $mod_strings["LBL_UNITS"];
$total_operations = $focus->total_operations . " " . $mod_strings["LBL_UNITS"];
//begin the Body's html creation (the Header and Footer are called later)
$bodyHtml .= $pdf->sectionHeading($mod_strings["LBL_MODULE_NAME"], $focus->name);
$bodyHtml .= $pdf->createHeading();
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_NAME"], $focus->name, $mod_strings["LBL_ASSIGNED_USER_ID"], $focus->assigned_user_name);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_ESTIMATE_NAME"], $focus->estimate_name, $mod_strings["LBL_STATUS"], $focus->status);
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_ESTIMATE_TOTAL"], $total, $mod_strings["LBL_DESCRIPTION"], nl2br(url2html($focus->description)));
$bodyHtml .= $pdf->createTr(false, $mod_strings["LBL_PAPER_ESTIMATE"], $total_paper, $mod_strings["LBL_PREPRESS_ESTIMATE"], $total_prepress);
$bodyHtml .= $pdf->createTr(true, $mod_strings["LBL_PRESS_ESTIMATE"], $total_press, $mod_strings["LBL_OPERATIONS_ESTIMATE"], $total_operations);
$bodyHtml .= $pdf->createHeading();
$bodyHtml .= $focus->component_estimate_pdf();
$bodyHtml .= "<newpage>";
////
////
//Prepress
$CompEstCalc = new ComponentEstimateCalc();
$query = 'SELECT component_id FROM ' . $CompEstCalc->table_name . ' WHERE estimate_id="' . $focus->estimate_id . '" AND deleted=0 ';
$result = $focus->db->query($query, true, "Error filling layout fields: ");