$query = "SELECT name, type, number, paper FROM `clientorders_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;
}
//////////////
$xtpl = new XTemplate("modules/{$currentModule}/CreatePDF.html");
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$pdf = new HTML2FPDF();
$xtpl->assign("HEADER", $pdf->headerPDF());
$xtpl->assign("FOOTER", $pdf->footerPDF());
$xtpl->assign("ROWS", $pdf->CompRows($list));
$xtpl->parse("main.row1");
//Assign layout attributes
$xtpl->assign("LABEL_COLOR", $pdfColors["label"]);
$xtpl->assign("FIELD_COLOR", $pdfColors["field"]);
$xtpl->assign("colspan", count($fields));
$xtpl->assign("fSize", $pdfFontSize["default"]);
$xtpl->assign("headingFontSize", $pdfFontSize["heading"]);
$xtpl->assign("headingColor", $pdfColors["heading"]);
$xtpl->assign("titleColor", $pdfColors["headerFld"]);
$xtpl->assign("firstCol", "20%");
$xtpl->assign("secCol", "30%");
//Line divider attributes
$xtpl->assign("dividerHeight", "1px");
$xtpl->assign("dividerColor", $pdfColors["dividerColor"]);
$xtpl->assign("dividerSpan", 4);
$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);
$bodyHtml .= $pdf->createHeading($mod_strings["LBL_COMPONENTS_LIST"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_NAME"], true, true, false);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_TYPE"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_PAPER_DESCRIPTION"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COLORS_A"]);
$bodyHtml .= $pdf->genCells($mod_strings["LBL_COLORS_B"], false, false, true);
$bodyHtml .= $pdf->CompRows($list);
$bodyHtml .= "</table>";
$bodyHtml .= "<newpage>";
//Get the components' ids
$list = null;
$query = "SELECT id FROM `estimates_components` WHERE parent_id='" . $focus->id . "' AND deleted=0 AND parent_bean = 'ClientRequest'";
//$query = "SELECT id FROM `estimates_components` WHERE deleted=0 AND parent_bean = 'ClientRequest'";
$result = $focus->db->query($query, true, "Error filling layout fields: ");
while ($row = $focus->db->fetchByAssoc($result)) {
    $list[] = $row['id'];
}
//Initializing of EstimateComponents object needs to be done for every record
for ($i = 0; $i < count($list); $i++) {
    $RqComps = new EstimateComponents();
    $RqComps->retrieve($list[$i]);
    //get the $mod_strings from EstimateComponents module