Ejemplo n.º 1
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.º 2
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.º 3
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
    
    }
    */
    function body_content()
    {
        //Should this really be done with global?
        //global $FANNIE_URL, $FANNIE_EQUITY_DEPARTMENTS;
        include '../../config.php';
        ob_start();
        echo showInstallTabs("Sample Data", '../');
        ?>

<form action=InstallSampleDataPage.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 />
<div class="well"><em>
<?php 
        /* First, if this is a request to load a file, do that.
        */
        $db = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        if (isset($_REQUEST['employees'])) {
            echo "Loading employees";
            $db->query("TRUNCATE TABLE employees");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'employees');
        } elseif (isset($_REQUEST['custdata'])) {
            echo "Loading custdata";
            $backup1 = $db->query('TRUNCATE TABLE custdataBackup');
            $backup2 = $db->query('INSERT INTO custdataBackup SELECT * FROM custdata');
            if ($backup1 === false || $backup2 === false) {
                echo _(' - failed to backup current data. Sample data not loaded.');
            } else {
                $db->query("TRUNCATE TABLE custdata");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'custdata');
            }
        } elseif (isset($_REQUEST['memtype'])) {
            echo "Loading memtype";
            $db->query("TRUNCATE TABLE memtype");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'memtype');
        } elseif (isset($_REQUEST['products'])) {
            echo "Loading products";
            $backup1 = $db->query('TRUNCATE TABLE productBackup');
            $backup2 = $db->query('INSERT INTO productBackup SELECT * FROM products');
            if ($backup1 === false || $backup2 === false) {
                echo _(' - failed to backup current data. Sample data not loaded.');
            } else {
                $db->query("TRUNCATE TABLE products");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'products');
            }
        } elseif (isset($_REQUEST['prod-flags'])) {
            echo "Loading product flags";
            $db->query("TRUNCATE TABLE prodFlags");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'prodFlags');
        } elseif (isset($_REQUEST['batchType'])) {
            echo "Loading batchn types";
            $db->query("TRUNCATE TABLE batchType");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'batchType');
        } elseif (isset($_REQUEST['depts'])) {
            echo "Loading departments";
            $db->query("TRUNCATE TABLE departments");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'departments');
            /* subdepts sample data is of questionable use
               echo "<br />Loading subdepts";
               $db->query("TRUNCATE TABLE subdepts");
               \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db,'subdepts');
               */
        } elseif (isset($_REQUEST['superdepts'])) {
            echo "Loading super departments";
            $db->query("TRUNCATE TABLE superdepts");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'superdepts');
            $db->query("TRUNCATE TABLE superDeptNames");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'superDeptNames');
        } elseif (isset($_REQUEST['tenders'])) {
            echo "Loading tenders";
            $db->query("TRUNCATE TABLE tenders");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'tenders');
        } elseif (isset($_REQUEST['authentication'])) {
            echo "Loading authentication info";
            $db->query("TRUNCATE TABLE userKnownPrivs");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userKnownPrivs');
        } elseif (isset($_REQUEST['origin'])) {
            echo "Loading country info";
            $db->query("TRUNCATE TABLE originCountry");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'originCountry');
            echo "<br />Loading state/province info";
            $db->query("TRUNCATE TABLE originStateProv");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'originStateProv');
        } else {
            if (isset($_REQUEST['authGroups'])) {
                echo "Loading authentication groups";
                $db->query("TRUNCATE TABLE userGroups");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userGroups');
                $db->query("TRUNCATE TABLE userGroupPrivs");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userGroupPrivs');
                // give "Administrators" group all permissions
                $db->query("INSERT userGroupPrivs SELECT \n            1, auth_class, 'all', 'all'\n            FROM userKnownPrivs");
            }
        }
        ?>
</em></div>

<?php 
        /* Display a list of data that can be loaded.
        */
        ?>
