コード例 #1
0
#
#
#
#
#
#
#
#
#
#
require "settings.php";
if (!isset($_GET["redir"]) or strlen($_GET["redir"]) < 1) {
    return "Invalid use of module.";
}
$redir = $_GET["redir"];
$navlink_target = getNavLinkTarget();
$OUTPUT = "\n\t<script>\n\t\tfunction link(url) {\n\t\t\tif ({$navlink_target} == 0) {\n\t\t\t\tdocument.location.href = url;\n\t\t\t} else {\n\t\t\t\tpopupSized(url, 'popup' + url, 800, 600,'');\n\t\t\t}\n\t\t}\n\t\tlink('{$redir}');\n\t</script>";
require "template.php";
function getNavLinkTarget()
{
    db_conn("cubit");
    $sql = "SELECT LOWER(SUBSTR(value, 1, 1)) FROM settings WHERE constant='NAVLINK_TARGET'";
    $rslt = db_exec($sql) or errDie("Error reading navigation link target.");
    if (pg_num_rows($rslt) <= 0) {
        $sql = "\n\t\t\tINSERT INTO settings (\n\t\t\t\tconstant, label, value, type, datatype, minlen, maxlen, div, readonly\n\t\t\t) VALUES (\n\t\t\t\t'NAVLINK_TARGET', 'Home Navigation Opens in New Window', 'Yes', 'layout', 'string', '2', '3', 0, 't'\n\t\t\t)";
        $rslt = db_exec($sql) or errDie("Error updating navigation link target (INS).");
        $nlt = "y";
    } else {
        $nlt = pg_fetch_result($rslt, 0, 0);
    }
    return $nlt == "y" ? "1" : "0";
コード例 #2
0
function main()
{
    $STYLES = "\n\t<style type='text/css'>\n\t.ctable {\n\t\tpadding: " . TMPL_tblCellPadding . "px;\n\t\tborder-spacing: " . TMPL_tblCellSpacing . "px;\n\t}\n\n\t.v_show {\n\t\tvisibility: visible;\n\t}\n\n\t.v_hide {\n\t\tvisibility: collapse;\n\t}\n\n\t#navigator {\n\t\tposition: absolute;\n\t\tleft: 0px;\n\t\ttop: 87px;\n\n\t\twidth: 100%;\n\t\theight: 80%;\n\t}\n\n\t#navigator td {\n\t\ttext-align: center;\n\t\tvertical-align: middle;\n\t}\n\n\t#categories {\n\t\tposition: relative;\n\t\tleft: 0px;\n\t\ttop: 0px;\n\n\t\twidth: 756px;\n\t\theight: 100px;\n\t}\n\n\t#categories td {\n\t\ttext-align: center;\n\t\tvertical-align: top;\n\t\twidth: 108px;\n\t\tfont-weight: bold;\n\t\tcursor: pointer;\n\t}\n\n\t#actions {\n\t\tposition: relative;\n\t\tleft: 0px;\n\t\ttop: 0px;\n\n\t\twidth: 756px;\n\t\theight: 50px;\n\t}\n\n\t#actions td {\n\t\ttext-align: center;\n\t\tvertical-align: middle;\n\t\twidth: 189px;\n\t}\n\n\t.actiontd1_off {\n\t\tbackground: url(images/new2/regular_processing.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t}\n\n\t.actiontd1_on {\n\t\tbackground: url(images/new2/regular_processing_sh.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\twidth: 1000px;\n\t}\n\n\t.actiontd2_off {\n\t\tbackground: url(images/new2/processing.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t}\n\n\t.actiontd2_on {\n\t\tbackground: url(images/new2/processing_sh.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\twidth: 1000px;\n\t}\n\n\t.actiontd3_off {\n\t\tbackground: url(images/new2/reports.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t}\n\n\t.actiontd3_on {\n\t\tbackground: url(images/new2/reports_sh.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\twidth: 1000px;\n\t}\n\n\t.actiontd4_off {\n\t\tbackground: url(images/new2/maintenance.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t}\n\n\t.actiontd4_on {\n\t\tbackground: url(images/new2/maintenance_sh.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\twidth: 1000px;\n\t}\n\n\t.actiontd5_off {\n\t\tbackground: url(images/new2/settings.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t}\n\n\t.actiontd5_on {\n\t\tbackground: url(images/new2/settings_sh.gif);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\twidth: 1000px;\n\t}\n\n\n\n\n\n\n\t#actions div {\n\t\twidth: 135px;\n\t\theight: 36px;\n\t\tdisplay: table-cell;\n\t\tvertical-align: middle;\n\t\tfont-weight: bold;\n\t\tcursor: pointer;\n\t}\n\n\t#links_container {\n\t\tdisplay: table-cell;\n\t\twidth: 690px;\n\t\theight: 270px;\n\t}\n\n\t#links_container_data {\n\t\tvertical-align: top;\n\t}\n\n\t#links_container_data td {\n\t\twidth: 115px;\n\t\theight: 35px;\n\t\tborder: 2px solid #222;\n\t\tbackground: #fff;\n\t\tcursor: pointer;\n\t\tfont-size: 9pt;\n\t\t-moz-border-radius: 8px;\n\t}\n\t</style>";
    $navlink_target = getNavLinkTarget();
    $SCRIPTS = "\n\t<script>\n\t/* function: handles the links */\n\tfunction link(url) {\n\t\tif ({$navlink_target} == 0) {\n\t\t\tdocument.location.href = url;\n\t\t} else {\n\t\t\tpopupSized(url, 'popup' + url, screen.availWidth, screen.availHeight,'');\n\t\t}\n\t}\n\n\t/* function: links to self with supplied get vars */\n\tfunction selflink(getvars) {\n\t\tdocument.location.href = '" . SELF . "?' + getvars;\n\t}\n\n\t/* function: links to top frame */\n\tfunction parentlink(url) {\n\t\ttop.location.href = url;\n\t}\n\n\t/* function: sets category */\n\tfunction set_category(el, img, catid) {\n\t\t// reset all of them\n\t\tunset_cat_bg('customers', \t'images/new2/customers.gif');\n\t\tunset_cat_bg('suppliers', \t'images/new2/suppliers.gif');\n\t\tunset_cat_bg('inventory', \t'images/new2/stock.gif');\n\t\tunset_cat_bg('ledger', \t\t'images/new2/general_ledger.gif');\n\t\tunset_cat_bg('payroll', \t'images/new2/salaries.gif');\n\t\tunset_cat_bg('business', \t'images/new2/business.gif');\n\n\t\t// get the elements\n\t\tce = document.getElementById('catc_' + el);\n\t\tie = document.getElementById('cat_' + el);\n\n\t\t// alter them\n\t\tce.style.border = '1px solid #ddd';\n\t\tie.src = img;\n\n\t\tsel_category = catid;\n\t\tUpdateContainer();\n\t}\n\n\t/* function: sets the specified category cell's background pic and mode */\n\tfunction unset_cat_bg(el, img) {\n\t\tce = document.getElementById('catc_' + el);\n\t\tie = document.getElementById('cat_' + el);\n\n\t\tce.style.border = 'none';\n\t\tie.src = img;\n\t}\n\n\t/* function: sets action */\n\tfunction set_action(cell, actid, button_action_command) {\n\t\tunset_action_bg('a_regproc','actiontd1_off');\n\t\tunset_action_bg('a_proc','actiontd2_off');\n\t\tunset_action_bg('a_reports','actiontd3_off');\n\t\tunset_action_bg('a_maint','actiontd4_off');\n\t\tunset_action_bg('a_admin','actiontd5_off');\n\n\t\tcell.className = button_action_command;\n\n\t\tsel_action = actid;\n\t\tUpdateContainer();\n\t}\n\n\t/* function: sets the specified action cell's background pic and mode */\n\tfunction unset_action_bg(cell,button_action_command2) {\n\t\tce = document.getElementById(cell);\n\t\tce.className = button_action_command2;\n\t}\n\n\t/* function: sets sub action */\n\tfunction set_subaction(cell, actid) {\n\t\t// get the clicked cell's id, because we are going to update the whole\n\t\t// links container, and that means even the cell we clicked on\n\t\t// this way we can just get the cell with the same id in the new data\n\t\t// and set's it's style to give a 'clicked' effect\n\t\tcid = cell.id;\n\n\t\t// set the subaction id to update the links in the container\n\t\tsel_subaction = actid;\n\t\tUpdateSubContainer();\n\n\t\t// now use the saved id to set the sister link's background color\n\t\tdocument.getElementById(cid).style.background = '#f00';\n\t}\n\n\t/* function: unsets the sub action button backgrounds */\n\tfunction unset_subaction_bg(cell) {\n\t\tc = document.getElementById(cell);\n\n\t\tif (c) {\n\t\t\tc.style.background = '#000';\n\t\t}\n\t}\n\n\t/* updates the container data */\n\tfunction UpdateContainer() {\n\t\tdocument.getElementById('links_container').innerHTML = lc_data[sel_category][sel_action];\n\t}\n\n\t/* updates the container data with subaction array */\n\tfunction UpdateSubContainer() {\n\t\tdocument.getElementById('links_container').innerHTML = lc_subdata[sel_subaction];\n\t}\n\n\t/* makes the email popup */\n\tfunction linkEmail() {\n\t\temailwin = window.open('groupware/index.php','email_window', 'scrollbars=no, width=750, height=550');\n\t\temailwin.focus();\n\t}\n\n\t/* link container array */\n\tlc_data = new Array();\n\tlc_subdata = new Array();";
    /* take the lc data to java script */
    // has set the default selected category and action
    $setdefault = false;
    // it unnecessary to set the action constants with every category
    $setactions = false;
    // category + action counters
    $cat_num = 0;
    $act_num = 0;
    $sub_num = 0;
    // get lc data
    $lc = getLC();
    // go!
    foreach ($lc as $cat => $actions) {
        // constant to reference categories
        $SCRIPTS .= "{$cat} = {$cat_num};\n";
        // reset the category to array
        $SCRIPTS .= "lc_data[{$cat}] = new Array()\n";
        foreach ($actions as $act => $lcdata) {
            if (is_array($lcdata)) {
                continue;
            }
            if (!$setactions) {
                // constant to reference actions
                $SCRIPTS .= "{$act} = {$act_num};\n";
                ++$act_num;
            }
            // set default selections
            if (!$setdefault) {
                if (isset($_GET["selected"]) && strtoupper($_GET["selected"]) == strtoupper($cat)) {
                    $SCRIPTS .= "sel_category = {$cat};\n";
                    $SCRIPTS .= "sel_action = {$act};\n";
                    $setdefault = true;
                } else {
                    if (!isset($_GET["selected"])) {
                        $SCRIPTS .= "sel_category = {$cat};\n";
                        $SCRIPTS .= "sel_action = {$act};\n";
                        $setdefault = true;
                    }
                }
            }
            // dump the data
            $itemdata = preg_replace("/[\r\n]/", "", $lcdata);
            $itemdata = preg_replace("/[\"]/", "\\\"", $itemdata);
            $SCRIPTS .= "lc_data[{$cat}][{$act}] = \"{$itemdata}\";\n";
            if (isset($actions["{$act}S"]) && is_array($actions["{$act}S"])) {
                foreach ($actions["{$act}S"] as $subid => $subdata) {
                    // set the constant
                    $SCRIPTS .= "{$cat}_{$act}_{$subid} = {$sub_num};\n";
                    // dump the sub data
                    $subitemdata = preg_replace("/[\r\n]/", "", $subdata);
                    $subitemdata = preg_replace("/[\"]/", "\\\"", $subitemdata);
                    $SCRIPTS .= "lc_subdata[{$cat}_{$act}_{$subid}] = \"{$itemdata}{$subitemdata}\";\n";
                    ++$sub_num;
                }
            }
        }
        ++$cat_num;
        $setactions = true;
    }
    $SCRIPTS .= "\n\t</script>";
    addonload("UpdateContainer();");
    #get this company's logo
    db_conn("cubit");
    $get_logo = "SELECT imgtype FROM compinfo WHERE div = '" . USER_DIV . "' AND length(tel) > 0 LIMIT 1";
    $run_logo = db_exec($get_logo);
    if (pg_numrows($run_logo) < 1) {
        //		$showlogo = "<a href='compinfo-view.php'><img src='images/blanklogo.png' border='0' /></a>";
        $showlogo = "<a href=\"javascript:popupSized('compinfo-view.php', 'Company Information', screen.width, screen.height)\"><img src='images/blanklogo.png' border='0' /></a>";
    } else {
        $arr = pg_fetch_array($run_logo);
        if (strlen($arr['imgtype']) < 1) {
            $showlogo = "<img src='images/bluelogo.png' border='0' />";
        } else {
            $showlogo = "<img src='images/showlogo.php' height='80' />";
        }
    }
    /* create the selections */
    $sel_customers = "";
    $sel_suppliers = "";
    $sel_inventory = "";
    $sel_payroll = "";
    $sel_ledger = "";
    $sel_business = "";
    if (isset($_GET["selected"])) {
        ${"sel_" . strtolower($_GET["selected"])} = "style='border: 1px solid #ddd'";
    } else {
        $sel_customers = "style='border: 1px solid #ddd'";
    }
    // Should we display the heart?
    $sql = "SELECT value FROM cubit.settings WHERE constant='HEART'";
    $heart_rslt = db_exec($sql) or errDie("Unable to check if heart should be displayed");
    $heart = pg_fetch_result($heart_rslt, 0);
    if ($heart) {
        $showheart = "<a href=\"javascript:popupSized('health_report.php', 'Health Report', screen.width, screen.height)\"><img src='images/cubithealth3.jpg' border='0' height='70' /></a>";
    } else {
        $showheart = "";
    }
    /*
    	<table ".TMPL_tblDflts." style='width: 100%;'>
    		<tr>
    			<td align='center'>$showlogo</td>
    		</tr>
    	</table>
    */
    //			Customers
    //			Suppliers
    //			Stock
    //			Salaries
    //			General Ledger
    //			Business
    $OUTPUT = "\n\t<div style='position: absolute; top: 0px; left: 0px; width: 100%; display: table-cell; text-align: right'>\n\t\t<a href='logout.php'><img src='images/logout.gif' border='0' /></a><br />\n\t\t{$showheart}\n\t</div>\n\t<center>\n\t<div style='position: absolute; top: 0px; display: table-cell;'>\n\t\t{$showlogo}\n\t</div>\n\t</center>\n\t<table id='navigator' class='ctable'><tr><td>\n\n\t<center>\n\t<!-- Categories -->\n\t<table id='categories' class='ctable'>\n\t<tr>\n\t\t<td id='catc_customers' onclick='set_category(\"customers\", \"images/new2/customers_sh.gif\", CUSTOMERS);' {$sel_customers}>\n\t\t\t<img id='cat_customers' src='images/new2/customers.gif' /><br />\n\n\t\t</td>\n\t\t<td id='catc_suppliers' onclick='set_category(\"suppliers\", \"images/new2/suppliers_sh.gif\", SUPPLIERS);' {$sel_suppliers}>\n\t\t\t<img id='cat_suppliers' src='images/new2/suppliers.gif' /><br />\n\n\t\t</td>\n\t\t<td id='catc_inventory' onclick='set_category(\"inventory\", \"images/new2/stock_sh.gif\", STOCK);' {$sel_inventory}>\n\t\t\t<img id='cat_inventory' src='images/new2/stock.gif' /><br />\n\n\t\t</td>\n\t\t<td id='catc_payroll' onclick='set_category(\"payroll\", \"images/new2/salaries_sh.gif\", SALARIES);' {$sel_payroll}>\n\t\t\t<img id='cat_payroll' src='images/new2/salaries.gif' /><br />\n\n\t\t</td>\n\t\t<td id='catc_ledger' onclick='set_category(\"ledger\", \"images/new2/general_ledger_sh.gif\", LEDGER);' {$sel_ledger}>\n\t\t\t<img id='cat_ledger' src='images/new2/general_ledger.gif' /><br />\n\n\t\t</td>\n\t\t<td id='catc_business' onclick='set_category(\"business\", \"images/new2/business_sh.gif\", BUSINESS);' {$sel_business}>\n\t\t\t<img id='cat_business' src='images/new2/business.gif' /><br />\n\n\t\t</td>\n\t</tr>\n\t</table>\n\t<br />\n\t<!-- Actions -->\n\t<table id='actions' class='ctable'>\n\t<tr>\n\t\t<td onclick=\"set_action(this, REGPROC, 'actiontd1_on');\" id='a_regproc' class='actiontd1_on'><center><div></div></center></td>\n\t\t<td onclick=\"set_action(this, PROC, 'actiontd2_on');\" id='a_proc' class='actiontd2_off'><center><div></div></center></td>\n\t\t<td onclick=\"set_action(this, REPORTS, 'actiontd3_on');\" id='a_reports' class='actiontd3_off'><center><div></div></center></td>\n\t\t<td onclick=\"set_action(this, MAINT, 'actiontd4_on');\" id='a_maint' class='actiontd4_off'><center><div></div></center></td>\n\t\t<td onclick=\"set_action(this, ADMIN, 'actiontd5_on');\" id='a_admin' class='actiontd5_off'><center><div></div></center></td>\n\t</tr>\n\t</table>\n\n\t<!-- Links Container -->\n\t<div id='links_container'>\n\t</div>\n\n\t<script>\n\tvar arrNavClear = new Array();\n\tvar iNavClear = 0;\n\tfunction clearNavBtn(btn) {\n\t\tarrNavClear[iNavClear] = btn;\n\t\tsetTimeout('clearNavBtnAct(' + iNavClear + ')', 200);\n\n\t\t//clearNavBtnAct(iNavClear);\n\n\t\tif (++iNavClear == 65535) {\n\t\t\tiNavClear = 0;\n\t\t}\n\t}\n\n\tfunction clearNavBtnAct(arrid) {\n\t\tarrNavClear[arrid].style.background=\"#fff\";\n\t\tarrNavClear[arrid] = null;\n\t}\n\t</script>\n\n\t</center>\n\n\t</td></tr>\n       <tr>\n                <td valign='center'>\n                        <div>Powered By <br /><a style='text-decoration: none' href='http://www.cubit.co.za'><img border='0' src='images/newcubitlogo.jpg' /></a>\n                        <p>This software is used in accordance with the <a target='_blank' href='license.html'>Cubit Licence</a></p></div>\n                </td>\n        </tr>\n\t</table>";
    return $STYLES . $SCRIPTS . $OUTPUT;
}