$xtpl->assign('description', $focus->description);
$xtpl->assign('run_style_options', get_select_options_with_id($app_list_strings['layout_type_options'], ''));
$xtpl->assign("client_paper_options", get_select_options_with_id($app_list_strings['client_paper_options'], $focus->client_paper));
if (empty($focus->status) || is_null($focus->status)) {
    $xtpl->assign('status', get_select_options_with_id($app_list_strings['estimate_component_status_draft'], $focus->status));
} else {
    $xtpl->assign('status', get_select_options_with_id($app_list_strings['estimate_component_status_' . $focus->status], $focus->status));
}
$app_list_strings['products_format_options'] = $format->Get_Dropdown_Data();
$xtpl->assign("FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->base_format));
$app_list_strings['products_format_options'] = $pressformat->Get_Dropdown_Data();
$xtpl->assign("PRESS_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->pressformat));
$xtpl->assign("base_x", $focus->base_x);
$xtpl->assign("base_y", $focus->base_y);
if (!empty($focus->child_x) && !empty($focus->child_y)) {
    $app_list_strings['products_format_options'] = $childformat->Get_Dropdown_Data($format->get_parent_id($focus->base_format));
    $xtpl->assign("CHILD_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->child_format));
    $xtpl->assign("child_x", $focus->child_x);
    $xtpl->assign("child_y", $focus->child_y);
    $select_child = '';
    if (!is_null($focus->child_format) && !empty($focus->child_format)) {
        $select_child = "<script type='text/javascript'> getBaseFormat('{$focus->child_format}','child_format','get_estimate_base_format') </script>";
    }
    $xtpl->parse("main.child_format");
}
$xtpl->assign("fsize_h", $focus->fsize_h);
$xtpl->assign("fsize_w", $focus->fsize_w);
$xtpl->assign("run_size_x", $focus->run_size_x);
$xtpl->assign("run_size_y", $focus->run_size_y);
$xtpl->assign("bleed_size_x", $focus->bleed_size_x);
$xtpl->assign("bleed_size_y", $focus->bleed_size_y);
 function Get_Format($selected_format, $name, $module = null)
 {
     global $app_list_strings;
     global $app_strings;
     global $mod_strings;
     if ($module == null) {
         $module = 'Paperformat';
     }
     $xtpl = new XTemplate('modules/' . $module . '/format_ui_elements.html');
     $xtpl->assign('APP', $app_strings);
     $xtpl->assign('MOD', $mod_strings);
     if ($name == 'child_format') {
         $bean = new Childformat();
     } else {
         $bean = $this;
     }
     $query = " SELECT id,x,y FROM {$bean->table_name} where name='{$selected_format}' AND deleted=0 ";
     $result = $bean->db->query($query, true, " Error getting format");
     $data = $bean->db->fetchByAssoc($result);
     $parent_id = $data['id'];
     $prefix = trim($name, "_format");
     echo $prefix;
     if ($selected_format == '-') {
         $data['x'] = '';
         $data['y'] = '';
     }
     $xtpl->assign($prefix . '_x', $data['x']);
     $xtpl->assign($prefix . '_y', $data['y']);
     if ($bean->object_name == "Childformat") {
         $bean->retrieve($data['id']);
         $app_list_strings['format_options'] = $bean->Get_Dropdown_Data($bean->parent_id);
         $this->retrieve($bean->parent_id);
         $coef = $this->calc_coef($this, $bean);
         $xtpl->assign("COEF", '1:' . $coef);
     } else {
         $app_list_strings['format_options'] = $bean->Get_Dropdown_Data();
     }
     $type_pref = $prefix;
     $type_pref = strtoupper($type_pref);
     $xtpl->assign($type_pref . "_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['format_options'], $selected_format));
     $xtpl->parse($prefix . "_format");
     $xtpl->out($prefix . "_format");
     if ($name == 'base_format') {
         //Retrieve child formats
         $child = new Childformat();
         $query = ' SELECT id,x,y FROM ' . $child->table_name . ' where parent_id="' . $parent_id . '" AND deleted=0 ';
         $result = $this->db->query($query, true, " Error getting format");
         $data = $this->db->fetchByAssoc($result);
         if ($selected_format == '-') {
             $xtpl->parse("empty_child");
             $xtpl->out("empty_child");
         } elseif ($data == null) {
             $xtpl->parse("no_child_defined");
             $xtpl->out("no_child_defined");
         } else {
             //TO DO
             $app_list_strings['format_options'] = $child->Get_Dropdown_Data($parent_id);
             $xtpl->assign("CHILD_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['format_options'], ''));
             $xtpl->parse("child_format");
             $xtpl->out("child_format");
         }
     }
 }