Exemple #1
0
 public function testTasks()
 {
     $tasks = FannieAPI::listModules('FannieTask', true);
     foreach ($tasks as $task_class) {
         $obj = new $task_class();
     }
 }
Exemple #2
0
 public function testPages()
 {
     $pages = FannieAPI::listModules('FanniePage', true);
     $config = FannieConfig::factory();
     $logger = new FannieLogger();
     $op_db = $config->get('OP_DB');
     $dbc = FannieDB::get($op_db);
     $dbc->throwOnFailure(true);
     foreach ($pages as $page_class) {
         $obj = new $page_class();
         $obj->setConfig($config);
         $obj->setLogger($logger);
         $dbc->selectDB($op_db);
         $obj->setConnection($dbc);
         if ($page_class == 'WfcHtViewSalaryPage') {
             continue;
         }
         // header/redirect problem
         ob_start();
         $pre = $obj->preprocess();
         ob_end_clean();
         $this->assertInternalType('boolean', $pre);
         $help = $obj->helpContent();
         $this->assertInternalType('string', $help);
         $auth = $obj->checkAuth();
         $this->assertInternalType('boolean', $pre);
         $obj->unitTest($this);
     }
 }
Exemple #3
0
 public function testItems()
 {
     $mems = FannieAPI::listModules('MemberModule', true);
     foreach ($mems as $mem_class) {
         $obj = new $mem_class();
     }
 }
Exemple #4
0
 public function testItems()
 {
     $items = FannieAPI::listModules('ItemModule', true);
     foreach ($items as $item_class) {
         $obj = new $item_class();
     }
 }
Exemple #5
0
 /**
   Find a data source class for the existing name
   @param [string] $report_class_name name of report
   @return [CwReportDataSource] data source object 
     or [boolean] false if none exists
 */
 public static function getDataSource($report_class_name)
 {
     $sources = \FannieAPI::listModules('\\COREPOS\\Fannie\\Plugin\\CoreWarehouse\\CwReportDataSource');
     foreach ($sources as $source_class) {
         $obj = new $source_class();
         if ($obj->sourceForReport($report_class_name)) {
             return $obj;
         }
     }
     return false;
 }
 protected function get_view()
 {
     $privs = new UserKnownPrivsModel($this->connection);
     $pages = FannieAPI::listModules('FanniePage');
     sort($pages);
     $custom = new PagePermissionsModel($this->connection);
     $ret = '<form method="post">
         <div class="panel panel-default">
             <div class="panel-heading">Create Custom Permissions</div>
             <div class="panel-body">
                 <div class="form-group">
                     <label>Page</label>
                     <select name="page" class="form-control">
                         <option value="">Choose page</option>
                         ' . array_reduce($pages, function ($carry, $page) {
         return $carry . '<option>' . $page . '</option>';
     }) . '
                     </select>
                 </div>
                 <div class="form-group">
                     <label>Permission Class</label>
                     <select name="auth" class="form-control">
                     ' . $privs->toOptions(-1, true) . '
                     </select>
                 </div>
                 <div class="form-group">
                     <button type="submit" class="btn btn-default btn-core">Create</button>
                 </div>
             </div>
         </div>
         </form>
         <div class="panel panel-default">
             <div class="panel-heading">Pages With Custom Permissions</div>
             <div class="panel-body">
                 <table class="table table-bordered table-striped">
                     <tr><th>Name</th><th>Description</th><th>&nbsp;</th></tr>
                     ' . array_reduce($custom->find('pageClass'), function ($carry, $obj) {
         $page_class = $obj->pageClass();
         $page = new $page_class();
         return $carry . sprintf('<tr><td>%s</td><td>%s</td><td>
                             <a href="_method=delete&id=%s" class="btn btn-danger btn-xs">%s</a></td></tr>', $page_class, $page->description, $page_class, \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }) . '
                 </table>
             </div>
         </div>
         ';
     return $ret;
 }
Exemple #7
0
 public function testModels()
 {
     $models = FannieAPI::listModules('BasicModel', true);
     foreach ($models as $model_class) {
         $obj = new $model_class(null);
         $rc = new ReflectionClass($obj);
         $columns = $rc->getProperty('columns');
         $columns->setAccessible(true);
         $columns = $columns->getValue($obj);
         // check column definitions
         $this->assertInternalType('array', $columns);
         foreach ($columns as $column_name => $column_definition) {
             // must be array, must have a type
             $this->assertInternalType('array', $column_definition);
             $this->assertArrayHasKey('type', $column_definition, $model_class . ' missing type for ' . $column_name);
             // must have a get/set method for each collumn
             $val = rand();
             $obj->{$column_name}($val);
             $this->assertEquals($val, $obj->{$column_name}(), 'Get/set busted for ' . $model_class . ' :: ' . $column_name);
         }
     }
 }
Exemple #8
0
 public function get_id_view()
 {
     $pages = FannieAPI::listModules('FanniePage');
     $strong = array();
     $weak = array();
     $search_term = strtoupper($this->id);
     foreach ($pages as $page_class) {
         $obj = new $page_class();
         if (!$obj->discoverable) {
             continue;
         }
         if (strpos(strtoupper($obj->description), $search_term) !== false) {
             $strong[] = $obj;
         }
     }
     if (count($strong) == 0) {
         return '<div class="alert alert-danger">No matches</div>' . $this->get_view();
     }
     $ret = '<div class="panel panel-default">
         <div class="panel-heading">Search Results</div>
         <div class="panel-body"><ul>';
     $URL = $this->config->URL;
     $ROOT = $this->config->ROOT;
     foreach ($strong as $obj) {
         $reflect = new ReflectionClass($obj);
         $page_link = $URL . str_replace($ROOT, '', $reflect->getFileName());
         $description = $obj->description;
         $linked = preg_replace('/(' . $this->id . ')/i', '<strong>\\1</strong>', $description);
         $linked = preg_replace('/\\[(.+)\\]/', '<a href="' . $page_link . '">\\1</a>', $linked);
         if ($linked === $description) {
             $linked .= ' (<a href="' . $url . '">Link</a>)';
         }
         $ret .= '<li>' . $linked . '</li>';
     }
     $ret .= '</ul></div></div>';
     return $this->get_view() . $ret;
 }
