Example #1
0
 public static function insert($DATA)
 {
     $DB = portal::database();
     extract($DATA['POST']);
     $INVENTORY = array();
     $CHARACTERISTIC = array();
     foreach ($inventory as $KEY => $VALUE) {
         switch ($KEY) {
             case 'SKU':
             case 'CATEGORY_ID':
             case 'CLASSIFICATION_ID':
             case 'WEIGHT':
                 $INVENTORY[$KEY] = $VALUE;
                 break;
             default:
                 $CHARACTERISTIC[$KEY] = $VALUE;
                 break;
         }
     }
     $DB->select("ID AS INVENTORY_ID", "inventory", "SKU = ?", array($INVENTORY['SKU']));
     if ($DB->fetch_assoc()) {
         $_SESSION[CLIENT]['ERROR_MSG'] = 'Duplicate SKU, please resubmit with a valid SKU.';
         return;
     }
     $DB->insert("inventory", array("SKU" => $INVENTORY['SKU'], "CATEGORY_ID" => $INVENTORY['CATEGORY_ID'], "CLASSIFICATION_ID" => $INVENTORY['CLASSIFICATION_ID'], "WEIGHT" => $INVENTORY['WEIGHT']));
     $DB->select("ID AS INVENTORY_ID", "inventory", "SKU = ?", array($INVENTORY['SKU']));
     extract($DB->fetch_assoc());
     $DB->insert("inventory_characteristic", array("INVENTORY_ID" => $INVENTORY_ID, "CHARACTERISTICS" => json_encode($CHARACTERISTIC)));
     $DB->insert("inventory_worked_by", array("INVENTORY_ID" => $INVENTORY_ID, "USER_ACCOUNT_ID" => $_SESSION[CLIENT]['ID']));
 }
Example #2
0
 public function __construct($TITLE, $CONTROL_PANEL, $MODE = NULL, $THEAD, $SELECTABLE = '')
 {
     $this->HEADER = '<div class="panel-heading">' . $TITLE . '</div>';
     $this->CONTROL_PANEL = '<ul class="nav nav-pills nav-justified">';
     foreach ($CONTROL_PANEL as $KEY => $VALUE) {
         $this->CONTROL_PANEL .= '<li><a' . (isset($VALUE['href']) ? ' href="' . $VALUE['href'] . '"' : '') . (isset($VALUE['id']) ? ' id="' . $VALUE['id'] . '"' : '') . ' class="CONTROL_PANEL list-group-item' . (isset($VALUE['class']) ? ' ' . $VALUE['class'] : '') . '">' . $KEY . '</a></li>';
     }
     $this->CONTROL_PANEL .= '</ul>';
     if (isset($MODE) && is_array($MODE)) {
         foreach ($MODE as $KEY => $VALUE) {
             $this->MODE[] = isset($VALUE) ? portal::warp($_GET['subnav'], $VALUE) : '';
         }
     } else {
         $this->MODE = isset($MODE) ? portal::warp($_GET['subnav'], $MODE) : '';
     }
     $this->TABLE = '<table class="' . $SELECTABLE . ' table table-hover">';
     $this->TABLE .= '<thead><tr>';
     foreach ($THEAD as $KEY => $VALUE) {
         $this->TABLE .= '<th><a href="?' . self::orderBy($VALUE) . '" class="list-group-item">' . $KEY . ' <span class="' . self::orderByIcon($VALUE) . '"></span></a></th>';
     }
     $this->TABLE .= '</tr></thead>';
     $this->TABLE .= portal::warp($_GET['subnav'], 'TBODY');
     $this->TABLE .= '</table>';
 }
Example #3
0
 public static function delete($DATA)
 {
     extract($DATA['GET']);
     $DB = portal::database();
     $IDS = json_decode($id);
     foreach ($IDS as $ID) {
         $DB->delete("user_type", "ID = ?", array($ID));
     }
 }
Example #4
0
<?php

include 'models/admin/admin.php';
?>
<div id="sidebar" class="visible-lg col-lg-2">
    <ul class="list-group" style="list-style-type:none;">
        <?php 
