///////////////////////////////////////////////////////////////////////////////
////    HANDLE CHANGES
if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'true') {
    $logo = $_REQUEST['logo'];
    $country = $_POST['country'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $street = $_POST['street'];
    $phone = $_POST['phone'];
    $fax = $_POST['fax'];
    $web = $_POST['web'];
    $email = $_POST['email'];
    $datab = new MysqlManager();
    $datab->connect();
    $q = "SELECT * FROM `companyinfo`";
    $res = $datab->query($q, true, " Error filling in additional detail fields: ");
    $num = $datab->getRowCount($result);
    if ($num = 0) {
        $query = 'INSERT into companyinfo (logo, country, city, state, street, phone, fax, web, email) VALUES';
        $query .= "('{$logo}', '{$country}', '{$city}', '{$state}', '{$street}', '{$phone}', '{$fax}', '{$web}', '{$email}') ";
        $result = $datab->query($query, true, " Error filling in additional detail fields: ");
    } else {
        $query = "UPDATE companyinfo SET    logo = '{$logo}' , \n                                            country = '{$country}' , \n                                            city = '{$city}', \n                                            state = '{$state}', \n                                            street = '{$street}', \n                                            phone = '{$phone}', \n                                            fax = '{$fax}', \n                                            web = '{$web}', \n                                            email = '{$email}'";
        $result = $datab->query($query, true, " Error filling in additional detail fields: ");
    }
    $cfg->populateFromPost();
    $cfg->handleOverride();
}
///////////////////////////////////////////////////////////////////////////////
////    PAGE OUTPUT
$sugar_smarty->assign('MOD', $mod_strings);
 function headerPDF()
 {
     global $app_strings;
     global $pdfFontSize, $pdfColors;
     $headerLblCol = $pdfColors["headerLbl"];
     $headerFldCol = $pdfColors["headerFld"];
     $headerBg = $pdfColors["field"];
     $headerFontSize = $pdfFontSize["header"];
     $datab = new MysqlManager();
     $datab->connect();
     $q = "SELECT logo, country, city, state, street, phone, fax, web, email FROM companyinfo";
     $res = $datab->query($q, true, " Error filling in additional detail fields: ");
     $r = mysql_fetch_array($res);
     $header = null;
     $header .= "<img width=212px height=40px src=include/images/company_logo_pdf.jpg>";
     $header .= "<br /><br /><hr>";
     $header .= "<table cellspacing=0 cellpadding=0 width=100% bgcolor={$headerBg}>";
     $header .= "<tr><td><font size={$headerFontSize}>";
     $header .= "<font color={$headerLblCol}>" . $app_strings['LBL_ADDRESS'] . ":</font>&nbsp;<font color={$headerFldCol}>" . $r['street'] . ", " . $r['city'] . ", " . $r['country'] . "</font>&nbsp;";
     $header .= "<font color={$headerLblCol}>" . $app_strings['LBL_PHONE'] . ":</font>&nbsp;<font color={$headerFldCol}>" . $r['phone'] . "</font>,&nbsp;";
     $header .= "<font color={$headerLblCol}>" . $app_strings['LBL_FAX'] . ":</font>&nbsp;<font color={$headerFldCol}>" . $r['fax'] . "</font>,&nbsp;";
     $header .= "<font color={$headerLblCol}>" . $app_strings['LBL_WWW'] . ":</font>&nbsp;<font color={$headerFldCol}>" . $r['web'] . "</font>,&nbsp;";
     $header .= "<font color={$headerLblCol}>" . $app_strings['LBL_EMAIL'] . ":</font>&nbsp;<font color={$headerFldCol}>" . $r['email'] . "</font>";
     $header .= "</font></td></tr></table>";
     return $header;
 }