示例#1
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
    }
示例#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()
    }
示例#3
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
    }