<p class="ichunk">
Some sample data is available to get a test lane
up and running quickly and to try Fannie functions.
<h3>Keep in mind this data overwrites whatever is currently in the table.</h3>
<br />These utilities populate the server tables.
Then use the <a href="../../sync/SyncIndexPage.php"
target="_sync"><u>Synchronize</u></a>
utilities to populate the lane tables.
</p>
<hr />
<h4 class="install"><?php 
        echo _('Cashiers');
        ?>
</h4>
    This table contains login information for cashiers. The two
    included logins are '56' and '7000'.<br />
    <?php 
        echo $this->loadButton('employees', 'employees', _('Load sample cashiers'));
        ?>
<hr />
<h4 class="install">Customer Data</h4>
    Customer data is the membership information. Sample data includes
    a bunch of members and default non-member 11.<br />
    <?php 
        echo $this->loadButton('custdata', 'custdata', _('Load sample customers'));
        ?>
    <br />
    <br />
    Customers are classified into different membership types.<br />
    <?php 
        echo $this->loadButton('memtype', 'memtype', _('Load sample member types'));
        ?>
<hr />
    <h4 class="install">Products</h4>
    Stuff to sell. There's a lot of sample data. I think this might
    be the Wedge's or at least a snapshot of it.<br />
    <?php 
        echo $this->loadButton('products', 'products', _('Load sample products'));
        ?>
<hr />
    <h4 class="install">Product Flags</h4>
    Product Flags are a flexible method for identifying custom attributes of items.
    CORE includes a default set of some more common flags.<br />
    <?php 
        echo $this->loadButton('prodFlags', 'prod-flags', _('Load sample product flags'));
        ?>
<hr />
    <h4 class="install">Batch Types</h4>
    Batches are used for temporary promotional pricing as well as scheduling changes
    in regular retail price. Batches may be organized by type. Sample data includes
    a couple common options.
    <?php 
        echo $this->loadButton('batchType', 'batchType', _('Load sample batch types'));
        ?>
<hr />
    <h4 class="install">Departments</h4>
    Products get categorized into departments .
    You can also ring amounts directly to a department. Not needed,
    strictly speaking, for a basic lane (Ring up items, total, 
    accept tender, provide change).<br />
    <?php 
        echo $this->loadButton('departments', 'depts', _('Load sample departments'));
        ?>
<hr />
    <h4 class="install">Super-Department Names <span style="font-weight:400;">and</span> Super-Department Links</h4>
    Super Departments are tags for grouping Departments.
    A Department can have more than one, that is, belong to more than one Super-Department.
    This rudimentary set agrees with the Products sample data.
    Super-Departments can also be used to group the domains of Buyers.
    Use them with e.g. the <a href="../../fannie/item/productList.php">Product List report/tool</a>
    They are also used for grouping shelftags for printing and for grouping data in reports.
    <?php 
        echo $this->loadButton('superdepts', 'superdepts', _('Load sample super departments'));
        ?>
<hr />
<h4 class="install">Tenders</h4>
    Load all the default tenders into the tenders table.<br />
    <?php 
        echo $this->loadButton('tenders', 'tenders', _('Load sample tenders'));
        ?>
<hr />
    <h4 class="install">Authentication</h4>
    Load information about currently defined authorization classes<br />
    <?php 
        echo $this->loadButton('userKnownPrivs', 'authentication', _('Load auth classes'));
        ?>
<br /><br />
    Load default groups<br />
    <?php 
        echo $this->loadButton('userGroups', 'authGroups', _('Load auth groups'));
        ?>
<hr />
    <h4 class="install">Countries, States, and Provinces</h4>
    Load default place-of-origin information<br />
    <?php 
        echo $this->loadButton('originCountry', 'origin', _('Load origin info'));
        ?>
<hr />

</form>

<?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 4
0
    /**
      Define any javascript needed
      @return a javascript string
    function javascript_content(){
        $js ="";
        return $js;
    //js_content()
    }
    */
    function body_content()
    {
        //Should this really be done with global?
        global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS;
        ob_start();
        echo showInstallTabs('Plugins');
        ?>

<form action=InstallPluginsPage.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>";
        }
        ?>