Exemple #9
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
    }
Exemple #10
0
 function __autoload($name)
 {
     FannieAPI::loadClass($name);
 }
Exemple #11
0
 public function get_view()
 {
     global $FANNIE_ROOT, $FANNIE_URL;
     $pages = FannieAPI::listModules('FanniePage');
     $sets = array();
     $help = array('done' => 0, 'total' => 0);
     $test_stats = array('done' => 0, 'total' => 0);
     foreach ($pages as $p) {
         $obj = new $p();
         if (!$obj->discoverable) {
             continue;
         }
         $reflect = new ReflectionClass($obj);
         $url = $FANNIE_URL . str_replace($FANNIE_ROOT, '', $reflect->getFileName());
         if (!isset($sets[$obj->page_set])) {
             $sets[$obj->page_set] = array();
         }
         $sets[$obj->page_set][$p] = array('url' => $url, 'info' => $obj->description);
         $help['total']++;
         if ($obj->helpContent() && substr($obj->helpContent(), 0, 17) != '<!-- need doc -->') {
             $help['done']++;
             $sets[$obj->page_set][$p]['help'] = 'alert-success';
         } else {
             $sets[$obj->page_set][$p]['help'] = 'alert-danger';
         }
         $test_stats['total']++;
         if ($obj->has_unit_tests) {
             $test_stats['done']++;
             $sets[$obj->page_set][$p]['test'] = 'alert-success';
         } else {
             $sets[$obj->page_set][$p]['test'] = 'alert-danger';
         }
     }
     $ret = '';
     $ret .= '<div class="alert alert-info">';
     $ret .= sprintf('New UI help content percent: <strong>%.2f%%</strong><br />', (double) $help['done'] / $help['total'] * 100);
     $ret .= sprintf('Unit test coverage for pages: <strong>%.2f%%</strong><br />', (double) $test_stats['done'] / $test_stats['total'] * 100);
     $ret .= '</div>';
     $keys = array_keys($sets);
     sort($keys);
     $ret .= '<ul>';
     foreach ($keys as $set_name) {
         $ret .= '<li>' . $set_name;
         $ret .= '<ul>';
         $page_keys = array_keys($sets[$set_name]);
         sort($page_keys);
         foreach ($page_keys as $page_key) {
             $description = $sets[$set_name][$page_key]['info'];
             $url = $sets[$set_name][$page_key]['url'];
             $linked = preg_replace('/\\[(.+)\\]/', '<a href="' . $url . '">\\1</a>', $description);
             if ($linked === $description) {
                 $linked .= ' (<a href="' . $url . '">Link</a>)';
             }
             $ret .= sprintf('<li>%s 
                 <span class="%s">Help</span>
                 <span class="%s">Tested</span>
                 </li>', $linked, $sets[$set_name][$page_key]['help'], $sets[$set_name][$page_key]['test']);
         }
         $ret .= '</ul>';
         $ret .= '</li>';
     }
     $ret .= '</ul>';
     return $ret;
 }
Exemple #12
0
 function body_content()
 {
     global $FANNIE_ROOT, $FANNIE_URL;
     $ret = '';
     $ret .= '<div id="alert-area"></div>';
     $ret .= '<p>';
     if (function_exists('posix_getpwuid')) {
         $chk = posix_getpwuid(posix_getuid());
         $ret .= "PHP is running as: " . $chk['name'] . "<br />";
         $ret .= "Fannie will attempt to use their crontab<br /><br />";
     } else {
         $ret .= "PHP is (probably) running as: " . get_current_user() . "<br />";
         $ret .= "This is probably Windows; this tool won't work<br /><br />";
     }
     $ret .= '</p>';
     $ret .= '<p>';
     if (!is_writable($FANNIE_ROOT . 'logs/fannie.log')) {
         $ret .= "<i>Warning: fannie.log ({$FANNIE_ROOT}logs/fannie.log)\n                is not writable. Logging task results may\n                not work</i>";
     } else {
         $ret .= "Default logging will be to {$FANNIE_ROOT}logs/fannie.log";
     }
     $ret .= '</p>';
     $ret .= "<p>Click the 'Command' link for popup Help.</p>";
     $jobs = $this->scanScripts($FANNIE_ROOT . 'cron', array());
     $tasks = FannieAPI::listModules('FannieTask');
     $tab = $this->readCrontab();
     $mode = FormLib::get_form_value('mode', 'simple');
     $ret .= "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\" class=\"form form-inline\">";
     $ret .= sprintf('<input type="hidden" name="mode" value="%s" />', $mode);
     if ($mode == 'simple') {
         $ret .= '<a href="CronManagementPage.php?mode=advanced">Switch to Advanced View</a><br />';
     } else {
         $ret .= '<a href="CronManagementPage.php?mode=simple">Switch to Simple View</a><br />';
     }
     $ret .= "<label>E-mail address</label><input name=\"email\" value=\"{$tab['email']}\" class=\"form-control\" />";
     $ret .= "<table class=\"table\">";
     $ret .= "<tr><th>Enabled</th><th>Min</th><th>Hour</th><th>Day</th><th>Month</th><th>Wkdy</th><th>Command/Help</th></tr>";
     $i = 0;
     foreach ($tasks as $task) {
         $obj = new $task();
         if (!$obj->schedulable) {
             continue;
         }
         $cmd = 'php ' . realpath(dirname(__FILE__) . '/../../classlib2.0/FannieTask.php') . ' ' . $task . ' >> ' . $FANNIE_ROOT . 'logs/fannie.log';
         $simple = $this->simpleRow($task, $task, $cmd, $tab, $i);
         if ($simple !== false && $mode == 'simple') {
             $ret .= $simple;
         } else {
             $ret .= $this->advancedRow($task, $task, $cmd, $tab, $i);
         }
         $i++;
     }
     foreach ($jobs as $job) {
         $filename = basename($job);
         $classname = substr($filename, 0, strlen($filename) - 4);
         if (in_array($classname, $tasks)) {
             // tasks must be listed separately
             continue;
         }
         $shortname = substr($job, strlen($FANNIE_ROOT . "cron/"));
         $nicename = rtrim($shortname, 'php');
         $nicename = rtrim($nicename, '.');
         $nicename = str_replace('.', ' ', $nicename);
         $cmd = "cd {$FANNIE_ROOT}cron && php ./{$shortname} >> {$FANNIE_ROOT}logs/fannie.log";
         $simple = $this->simpleRow($shortname, $nicename, $cmd, $tab, $i);
         if ($simple !== false && $mode == 'simple') {
             $simple = str_replace('taskOn', 'deprecatedJobOn', $simple);
             $simple = str_replace('taskOff', 'deprecatedJobOff', $simple);
             $ret .= $simple;
         } else {
             $row = str_replace('taskOn', 'deprecatedJobOn', $this->advancedRow($shortname, $nicename, $cmd, $tab, $i));
             $row = str_replace('taskOff', 'deprecatedJobOff', $row);
             $ret .= $row;
         }
         // defaults are set as once a year so someone doesn't accidentallly
         // start firing a job off every minute
         if (isset($tab['jobs'][$shortname])) {
             unset($tab['jobs'][$shortname]);
         }
         $i++;
     }
     /* list out any jobs that WERE NOT covered
           in the above loop. Those jobs weren't
           set up by this tool and should not be edited
        */
     foreach ($tab['jobs'] as $job) {
         $ret .= sprintf('<tr>
             <td><input type="checkbox" name="enabled[]" %s value="%d" /></td>
             <td><input type="text" size="2" name="min[]" value="%s" /></td>
             <td><input type="text" size="2" name="hour[]" value="%s" /></td>
             <td><input type="text" size="2" name="day[]" value="%s" /></td>
             <td><input type="text" size="2" name="month[]" value="%s" /></td>
             <td><input type="text" size="2" name="wkdy[]" value="%s" /></td>
             <td><input type="hidden" name="cmd[]" value="%s" />%s</td>
             </tr>', 'checked', $i, $job['min'], $job['hour'], $job['day'], $job['month'], $job['wkdy'], $job['cmd'], $job['cmd']);
         $i++;
     }
     $ret .= "</table>";
     $ret .= '<p><button type="submit" name="submit" value="Save"
                 class="btn btn-default">Save</button></p>';
     $ret .= '</form>';
     $this->add_script($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.js?v=1');
     $this->add_css_file($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.css');
     $this->add_onload_command('$(\'.fancybox-link\').fancybox();');
     return $ret;
 }
Exemple #13
0
 /**
   Search available classes to load applicable
   hook objects into this instance
 */
 protected function loadHooks()
 {
     $this->hooks = array();
     if (class_exists('FannieAPI')) {
         $hook_classes = FannieAPI::listModules('BasicModelHook');
         $others = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\data\\hooks\\BasicModelHook');
         foreach ($others as $o) {
             if (!in_array($o, $hook_classes)) {
                 $hook_classes[] = $o;
             }
         }
         foreach ($hook_classes as $class) {
             if (!class_exists($class)) {
                 continue;
             }
             $hook_obj = new $class();
             if ($hook_obj->operatesOnTable($this->name)) {
                 $this->hooks[] = $hook_obj;
             }
         }
     }
     // placeholder value to signify this has actually run
     $this->hooks[] = '_loaded';
 }
Exemple #14
0
        return $parts[1];
    }
}
if (php_sapi_name() === 'cli' && basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
    if ($argc < 2) {
        echo "Usage: php FannieTask.php <Task Class Name>\n";
        return 1;
    }
    include dirname(__FILE__) . '/../config.php';
    include dirname(__FILE__) . '/FannieAPI.php';
    $config = FannieConfig::factory();
    $logger = new FannieLogger();
    FannieDispatch::setLogger($logger);
    FannieDispatch::setErrorHandlers();
    // prepopulate autoloader
    $preload = FannieAPI::listModules('FannieTask');
    $class = $argv[1];
    if (!class_exists($class)) {
        echo "Error: class '{$class}' does not exist\n";
        return 1;
    }
    $obj = new $class();
    if (!is_a($obj, 'FannieTask')) {
        echo "Error: invalid class. Must be subclass of FannieTask\n";
        return 1;
    }
    if (is_numeric($config->get('TASK_THRESHOLD'))) {
        $obj->setThreshold($config->get('TASK_THRESHOLD'));
    }
    $obj->setConfig($config);
    $obj->setLogger($logger);
Exemple #15
0
 function body_content()
 {
     global $FANNIE_MEMBER_MODULES;
     $ret = '';
     $list = FormLib::get_form_value('l');
     $ret .= '<form action="MemberEditor.php" method="post">';
     $ret .= sprintf('<input type="hidden" name="memNum" value="%d" />', $this->memNum);
     if (is_array($list)) {
         foreach ($list as $l) {
             $ret .= sprintf('<input type="hidden" name="l[]" value="%d" />', $l);
         }
     }
     $load = array();
     $editJS = '';
     $ret .= '<div class="container-fluid">
         <div id="alert-area">';
     if (!empty($this->msgs)) {
         $ret .= '<div class="alert alert-danger">' . $this->msgs . '</div>';
     }
     $current_width = 100;
     $account = \COREPOS\Fannie\API\member\MemberREST::get($this->memNum);
     \COREPOS\Fannie\API\member\MemberModule::setAccount($account);
     FannieAPI::listModules('MemberModule');
     foreach ($FANNIE_MEMBER_MODULES as $mm) {
         if (!class_exists($mm)) {
             continue;
         }
         $instance = new $mm();
         if ($current_width + $instance->width() > 100) {
             $ret .= '</div>' . "\n" . '<div class="row">';
             $current_width = 0;
         }
         switch ($instance->width()) {
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_THIRD:
                 $ret .= '<div class="col-sm-4">' . "\n";
                 break;
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_HALF:
                 $ret .= '<div class="col-sm-6">' . "\n";
                 break;
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_FULL:
             default:
                 $ret .= '<div class="col-sm-12">' . "\n";
                 break;
         }
         $ret .= $instance->showEditForm($this->memNum, $this->country);
         $ret .= '</div>';
         $current_width += $instance->width();
         $editJS .= $instance->getEditJavascript();
         foreach ($instance->getEditLoadCommands() as $cmd) {
             $load[] = $cmd;
         }
     }
     $ret .= '</div>';
     // close last module row
     $ret .= '</div>';
     // close fluid-container
     $ret .= '<p>';
     if (is_array($list)) {
         $ret .= '<button type="submit" name="saveBtn" value="Save &amp; Next"
             class="btn btn-default">Save &amp; Next</button>';
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     }
     $ret .= '<button type="submit" name="saveBtn" value="Save" 
         class="btn btn-default btn-core">Save</button>';
     $ret .= '<button type="reset" class="btn btn-default btn-reset">Reset Form</button>';
     $ret .= '</p>';
     $ret .= '</form>';
     if ($editJS != '') {
         $ret .= '<script type="text/javascript">' . $editJS . '</script>';
     }
     foreach ($load as $cmd) {
         $this->add_onload_command($cmd);
     }
     return $ret;
 }
Exemple #16
0
 function form_content()
 {
     global $FANNIE_MEMBER_MODULES, $FANNIE_OP_DB;
     $ret = '';
     $review = FormLib::get_form_value('review', False);
     if ($review !== false) {
         $ret .= '<fieldset><legend>Review</legend>';
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $account = \COREPOS\Fannie\API\member\MemberREST::get($review);
         $ret .= 'Saved Member #' . $review . ' (';
         if ($account) {
             foreach ($account['customers'] as $row) {
                 if ($row['accountHolder']) {
                     $ret .= $row['firstName'] . ' ' . $row['lastName'];
                     break;
                 }
             }
         }
         $ret .= ')';
         $ret .= '<br /><a href="MemberEditor.php?memNum=' . $review . '">Edit Again</a>';
         $list = FormLib::get('l');
         if (!class_exists('MemberEditor')) {
             include dirname(__FILE__) . '/MemberEditor.php';
         }
         $links = MemberEditor::memLinksPrevNext($review, $list);
         if (!empty($links[0])) {
             $ret .= '&nbsp;&nbsp;&nbsp;' . $links[0];
         }
         if (!empty($links[1])) {
             $ret .= '&nbsp;&nbsp;&nbsp;' . $links[1];
         }
         $ret .= '</fieldset>';
     }
     $ret .= '<div class="well">
         Enter criteria to find one member or a list members from which to choose.</div>';
     $ret .= '<form action="MemberSearchPage.php" method="get">';
     $ret .= '<div class="container-fluid">';
     $ret .= '<div class="form-group form-inline row">
         <label>Member Number</label>
         <input type="text" name="memNum" id="mn" class="form-control" />
         </div>';
     $searchJS = '';
     $load = array();
     FannieAPI::listModules('MemberModule');
     foreach ($FANNIE_MEMBER_MODULES as $mm) {
         if (class_exists($mm)) {
             $instance = new $mm();
             if ($instance->hasSearch()) {
                 $ret .= $instance->showSearchForm($this->country);
                 $searchJS .= $instance->getSearchJavascript();
                 foreach ($instance->getSearchLoadCommands() as $cmd) {
                     $load[] = $cmd;
                 }
             }
         }
     }
     $ret .= '</div>';
     $ret .= '<p><button type="submit" value="Search" name="doSearch" 
         class="btn btn-default">Search</button></p>';
     $ret .= '</form>';
     $ret .= '<script type="text/javascript" src="../item/autocomplete.js"></script>';
     if ($searchJS != '') {
         $ret .= '<script type="text/javascript">' . $searchJS . '</script>';
     }
     foreach ($load as $cmd) {
         $this->add_onload_command($cmd);
     }
     return $ret;
 }
Exemple #17
0
    public function body_content()
    {
        global $FANNIE_ROOT, $FANNIE_URL;
        ob_start();
        $terminology = '
<ul>
<li><strong>Terminology (<a href="" onclick="$(\'#terminologyList\').toggle(); return false;">Show/Hide</a>)</strong>
<ul class="collapse" id="terminologyList">
<li>"Buyer" and "Super Department" usually refer to the same kind of thing:
a grouping of Departments. 
Some coops organize their Super Departments by Buyer, the person buying, but others do not.
A Department can be in more than one Super Department,
say by Buyer e.g. "Patricia" and by Category of Product e.g. "Oils and Vinegars",
so in that sense they are like tags.
However, a product (item) cannot be in more than one Department.
</li>
<li>"Vendor", "Distributor" and "Supplier" usually refer to the same kind of thing:
the organization from which the coop obtained, purchased, bought the product.
It may refer to the same organization that made it, the Manufacturer,
but the name used in IS4C may be different.
</li>
<li>"Manufacturer" and "Brand" usually refer to the same kind of thing:
the organization that made the product and often whose name is on it.
Real UPCs are usually supplied by the Manufacturer.
The first five digits, or six, if the first is not 0, digits of the UPC usually identify the
manufacturer, but this is less strict than it used to be,
so that sometimes more leading digits identify the manufacturer.
IS4C UPCs have 13 characters, padded on the left with zeroes, so there may be two or three zeroes
before the first significant digit.
You can usually enter numbers starting with the first non-zero, but zeroes at the end are not assumed.
<li>"UPC" and "PLU" usually refer to the same kind of thing:
The unique code for an item that is scanned or typed at the PoS terminal.
More strictly, PLUs are used on produce and UPCs on packaged goods.
</li>
<li>"Member", "Owner" and "Customer" refer to the same thing: the membership designated by the member number.
It is printed at the end of receipts.
The Membership Card number, the barcode on the card is different; it is used to find the member number.
All member-related things in IS4C are on the member number.
</li>
<li><span style="font-weight:bold;">Download</span>
    <ul>
    <li>"Excel", in newer reports, where "CSV" is also an option, refers to a file
    with formatting similar to that on the page.
    It is for further use in Excel or another similar spreadsheet program.
    In older reports, where there is no "CSV" option, it is more like CSV (raw data).
    </li>
    <li>"CSV" refers to a file of raw data, without formatting.
    Literally, "Comma-Separated Values".  Many applications, including Excel, can import this format.
    </li>
    </ul>
    </li>
    </ul>
</li>
<li><strong>Note</strong>
<br />While making these reports it can be useful to have the 
<a href="../item/ItemEditorPage.php" target="_itemEdit">Item Maintenance</a> application
open in a separate tab or window as a reference for Manufacturers and Vendors (Distributors).
</li>
</ul>';
        echo $terminology;
        $report_sets = array();
        $other_reports = array();
        $reports = FannieAPI::listModules('FannieReportPage');
        foreach ($reports as $class) {
            $obj = new $class();
            if (!$obj->discoverable) {
                continue;
            }
            $reflect = new ReflectionClass($obj);
            $url = $FANNIE_URL . str_replace($FANNIE_ROOT, '', $reflect->getFileName());
            if ($obj->report_set != '') {
                if (!isset($report_sets[$obj->report_set])) {
                    $report_sets[$obj->report_set] = array();
                }
                $report_sets[$obj->report_set][] = array('url' => $url, 'info' => $obj->description);
            } else {
                $other_reports[] = array('url' => $url, 'info' => $obj->description);
            }
        }
        $tools = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\FannieReportTool');
        foreach ($tools as $class) {
            $obj = new $class();
            if (!$obj->discoverable) {
                continue;
            }
            $reflect = new ReflectionClass($obj);
            $url = $FANNIE_URL . str_replace($FANNIE_ROOT, '', $reflect->getFileName());
            if ($obj->report_set != '') {
                if (!isset($report_sets[$obj->report_set])) {
                    $report_sets[$obj->report_set] = array();
                }
                $report_sets[$obj->report_set][] = array('url' => $url, 'info' => $obj->description);
            } else {
                $other_reports[] = array('url' => $url, 'info' => $obj->description);
            }
        }
        echo '<ul>';
        $keys = array_keys($report_sets);
        sort($keys);
        foreach ($keys as $set_name) {
            echo '<li>' . $set_name;
            echo '<ul>';
            $reports = $report_sets[$set_name];
            usort($reports, array('ReportsIndexPage', 'reportAlphabetize'));
            foreach ($reports as $report) {
                $description = $report['info'];
                $url = $report['url'];
                $linked = preg_replace('/\\[(.+)\\]/', '<a href="' . $url . '">\\1</a>', $description);
                if ($linked === $description) {
                    $linked .= ' (<a href="' . $url . '">Link</a>)';
                }
                echo '<li>' . $linked . '</li>';
            }
            echo '</ul></li>';
        }
        usort($other_reports, array('ReportsIndexPage', 'reportAlphabetize'));
        foreach ($other_reports as $report) {
            $description = $report['info'];
            $url = $report['url'];
            $linked = preg_replace('/\\[(.+)\\]/', '<a href="' . $url . '">\\1</a>', $description);
            if ($linked === $description) {
                $linked .= ' (<a href="' . $url . '">Link</a>)';
            }
            echo '<li>' . $linked . '</li>';
        }
        echo '</ul>';
        return ob_get_clean();
    }
Exemple #18
0
    public function form_content()
    {
        $ret = <<<HTML
<form method="get">
    <div class="form-group">
        <label>Table</label>
        <select name="id" class="form-control">
            {{ models }}
        </select>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-default">Submit</button>
    </div>
</form>
HTML;
        $models = FannieAPI::listModules('BasicModel');
        sort($models);
        $opts = array_reduce($models, function ($c, $i) {
            return $c . '<option>' . $i . '</option>';
        });
        $ret = str_replace('{{ models }}', $opts, $ret);
        return $ret;
    }
Exemple #19
0
 public function testPlugins()
 {
     $plugin_path = dirname(__FILE__) . '/../../fannie/modules/plugins2.0/';
     $first = array('CwReportDataSource' => '');
     $files = array();
     foreach (FannieAPI::listFiles($plugin_path) as $file) {
         $class = substr(basename($file), 0, strlen(basename($file)) - 4);
         if (isset($first[$class])) {
             $first[$class] = $file;
         } else {
             $files[] = $file;
         }
     }
     foreach ($first as $class => $file) {
         array_unshift($files, $file);
     }
     $functions = get_defined_functions();
     $sniffer = null;
     $standard = dirname(__FILE__) . '/CodingStandard/CORE_PSR1/';
     if (getenv('TRAVIS') === false && class_exists('PHP_CodeSniffer')) {
         $sniffer = new PHP_CodeSniffer();
         $sniffer->initStandard($standard);
         $sniffer->cli->setCommandLineValues(array('--report=Json'));
         $sniffer->cli->setCommandLineValues($files);
         $sniffer->processFiles($files);
         ob_start();
         $sniffer->reporting->printReport('Json', true, $sniffer->cli->getCommandLineValues(), null);
         $json = ob_get_clean();
         $json = json_decode($json, true);
         $errors = 0;
         $errorMsg = '';
         $json = $json['files'];
         foreach ($json as $filename => $jsonfile) {
             foreach ($jsonfile['messages'] as $message) {
                 if ($message['type'] == 'ERROR') {
                     $errors++;
                     $errorMsg .= $filename . ': ' . $message['message'] . "\n";
                 } else {
                     echo "Coding Standard Warning: " . $filename . ': ' . $message['message'] . "\n";
                 }
             }
         }
         $this->assertEquals(0, $errors, $errorMsg);
     } else {
         echo "PHP_CodeSniffer is not installed. This test will be less effective.\n";
         echo "Use composer to install it.\n";
     }
     foreach ($files as $file) {
         $file = realpath($file);
         $class_name = substr(basename($file), 0, strlen(basename($file)) - 4);
         $namespaced_class_name = FannieAPI::pathToClass($file);
         if (class_exists($class_name, false)) {
             // may have already been included
             $reflect = new ReflectionClass($class_name);
             $this->assertEquals($file, $reflect->getFileName(), $class_name . ' is defined by ' . $file . ' AND ' . $reflect->getFileName());
         } elseif (class_exists($namespaced_class_name, false)) {
             // may have already been included
             $reflect = new ReflectionClass($namespaced_class_name);
             $this->assertEquals($file, $reflect->getFileName(), $namespaced_class_name . ' is defined by ' . $file . ' AND ' . $reflect->getFileName());
         } else {
             ob_start();
             include $file;
             $output = ob_get_clean();
             $this->assertEquals('', $output, $file . ' produces output when included');
             $current_functions = get_defined_functions();
             $this->assertEquals(count($functions['user']), count($current_functions['user']), $file . ' has defined additional functions: ' . $this->detailedFunctionDiff($current_functions['user'], $functions['user']));
             $classes = get_declared_classes();
             $this->assertThat($classes, $this->logicalOr($this->contains($class_name), $this->contains($namespaced_class_name), $this->contains(ltrim($namespaced_class_name, '\\'))), $file . ' does not define ' . $class_name . ' or ' . $namespaced_class_name);
         }
     }
 }
Exemple #20
0
    public function get_view()
    {
        $ret = '';
        $ret .= '<form target="_blank" action="' . filter_input(INPUT_SERVER, 'PHP_SELF') . '" method="post" id="signform">';
        $mods = FannieAPI::listModules('FannieSignage');
        $others = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\item\\FannieSignage');
        foreach ($others as $o) {
            if (!in_array($o, $mods)) {
                $mods[] = $o;
            }
        }
        sort($mods);
        $ret .= '<div class="form-group form-inline">';
        $ret .= '<label>Layout</label>: 
            <select name="signmod" class="form-control" >';
        foreach ($mods as $m) {
            $name = $m;
            if (strstr($m, '\\')) {
                $pts = explode('\\', $m);
                $name = $pts[count($pts) - 1];
            }
            $ret .= sprintf('<option %s value="%s">%s</option>', $m == $this->config->get('DEFAULT_SIGNAGE') ? 'selected' : '', $m, $name);
        }
        $ret .= '</select>';
        $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
        $ret .= '<button type="submit" name="pdf" value="Print" 
                    class="btn btn-default">Print</button>';
        $ret .= '</div>';
        $ret .= '<hr />';
        $ret .= <<<HTML
<table class="table table-bordered table-striped small">
    <thead>
    <tr>
        <th>Brand</th>
        <th>Description</th>
        <th>Price</th>
        <th>Scale</th>
        <th>Size</th>
        <th>Origin</th>
    </tr>
    </thead>
    <tbody>
    <tr class="info">
        <td>
            <input type="text" class="form-control input-sm" placeholder="Change All"
                onchange="if (this.value !== '') \$('.input-brand').val(this.value);" />
        </td>
        <td>
            <input type="text" class="form-control input-sm" placeholder="Change All"
                onchange="if (this.value !== '') \$('.input-description').val(this.value);" />
        </td>
        <td>
            <input type="text" class="form-control price-field input-sm" placeholder="Change All"
                onchange="if (this.value !== '') \$('.input-price').val(this.value);" />
        </td>
        <td>
            <select class="form-control input-sm" onchange="if (this.value !== '-1') \$('.input-scale').val(this.value);">
                <option value="-1">Change All</option>
                <option value="0">No</option>
                <option value="1">Yes</option>
            </select>
        <td>
            <input type="text" class="form-control input-sm" placeholder="Change All"
                onchange="if (this.value !== '') \$('.input-size').val(this.value);" />
        </td>
        <td>
            <input type="text" class="form-control input-sm" placeholder="Change All"
                onchange="if (this.value !== '') \$('.input-origin').val(this.value);" />
        </td>
    </tr>
HTML;
        for ($i = 0; $i < 32; $i++) {
            $ret .= <<<HTML
<tr>
    <td><input type="text" name="brand[]" class="form-control input-sm input-brand" /></td>
    <td><input type="text" name="description[]" class="form-control input-sm input-description" /></td>
    <td><input type="text" name="price[]" class="form-control input-sm input-price price-field" /></td>
    <td><select name="scale[]" class="form-control input-sm input-scale">
        <option value="0">No</option>
        <option value="1">Yes</option>
    </select></td>
    <td><input type="text" name="size[]" class="form-control input-sm input-size" /></td>
    <td><input type="text" name="origin[]" class="form-control input-sm input-origin" /></td>
</tr>
HTML;
        }
        $ret .= '</tbody></table>';
        return $ret;
    }
    /**
      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
    }
Exemple #22
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
    }
Exemple #23
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
    }
Exemple #24
0
 function SaveFormData($upc)
 {
     $FANNIE_PRODUCT_MODULES = FannieConfig::config('PRODUCT_MODULES', array());
     $upc = BarcodeLib::padUPC($upc);
     $dbc = $this->db();
     $model = new ProductsModel($dbc);
     $model->upc($upc);
     if (!$model->load()) {
         // fully init new record
         $model->special_price(0);
         $model->specialpricemethod(0);
         $model->specialquantity(0);
         $model->specialgroupprice(0);
         $model->advertised(0);
         $model->tareweight(0);
         $model->start_date('0000-00-00');
         $model->end_date('0000-00-00');
         $model->discounttype(0);
         $model->wicable(0);
         $model->scaleprice(0);
         $model->inUse(1);
     }
     $stores = FormLib::get('store_id', array());
     for ($i = 0; $i < count($stores); $i++) {
         $model->store_id($stores[$i]);
         $taxes = FormLib::get('tax');
         if (isset($taxes[$i])) {
             $model->tax($taxes[$i]);
         }
         $fs = FormLib::get('FS', array());
         if (in_array($stores[$i], $fs)) {
             $model->foodstamp(1);
         } else {
             $model->foodstamp(0);
         }
         $scale = FormLib::get('Scale', array());
         if (in_array($stores[$i], $scale)) {
             $model->scale(1);
         } else {
             $model->scale(0);
         }
         $qtyFrc = FormLib::get('QtyFrc', array());
         if (in_array($stores[$i], $qtyFrc)) {
             $model->qttyEnforced(1);
         } else {
             $model->qttyEnforced(0);
         }
         $wic = FormLib::get('prod-wicable', array());
         if (in_array($stores[$i], $wic)) {
             $model->wicable(1);
         } else {
             $model->wicable(0);
         }
         $discount_setting = FormLib::get('discount');
         if (isset($discount_setting[$i])) {
             switch ($discount_setting[$i]) {
                 case 0:
                     $model->discount(0);
                     $model->line_item_discountable(0);
                     break;
                 case 1:
                     $model->discount(1);
                     $model->line_item_discountable(1);
                     break;
                 case 2:
                     $model->discount(1);
                     $model->line_item_discountable(0);
                     break;
                 case 3:
                     $model->discount(0);
                     $model->line_item_discountable(1);
                     break;
             }
         }
         $price = FormLib::get('price');
         if (isset($price[$i])) {
             $model->normal_price($price[$i]);
         }
         $cost = FormLib::get('cost');
         if (isset($cost[$i])) {
             $model->cost($cost[$i]);
         }
         $desc = FormLib::get('descript');
         if (isset($desc[$i])) {
             $model->description(str_replace("'", '', $desc[$i]));
         }
         $brand = FormLib::get('manufacturer');
         if (isset($brand[$i])) {
             $model->brand(str_replace("'", '', $brand[$i]));
         }
         $model->pricemethod(0);
         $model->groupprice(0.0);
         $model->quantity(0);
         $dept = FormLib::get('department');
         if (isset($dept[$i])) {
             $model->department($dept[$i]);
         }
         $size = FormLib::get('size');
         if (isset($size[$i])) {
             $model->size($size[$i]);
         }
         $model->modified(date('Y-m-d H:i:s'));
         $unit = FormLib::get('unitm');
         if (isset($unit[$i])) {
             $model->unitofmeasure($unit[$i]);
         }
         $subdept = FormLib::get('subdept');
         if (isset($subdept[$i])) {
             $model->subdept($subdept[$i]);
         }
         // lookup vendorID by name
         $vendorID = 0;
         $v_input = FormLib::get('distributor');
         if (isset($v_input[$i])) {
             $vendor = new VendorsModel($dbc);
             $vendor->vendorName($v_input[$i]);
             foreach ($vendor->find('vendorID') as $obj) {
                 $vendorID = $obj->vendorID();
                 break;
             }
         }
         $model->default_vendor_id($vendorID);
         $inUse = FormLib::get('prod-in-use', array());
         if (in_array($stores[$i], $inUse)) {
             $model->inUse(1);
         } else {
             $model->inUse(0);
         }
         $idEnf = FormLib::get('id-enforced', array());
         if (isset($idEnf[$i])) {
             $model->idEnforced($idEnf[$i]);
         }
         $local = FormLib::get('prod-local');
         if (isset($local[$i])) {
             $model->local($local[$i]);
         }
         $deposit = FormLib::get('deposit-upc');
         if (isset($deposit[$i])) {
             if ($deposit[$i] == '') {
                 $deposit[$i] = 0;
             }
             $model->deposit($deposit[$i]);
         }
         /* products.formatted_name is intended to be maintained automatically.
          * Get all enabled plugins and standard modules of the base.
          * Run plugins first, then standard modules.
          */
         $formatters = FannieAPI::ListModules('ProductNameFormatter');
         $fmt_name = "";
         $fn_params = array('index' => $i);
         foreach ($formatters as $formatter_name) {
             $formatter = new $formatter_name();
             $fmt_name = $formatter->compose($fn_params);
             if (isset($formatter->this_mod_only) && $formatter->this_mod_only) {
                 break;
             }
         }
         $model->formatted_name($fmt_name);
         $model->save();
     }
     /**
       If a vendor is selected, intialize
       a vendorItems record
     */
     if ($vendorID != 0) {
         $vitem = new VendorItemsModel($dbc);
         $vitem->vendorID($vendorID);
         $vitem->upc($upc);
         $sku = FormLib::get('vendorSKU');
         if (empty($sku)) {
             $sku = $upc;
         } else {
             /**
               If a SKU is provided, update any
               old record that used the UPC as a
               placeholder SKU.
             */
             $existsP = $dbc->prepare('
                 SELECT sku
                 FROM vendorItems
                 WHERE sku=?
                     AND upc=?
                     AND vendorID=?');
             $existsR = $dbc->execute($existsP, array($sku, $upc, $vendorID));
             if ($dbc->numRows($existsR) > 0 && $sku != $upc) {
                 $delP = $dbc->prepare('
                     DELETE FROM vendorItems
                     WHERE sku =?
                         AND upc=?
                         AND vendorID=?');
                 $dbc->execute($delP, array($upc, $upc, $vendorID));
             } else {
                 $fixSkuP = $dbc->prepare('
                     UPDATE vendorItems
                     SET sku=?
                     WHERE sku=?
                         AND vendorID=?');
                 $dbc->execute($fixSkuP, array($sku, $upc, $vendorID));
             }
         }
         $vitem->sku($sku);
         $vitem->size($model->size());
         $vitem->description($model->description());
         $vitem->brand($model->brand());
         $vitem->units(FormLib::get('caseSize', 1));
         $vitem->cost($model->cost());
         $vitem->save();
     }
     if ($dbc->table_exists('prodExtra')) {
         $extra = new ProdExtraModel($dbc);
         $extra->upc($upc);
         if (!$extra->load()) {
             $extra->variable_pricing(0);
             $extra->margin(0);
             $extra->case_quantity('');
             $extra->case_cost(0.0);
             $extra->case_info('');
         }
         $brand = FormLib::get('manufacturer');
         if (isset($brand[0])) {
             $extra->manufacturer(str_replace("'", '', $brand[0]));
         }
         $dist = FormLib::get('distributor');
         if (isset($dist[0])) {
             $extra->distributor(str_replace("'", '', $dist[0]));
         }
         $cost = FormLib::get('cost');
         if (isset($cost[0])) {
             $extra->cost($cost[0]);
         }
         $extra->save();
     }
     if (!isset($FANNIE_PRODUCT_MODULES['ProdUserModule'])) {
         if ($dbc->table_exists('productUser')) {
             $ldesc = FormLib::get_form_value('puser_description');
             $model = new ProductUserModel($dbc);
             $model->upc($upc);
             $model->description($ldesc);
             $model->save();
         }
     }
 }
Exemple #25
0
 function post_u_view()
 {
     $ret = '';
     $ret .= '<form action="' . filter_input(INPUT_SERVER, 'PHP_SELF') . '" method="post" id="signform">';
     $mods = FannieAPI::listModules('FannieSignage');
     $others = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\item\\FannieSignage');
     foreach ($others as $o) {
         if (!in_array($o, $mods)) {
             $mods[] = $o;
         }
     }
     sort($mods);
     $ret .= '<div class="form-group form-inline">';
     $ret .= '<label>Layout</label>: 
         <select name="signmod" class="form-control" onchange="$(\'#signform\').submit()">';
     foreach ($mods as $m) {
         $name = $m;
         if (strstr($m, '\\')) {
             $pts = explode('\\', $m);
             $name = $pts[count($pts) - 1];
         }
         $ret .= sprintf('<option %s value="%s">%s</option>', $m == $this->signage_mod ? 'selected' : '', $m, $name);
     }
     $ret .= '</select>';
     if (isset($this->upcs)) {
         foreach ($this->upcs as $u) {
             $ret .= sprintf('<input type="hidden" name="u[]" value="%s" />', $u);
         }
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         $item_mode = FormLib::get('item_mode', 0);
         $modes = array('Current Retail', 'Upcoming Retail', 'Current Sale', 'Upcoming Sale');
         $ret .= '<select name="item_mode" class="form-control"
             onchange="$(\'#signform\').submit()">';
         foreach ($modes as $id => $label) {
             $ret .= sprintf('<option %s value="%d">%s</option>', $id == $item_mode ? 'selected' : '', $id, $label);
         }
         $ret .= '</select>';
     } else {
         if (isset($this->batch)) {
             foreach ($this->batch as $b) {
                 $ret .= sprintf('<input type="hidden" name="batch[]" value="%d" />', $b);
             }
         }
     }
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<button type="submit" name="pdf" value="Print" 
                 class="btn btn-default">Print</button>';
     $ret .= '</div>';
     $ret .= '<hr />';
     $ret .= $this->signage_obj->listItems();
     $ret .= '<p><button type="submit" name="update" id="updateBtn" value="Save Text"
                 class="btn btn-default">Save Text</button></p>';
     $this->add_onload_command('$(".FannieSignageField").keydown(function(event) {
         if (event.which == 13) {
             event.preventDefault();
             $("#updateBtn").click();
         }
     });');
     $ret .= '</form>';
     $this->addScript('../../src/javascript/tablesorter/jquery.tablesorter.js');
     $this->addOnloadCommand("\$('.tablesorter').tablesorter();");
     return $ret;
 }