예제 #1
0
function allLanes($upc)
{
    if (!class_exists("SQLManager")) {
        require_once "../../src/SQLManager.php";
    }
    include '../lanedefs.php';
    $queryItem = '';
    $args = array();
    if (is_numeric($upc)) {
        $upc = str_pad($upc, 13, 0, STR_PAD_LEFT);
        $queryItem = "SELECT * FROM products WHERE upc = ?";
        $args = array($upc);
    } else {
        $queryItem = "SELECT * FROM products WHERE description LIKE ? ORDER BY description";
        $args = array('%' . $upc . '%');
    }
    for ($i = 0; $i < count($lanes); $i++) {
        $currentLane = $lanes[$i];
        if (substr($currentLane, 0, 3) == "POS") {
            $currentLane = "129.103.2.1" . substr($currentLane, -1);
        }
        $sql = new SQLManager($currentLane, $types[$i], $dbs[$i], $users[$i], $pws[$i]);
        //continue;
        $prep = $sql->prepare($queryItem);
        $resultItem = $sql->execute($prep, $args);
        $num = $sql->num_rows($resultItem);
        if ($num == 0) {
            echo "Item <font color='red'>{$upc}</font> not found on Lane " . ($i + 1) . "<br />";
        } else {
            if ($num > 1) {
                echo "Item <font color='red'>{$upc}</font> found multiple times on Lane " . ($i + 1) . "<br />";
                while ($rowItem = $sql->fetch_array($resultItem)) {
                    echo "{$rowItem['upc']} {$rowItem['description']}<br />";
                }
            } else {
                $rowItem = $sql->fetch_array($resultItem);
                echo "Item <font color='red'>{$upc}</font> on Lane " . ($i + 1) . "<br />";
                echo "Price: {$rowItem['normal_price']}";
                if ($rowItem['special_price'] != 0) {
                    echo "&nbsp;&nbsp;&nbsp;&nbsp;<font color=green>ON SALE: {$rowItem['special_price']}</font>";
                }
                echo "<br />";
            }
        }
        if ($i < count($lanes) - 1) {
            echo "<hr />";
        }
    }
}
예제 #2
0
function allLanes($upc)
{
    global $FANNIE_LANES, $FANNIE_ROOT;
    if (!class_exists("SQLManager")) {
        require_once $FANNIE_ROOT . "src/SQLManager.php";
    }
    $ret = "";
    $queryItem = '';
    if (is_numeric($upc)) {
        $upc = str_pad($upc, 13, 0, STR_PAD_LEFT);
        $queryItem = "SELECT * FROM products WHERE upc = '{$upc}'";
    } else {
        $queryItem = "SELECT * FROM products WHERE description LIKE '%{$upc}%' ORDER BY description";
    }
    for ($i = 0; $i < count($FANNIE_LANES); $i++) {
        $f = $FANNIE_LANES[$i];
        $sql = new SQLManager($f['host'], $f['type'], $f['op'], $f['user'], $f['pw']);
        if ($sql === False) {
            $ret .= "Can't connect to lane: " . ($i + 1) . "<br />";
            continue;
        }
        $resultItem = $sql->query($queryItem);
        $num = $sql->num_rows($resultItem);
        if ($num == 0) {
            $ret .= "Item <span style=\"color:red;\">{$upc}</span> not found on Lane " . ($i + 1) . "<br />";
        } else {
            if ($num > 1) {
                $ret .= "Item <span style=\"color:red;\">{$upc}</span> found multiple times on Lane " . ($i + 1) . "<br />";
                while ($rowItem = $sql->fetch_array($resultItem)) {
                    $ret .= "{$rowItem['upc']} {$rowItem['description']}<br />";
                }
            } else {
                $rowItem = $sql->fetch_array($resultItem);
                $ret .= "Item <span style=\"color:red;\">{$upc}</span> on Lane " . ($i + 1) . "<br />";
                $ret .= "Price: {$rowItem['normal_price']}";
                if ($rowItem['special_price'] != 0) {
                    $ret .= "&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:green;\">ON SALE: {$rowItem['special_price']}</span>";
                }
                $ret .= "<br />";
            }
        }
        if ($i < count($FANNIE_LANES) - 1) {
            $ret .= "<hr />";
        }
    }
    return $ret;
}
예제 #3
0
파일: import.php 프로젝트: phpsmith/IS4C
$dbc = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$p1 = $dbc->prepare_statement("SELECT upc FROM productUser where upc=?");
$p2 = $dbc->prepare_statement("SELECT upc FROM products WHERE upc=?");
$upP = $dbc->prepare_statement("UPDATE productUser SET photo=? WHERE upc=?");
$dh = opendir('new');
while (($file = readdir($dh)) !== False) {
    $exts = explode(".", $file);
    $e = strtolower(array_pop($exts));
    if ($e != "png" && $e != "gif" && $e != "jpg" && $e != "jpeg") {
        continue;
    }
    $u = array_pop($exts);
    if (!is_numeric($u)) {
        continue;
    }
    $upc = str_pad($u, 13, '0', STR_PAD_LEFT);
    $r1 = $dbc->exec_statement($p1, array($upc));
    if ($dbc->num_rows($r1) > 0) {
        echo "UPC {$upc} found in productUser\n";
        $upR = $dbc->exec_statement($upP, array($file, $upc));
        rename('new/' . $file, 'done/' . $file);
        rename('new/' . $u . '.thumb.' . $e, 'done/' . $u . '.thumb.' . $e);
    } else {
        $r2 = $dbc->exec_statement($p2, array($upc));
        if ($dbc->num_rows($r2) > 0) {
            echo "UPC {$upc} found in products\n";
        } else {
            echo "UPC {$upc} not found\n";
        }
    }
}
예제 #4
0
 
   homeless.specialorder.php

   Check for SOs w/o a department
   and spam out email until someone fixes it

