Ejemplo n.º 1
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
        $js ="";
        return $js;
    }
    */
    function body_content()
    {
        include dirname(__FILE__) . '/../config.php';
        ob_start();
        echo showInstallTabs('Products');
        ?>

        <form action=InstallProductsPage.php method=post>
        <h1 class="install">
            <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
        </h1>
        <?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
        <hr />
        <h4 class="install">Product Information Modules</h4>
        The product editing interface displayed after you select a product at:
        <br /><a href="<?php 
        echo $FANNIE_URL;
        ?>
item/" target="_item"><?php 
        echo $FANNIE_URL;
        ?>
item/</a>
        <br />consists of fields grouped in several sections, called modules, listed below.
        <br />The enabled (active) ones are highlighted.
        <br />The <i>Show</i> setting controls whether or not the module is displayed. The <i>Auto</i>
              means only display the module if it is relevant to the current item.
        <br />The <i>Expand</i> setting controls whether the module is intially expanded or collapsed.
             The <i>Auto</i> option means display expanded if relevant to the current item.
        <br />
        <br /><b>Available Modules</b> <br />
        <?php 
        $mods = FannieAPI::ListModules('ItemModule', True);
        sort($mods);
        ?>
        <table class="table">
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Show</th>
            <th>Expand</th>
        </tr>
        <?php 
        /**
          Change by Andy 2Jun14
          Store modules in a keyed array.
          Format:
           - module_name => settings array
             + seq [int] display order
             + show [int] yes/no/auto
             + expand [int] yes/no/auto
        
          The settings for each module control
          how it is displayed. The "auto" option
          will only print or expand a module if
          it is relevant for that particular item.
        */
        $in_mods = FormLib::get('_pm', array());
        $in_seq = FormLib::get('_pmSeq', array());
        $in_show = FormLib::get('_pmShow', array());
        $in_exp = FormLib::get('_pmExpand', array());
        for ($i = 0; $i < count($in_mods); $i++) {
            if (!isset($in_show[$i]) || $in_show[$i] == 0) {
                if (isset($FANNIE_PRODUCT_MODULES[$in_mods[$i]])) {
                    unset($FANNIE_PRODUCT_MODULES[$in_mods[$i]]);
                }
                continue;
            }
            $FANNIE_PRODUCT_MODULES[$in_mods[$i]] = array('seq' => isset($in_seq[$i]) ? $in_seq[$i] : 0, 'show' => isset($in_show[$i]) ? $in_show[$i] : 0, 'expand' => isset($in_exp[$i]) ? $in_exp[$i] : 0);
        }
        /*
          Convert old settings to new format.
        */
        $legacy_indexes = array();
        $replacement_values = array();
        foreach ($FANNIE_PRODUCT_MODULES as $id => $m) {
            if (preg_match('/^\\d+$/', $id)) {
                // old setting. convert to new.
                $legacy_indexes[] = $id;
                $replacement_values[$m] = array('seq' => $id, 'show' => 1, 'expand' => 1);
            }
        }
        foreach ($legacy_indexes as $index) {
            unset($FANNIE_PRODUCT_MODULES[$index]);
        }
        foreach ($replacement_values as $name => $params) {
            $FANNIE_PRODUCT_MODULES[$name] = $params;
        }
        // set a default if needed
        if (count($FANNIE_PRODUCT_MODULES) == 0) {
            $FANNIE_PRODUCT_MODULES['BaseItemModule'] = array('seq' => 0, 'show' => 1, 'expand' => 1);
        }
        $default = array('seq' => 0, 'show' => 0, 'expand' => 0);
        $opts = array('No', 'Yes', 'Auto');
        foreach ($mods as $module) {
            $css = isset($FANNIE_PRODUCT_MODULES[$module]) ? 'class="info"' : '';
            printf('<tr %s><td>%s<input type="hidden" name="_pm[]" value="%s" /></td>', $css, $module, $module);
            $params = isset($FANNIE_PRODUCT_MODULES[$module]) ? $FANNIE_PRODUCT_MODULES[$module] : $default;
            printf('<td><input type="number" class="form-control" name="_pmSeq[]" value="%d" /></td>', $params['seq']);
            echo '<td><select name="_pmShow[]" class="form-control">';
            foreach ($opts as $id => $label) {
                printf('<option %s value="%d">%s</option>', $id == $params['show'] ? 'selected' : '', $id, $label);
            }
            echo '</select></td>';
            echo '<td><select name="_pmExpand[]" class="form-control">';
            foreach ($opts as $id => $label) {
                printf('<option %s value="%d">%s</option>', $id == $params['expand'] ? 'selected' : '', $id, $label);
            }
            echo '</select></td>';
            echo '</tr>';
        }
        $saveStr = 'array(';
        foreach ($FANNIE_PRODUCT_MODULES as $name => $info) {
            $saveStr .= sprintf("'%s'=>array('seq'=>%d,'show'=>%d,'expand'=>%d),", $name, $info['seq'], $info['show'], $info['expand']);
        }
        $saveStr = substr($saveStr, 0, strlen($saveStr) - 1) . ')';
        confset('FANNIE_PRODUCT_MODULES', $saveStr);
        ?>
        </table>
        <hr />
        <label>Default Batch View</label>
        <?php 
        $batch_opts = array('all' => 'All', 'current' => 'Current', 'Pending' => 'Pending', 'Historical' => 'Historical');
        echo installSelectField('FANNIE_BATCH_VIEW', $FANNIE_BATCH_VIEW, $batch_opts, 'all');
        ?>
        <hr />
        <label>Default Reporting Departments View</label>
        <?php 
        $report_opts = array('range' => 'Range of Departments', 'multi' => 'Multi Select');
        echo installSelectField('FANNIE_REPORT_DEPT_MODE', $FANNIE_REPORT_DEPT_MODE, $report_opts, 'range');
        ?>
        <hr />
        <label>Default Shelf Tag Layout</label>
        <?php 
        $layouts = 'No Layouts Found!';
        if (file_exists($FANNIE_ROOT . 'admin/labels/scan_layouts.php') && !function_exists('scan_layouts')) {
            include $FANNIE_ROOT . 'admin/labels/scan_layouts.php';
            $layouts = scan_layouts();
        }
        echo installSelectField('FANNIE_DEFAULT_PDF', $FANNIE_DEFAULT_PDF, $layouts, 'Fannie Standard');
        ?>
        <label>Shelf Tag Data Source</label>
        <?php 
        $mods = FannieAPI::listModules('TagDataSource');
        $source = array('' => 'Default');
        foreach ($mods as $m) {
            $source[$m] = $m;
        }
        echo installSelectField('FANNIE_TAG_DATA_SOURCE', $FANNIE_TAG_DATA_SOURCE, $source);
        ?>
        <label>Default Signage Layout</label>
        <?php 
        $mods = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\item\\FannieSignage');
        echo installSelectField('FANNIE_DEFAULT_SIGNAGE', $FANNIE_DEFAULT_SIGNAGE, $mods);
        ?>
        <label>Default Account Coding</label>
        <?php 
        $mods = array('\\COREPOS\\Fannie\\API\\item\\Accounting', '\\COREPOS\\Fannie\\API\\item\\StandardAccounting');
        $mods = array_merge($mods, FannieAPI::listModules('\\COREPOS\\Fannie\\API\\item\\Accounting'));
        echo installSelectField('FANNIE_ACCOUNTING_MODULE', $FANNIE_ACCOUNTING_MODULE, $mods);
        ?>
        <hr />
        <h4 class="install">Service Scale Integration</h4>
        <p class='ichunk' style="margin:0.4em 0em 0.4em 0em;"><b>Data Gate Weigh directory</b>
        <?php 
        echo installTextField('FANNIE_DGW_DIRECTORY', $FANNIE_DGW_DIRECTORY, '');
        if ($FANNIE_DGW_DIRECTORY !== '') {
            if (is_writable($FANNIE_DGW_DIRECTORY)) {
                echo "<div class=\"alert alert-success\">{$FANNIE_DGW_DIRECTORY} is writable</div>";
            } elseif (!file_exists($FANNIE_DGW_DIRECTORY)) {
                echo "<div class=\"alert alert-danger\">{$FANNIE_DGW_DIRECTORY} does not exist</div>";
            } else {
                echo "<div class=\"alert alert-danger\">{$FANNIE_DGW_DIRECTORY} is not writable</div>";
            }
        }
        ?>
        <p class='ichunk' style="margin:0.4em 0em 0.4em 0em;"><b>E-Plum directory</b>
        <?php 
        echo installTextField('FANNIE_EPLUM_DIRECTORY', $FANNIE_EPLUM_DIRECTORY, '');
        if ($FANNIE_EPLUM_DIRECTORY !== '') {
            if (is_writable($FANNIE_EPLUM_DIRECTORY)) {
                echo "<div class=\"alert alert-success\">{$FANNIE_EPLUM_DIRECTORY} is writable</div>";
            } elseif (!file_exists($FANNIE_EPLUM_DIRECTORY)) {
                echo "<div class=\"alert alert-danger\">{$FANNIE_EPLUM_DIRECTORY} does not exist</div>";
            } else {
                echo "<div class=\"alert alert-danger\">{$FANNIE_EPLUM_DIRECTORY} is not writable</div>";
            }
        }
        ?>

        <hr />
        <h4 class="install">Product Editing</h4>
        <p class='ichunk' style="margin:0.4em 0em 0.4em 0em;"><b>Compose Product Description</b>: 
        <?php 
        echo installSelectField('FANNIE_COMPOSE_PRODUCT_DESCRIPTION', $FANNIE_COMPOSE_PRODUCT_DESCRIPTION, array(1 => 'Yes', 0 => 'No'), 0);
        ?>
        <br />If No products.description, which appears on the receipt, will be used as-is.
        <br />If Yes it will be shortened enough hold a "package" description made by
        concatenating products.size and products.unitofmeasure so that the whole
        string is still 30 or less characters:
        <br /> "Eden Seville Orange Marma 500g"
        </p>

        <p class='ichunk' style="margin:0.0em 0em 0.4em 0em;"><b>Compose Long Product Description</b>: 
        <?php 
        echo installSelectField('FANNIE_COMPOSE_LONG_PRODUCT_DESCRIPTION', $FANNIE_COMPOSE_LONG_PRODUCT_DESCRIPTION, array(1 => 'Yes', 0 => 'No'), 0);
        ?>
        <br />If No productUser.description, which may be used in Product Verification, will be used as-is.
        <br />If Yes productUser.brand will be prepended and a "package" description made by
        concatenating products.size and products.unitofmeasure will be appended:
        <br /> "EDEN | Marmalade, Orange, Seville, Rough-Cut | 500g"<br />
        </p>

        <hr />
        <p>
            <button type="submit" class="btn btn-default">Save Configuration</button>
        </p>
        </form>

        <?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 2
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
        $js="";
        return $js;
    }
    */
    function body_content()
    {
        include '../config.php';
        ob_start();
        echo showInstallTabs('Necessities');
        $self = basename($_SERVER['PHP_SELF']);
        echo "<form action='{$self}' method='post'>";
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        // Path detection: Establish ../../
        $FILEPATH = rtrim(__FILE__, "{$self}");
        if (DIRECTORY_SEPARATOR == '\\') {
            $FILEPATH = str_replace(DIRECTORY_SEPARATOR, '/', $FILEPATH);
        }
        $URL = rtrim($_SERVER['SCRIPT_NAME'], "{$self}");
        $FILEPATH = rtrim($FILEPATH, '/');
        $URL = rtrim($URL, '/');
        $FILEPATH = rtrim($FILEPATH, 'install');
        $URL = rtrim($URL, 'install');
        $FANNIE_ROOT = $FILEPATH;
        $FANNIE_URL = $URL;
        if (function_exists('posix_getpwuid')) {
            $chk = posix_getpwuid(posix_getuid());
            echo "PHP is running as: " . $chk['name'] . "<br />";
        } else {
            echo "PHP is (probably) running as: " . get_current_user() . "<br />";
        }
        if (is_writable($FILEPATH . 'config.php')) {
            confset('FANNIE_ROOT', "'{$FILEPATH}'");
            confset('FANNIE_URL', "'{$URL}'");
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
            echo "<hr />";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
            echo "<div class=\"well\">";
            echo "config.php ({$FILEPATH}config.php) is Fannie's main configuration file.";
            echo "<ul>";
            echo "<li>If this file exists, ensure it is writable by the user running PHP (see above)";
            echo "<li>If the file does not exist, copy config.dist.php ({$FILEPATH}config.dist.php) to config.php";
            echo "<li>If neither file exists, create a new config.php ({$FILEPATH}config.php) containing:";
            echo "</ul>";
            echo "<pre>\n&lt;?php\n?&gt;\n</pre>";
            echo "</div>";
            echo '<button type="submit" class="btn btn-default">Refresh this page</button>';
            echo "</form>";
            return ob_get_clean();
        }
        if (!is_dir(dirname(__FILE__) . '/../../vendor')) {
            echo "<div class=\"alert alert-warning\"><b>Warning</b>: dependencies appear to be missing.</div>";
            echo '<div class=\\"well\\">';
            echo 'Install <a href="https://getcomposer.org/">Composer</a> then run ';
            echo "<pre>";
            echo '$ cd "' . $FILEPATH . "\"\n";
            echo '$ /path/to/composer.phar update';
            echo '</pre>';
            echo '<a href="https://github.com/CORE-POS/IS4C/wiki/Installation#composer">More info about Composer</a>';
            echo '</div>';
        } else {
            $json = file_get_contents(dirname(__FILE__) . '/../../composer.json');
            $obj = json_decode($json);
            $missing = false;
            foreach (get_object_vars($obj->require) as $package => $version) {
                if (!is_dir(dirname(__FILE__) . '/../../vendor/' . $package)) {
                    $missing = true;
                    echo "<div class=\"alert alert-danger\"><b>Warning</b>: package " . $package . " is not installed.</div>";
                }
            }
            if ($missing) {
                echo '<div class="well">Install dependencies by running';
                echo "<pre>";
                echo '$ cd "' . substr($FILEPATH, 0, strlen($FILEPATH) - 7) . "\"\n";
                echo '$ /path/to/composer.phar update';
                echo '</pre></div>';
            }
        }
        /**
            Detect databases that are supported
        */
        $supportedTypes = \COREPOS\common\sql\Lib::getDrivers();
        if (count($supportedTypes) == 0) {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: no database driver available</div>";
            echo "<div class=\"well\">";
            echo 'Install at least one of the following PHP extensions: pdo_mysql, mysqli, mysql,
                or mssql. If you installed one or more of these and are still seeing this
                error, make sure they are enabled in your PHP configuration and try 
                restarting your web server.';
            echo "</div>";
            return false;
        }
        $db_keys = array_keys($supportedTypes);
        $defaultDbType = $db_keys[0];
        echo '<h4 class="install"><a href="" onclick="$(\'#serverConfTable\').toggle(); return false;">Main Server</a> +</h4>';
        echo '<table id="serverConfTable">';
        echo '<tr><td>Server Database Host</td>' . '<td>' . installTextField('FANNIE_SERVER', $FANNIE_SERVER, '127.0.0.1') . '</td></tr>';
        echo '<tr><td>Server Database Type</td>' . '<td>' . installSelectField('FANNIE_SERVER_DBMS', $FANNIE_SERVER_DBMS, $supportedTypes, $defaultDbType) . '</td></tr>';
        echo '<tr><td>Server Database Username</td>' . '<td>' . installTextField('FANNIE_SERVER_USER', $FANNIE_SERVER_USER, 'root') . '</td></tr>';
        echo '<tr><td>Server Database Password</td>' . '<td> ' . installTextField('FANNIE_SERVER_PW', $FANNIE_SERVER_PW, '', true, array('type' => 'password')) . '</td></tr>';
        echo '<tr><td>Server Operational DB name</td>' . '<td>' . installTextField('FANNIE_OP_DB', $FANNIE_OP_DB, 'core_op') . '</td></tr>';
        echo '<tr><td>Server Transaction DB name</td>' . '<td>' . installTextField('FANNIE_TRANS_DB', $FANNIE_TRANS_DB, 'core_trans') . '</td></tr>';
        echo '</table>';
        $sql = db_test_connect($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        $createdOps = false;
        if ($sql === false) {
            echo "<div class=\"alert alert-danger\">Testing Operational DB connection failed</div>";
        } else {
            echo "<div class=\"alert alert-success\">Testing Operational DB connection succeeded</div>";
            $msgs = $this->create_op_dbs($sql, $FANNIE_OP_DB);
            $createdOps = true;
            foreach ($msgs as $msg) {
                if ($msg['error'] == 0) {
                    continue;
                }
                echo $msg['error_msg'] . '<br />';
            }
        }
        $sql = db_test_connect($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        $createdTrans = false;
        if ($sql === false) {
            echo "<div class=\"alert alert-danger\">Testing Transaction DB connection failed</div>";
        } else {
            echo "<div class=\"alert alert-success\">Testing Transaction DB connection succeeded</div>";
            $msgs = $this->create_trans_dbs($sql, $FANNIE_TRANS_DB, $FANNIE_OP_DB);
            foreach ($msgs as $msg) {
                if ($msg['error'] == 0) {
                    continue;
                }
                echo $msg['error_msg'] . '<br />';
            }
            $createdTrans = true;
        }
        if ($createdOps && $createdTrans) {
            // connected to both databases
            // collapse config fields
            $this->add_onload_command('$(\'#serverConfTable\').hide();');
        }
        ?>
        <hr />
        <?php 
        echo '<h4 class="install"><a href="" onclick="$(\'#archiveConfTable\').toggle(); return false;">Transaction Archiving</a> +</h4>';
        echo '<table id="archiveConfTable">';
        echo '<tr><td>Archive DB name</td>' . '<td>' . installTextField('FANNIE_ARCHIVE_DB', $FANNIE_ARCHIVE_DB, 'trans_archive') . '</td></tr>';
        echo '<tr><td>Archive Method</td>' . '<td>' . installSelectField('FANNIE_ARCHIVE_METHOD', $FANNIE_ARCHIVE_METHOD, array('partitions', 'tables'), 'partitions') . '</td></tr>';
        echo '</table>';
        //local archiving - set up now
        $sql = db_test_connect($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        if ($sql === false) {
            echo "<div class=\"alert alert-danger\">Testing Archive DB connection failed</div>";
        } else {
            echo "<div class=\"alert alert-success\">Testing Archive DB connection succeeded</div>";
            $msgs = $this->create_archive_dbs($sql, $FANNIE_ARCHIVE_DB, $FANNIE_ARCHIVE_METHOD);
            foreach ($msgs as $msg) {
                if ($msg['error'] == 0) {
                    continue;
                }
                echo $msg['error_msg'] . '<br />';
            }
            $this->add_onload_command('$(\'#archiveConfTable\').hide();');
        }
        ?>
        <hr />
        <h4 class="install">Lanes</h4>
        Number of lanes
        <?php 
        if (!isset($FANNIE_NUM_LANES)) {
            $FANNIE_NUM_LANES = 0;
        }
        if (isset($_REQUEST['FANNIE_NUM_LANES'])) {
            $FANNIE_NUM_LANES = $_REQUEST['FANNIE_NUM_LANES'];
        }
        confset('FANNIE_NUM_LANES', "{$FANNIE_NUM_LANES}");
        echo "<input type=text name=FANNIE_NUM_LANES value=\"{$FANNIE_NUM_LANES}\" size=3 />";
        ?>
        <br />
        <?php 
        if ($FANNIE_NUM_LANES == 0) {
            confset('FANNIE_LANES', 'array()');
        } else {
            ?>
        <script type=text/javascript>
        function showhide(i,num){
            for (var j=0; j<num; j++){
                if (j == i)
                    document.getElementById('lanedef'+j).style.display='block';
                else
                    document.getElementById('lanedef'+j).style.display='none';
            }
        }
        </script>
        <?php 
            echo "<select onchange=\"showhide(this.value,{$FANNIE_NUM_LANES});\">";
            for ($i = 0; $i < $FANNIE_NUM_LANES; $i++) {
                echo "<option value={$i}>Lane " . ($i + 1) . "</option>";
            }
            echo "</select><br />";
            $conf = 'array(';
            for ($i = 0; $i < $FANNIE_NUM_LANES; $i++) {
                $style = $i == 0 ? '' : 'class="collapse"';
                echo "<div id=\"lanedef{$i}\" {$style}>";
                if (!isset($FANNIE_LANES[$i])) {
                    $FANNIE_LANES[$i] = array();
                }
                $conf .= 'array(';
                if (!isset($FANNIE_LANES[$i]['host'])) {
                    $FANNIE_LANES[$i]['host'] = '127.0.0.1';
                }
                if (isset($_REQUEST["LANE_HOST_{$i}"])) {
                    $FANNIE_LANES[$i]['host'] = $_REQUEST["LANE_HOST_{$i}"];
                }
                $conf .= "'host'=>'{$FANNIE_LANES[$i]['host']}',";
                echo "Lane " . ($i + 1) . " Database Host: <input type=text name=LANE_HOST_{$i} value=\"{$FANNIE_LANES[$i]['host']}\" /><br />";
                if (!isset($FANNIE_LANES[$i]['type'])) {
                    $FANNIE_LANES[$i]['type'] = $defaultDbType;
                }
                if (isset($_REQUEST["LANE_TYPE_{$i}"])) {
                    $FANNIE_LANES[$i]['type'] = $_REQUEST["LANE_TYPE_{$i}"];
                }
                $conf .= "'type'=>'{$FANNIE_LANES[$i]['type']}',";
                echo "Lane " . ($i + 1) . " Database Type: <select name=LANE_TYPE_{$i}>";
                foreach ($supportedTypes as $val => $label) {
                    printf('<option value="%s" %s>%s</option>', $val, $FANNIE_LANES[$i]['type'] == $val ? 'selected' : '', $label);
                }
                echo "</select><br />";
                if (!isset($FANNIE_LANES[$i]['user'])) {
                    $FANNIE_LANES[$i]['user'] = '******';
                }
                if (isset($_REQUEST["LANE_USER_{$i}"])) {
                    $FANNIE_LANES[$i]['user'] = $_REQUEST["LANE_USER_{$i}"];
                }
                $conf .= "'user'=>'{$FANNIE_LANES[$i]['user']}',";
                echo "Lane " . ($i + 1) . " Database Username: <input type=text name=LANE_USER_{$i} value=\"{$FANNIE_LANES[$i]['user']}\" /><br />";
                if (!isset($FANNIE_LANES[$i]['pw'])) {
                    $FANNIE_LANES[$i]['pw'] = '';
                }
                if (isset($_REQUEST["LANE_PW_{$i}"])) {
                    $FANNIE_LANES[$i]['pw'] = $_REQUEST["LANE_PW_{$i}"];
                }
                $conf .= "'pw'=>'{$FANNIE_LANES[$i]['pw']}',";
                echo "Lane " . ($i + 1) . " Database Password: <input type=password name=LANE_PW_{$i} value=\"{$FANNIE_LANES[$i]['pw']}\" /><br />";
                if (!isset($FANNIE_LANES[$i]['op'])) {
                    $FANNIE_LANES[$i]['op'] = 'opdata';
                }
                if (isset($_REQUEST["LANE_OP_{$i}"])) {
                    $FANNIE_LANES[$i]['op'] = $_REQUEST["LANE_OP_{$i}"];
                }
                $conf .= "'op'=>'{$FANNIE_LANES[$i]['op']}',";
                echo "Lane " . ($i + 1) . " Operational DB: <input type=text name=LANE_OP_{$i} value=\"{$FANNIE_LANES[$i]['op']}\" /><br />";
                if (!isset($FANNIE_LANES[$i]['trans'])) {
                    $FANNIE_LANES[$i]['trans'] = 'translog';
                }
                if (isset($_REQUEST["LANE_TRANS_{$i}"])) {
                    $FANNIE_LANES[$i]['trans'] = $_REQUEST["LANE_TRANS_{$i}"];
                }
                $conf .= "'trans'=>'{$FANNIE_LANES[$i]['trans']}'";
                echo "Lane " . ($i + 1) . " Transaction DB: <input type=text name=LANE_TRANS_{$i} value=\"{$FANNIE_LANES[$i]['trans']}\" /><br />";
                $conf .= ")";
                echo "</div>";
                if ($i == $FANNIE_NUM_LANES - 1) {
                    $conf .= ")";
                } else {
                    $conf .= ",";
                }
            }
            confset('FANNIE_LANES', $conf);
        }
        ?>
        <a href="LaneConfigPages/index.php">Edit Global Lane Configuration Page</a>
        <hr />
        <h4 class="install">Logs &amp; Debugging</h4>
        Fannie writes to the following log files:
        <?php 
        if (!class_exists('LogViewer')) {
            include dirname(__FILE__) . '/../logs/LogViewer.php';
        }
        $log = new LogViewer();
        ?>
        <ul>
        <li><?php 
        check_writeable('../logs/fannie.log');
        ?>
            <ul>
            <li>Contains info, notice, warning, error, critical, alert, and emergency level messages.</li>
            <li>
            <a href="" onclick="$('#dayendLogView').toggle(); return false;">See Recent Entries</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="../logs/LogViewer.php?logfile=<?php 
        echo base64_encode('fannie.log');
        ?>
">View Entire Log</a>
            <?php 
        $dayend = $log->getLogFile('../logs/fannie.log', 100);
        ?>
            <pre id="dayendLogView" class="tailedLog highlight"><?php 
        echo $dayend;
        ?>
</pre>
            </li>
            <li>If this file is missing, messages may be written to legacy log file dayend.log</li>
            </ul>  
        <li><?php 
        check_writeable('../logs/debug_fannie.log');
        ?>
            <ul>
            <li>Contains debug level messages including failed queries and PHP notice/warning/error messages.</li>
            <li>
            <a href="" onclick="$('#dayendLogView').toggle(); return false;">See Recent Entries</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="../logs/LogViewer.php?logfile=<?php 
        echo base64_encode('debug_fannie.log');
        ?>
">View Entire Log</a>
            <?php 
        $dayend = $log->getLogFile('../logs/debug_fannie.log', 100);
        ?>
            <pre id="dayendLogView" class="tailedLog highlight"><?php 
        echo $dayend;
        ?>
</pre>
            </li>
            <li>If this file is missing, messages may be written to legacy log file php_errors.log &amp; queries.log</li>
            </ul>  
        </ul>
        <?php 
        echo '<div class="row form-group">
              <label class="control-label col-sm-2">Color-Highlighted Logs</label>
              <div class="col-sm-3">' . installSelectField('FANNIE_PRETTY_LOGS', $FANNIE_PRETTY_LOGS, array('true' => 'Yes', 'false' => 'No'), false, false) . '</div></div>';
        echo '<div class="row form-group">
                <label class="control-label col-sm-2">Log Rotation Count</label>
                <div class="col-sm-3">' . installTextField('FANNIE_LOG_COUNT', $FANNIE_LOG_COUNT, 5, false) . '</div></div>';
        $errorOpts = array(1 => 'Yes', 0 => 'No');
        if ($FANNIE_CUSTOM_ERRORS > 1) {
            $FANNIE_CUSTOM_ERRORS = 1;
        }
        echo '<div class="row form-group">
                <label class="control-label col-sm-2">Verbose Debug Messages</label>
                <div class="col-sm-3">' . installSelectField('FANNIE_CUSTOM_ERRORS', $FANNIE_CUSTOM_ERRORS, $errorOpts, false, false) . '</div></div>';
        $taskOpts = array(99 => 'Never email on error', 0 => 'Emergency', 1 => 'Alert', 2 => 'Critical', 3 => 'Error', 4 => 'Warning', 5 => 'Notice', 6 => 'Info', 7 => 'Debug');
        echo '<div class="row form-group">
                <label class="control-label col-sm-2">Task Error Severity resulting in emails</label>
                <div class="col-sm-3">' . installSelectField('FANNIE_TASK_THRESHOLD', $FANNIE_TASK_THRESHOLD, $taskOpts, 99, false) . '</div></div>';
        echo '<p>
            CORE can send logs to a remote syslog server if a host name or IP
            is provided.
            </p>';
        echo '<div class="row form-group">
            <label class="control-label col-sm-2">Remote Syslog Host</label>
            <div class="col-sm-3">' . installTextField('FANNIE_SYSLOG_SERVER', $FANNIE_SYSLOG_SERVER) . '</div>
            </div>';
        echo '<div class="row form-group">
            <label class="control-label col-sm-2">Remote Syslog Port</label>
            <div class="col-sm-3">' . installTextField('FANNIE_SYSLOG_PORT', $FANNIE_SYSLOG_PORT, 514) . '</div>
            </div>';
        echo '<div class="row form-group">
            <label class="control-label col-sm-2">Remote Syslog Protocol</label>
            <div class="col-sm-3">' . installSelectField('FANNIE_SYSLOG_PROTOCOL', $FANNIE_SYSLOG_PROTOCOL, array('tcp', 'udp'), 'udp') . '</div>
            </div>';
        ?>
        <hr />
        <h4 class="install">Co-op</h4>
        Use this to identify code that is specific to your co-op.
        <br />Particularly important if you plan to contribute to the CORE IT code base.
        <br />Try to use a code that will not be confused with any other, e.g. "WEFC_Toronto" instead of "WEFC".
        <br />Co-op ID: 
        <?php 
        echo installTextField('FANNIE_COOP_ID', $FANNIE_COOP_ID);
        ?>
        <br />Home Page (URL)
        <br />Normally the item editor is displayed by default but another page or site can
        be designated instead.
        <?php 
        echo installTextField('FANNIE_HOME_PAGE', $FANNIE_HOME_PAGE, 'item/ItemEditorPage.php');
        ?>

        <hr />
        <h4 class="install">Locale</h4>
        Set the Country and Language where Fannie will run.
        <br />If these are not set in Fannie configuration but are set in the Linux environment the environment values will be used as
        defaults that can be overridden by settings here.

        <?php 
        echo '<br />Country: ';
        //Use I18N country codes.
        $countries = array("US" => "USA", "CA" => "Canada");
        echo installSelectField('FANNIE_COUNTRY', $FANNIE_COUNTRY, $countries, '');
        echo '<br />Language: ';
        //Use I18N language codes.
        $langs = array("en" => "English", "fr" => "French", "sp" => "Spanish");
        echo installSelectField('FANNIE_LANGUAGE', $FANNIE_LANGUAGE, $langs, '');
        ?>
        <hr />
        <h4 class="install">Back Office Transactions</h4>
        <i>Values used when generating transaction data via Fannie
        instead of through an actual POS terminal. The corrections department
        is only used for balancing individual transactions. Total sales
        to that department via generated transactions should always be
        zero. The catch-all department is used when generated transactions
        will generate a sale (or refund) but it is not known where the 
        amount belongs for accounting purposes.
        </i><br />
        <?php 
        echo '<table>';
        echo '<tr><td>Employee#</td>' . '<td>' . installTextField('FANNIE_EMP_NO', $FANNIE_EMP_NO, 1001, false) . '</td></tr>';
        echo '<tr><td>Register#</td>' . '<td>' . installTextField('FANNIE_REGISTER_NO', $FANNIE_REGISTER_NO, 30, false) . '</td></tr>';
        echo '<tr><td>Corrections Dept#</td>' . '<td>' . installTextField('FANNIE_CORRECTION_DEPT', $FANNIE_CORRECTION_DEPT, 800, false) . '</td></tr>';
        echo '<tr><td>Patronage Transfer Dept#</td>' . '<td>' . installTextField('FANNIE_PATRONAGE_DEPT', $FANNIE_PATRONAGE_DEPT, 800, false) . '</td></tr>';
        echo '<tr><td>Catch-all Dept#</td>' . '<td>' . installTextField('FANNIE_MISC_DEPT', $FANNIE_MISC_DEPT, 800, false) . '</td></tr>';
        echo '</table>';
        ?>
        <hr />
        <p>
            <button type="submit" class="btn btn-default">Save Configuration</button>
        </p>
        </form>


        <?php 
        return ob_get_clean();
        // body_content()
    }
Ejemplo n.º 3
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
        $js ="";
        return $js;
    
    }
    */
    function body_content()
    {
        global $FANNIE_AUTH_ENABLED;
        include '../config.php';
        ob_start();
        echo showInstallTabs('Authentication');
        ?>

<form action=InstallAuthenticationPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger;\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />
<p class="ichunk" style="margin-top: 1.0em;">
<b>Authentication enabled</b>
<?php 
        echo installSelectField('FANNIE_AUTH_ENABLED', $FANNIE_AUTH_ENABLED, array(1 => 'Yes', 0 => 'No'), false, false);
        ?>
</p><!-- /.ichunk -->
<?php 
        // Default to Authenticate ("Authenticate Everything") or not.
        if ($FANNIE_AUTH_ENABLED) {
            echo "<p class='ichunk'>";
            echo "<b>Authenticate by default </b>";
            echo installSelectField('FANNIE_AUTH_DEFAULT', $FANNIE_AUTH_DEFAULT, array(1 => 'Yes', 0 => 'No'), false, false);
            echo "If 'Yes' all Admin utilities will require Login<br />";
            echo "If 'No' only those utilities coded for it will require Login";
            echo "</p><!-- /.ichunk -->";
        }
        if ($FANNIE_AUTH_ENABLED) {
            if (!function_exists("login")) {
                include $FANNIE_ROOT . 'auth/login.php';
            }
            // if no users exist, offer to create one
            if (getNumUsers() == 0) {
                $success = False;
                if (isset($_REQUEST['newuser']) && isset($_REQUEST['newpass'])) {
                    $FANNIE_AUTH_ENABLED = False;
                    // toggle to bypass user checking
                    $newUser = $_REQUEST['newuser'];
                    $success = createLogin($_REQUEST['newuser'], $_REQUEST['newpass']);
                    if ($success) {
                        echo "<i>User " . $_REQUEST['newuser'] . " created</i><br />";
                        $FANNIE_AUTH_ENABLED = True;
                        // toggle enforce error checking
                        $success = addAuth($_REQUEST['newuser'], 'admin');
                        if ($success) {
                            echo "<i>User " . $_REQUEST['newuser'] . " is an admin</i><br />";
                            echo "You can use these credentials at the <a href='../auth/ui/' target='_aui'>Authentication Interface</a></br />";
                            echo " Other protected pages may require different credentials.<br />";
                            $success = addAuth($_REQUEST['newuser'], 'sysadmin');
                            if ($success) {
                                echo "<i>User " . $_REQUEST['newuser'] . " is a sysadmin</i><br />";
                                echo "You can use these credentials at the Installation and Configuration Interface (these pages)</br />";
                                // populate known privileges table automatically
                                $db = FannieDB::get($FANNIE_OP_DB);
                                ob_start();
                                // don't care about primary key errors
                                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userKnownPrivs');
                                ob_end_clean();
                                // loaddata() has no return value; success assumed.
                                echo "Table {$FANNIE_OP_DB}.userKnownPrivs has been populated with the standard privilege set.<br />";
                            } else {
                                echo "<b>Error making user {$newUser} a sysadmin</b><br />";
                            }
                        } else {
                            echo "<b>Error making user {$newUser} an admin</b><br />";
                        }
                    } else {
                        echo "<b>Error creating initial user</b><br />";
                    }
                    $FANNIE_AUTH_ENABLED = True;
                    // toggle enforce error checking
                }
                if (!$success) {
                    echo "<br /><i>No users defined. To create an initial admin user,\n                enter a username and password below</i><br />";
                    echo 'Username: <input type="text" name="newuser" /><br />';
                    echo 'Password: <input type="password" name="newpass" /><br />';
                }
            } else {
                echo "<p class='ichunk'>You can manage Login users and groups via the <a href='../auth/ui/' target='_aui'>Authentication Interface</a>";
                echo "</p><!-- /.ichunk -->";
            }
            echo "<p class='ichunk'><a href='../../documentation/Fannie/developer/auth.html' target='_audoc'>How Authentication Works</a>";
            echo "</p><!-- /.ichunk -->";
        }
        ?>
<hr />
<b>Allow shadow logins</b>
<?php 
        echo installSelectField('FANNIE_AUTH_SHADOW', $FANNIE_AUTH_SHADOW, array(1 => 'Yes', 0 => 'No'), false, false);
        if (!file_exists("../auth/shadowread/shadowread")) {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: shadowread utility does not exist</div>";
            echo "<div class=\"well\">";
            echo "shadowread lets Fannie authenticate users agaist /etc/shadow. To create it:";
            echo "<pre>\ncd " . realpath('../auth/shadowread') . "\nmake\n    </pre>";
            echo "</div>";
        } else {
            $perms = fileperms("../auth/shadowread/shadowread");
            if ($perms == 0104755) {
                echo "<div class=\"alert alert-success\">shadowread utility has proper permissions</div>";
            } else {
                echo "<div class=\"alert alert-danger\"><b>Warning</b>: shadowread utility has incorrect permissions</div>";
                echo "<div class=\"well\">";
                echo "shadowread needs setuid permission. To fix it: ";
                echo "<pre>\ncd " . realpath('../auth/shadowread') . "\nsudo make install\n        </pre>";
                echo "</div>";
            }
        }
        ?>
<hr />
<b>Allow LDAP logins</b>
<?php 
        echo installSelectField('FANNIE_AUTH_LDAP', $FANNIE_AUTH_LDAP, array(1 => 'Yes', 0 => 'No'), false, false);
        if (!function_exists("ldap_connect")) {
            echo "<div class=\"alert alert-danger\"><b>Warning</b>: PHP install does not have LDAP support enabled</div>";
        } else {
            echo "<div class=\"alert alert-success\">PHP has LDAP support enabled</div>";
        }
        ?>
<br />
<label>LDAP Server Host</label>
<?php 
        echo installTextField('FANNIE_LDAP_SERVER', $FANNIE_LDAP_SERVER, '127.0.0.1');
        ?>
<label>LDAP Port</label>
<?php 
        echo installTextField('FANNIE_LDAP_PORT', $FANNIE_LDAP_PORT, '389');
        ?>
<label>LDAP Domain (DN)</label>
<?php 
        echo installTextField('FANNIE_LDAP_DN', $FANNIE_LDAP_DN, 'ou=People,dc=example,dc=org');
        ?>
<label>LDAP Username Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_SEARCH_FIELD', $FANNIE_LDAP_SEARCH_FIELD, 'uid');
        ?>
<label>LDAP User ID# Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_UID_FIELD', $FANNIE_LDAP_UID_FIELD, 'uidnumber');
        ?>
<label>LDAP Real Name Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_RN_FIELD', $FANNIE_LDAP_RN_FIELD, 'cn');
        ?>
<hr />
<p>
    <button type=submit class="btn btn-default">Save Configuration</button>
</p>
</form>

<?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 4
0
    function body_content()
    {
        include '../config.php';
        ob_start();
        echo showInstallTabs('Theming');
        ?>

        <form action="InstallThemePage.php" method="post">
        <h1 class="install">
            <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
        </h1>
        <?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        echo '<h4 class="install">Colors</h4>';
        echo '<table class="table" id="colorsConfTable">';
        echo '<tr><td>Background Color</td>' . '<td>' . installTextField('FANNIE_CSS_BG_COLOR', $FANNIE_CSS_BG_COLOR, '#FFFFFF') . '</td>' . '<td><div style="background-color: ' . $FANNIE_CSS_BG_COLOR . '; width: 20px; margin:3px; ' . ' height: 20px; border:solid 1px black; "></div></td>' . '</tr>';
        echo '<tr><td>Text Color</td>' . '<td>' . installTextField('FANNIE_CSS_FG_COLOR', $FANNIE_CSS_FG_COLOR, '#222222') . '</td>' . '<td><div style="background-color: ' . $FANNIE_CSS_FG_COLOR . '; width: 20px; margin:3px; ' . ' height: 20px; border:solid 1px black; "></div></td>' . '</tr>';
        echo '<tr><td>Primary Highlight Color</td>' . '<td>' . installTextField('FANNIE_CSS_PRIMARY_COLOR', $FANNIE_CSS_PRIMARY_COLOR, '#330066') . '</td>' . '<td><div style="background-color: ' . $FANNIE_CSS_PRIMARY_COLOR . '; width: 20px; margin:3px; ' . ' height: 20px; border:solid 1px black; "></div></td>' . '</tr>';
        echo '<tr><td>Secondary Highlight Color</td>' . '<td>' . installTextField('FANNIE_CSS_SECONDARY_COLOR', $FANNIE_CSS_SECONDARY_COLOR, '#444444') . '</td>' . '<td><div style="background-color: ' . $FANNIE_CSS_SECONDARY_COLOR . '; width: 20px; margin:3px; ' . ' height: 20px; border:solid 1px black; "></div></td>' . '</tr>';
        echo '</table>';
        echo '<h4 class="install">Other</h4>';
        echo '<table id="otherConfTable" class="table">';
        echo '<tr><td>Backend Name</td>' . '<td>' . installTextField('FANNIE_BACKEND_NAME', $FANNIE_BACKEND_NAME, 'Fannie') . '</td>';
        echo '<tr><td>Custom Title</td>' . '<td>' . installTextField('FANNIE_CUSTOM_TITLE', $FANNIE_CUSTOM_TITLE, '') . '</td>';
        echo '<tr><td>Font</td>' . '<td>' . installTextField('FANNIE_CSS_FONT', $FANNIE_CSS_FONT, '') . '</td>';
        $family = str_replace(';', '', $FANNIE_CSS_FONT);
        $family = str_replace('\'', '"', $family);
        $family = rtrim($family, ',');
        $family .= ', arial, sans-serif';
        echo '<td><div style=\'font-family: ' . $family . '; margin:3px; padding:5px;' . ' border:solid 1px black; \'>Lorem Ipsum</div></td>' . '</tr>';
        echo '<tr><td>Character Set</td>' . '<td>' . installTextField('FANNIE_CHARSET', $FANNIE_CHARSET, 'ISO-8859-1') . '</td>' . '</tr>';
        echo '<tr><td>Logo</td>' . '<td>' . installTextField('FANNIE_CSS_LOGO', $FANNIE_CSS_LOGO, '') . '</td>' . '<td><img src="' . $FANNIE_CSS_LOGO . '" alt="logo preview" /></td>' . '</tr>';
        echo '</table>';
        echo '<hr />
            <p>
                <button type="submit" name="psubmit" value="1" class="btn btn-default">Save Configuration</button>
            </p>
            </form>';
        return ob_get_clean();
    }
Ejemplo n.º 5
0
    public function body_content()
    {
        include dirname(__FILE__) . '/../config.php';
        ob_start();
        echo showInstallTabs('Stores');
        ?>

<form action=InstallStoresPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<p class="ichunk">Revised 23Apr2014</p>
<?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />
<h4 class="install">Stores</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
<?php 
        $model = new StoresModel(FannieDB::get($FANNIE_OP_DB));
        $model->dbHost($FANNIE_SERVER);
        $myself = $model->find();
        if (count($myself) == 0) {
            echo '<i>No entry found for this store. Adding one automatically...</i><br />';
            $model->description('CURRENT STORE');
            $model->save();
        } else {
            if (count($myself) > 1) {
                echo '<i>Warning: more than one entry for store host: ' . $FANNIE_SERVER . '</i><br />';
            } else {
                echo '<i>This store is #' . installTextField('FANNIE_STORE_ID', $FANNIE_STORE_ID, $myself[0]->storeID()) . '</i><br />';
            }
        }
        $model->reset();
        echo '<label>Mode</label>';
        echo installSelectField('FANNIE_STORE_MODE', $FANNIE_STORE_MODE, array('STORE' => 'Single Store', 'HQ' => 'HQ'), 'STORE');
        $supportedTypes = array('none' => '');
        if (extension_loaded('pdo') && extension_loaded('pdo_mysql')) {
            $supportedTypes['PDO_MYSQL'] = 'PDO MySQL';
        }
        if (extension_loaded('mysqli')) {
            $supportedTypes['MYSQLI'] = 'MySQLi';
        }
        if (extension_loaded('mysql')) {
            $supportedTypes['MYSQL'] = 'MySQL';
        }
        if (extension_loaded('mssql')) {
            $supportedTypes['MSSQL'] = 'MSSQL';
        }
        ?>
<table class="table">
<tr>
    <th>Store #</th><th>Description</th><th>DB Host</th>
    <th>Driver</th><th>Username</th><th>Password</th>
    <th>Operational DB</th>
    <th>Transaction DB</th>
    <th>Push</th>
    <th>Pull</th>
    <th>Own Items</th>
    <th>Delete Entry</th>
</tr>
<?php 
        foreach ($model->find('storeID') as $store) {
            printf('<tr %s>
            <td>%d<input type="hidden" name="storeID[]" value="%d" /></td>
            <td><input type="text" class="form-control" name="storeName[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeHost[]" value="%s" /></td>', $store->dbHost() == $FANNIE_SERVER ? 'class="info"' : '', $store->storeID(), $store->storeID(), $store->description(), $store->dbHost());
            echo '<td><select name="storeDriver[]" class="form-control">';
            foreach ($supportedTypes as $key => $label) {
                printf('<option %s value="%s">%s</option>', $store->dbDriver() == $key ? 'selected' : '', $key, $label);
            }
            echo '</select></td>';
            printf('<td><input type="text" class="form-control" name="storeUser[]" value="%s" /></td>
            <td><input type="password" class="form-control" name="storePass[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeOp[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeTrans[]" value="%s" /></td>
            <td><input type="checkbox" name="storePush[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storePull[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storeItems[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storeDelete[]" value="%d" /></td>
            </tr>', $store->dbUser(), $store->dbPassword(), $store->opDB(), $store->transDB(), $store->storeID(), $store->push() ? 'checked' : '', $store->storeID(), $store->pull() ? 'checked' : '', $store->storeID(), $store->hasOwnItems() ? 'checked' : '', $store->storeID());
        }
        ?>
</table>
</p>
<hr />
<h4 class="install">Testing Connections</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
    <ul>
<?php 
        foreach ($model->find('storeID') as $store) {
            $test = db_test_connect($store->dbHost(), $store->dbDriver(), $store->transDB(), $store->dbUser(), $store->dbPassword());
            echo '<li> Store #' . $store->storeID() . ': ' . ($test ? 'Connected' : 'No connection') . '</li>';
        }
        ?>
    </ul>
    <i>Note: it's OK if this store's connection fails as long as it succeeds
       on the "Necessities" tab.</i>
</p>
<hr />
<h4 class="install">Read-only Database Server(s)</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
Specify one or more database servers that can be used strictly
for read operations. If more than one database is listed, read-only
queries will be load-balanced across them.
<?php 
        if (!isset($FANNIE_READONLY_JSON)) {
            $FANNIE_READONLY_JSON = json_encode(array(array('host' => $FANNIE_SERVER, 'type' => $FANNIE_SERVER_DBMS, 'user' => $FANNIE_SERVER_USER, 'pw' => $FANNIE_SERVER_PW)));
        }
        confset('FANNIE_READONLY_JSON', "'{$FANNIE_READONLY_JSON}'");
        ?>
<textarea rows="10" cols="30" name="FANNIE_READONLY_JSON" class="form-control">
<?php 
        echo \COREPOS\Fannie\API\lib\FannieUI::prettyJSON($FANNIE_READONLY_JSON);
        ?>
</textarea>
<hr />
<p>
<button type=submit name="saveButton" value="Save" class="btn btn-default">Save</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type=submit name="addButton" value="Add Another Store" class="btn btn-default">Add Another Store</button>
</p>
</form>

<?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 6
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
        $js ="";
        return $js;
    }
    */
    function body_content()
    {
        include '../config.php';
        ob_start();
        echo showInstallTabs("Members");
        ?>

<form action=InstallMembershipPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />

<p class="ichunk2"><b>Names per membership: </b>
<?php 
        echo installTextField('FANNIE_NAMES_PER_MEM', $FANNIE_NAMES_PER_MEM, 1);
        ?>
</p>

<hr />
<h4 class="install">Equity/Store Charge</h4>
<p class="ichunk2"><b>Equity Department(s): </b>
<?php 
        echo installTextField('FANNIE_EQUITY_DEPARTMENTS', $FANNIE_EQUITY_DEPARTMENTS, '');
        ?>
</p>

<p class="ichunk2"><b>Store Charge Department(s): </b>
<?php 
        echo installTextField('FANNIE_AR_DEPARTMENTS', $FANNIE_AR_DEPARTMENTS, '');
        ?>
</p>

<hr />
<h4 class="install">Membership Information Modules</h4>
The Member editing interface displayed after you select a member at:
<br /><a href="<?php 
        echo $FANNIE_URL;
        ?>
mem/MemberSearchPage.php" target="_mem"><?php 
        echo $FANNIE_URL;
        ?>
mem/MemberSearchPage.php</a>
<br />consists of fields grouped in several sections, called modules, listed below.
<br />The enabled (active) ones are selected/highlighted. May initially be none.
<br />
<br /><b>Available Modules</b> <br />
<?php 
        if (!isset($FANNIE_MEMBER_MODULES)) {
            $FANNIE_MEMBER_MODULES = array('ContactInfo', 'MemType');
        }
        if (isset($_REQUEST['FANNIE_MEMBER_MODULES'])) {
            $FANNIE_MEMBER_MODULES = array();
            foreach ($_REQUEST['FANNIE_MEMBER_MODULES'] as $m) {
                $FANNIE_MEMBER_MODULES[] = $m;
            }
        }
        $saveStr = 'array(';
        foreach ($FANNIE_MEMBER_MODULES as $m) {
            $saveStr .= '"' . $m . '",';
        }
        $saveStr = rtrim($saveStr, ",") . ")";
        confset('FANNIE_MEMBER_MODULES', $saveStr);
        ?>
<select multiple name="FANNIE_MEMBER_MODULES[]" size="10" class="form-control">
<?php 
        $tmp = array();
        $modules = FannieAPI::listModules('MemberModule');
        foreach ($modules as $class) {
            $tmp[] = $class;
        }
        $modules = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\member\\MemberModule');
        foreach ($modules as $class) {
            $tmp[] = $class;
        }
        sort($tmp);
        foreach ($tmp as $module) {
            printf("<option %s>%s</option>", in_array($module, $FANNIE_MEMBER_MODULES) ? 'selected' : '', $module);
        }
        ?>
</select><br />
Click or ctrl-Click or shift-Click to select/deselect modules for enablement.
<br /><br />
<a href="InstallMemModDisplayPage.php">Adjust Module Display Order</a>

<hr />
<h4 class="install">Member Cards</h4>
Member Card UPC Prefix: 
<?php 
        echo installTextField('FANNIE_MEMBER_UPC_PREFIX', $FANNIE_MEMBER_UPC_PREFIX, '');
        ?>
<hr />
<h4 class="install">Lane On-Screen Display</h4>
<div id="blueline-input-div">
This controls what is displayed on the upper left of the cashier's screen after a member
is selected.
<?php 
        echo installTextField('FANNIE_BLUELINE_TEMPLATE', $FANNIE_BLUELINE_TEMPLATE, '');
        ?>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{ACCOUNTNO}}'); return false;">
    Account#
</a>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{ACCOUNTTYPE}}'); return false;">
    Account Type
</a>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{FIRSTNAME}}'); return false;">
    First Name
</a>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{LASTNAME}}'); return false;">
    Last Name
</a>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{FIRSTINITIAL}}'); return false;">
    First Initial
</a>
<a href="" class="btn btn-default btn-xs"
    onclick="$('#blueline-input-div input').focus().val($('#blueline-input-div input').val() + '{{LASTINITIAL}}'); return false;">
    Last Initial
</a>
</div>
<hr />
<h4 class="install">Data Mode</h4>
<div>
Choose how customer data is stored in the database. Using "classic" is highly
recommended in production environments. The "new" mode should not be without
a developer and/or database administrator on hand to help with potential bugs.
<?php 
        $modes = array(1 => 'New', 0 => 'Classic');
        echo installSelectField('FANNIE_CUST_SCHEMA', $FANNIE_CUST_SCHEMA, $modes, 0);
        ?>
<hr />
<p>
    <button type="submit" class="btn btn-default">Save Configuration</button>
</p>
</form>
<?php 
        $sql = db_test_connect($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        if (!$sql) {
            echo "<div class='alert alert-danger'>Cannot connect to database to refresh views.</div>";
        } else {
            echo "Refreshing database views ... ";
            $this->recreate_views($sql);
            echo "done.";
        }
        return ob_get_clean();
        // body_content
    }