<h4 class="install">Available plugins</h4>
<?php 
        if (!isset($FANNIE_PLUGIN_LIST)) {
            $FANNIE_PLUGIN_LIST = array();
        }
        if (!is_array($FANNIE_PLUGIN_LIST)) {
            $FANNIE_PLUGIN_LIST = array();
        }
        if (!isset($FANNIE_PLUGIN_SETTINGS)) {
            $FANNIE_PLUGIN_SETTINGS = array();
        }
        if (!is_array($FANNIE_PLUGIN_SETTINGS)) {
            $FANNIE_PLUGIN_SETTINGS = array();
        }
        $mods = FannieAPI::ListModules('FanniePlugin');
        $others = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\FanniePlugin');
        foreach ($others as $o) {
            if (!in_array($o, $mods)) {
                $mods[] = $o;
            }
        }
        sort($mods);
        if (isset($_REQUEST['PLUGINLIST']) || isset($_REQUEST['psubmit'])) {
            $oldset = $FANNIE_PLUGIN_LIST;
            if (!is_array($oldset)) {
                $oldset = array();
            }
            $newset = isset($_REQUEST['PLUGINLIST']) ? $_REQUEST['PLUGINLIST'] : array();
            foreach ($newset as $plugin_class) {
                if (!\COREPOS\Fannie\API\FanniePlugin::IsEnabled($plugin_class)) {
                    $obj = new $plugin_class();
                    $obj->pluginEnable();
                }
            }
            foreach ($oldset as $plugin_class) {
                if (!class_exists($plugin_class)) {
                    continue;
                }
                if (!in_array($plugin_class, $newset)) {
                    $obj = new $plugin_class();
                    $obj->pluginDisable();
                }
            }
            $FANNIE_PLUGIN_LIST = $_REQUEST['PLUGINLIST'];
        }
        echo '<table id="install" class="table">';
        $count = 0;
        foreach ($mods as $m) {
            $enabled = False;
            $instance = new $m();
            foreach ($FANNIE_PLUGIN_LIST as $r) {
                if ($r == $m) {
                    $enabled = True;
                    break;
                }
            }
            /* 17Jun13 Under Fannie Admin CSS the spacing is cramped.
                          The slider overlaps the text. Want it higher and to the right.
                          Not obvious why or how to fix.
                          Jiggered the CSS a little here and above but isn't really a fix.
               */
            echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '>
        <td style="width:10em;">&nbsp;</td>
        <td style="width:25em;">' . "\n";
            echo '<fieldset class="toggle">' . "\n";
            printf('<input name="PLUGINLIST[]" id="plugin_%s" type="checkbox" %s
        value="%s" onchange="$(\'#settings_%s\').toggle();" class="checkbox-inline" />
        <label onclick="" for="plugin_%s">%s</label>', $m, $enabled ? 'checked' : '', $m, $m, $m, $m);
            echo "\n" . '<span class="toggle-button"></span></fieldset>' . "\n";
            // 17Jun13 EL Added <br /> for overlap problem.
            printf('<br /><span class="noteTxt">%s</span>', $instance->plugin_description);
            echo '</td></tr>' . "\n";
            if (empty($instance->plugin_settings)) {
                echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '>
            <td colspan="2"><i>No settings required</i></td></tr>';
            } else {
                echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '>
            <td colspan="2" style="margin-bottom: 0px; height:auto;">';
                printf('<div id="settings_%s" %s>', $m, !$enabled ? 'class="collapse"' : '');
                foreach ($instance->plugin_settings as $field => $info) {
                    $form_id = $m . '_' . $field;
                    // ignore submitted values if plugin was not enabled
                    if ($enabled && isset($_REQUEST[$form_id])) {
                        $FANNIE_PLUGIN_SETTINGS[$field] = $_REQUEST[$form_id];
                    }
                    if (!isset($FANNIE_PLUGIN_SETTINGS[$field])) {
                        $FANNIE_PLUGIN_SETTINGS[$field] = isset($info['default']) ? $info['default'] : '';
                    }
                    echo '<b>' . (isset($info['label']) ? $info['label'] : $field) . '</b>: ';
                    if (isset($info['options'])) {
                        echo '<select name="' . $form_id . '" class="form-control">';
                        foreach ($info['options'] as $key => $val) {
                            printf('<option %s value="%s">%s</option>', $FANNIE_PLUGIN_SETTINGS[$field] == $val ? 'selected' : '', $val, $key);
                        }
                        echo '</select>';
                    } else {
                        printf('<input type="text" name="%s" value="%s" class="form-control" />', $form_id, $FANNIE_PLUGIN_SETTINGS[$field]);
                    }
                    // show the default if plugin isn't enabled, but
                    // unset so that it isn't saved in the configuration
                    if (!$enabled) {
                        unset($FANNIE_PLUGIN_SETTINGS[$field]);
                    }
                    // 17Jun13 EL Added <br /> for crampedness problem.
                    if (isset($info['description'])) {
                        echo '<br /><span class="noteTxt">' . $info['description'] . '</span>';
                    }
                    echo '<br />';
                    //confset($field,"'".$CORE_LOCAL->get($field)."'");
                }
                if ($enabled && isset($_REQUEST['psubmit'])) {
                    $instance->settingChange();
                }
                echo '</div>';
                echo '</td></tr>';
            }
            $count++;
        }
        echo '</table>';
        $saveStr = "array(";
        foreach ($FANNIE_PLUGIN_LIST as $r) {
            $saveStr .= "'" . $r . "',";
        }
        $saveStr = rtrim($saveStr, ",") . ")";
        confset('FANNIE_PLUGIN_LIST', $saveStr);
        $saveStr = "array(";
        foreach ($FANNIE_PLUGIN_SETTINGS as $key => $val) {
            $saveStr .= "'" . $key . "'=>'" . $val . "',";
        }
        $saveStr = rtrim($saveStr, ",") . ")";
        confset('FANNIE_PLUGIN_SETTINGS', $saveStr);
        ?>
<hr />
        <p>
            <button type="submit" name="psubmit" value="1" class="btn btn-default">Save Configuration</button>
        </p>
</form>

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

        <form action=InstallMenuPage.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 "<br />Full path is: " . '../config.php' . "<br />";
            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 />";
            }
        }
        ?>

        <hr  />
        <p class="ichunk">
        Whether to always show the Fannie Administration Menu.
        <ul>
        <li>Coops may prefer not to show the menu in order to maximize the space available on the page for the report or tool.
        <li>Some pages may show or not show the Fannie Menu regardless of this setting,
        but setting it to Yes will increase the number of pages on which the menu appears.
        </ul>
        <b>Show Admin menu</b>
        <!-- "windowdressing" is the term used in Class Lib 2.0 for the heading and navigation menu.
             Use this to set the value of $window_dressing. -->
        <?php 
        echo installSelectField('FANNIE_WINDOW_DRESSING', $FANNIE_WINDOW_DRESSING, array(1 => 'Yes', 0 => 'No'), false);
        ?>
        </p>

        <hr  />
        <p class="ichunk">
        Use this tool to customize Fannie's menu. Usage:
        <ul>
        <li>Left hand text box contains the menu entry text
        <li>Right hand box contains a URL or a special value for other
        types of entries such as section headers.
        <li>URLs are relative to Fannie <i>unless</i> they begin with / or
        a protocol (http://, https://, etc).
        </ul>

        <h4 class="install">Fannie Menu Builder</h4>
        <?php 
        $VALID_MENUS = array('Item Maintenance', 'Sales Batches', 'Reports', 'Membership', 'Synchronize', 'Admin', '__store__');
        if (!isset($FANNIE_MENU) || !is_array($FANNIE_MENU)) {
            include '../src/init_menu.php';
            $FANNIE_MENU = $INIT_MENU;
        } else {
            foreach ($FANNIE_MENU as $menu => $content) {
                if (!in_array($menu, $VALID_MENUS)) {
                    // menu is not valid
                    // reset to default
                    // obviously not ideal error recovery
                    include '../src/init_menu.php';
                    $FANNIE_MENU = $INIT_MENU;
                    break;
                }
            }
        }
        for ($i = 0; $i < count($VALID_MENUS); $i++) {
            $post_titles = FormLib::get('m_title' . $i);
            $post_urls = FormLib::get('m_url' . $i);
            if (!is_array($post_titles) || !is_array($post_urls)) {
                continue;
            }
            /** rebuild from posted data **/
            $FANNIE_MENU[$VALID_MENUS[$i]] = array();
            $divider_count = 1;
            for ($j = 0; $j < count($post_titles); $j++) {
                $p_title = $post_titles[$j];
                $p_url = $post_urls[$j];
                // url must have some kind of value
                // title may be empty on dividers
                if (empty($p_url)) {
                    continue;
                }
                if ($p_url == '__divider__') {
                    $p_title = 'divider' . $divider_count;
                    $divider_count++;
                } elseif (empty($p_title)) {
                    continue;
                }
                $FANNIE_MENU[$VALID_MENUS[$i]][$p_title] = $p_url;
            }
        }
        if (FormLib::get('import-menu') !== '') {
            $import = FormLib::get('import-menu');
            $json = json_decode($import, true);
            if ($json === null) {
                echo '<div class="alert alert-danger">Menu Import is not valid JSON</div>';
            } else {
                $valid = true;
                foreach ($json as $menu => $content) {
                    if (!in_array($menu, $VALID_MENUS)) {
                        echo '<div class="alert alert-danger"><strong>' . $menu . '</strong> is not a valid top-level menu</div>';
                        $valid = false;
                        break;
                    } elseif (!is_array($content)) {
                        echo '<div class="alert alert-danger">Entries for <strong>' . $menu . '</strong> are not valid. It should be a JSON
                            object with keys representing menu titles and values
                            represeting URLs or the special values __header__ and
                            __divider__</div>';
                        $valid = false;
                        break;
                    }
                }
                if ($valid) {
                    $FANNIE_MENU = $json;
                    echo '<div class="alert alert-success">Imported menu</div>';
                }
            }
        }
        $saveStr = 'array(';
        $menu_number = 0;
        $select = '<select onchange="$(this).next(\'input\').val($(this).val());"
                        class="form-control">
                <option value="">URL</option>';
        $opts = array('__header__' => 'Section Header', '__divider__' => 'Divider Line');
        foreach ($FANNIE_MENU as $menu => $content) {
            $saveStr .= "'" . $menu . "' => array(";
            echo '<b>' . $menu . '</b>';
            echo '<ul id="menuset' . $menu_number . '">';
            foreach ($content as $m_title => $m_url) {
                $saveStr .= "'" . str_replace("'", "\\'", $m_title) . "' => '" . $m_url . "',";
                echo '<li class="form-inline">';
                printf('<input type="text" name="m_title%d[]" value="%s" class="form-control" />', $menu_number, $m_title);
                echo $select;
                foreach ($opts as $key => $val) {
                    printf('<option %s value="%s">%s</option>', $key == $m_url ? 'selected' : '', $key, $val);
                }
                echo '</select>';
                printf('<input type="text" name="m_url%d[]" value="%s" class="form-control" />', $menu_number, $m_url);
                echo ' [ <a href="" onclick="$(this).parent().remove(); return false;">Remove Entry</a> ]';
                echo '</li>';
            }
            $saveStr .= '),';
            echo '</ul>';
            $newEntry = sprintf('<li class="form-inline">
                            <input type="text" name="m_title%d[]" value="" class="form-control" />%s', $menu_number, $select);
            foreach ($opts as $key => $val) {
                $newEntry .= sprintf('<option value="%s">%s</option>', $key, $val);
            }
            $newEntry .= sprintf('</select><input type="text" name="m_url%d[]" value="" class="form-control" />
                    [ <a href="" onclick="$(this).parent().remove(); return false;">Remove Entry</a> ]
                    </li>', $menu_number);
            echo '<div id="newEntry' . $menu_number . '" class="collapse">';
            echo $newEntry;
            echo '</div>';
            printf('[ <a href="" onclick="$(\'ul#menuset%d\').append($(\'#newEntry%d\').html()); return false;">Add New Entry</a>
                to %s ]', $menu_number, $menu_number, $menu);
            echo '<br />';
            $menu_number++;
        }
        $saveStr .= ')';
        confset('FANNIE_MENU', $saveStr);
        ?>
        <hr />
        <div class="form-group">
        <label>Hand-editable Menu / Export</label>
        <textarea class="form-control" rows="15">
<?php 
        echo \COREPOS\Fannie\API\lib\FannieUI::prettyJSON(json_encode($FANNIE_MENU));
        ?>
        </textarea>
        </div>
        <div class="form-group">
        <label>Import Menu (use same JSON format)</label>
        <textarea name="import-menu" class="form-control" rows="15"></textarea>
        </div>
        <p>
            <button type="submit" name="psubmit" value="1" class="btn btn-default">Save Configuration</button>
        </p>
        </form>
        </body>
        </html>

        <?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 6
0
    function body_content()
    {
        ob_start();
        echo showInstallTabs('Updates');
        ?>

<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<p class="ichunk">Database Updates.</p>
<?php 
        if (FormLib::get_form_value('mupdate') !== '') {
            $updateClass = FormLib::get_form_value('mupdate');
            echo '<div class="well">';
            echo 'Attempting to update model: "' . $updateClass . '"<br />';
            if (!class_exists($updateClass)) {
                echo '<div class="alert alert-danger">Error: class not found</div>';
            } elseif (!is_subclass_of($updateClass, 'BasicModel')) {
                echo '<div class="alert alert-danger">Error: not a valid model</div>';
            } else {
                $updateModel = new $updateClass(null);
                $db_name = $this->normalize_db_name($updateModel->preferredDB());
                if ($db_name === False) {
                    echo '<div class="alert alert-danger">Error: requested database unknown</div>';
                } else {
                    ob_start();
                    $changes = $updateModel->normalize($db_name, BasicModel::NORMALIZE_MODE_APPLY, true);
                    $details = ob_get_clean();
                    if ($changes === False) {
                        echo '<div class="alert alert-danger">An error occured applying the update</div>';
                    } else {
                        echo '<div class="alert alert-success">Update complete</div>';
                    }
                    printf(' <a href="" onclick="$(\'#updateDetails\').toggle();return false;"
                        >Details</a><pre class="collapse" id="updateDetails">%s</pre>', $details);
                }
            }
            echo '</div>';
        }
        $obj = new BasicModel(null);
        $models = FannieAPI::listModules('BasicModel');
        $cmd = new ReflectionClass('BasicModel');
        $cmd = $cmd->getFileName();
        echo '<ul>';
        foreach ($models as $class) {
            $model = new $class(null);
            $db_name = $this->normalize_db_name($model->preferredDB());
            if ($db_name === False) {
                continue;
            }
            ob_start();
            $changes = $model->normalize($db_name, BasicModel::NORMALIZE_MODE_CHECK);
            $details = ob_get_clean();
            if ($changes === False) {
                printf('<li>%s had errors.', $class);
            } elseif ($changes > 0) {
                printf('<li>%s has updates available.', $class);
            } elseif ($changes < 0) {
                printf('<li>%s does not match the schema but cannot be updated.', $class);
            }
            if ($changes > 0) {
                $reflector = new ReflectionClass($class);
                $model_file = $reflector->getFileName();
                printf(' <a href="" onclick="$(\'#mDetails%s\').toggle();return false;"
                    >Details</a><br /><pre class="collapse" id="mDetails%s">%s</pre><br />
                    To apply changes <a href="InstallUpdatesPage.php?mupdate=%s">Click Here</a>
                    or run the following command:<br />
                    <pre>php %s --update %s %s</pre>
                    </li>', $class, $class, $details, $class, $cmd, $db_name, $model_file);
            } else {
                if ($changes < 0 || $changes === False) {
                    printf(' <a href="" onclick="$(\'#mDetails%s\').toggle();return false;"
                    >Details</a><br /><pre class="collapse" id="mDetails%s">%s</pre></li>', $class, $class, $details);
                }
            }
        }
        echo '</ul>';
        ?>
<hr />
<p class="ichunk">CORE Updates.</p>
<em>This is new; consider it alpha-y. Commit any changes before running an update.</em><br />
<?php 
        $version_info = \COREPOS\Fannie\API\data\DataCache::check('CoreReleases');
        if ($version_info === false) {
            ini_set('user_agent', 'CORE-POS');
            $json = file_get_contents('https://api.github.com/repos/CORE-POS/IS4C/tags');
            if ($json === false && function_exists('curl_init')) {
                $ch = curl_init('https://api.github.com/repos/CORE-POS/IS4C/tags');
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURL_TIMEOUT, 10);
                curl_setopt($ch, CURLOPT_USERAGENT, 'CORE-POS');
                $json = curl_exec($ch);
                curl_close($ch);
            }
            if ($json === false) {
                echo '<div class="alert alert-danger">Error downloading release information</div>';
            } else {
                $decoded = json_decode($json, true);
                if ($decoded === null) {
                    echo '<div class="alert alert-danger">Downloaded release information is invalid</div>';
                    var_dump($json);
                } else {
                    $version_info = $json;
                    \COREPOS\Fannie\API\data\DataCache::freshen($version_info, 'day', 'CoreReleases');
                }
            }
        }
        $version_info = json_decode($version_info, true);
        $tags = array();
        foreach ($version_info as $release) {
            $tags[] = $release['name'];
        }
        usort($tags, array('InstallUpdatesPage', 'versionSort'));
        $my_version = trim(file_get_contents(dirname(__FILE__) . '/../../VERSION'));
        if ($tags[count($tags) - 1] == $my_version) {
            echo '<div class="alert alert-success">Up to date</div>';
        } elseif (!in_array($my_version, $tags)) {
            echo '<div class="alert alert-warning">Current version <strong>' . $my_version . '</strong> not recognized</div>';
        } else {
            echo '<div class="alert alert-info">
                Current version: <strong>' . $my_version . '</strong><br />
                Newest version available: <strong>' . $tags[count($tags) - 1] . '</strong>
                </div>';
            echo '<h3>To get the latest version</h3>';
            echo '<i>Make note of the big string of letters and numbers produced
                by the "git log" command. If you want to undo the update, that will be handy</i><br />';
            echo '<p><code>';
            $dir = realpath(dirname(__FILE__) . '/../../');
            echo 'cd "' . $dir . '"<br />';
            echo 'git log -n1 --pretty=oneline<br />';
            echo 'git fetch upstream<br />';
            echo 'git merge ' . $tags[count($tags) - 1] . '<br />';
            echo '</code></p>';
            echo '<h3>Troubleshooting</h3>';
            echo '<p>Error message: <i>fatal: \'upstream\' does not appear to be a repository</i><br />';
            echo 'Solution: add the repository and re-run the update commands above<br />';
            echo '<code>git remote add upstream https://github.com/CORE-POS/IS4C</code>';
            echo '</p>';
            echo '<p>Error message: <i>Automatic merge failed; fix conflicts and then commit the result.</i><br />';
            echo 'Unfortunately this means the update cannot be applied automatically. If you are a developer
                you can of course fix the conflicts. If you just need to undo the update attempt and get back
                to a working state, first try this:<br />
                <code>git reset --merge</code><br />
                If problems persist (or you have an old version of git that doesn\'t support that command) use:<br />
                <code>git reset --hard</code>
                </p>';
            echo '<p>Undoing the update<br />
                If you noted the big string of letters and numbers from "git log", you can go back to that
                exact point. Replace PREVIOUS with the big string.<br />
                <code>git reset --merge PREVIOUS</code><br />
                If not, this should get back to the version you were running before but may not be quite
                identical.<br />
                <code>git reset --merge ' . $my_version . '</code>
                </p>';
        }
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 7
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.º 8
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.º 9
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.º 10
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
    }