*/
include dirname(__FILE__) . '/../config.php';
if (!class_exists('FannieAPI')) {
    include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php';
}
if (!function_exists('cron_msg')) {
    include $FANNIE_ROOT . 'src/cron_msg.php';
}
set_time_limit(0);
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$OP = $FANNIE_OP_DB . ($FANNIE_SERVER_DBMS == "MSSQL" ? 'dbo.' : '.');
$q = "\nselect s.order_id,description,datetime,\ncase when c.lastName ='' then b.LastName else c.lastName END as name\nfrom PendingSpecialOrder\nas s left join SpecialOrders as c on s.order_id=c.specialOrderID\nleft join {$OP}custdata as b on s.card_no=b.CardNo and s.voided=b.personNum\nwhere s.order_id in (\nselect p.order_id from PendingSpecialOrder as p\nleft join SpecialOrders as n\non p.order_id=n.specialOrderID\nwhere notes LIKE ''\ngroup by p.order_id\nhaving max(department)=0 and max(noteSuperID)=0\nand max(trans_id) > 0\n)\nand trans_id > 0\norder by datetime\n";
$r = $sql->query($q);
if ($sql->num_rows($r) > 0) {
    $msg_body = "Homeless orders detected!\n\n";
    while ($w = $sql->fetch_row($r)) {
        $msg_body .= $w['datetime'] . ' - ' . (empty($w['name']) ? '(no name)' : $w['name']) . ' - ' . $w['description'] . "\n";
        $msg_body .= "http://key" . $FANNIE_URL . "ordering/view.php?orderID=" . $w['order_id'] . "\n\n";
    }
    $msg_body .= "These messages will be sent daily until orders get departments\n";
    $msg_body .= "or orders are closed\n";
    $to = "buyers, michael";
    $subject = "Incomplete SO(s)";
    mail($to, $subject, $msg_body);
}
예제 #5
0
파일: DTrans.php 프로젝트: phpsmith/IS4C
 /**
   Get an available dtransactions.trans_no value
   @param $connection [SQLManager] database connection
   @param $emp_no [int] employee number
   @param $register_no [int] register number
   @return [int] trans_no
 */
 public static function getTransNo(SQLManager $connection, $emp_no = false, $register_no = false)
 {
     $config = FannieConfig::factory();
     if ($emp_no === false) {
         $emp_no = $config->get('EMP_NO');
     }
     if ($register_no === false) {
         $register_no = $config->get('REGISTER_NO');
     }
     $prep = $connection->prepare('
         SELECT MAX(trans_no) AS trans
         FROM ' . $config->get('TRANS_DB') . $connection->sep() . 'dtransactions
         WHERE emp_no=?
             AND register_no=?');
     $result = $connection->execute($prep, array($emp_no, $register_no));
     if (!$result || $connection->num_rows($result) == 0) {
         return 1;
     } else {
         $row = $connection->fetch_row($result);
         if ($row['trans'] == '') {
             return 1;
         } else {
             return $row['trans'] + 1;
         }
     }
 }
예제 #6
0
$sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
$upc = null;
$prevDept = null;
$q = "select u.upc,u.modified,dept,user from prodUpdate\nas u inner join products as p on p.upc=u.upc\norder by u.upc,u.modified";
if ($FANNIE_SERVER_DBMS == "MSSQL") {
    $q = str_replace("user", "[user]", $q);
}
$r = $sql->query($q);
while ($w = $sql->fetch_row($r)) {
    if ($upc === null || $upc != $w['upc']) {
        // next item, get previous
        // date and price from compressed
        // history if available
        $upc = $w['upc'];
        $prevDept = null;
        $prevDate = null;
        $chkR = $sql->query("SELECT modified,dept_ID FROM\n            prodDepartmentHistory WHERE upc='{$upc}'\n            ORDER BY modified DESC");
        if ($sql->num_rows($chkR) > 0) {
            $chk = $sql->fetch_row($chkR);
            $prevDate = $chk['modified'];
            $prevDept = $chk['dept_ID'];
        }
    }
    if ($prevDept != $w['dept']) {
        // price changed
        $ins = sprintf("INSERT INTO prodDepartmentHistory\n            (upc,modified,dept_ID,uid)\n            VALUES (%s,%s,%d,%d)", $sql->escape($upc), $sql->escape($w['modified']), $w['dept'], $w['user']);
        $sql->query($ins);
    }
    $prevDept = $w['dept'];
    $prevDate = $w['modified'];
}
예제 #7
0
    $sql->query($delQ);
}
// end auto-close
$query = "SELECT CASE WHEN matched > 10 THEN matched ELSE mixMatch END as mixMatch,\n            CASE WHEN matched > 10 THEN mixMatch ELSE matched END AS matched,\n            MAX(datetime) as tdate,\n            MAX(emp_no) as emp,\n            MAX(register_no) AS reg,\n            MAX(trans_no) AS trans \n          FROM transarchive\n          WHERE charflag='SO' \n            AND emp_no <> 9999 \n            AND register_no <> 99 \n            AND trans_status NOT IN ('X','Z')\n          GROUP BY mixMatch,matched\n          HAVING sum(total) <> 0";
$result = $sql->query($query);
$checkP = $sql->prepare("SELECT order_id\n                         FROM SpecialOrderHistory\n                         WHERE order_id=?\n                            AND entry_type='PURCHASED'\n                            AND entry_date=?\n                            AND entry_value=?");
$historyP = $sql->prepare("INSERT INTO SpecialOrderHistory\n                            (order_id, entry_date, entry_type, entry_value)\n                           VALUES\n                            (?, ?, 'PURCHASED', ?)");
$order_ids = array();
$trans_ids = array();
while ($row = $sql->fetch_row($result)) {
    $order_ids[] = (int) $row['mixMatch'];
    $trans_ids[] = (int) $row['matched'];
    // log to history if entry doesn't already exist
    $args = array((int) $row['mixMatch'], $row['tdate'], $row['emp'] . '-' . $row['reg'] . '-' . $row['trans']);
    $checkR = $sql->execute($checkP, $args);
    if ($checkR && $sql->num_rows($checkR) == 0) {
        $sql->execute($historyP, $args);
    }
}
$where = "( ";
for ($i = 0; $i < count($order_ids); $i++) {
    $where .= "(order_id=" . $order_ids[$i] . " AND trans_id=" . $trans_ids[$i] . ") ";
    if ($i < count($order_ids) - 1) {
        $where .= " OR ";
    }
}
$where .= ")";
echo cron_msg("Found " . count($order_ids) . " order items");
// copy item rows to completed and delete from pending
$copyQ = "INSERT INTO CompleteSpecialOrder SELECT * FROM PendingSpecialOrder WHERE {$where}";
$copyR = $sql->query($copyQ);