foreach ($LIST as $KEY => $VALUE) {
    echo '<li><a class="' . (isset($VALUE['subnav']) && $SUBNAV === $VALUE['subnav'] ? 'active ' : '') . 'list-group-item" href="?nav=admin&subnav=' . $VALUE['subnav'] . $VALUE['params'] . '">' . $KEY . '</a></li>';
}
?>
    </ul>
</div>
<div id="content" class="col-lg-10">
    <?php 
portal::getMsg();
if (isset($SUBNAV)) {
    portal::navigate($SUBNAV);
}
?>
</div>
Example #5
0
<?php

$URL = '?' . $_SERVER['QUERY_STRING'];
if (isset($_GET['id'])) {
    $TEMP = explode('&id', $URL);
    $URL = $TEMP[0];
}
$ACTION = array('create' => '&action=create', 'edit' => '&action=edit');
$TITLE = 'Classifications';
$CONTROL_PANEL = array('Select All' => array('id' => 'select_all'), 'Deselect All' => array('id' => 'deselect_all'), 'New Classification' => array('id' => 'create', 'href' => strpos($_SERVER['QUERY_STRING'], '&action=create') ? portal::scrubString($ACTION, '', $URL) : portal::scrubString($ACTION, '', $URL) . $ACTION['create']), 'Edit Classification' => array('id' => 'edit', 'href' => strpos($_SERVER['QUERY_STRING'], '&action=edit') ? portal::scrubString($ACTION, '', $URL) : portal::scrubString($ACTION, '', $URL) . $ACTION['edit']), 'Delete Classifications' => array('id' => 'delete'));
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'create':
            unset($CONTROL_PANEL['New Classification']);
            break;
        case 'edit':
            unset($CONTROL_PANEL['Edit Classification']);
            break;
    }
}
$THEAD = array('ID' => 'ID', 'Classification' => 'TYPE_NAME', 'Last Modified' => 'LAST_MODIFIED');
$TABLE = new table($TITLE, $CONTROL_PANEL, isset($_GET['action']) ? $_GET['action'] : NULL, $THEAD, 'selectable');
Example #6
0
<?php

/* =======================================================================
 * (C) 2015 Stephen Palmer
 * All Rights Reserved
 * File: warp.php
 * Description: Navigateable script that takes advantage of portal's warp
 *              function. This is primarily used for signing into the site. 
 *              Accepts get parameters for the page/class and the 
 *              action/function. Warp picks up the slack from there.
 * Author: Stephen Palmer <*****@*****.**>
 * PHP Version: 5.4
 * ======================================================================= */
session_start();
require_once '../classes/portal.php';
portal::warp($_GET['nav'], $_GET['action']);
Example #7
0
 public static function delete($DATA)
 {
     extract($DATA['GET']);
     $DB = portal::database();
     $IDS = json_decode($id);
     foreach ($IDS as $ID) {
         $DB->delete("inventory", "ID = ?", array($ID));
         $DB->delete("inventory_worked_by", "INVENTORY_ID = ?", array($ID));
         $DB->delete("inventory_characteristic", "INVENTORY_ID = ?", array($ID));
         $DB->delete("inventory_status", "INVENTORY_ID = ?", array($ID));
         $DB->delete("inventory_title", "INVENTORY_ID = ?", array($ID));
     }
 }
Example #8
0
    portal::getMsg();
    if (isset($_GET['nav'])) {
        portal::navigate($_GET['nav']);
    }
    ?>
            </div>
            <?php 
} else {
    ?>
            <div class="container">
                <form method="post" action="processes/warp.php?nav=portal&action=signIn" style="padding-top:30vh;" autocomplete="off">
                    <div class="col-lg-4 col-lg-offset-4">
                        <img style="width:100%;padding-bottom:15px;" src="images/logo.jpg">

                        <input type="text" name="USER_NAME" class="form-control" autocomplete="off">

                        <input type="password" name="USER_PASSWORD" class="form-control" autocomplete="off">

                        <button type="submit" class="btn btn-default form-control">Sign In</button>
                        <?php 
    portal::getMsg();
    ?>
                    </div>
                </form>
            </div>
            <?php 
}
?>
        </div>
    </body>
</html>
Example #9
0
<?php

session_start();
require_once '../classes/portal.php';
if (portal::isSignedIn() && isset($_GET['page']) && isset($_GET['action'])) {
    $ORIGIN = $_SERVER['HTTP_REFERER'];
    $ORIGIN = explode('?', $ORIGIN);
    $ORIGIN = '?' . $ORIGIN[1];
    $ORIGIN = explode('&action', $ORIGIN);
    $ORIGIN = $ORIGIN[0];
    if (!isset($_POST['cancel'])) {
        portal::warp($_GET['page'], $_GET['action']);
    }
    portal::redirect('../' . $ORIGIN);
} else {
    portal::redirect();
}
Example #10
0
<?php

$URL = '?' . $_SERVER['QUERY_STRING'];
if (isset($_GET['id'])) {
    $URL = explode('&id', $URL);
    $URL = $URL[0];
}
$ACTION = array('create' => '&action=create', 'view' => '&action=view');
$TITLE = 'Inventory Mapping';
$CONTROL_PANEL = array('Select All' => array('id' => 'select_all'), 'Deselect All' => array('id' => 'deselect_all'), 'New Mapping' => array('id' => 'create', 'href' => strpos($_SERVER['QUERY_STRING'], '&action=create') ? portal::scrubString($ACTION, '', $URL) : portal::scrubString($ACTION, '', $URL) . $ACTION['create']), 'View Mapping' => array('id' => 'view', 'href' => strpos($_SERVER['QUERY_STRING'], '&action=view') ? portal::scrubString($ACTION, '', $URL) : portal::scrubString($ACTION, '', $URL) . $ACTION['view']), 'Delete Mapping' => array('id' => 'delete'));
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'create':
            unset($CONTROL_PANEL['New Mapping']);
            break;
        case 'view':
            unset($CONTROL_PANEL['View Mapping']);
            break;
    }
}
$THEAD = array('ID' => 'ID', 'Category' => 'CATEGORY', 'Classification' => 'CLASSIFICATION', 'Last Modified' => 'LAST_MODIFIED');
$TABLE = new table($TITLE, $CONTROL_PANEL, isset($_GET['action']) ? $_GET['action'] : NULL, $THEAD, 'selectable');
Example #11
0
 public static function delete($DATA)
 {
     extract($DATA['GET']);
     $DB = portal::database();
     $IDS = json_decode($id);
     foreach ($IDS as $ID) {
         $DB->delete("classification", "ID = ?", array($ID));
         $DB->select("ID", "category_has_classification", "CLASSIFICATION_ID = ?", array($ID));
         $CHC_IDS = $DB->fetch_assoc_all();
         $DB->delete("category_has_classification", "CLASSIFICATION_ID = ?", array($ID));
         foreach ($CHC_IDS as $KEY => $VALUE) {
             $DB->delete("classification_has_characteristic", "CATEGORY_HAS_CLASSIFICATION_ID = ?", array($VALUE['ID']));
         }
     }
 }
Example #12
0
 public static function selectCharacteristic($ECHO = TRUE)
 {
     $DEFAULT_CHARACTERISTICS = portal::warp('characteristic', 'getCharacteristic');
     $SELECT = ' <div class="col-lg-6 col-lg-offset-3">
                         <div class="input-group">
                             <span class="input-group-addon">
                                 Characteristic
                             </span>
                             <select class="form-control" name="mapping[CHARACTERISTIC_ID][]">
                                 <option></option>';
     foreach ($DEFAULT_CHARACTERISTICS as $CHARACTERISTIC) {
         extract($CHARACTERISTIC);
         $SELECT .= '        <option value="' . $ID . '">' . $CHARACTERISTIC . '</option>';
     }
     $SELECT .= '        </select>
                             <span class="input-group-btn">
                                 <button type="button" class="removeCharacteristic btn btn-default">
                                     <span class="glyphicon glyphicon-remove"></span>
                                 </button>
                             </span>
                         </div>
                     </div>';
     if (!$ECHO) {
         return $SELECT;
     }
     echo $SELECT;
 }
Example #13
0
 public static function delete($DATA)
 {
     extract($DATA['GET']);
     $DB = portal::database();
     $IDS = json_decode($id);
     foreach ($IDS as $ID) {
         $DB->delete("characteristic", "ID = ?", array($ID));
         $DB->delete("classification_has_characteristic", "CHARACTERISTIC_ID = ?", array($ID));
     }
 }
Example #14
0
 public static function getUserGroup($DATA)
 {
     extract($DATA);
     $DB = portal::database();
     if (!isset($DATA['TYPE'])) {
         return;
     }
     switch ($DATA['TYPE']) {
         case 'ALL':
             $DB->query("SELECT user_account.ID, \r\n                                USER_NAME \r\n                                FROM user_account \r\n                                JOIN user_type ON USER_TYPE_ID = user_type.ID\r\n                                JOIN user_name ON USER_NAME_ID = user_name.ID");
             break;
         default:
             $DB->query("SELECT user_account.ID, \r\n                                USER_NAME \r\n                                FROM user_account \r\n                                JOIN user_type ON USER_TYPE_ID = user_type.ID\r\n                                JOIN user_name ON USER_NAME_ID = user_name.ID\r\n                                WHERE USER_TYPE = 'ADMIN' OR USER_TYPE = ?", array($TYPE));
             break;
     }
     return $DB->fetch_assoc_all();
 }
Example #15
0
 public static function userEmailExists($DATA)
 {
     extract($DATA);
     $DB = portal::database();
     if (isset($ID)) {
         $DB->select("USER_EMAIL", "user_email", "ID = ?", array($ID));
         if ($DB->fetch_assoc()) {
             return true;
         }
     } elseif (isset($USER_EMAIL)) {
         $DB->select("USER_EMAIL", "user_email", "USER_EMAIL = ?", array($USER_EMAIL));
         if ($DB->fetch_assoc()) {
             return true;
         }
     }
     return false;
 }
Example #16
0
$CATEGORY_OPTIONS = array();
foreach ($CATEGORIES as $KEY => $VALUE) {
    extract($VALUE);
    $CATEGORY_OPTIONS[] = '<option value="' . $ID . '"' . (isset($_GET['category']) && $ID === $_GET['category'] ? ' selected' : '') . '>' . $CATEGORY . '</option>';
}
$CATEGORY_OPTIONS = implode(',', $CATEGORY_OPTIONS);
if (isset($_GET['category'])) {
    $CLASSIFICATIONS = portal::warp('category', 'getCategoryClassification', array('ID' => $_GET['category']));
    $CLASSIFICATION_OPTIONS = array();
    foreach ($CLASSIFICATIONS as $KEY => $VALUE) {
        extract($VALUE);
        $CLASSIFICATION_OPTIONS[] = '<option value="' . $ID . '"' . (isset($_GET['classification']) && $ID === $_GET['classification'] ? ' selected' : '') . '>' . $CLASSIFICATION . '</option>';
    }
    $CLASSIFICATION_OPTIONS = implode('', $CLASSIFICATION_OPTIONS);
}
$CONDITION_OPTIONS = array('New', 'Pre-Owned', 'Damaged');
foreach ($CONDITION_OPTIONS as $OPTION) {
    $CONDITION_OPTIONS[] = '<option value="' . $OPTION . '">' . $OPTION . '</option>';
}
$CONDITION_OPTIONS = implode('', $CONDITION_OPTIONS);
if (isset($_GET['category']) && isset($_GET['classification'])) {
    $CHARACTERISTICS = portal::warp('classification', 'getClassificationCharacteristic', array('CATEGORY_ID' => $_GET['category'], 'CLASSIFICATION_ID' => $_GET['classification']));
    $CHARACTERISTIC_FIELDS = array();
    foreach ($CHARACTERISTICS as $KEY => $VALUE) {
        extract($VALUE);
        $CHARACTERISTIC_FIELDS[] = '<div class="col-lg-4">
                                          ' . $CHARACTERISTIC . '<input type="text" class="form-control" name="inventory[' . $CHARACTERISTIC . ']">
                                      </div>';
    }
    $CHARACTERISTIC_FIELDS = implode('', $CHARACTERISTIC_FIELDS);
}