示例#1
1
 function preprocess()
 {
     if (FormLib::get_form_value('start', False) !== False) {
         $pdf = new FPDF('P', 'in', 'Letter');
         $pdf->SetMargins(0.5, 0.5, 0.5);
         $pdf->SetAutoPageBreak(False, 0.5);
         $pdf->AddPage();
         $start = FormLib::get_form_value('start');
         $x = 0.5;
         $y = 0.5;
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
         $pdf->SetFont('Gill', '', 16);
         for ($i = 0; $i < 40; $i++) {
             $current = $start + $i;
             $pdf->SetXY($x, $y);
             $pdf->Cell(1.75, 0.5, $current, 0, 0, 'C');
             $pdf->Cell(1.75, 0.5, $current, 0, 0, 'C');
             if ($i % 2 == 0) {
                 $x += 1.75 * 2 + 0.5;
             } else {
                 $x = 0.5;
                 $y += 0.5;
             }
         }
         $pdf->Close();
         $pdf->Output("mem stickers {$start}.pdf", "I");
         return False;
     }
     return True;
 }
示例#2
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $FANNIE_EMP_NO = $this->config->get('EMP_NO');
     $FANNIE_REGISTER_NO = $this->config->get('REGISTER_NO');
     $FANNIE_CORRECTION_DEPT = $this->config->get('PATRONAGE_DEPT');
     /**
       Use fannie settings if properly configured
     */
     if (is_numeric($FANNIE_EMP_NO)) {
         $this->CORRECTION_CASHIER = $FANNIE_EMP_NO;
     }
     if (is_numeric($FANNIE_REGISTER_NO)) {
         $this->CORRECTION_LANE = $FANNIE_REGISTER_NO;
     }
     if (is_numeric($FANNIE_CORRECTION_DEPT)) {
         $this->CORRECTION_DEPT = $FANNIE_CORRECTION_DEPT;
     }
     if (FormLib::get_form_value('submit1', False) !== false) {
         $this->mode = 'confirm';
     } elseif (FormLib::get_form_value('submit2', False) !== False) {
         $this->mode = 'finish';
     }
     // error check inputs
     if ($this->mode != 'init') {
         $this->date = FormLib::get_form_value('date');
         $this->tn = FormLib::get_form_value('trans_num');
         $this->cn2 = FormLib::get_form_value('memTo');
         if (!is_numeric($this->cn2)) {
             $this->errors .= "<div class=\"alert alert-danger\">Error: member given (" . $this->cn2 . ") isn't a number</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         $account = \COREPOS\Fannie\API\member\MemberREST::get($this->cn2);
         if ($account == false) {
             $this->errors .= "<div class=\"alert alert-success\">Error: no such member: " . $this->cn2 . "</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $this->name2 = $c['firstName'] . ' ' . $c['lastName'];
                 break;
             }
         }
         $dlog = DTransactionsModel::selectDlog($this->date);
         $q = $dbc->prepare_statement("SELECT card_no FROM {$dlog} WHERE trans_num=? AND\n                tdate BETWEEN ? AND ?\n                ORDER BY card_no DESC");
         $r = $dbc->exec_statement($q, array($this->tn, $this->date . ' 00:00:00', $this->date . ' 23:59:59'));
         if ($dbc->num_rows($r) == 0) {
             $this->errors .= "<div class=\"alert alert-error\">Error: receipt not found: " . $this->tn . "</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         $w = $dbc->fetchRow($r);
         $this->cn1 = is_array($w) ? $w[0] : 0;
         $q = $dbc->prepare_statement("SELECT SUM(CASE WHEN trans_type in ('I','M','D') then total else 0 END)\n                FROM {$dlog} WHERE trans_num=? AND tdate BETWEEN ? AND ?");
         $r = $dbc->exec_statement($q, array($this->tn, $this->date . ' 00:00:00', $this->date . ' 23:59:59'));
         $w = $dbc->fetchRow($r);
         $this->amt = is_array($w) ? $w[0] : 0;
     }
     return True;
 }
示例#3
0
文件: Notes.php 项目: phpsmith/IS4C
 function saveFormData($memNum)
 {
     /* entry blank. do not save */
     $note = FormLib::get_form_value('Notes_text');
     if ($note == "") {
         return "";
     }
     /* entry has note changed. this means it's already
        in memberNotes as the most recent entry */
     $current = FormLib::get_form_value('Notes_current');
     if ($note == base64_decode($current)) {
         return "";
     }
     $dbc = $this->db();
     $insertNote = $dbc->prepare_statement("INSERT into memberNotes\n                (cardno, note, stamp, username)\n                VALUES (?, ?, " . $dbc->now() . ", 'Admin')");
     // convert newlines back to br tags
     // so displayed notes have user's
     // paragraph formatting
     $note = str_replace("\n", '<br />', $note);
     $test1 = $dbc->exec_statement($insertNote, array($memNum, $note));
     if ($test1 === False) {
         return "Error: problem saving Notes<br />";
     } else {
         return "";
     }
 }
示例#4
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     if (FormLib::get_form_value('deptStart', False) !== false) {
         $start = FormLib::get_form_value('deptStart');
         $end = FormLib::get_form_value('deptEnd');
         $pageID = FormLib::get_form_value('sID', 0);
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $prodP = $dbc->prepare_statement("\n                SELECT p.upc\n                FROM products AS p\n                WHERE p.department BETWEEN ? AND ?\n            ");
         $prodR = $dbc->exec_statement($prodP, array($start, $end));
         $tag = new ShelftagsModel($dbc);
         $product = new ProductsModel($dbc);
         while ($row = $dbc->fetch_row($prodR)) {
             $product->upc($row['upc']);
             $info = $product->getTagData();
             $tag->id($pageID);
             $tag->upc($row['upc']);
             $tag->setData($info);
             $tag->save();
         }
         $this->msgs = sprintf('<em>Created tags for departments #%d through #%d</em>
                 <br /><a href="ShelfTagIndex.php">Home</a>', $start, $end);
     }
     return true;
 }
示例#5
0
 function fetch_report_data()
 {
     $date1 = $this->form->date1;
     $date2 = $this->form->date2;
     $exclude = FormLib::get_form_value('excludes', '');
     $ex = preg_split('/\\D+/', $exclude, 0, PREG_SPLIT_NO_EMPTY);
     $exCondition = '';
     $exArgs = array();
     foreach ($ex as $num) {
         $exCondition .= '?,';
         $exArgs[] = $num;
     }
     $exCondition = substr($exCondition, 0, strlen($exCondition) - 1);
     $ret = array();
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $query = "\n            SELECT \n                CASE WHEN m.zip='' THEN 'none' ELSE m.zip END as zipcode,\n                COUNT(*) as num \n            FROM meminfo AS m \n                INNER JOIN memDates AS d ON m.card_no=d.card_no \n            WHERE ";
     if (!empty($exArgs)) {
         $query .= "m.card_no NOT IN ({$exCondition}) AND ";
     }
     $query .= "d.start_date >= ?\n            GROUP BY zipcode\n            ORDER BY COUNT(*) DESC";
     $exArgs[] = $date1 . ' 00:00:00';
     $prep = $dbc->prepare_statement($query);
     $result = $dbc->exec_statement($prep, $exArgs);
     while ($row = $dbc->fetch_row($result)) {
         $record = array($row['zipcode'], $row['num']);
         $ret[] = $record;
     }
     return $ret;
 }
示例#6
0
 function saveFormData($memNum)
 {
     $dbc = $this->db();
     /**
       Use primary member for default column values
     */
     $account = self::getAccount();
     if (!$account) {
         return "Error: Problem saving household members<br />";
     }
     $json = array('cardNo' => $memNum, 'customerTypeID' => $account['customerTypeID'], 'memberStatus' => $account['memberStatus'], 'activeStatus' => $account['activeStatus'], 'customers' => array());
     $primary = array('discount' => 0, 'staff' => 0, 'lowIncomeBenefits' => 0, 'chargeAllowed' => 0, 'checksAllowed' => 0);
     foreach ($account['customers'] as $c) {
         if ($c['accountHolder']) {
             $primary = $c;
             break;
         }
     }
     $fns = FormLib::get_form_value('HouseholdMembers_fn', array());
     $lns = FormLib::get_form_value('HouseholdMembers_ln', array());
     $ids = FormLib::get('HouseholdMembers_ID', array());
     for ($i = 0; $i < count($lns); $i++) {
         $json['customers'][] = array('customerID' => $ids[$i], 'firstName' => $fns[$i], 'lastName' => $lns[$i], 'accountHolder' => 0, 'discount' => $primary['discount'], 'staff' => $primary['staff'], 'lowIncomeBenefits' => $primary['lowIncomeBenefits'], 'chargeAllowed' => $primary['chargeAllowed'], 'checksAllowed' => $primary['checksAllowed']);
     }
     $resp = \COREPOS\Fannie\API\member\MemberREST::post($memNum, $json);
     if ($resp['errors'] > 0) {
         return "Error: Problem saving household members<br />";
     }
     return '';
 }
示例#7
0
 function saveFormData($memNum)
 {
     $dbc = $this->db();
     $formPref = FormLib::get_form_value('MemContactPref', -1);
     // Does a preference for this member exist?
     $infoQ = $dbc->prepare_statement("SELECT pref\n                FROM memContact\n                WHERE card_no=?");
     $infoR = $dbc->exec_statement($infoQ, array($memNum));
     // If no preference exists, add one if one was chosen.
     if ($dbc->num_rows($infoR) == 0) {
         if ($formPref > -1) {
             $upQ = $dbc->prepare_statement("INSERT INTO memContact (card_no, pref)\n                    VALUES (?, ?)");
             $upR = $dbc->exec_statement($upQ, array($memNum, $formPref));
             if ($upR === False) {
                 return "Error: problem adding Contact Preference.";
             } else {
                 return "";
             }
         }
     } else {
         $row = $dbc->fetch_row($infoR);
         $dbPref = $row['pref'];
         if ($formPref != $dbPref) {
             $upQ = $dbc->prepare_statement("UPDATE memContact SET pref = ?\n                    WHERE card_no = ?");
             $upR = $dbc->exec_statement($upQ, array($formPref, $memNum));
             if ($upR === False) {
                 return "Error: problem updating Contact Preference.";
             } else {
                 return "";
             }
         }
     }
     return "";
     // saveFormData
 }
示例#8
0
 function preprocess()
 {
     global $FANNIE_OP_DB, $FANNIE_PLUGIN_SETTINGS;
     $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);
     $this->emp_no = FormLib::get_form_value('emp_no', 0);
     $this->periodID = FormLib::get_form_value('periodID', 0);
     if (!headers_sent() && ($this->emp_no == 0 || $this->periodID == 0 || $this->emp_no < 0)) {
         header('Location: TsAdminMain.php');
         return False;
     }
     if ($_GET['function'] == 'edit' && isset($_GET['submitted']) && isset($_GET['emp_no']) && isset($_GET['periodID']) && isset($_GET['id'])) {
         $oneP = $ts_db->prepare_statement("UPDATE timesheet\n                SET time_in=?, time_out=?, area=?\n                WHERE ID=?");
         $twoP = $ts_db->prepare_statement("UPDATE timesheet\n                SET time_in=?\n                WHERE ID=?");
         foreach ($_GET['id'] as $key => $id) {
             $area = (int) $_GET['area'][$id];
             $date = $_GET['date'][$id];
             $timein = $this->parseTime($_GET['time_in'][$id], $_GET['inmeridian'][$id]);
             $timeout = $this->parseTime($_GET['time_out'][$id], $_GET['outmeridian'][$id]);
             $result = False;
             if ($area != 0) {
                 $args = array($date . ' ' . $timein, $date . ' ' . $timeout, $area, $id);
                 $result = $ts_db->exec_statement($oneP, $args);
             } else {
                 $args = array('2008-01-01 ' . $timein, $id);
                 $result = $ts_db->exec_statement($twoP, $args);
             }
             if (!$result) {
                 $this->errors[] = "<p>Query: {$query}</p>";
                 $this->errors[] = "<p>MySQL Error: " . $ts_db->error() . "</p>";
             }
         }
     }
     return True;
 }
示例#9
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $this->title = _("Fannie") . ' : ' . _("Manufacturer Shelf Tags");
     $this->header = _("Manufacturer Shelf Tags");
     if (FormLib::get_form_value('manufacturer', False) !== false) {
         $manu = FormLib::get_form_value('manufacturer');
         $pageID = FormLib::get_form_value('sID', 0);
         $cond = "";
         if (is_numeric($_REQUEST['manufacturer'])) {
             $cond = " p.upc LIKE ? ";
         } else {
             $cond = " p.brand LIKE ? ";
         }
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $prodP = $dbc->prepare_statement("\n                SELECT\n                    p.upc\n                FROM\n                    products AS p\n                WHERE {$cond}\n            ");
         $prodR = $dbc->exec_statement($prodP, array('%' . $manu . '%'));
         $tag = new ShelftagsModel($dbc);
         $product = new ProductsModel($dbc);
         while ($prodW = $dbc->fetch_row($prodR)) {
             $product->upc($prodW['upc']);
             $info = $product->getTagData();
             $tag->id($pageID);
             $tag->upc($prodW['upc']);
             $tag->setData($info);
             $tag->save();
         }
         $this->msgs = '<em>Created tags for manufacturer</em>
                 <br /><a href="ShelfTagIndex.php">Home</a>';
     }
     return true;
 }
示例#10
0
 function post_id_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $upc = BarcodeLib::padUPC($this->id);
     $model = new ProductsModel($dbc);
     $model->upc($upc);
     $model->store_id(1);
     $model->discounttype(0);
     $model->special_price(0);
     $model->modified(date('Y-m-d H:i:s'));
     $model->save();
     $batchID = FormLib::get_form_value('batchID');
     $batchUPC = FormLib::get_form_value('batchUPC');
     if ($batchID !== '' && $batchUPC !== '') {
         if (substr($batchUPC, 0, 2) != 'LC') {
             $batchUPC = BarcodeLib::padUPC($batchUPC);
         }
         $batchP = $dbc->prepare_statement('DELETE FROM batchList
                 WHERE upc=? AND batchID=?');
         $batchR = $dbc->exec_statement($batchP, array($batchUPC, $batchID));
     }
     require 'laneUpdates.php';
     updateProductAllLanes($upc);
     header('Location: ItemEditorPage.php?searchupc=' . $upc);
     return False;
 }
示例#11
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $id = FormLib::get_form_value('id', 0);
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $tags = new ShelftagsModel($dbc);
     $tags->id($id);
     $current_set = $tags->find();
     if (count($current_set) == 0) {
         $this->messages = '<div class="alert alert-info">
             Barcode table is already empty. <a href="ShelfTagIndex.php">Click here to continue</a>
             </div>';
         return true;
     }
     if (FormLib::get('submit', false) === '1') {
         /**
           Shelftags are not actually delete immediately
           Instead, the id field is negated so they disappear
           from view but can be manually retreived by IT if 
           someone comes complaining that they accidentally
           delete their tags (not that such a thing would
           ever occur). They're properly deleted by the 
           nightly.clipboard cron job.
         
           If the same user deletes the same UPC from tags
           multiple times in a day, the above procedure creates
           a primary key conflict. So any negative-id records
           that will create conflicts must be removed first.
         */
         $new_id = -1 * $id;
         if ($id == 0) {
             $new_id = -999;
         }
         $clear = new ShelftagsModel($dbc);
         $clear->id($new_id);
         foreach ($current_set as $tag) {
             // delete existing negative id tag for upc
             $clear->upc($tag->upc());
             $clear->delete();
             // save tag as negative id
             $old_id = $tag->id();
             $tag->id($new_id);
             $tag->save();
             $tag->id($old_id);
             $tag->delete();
         }
         $this->messages = '<div class="alert alert-success">
             Barcode table cleared <a href="ShelfTagIndex.php">Click here to continue</a>
             </div>';
         return true;
     } else {
         $this->messages = '<div class="alert alert-danger">
             <a href="DeleteShelfTags.php?id=' . $id . '&submit=1">Click 
             here to clear barcodes</a></div>';
         return true;
     }
     return true;
 }
示例#12
0
 public function preprocess()
 {
     /* allow ajax calls */
     if (FormLib::get_form_value('action') !== '') {
         $this->ajax_response(FormLib::get_form_value('action'));
         return false;
     }
     return true;
 }
示例#13
0
 public function preprocess()
 {
     $this->report_headers = array(_('Member'), '$Total Purchased', '$Average per Receipt', '#Receipts');
     $this->title = "Fannie : Patronage over Date Range Report";
     $this->header = "Patronage over Date Range Report";
     if (is_numeric(FormLib::get_form_value('top_n', 0))) {
         $this->top_n = FormLib::get_form_value('top_n', 0);
     }
     return parent::preprocess();
 }
示例#14
0
 function preprocess()
 {
     $this->tpath = sys_get_temp_dir() . "/misc/";
     $this->mode = 'form';
     /* Is this a request-to-upload or an initial display of the form? */
     if (FormLib::get_form_value('MAX_FILE_SIZE') != '' && FormLib::get_form_value('doUpload') != '') {
         $this->mode = 'process';
     }
     return True;
 }
示例#15
0
 protected function get_id_handler()
 {
     $this->card_no = $this->id;
     $my = FormLib::get_form_value('my', date('Ym'));
     $start = date("Y-m-d", mktime(0, 0, 0, substr($my, 4), 1, substr($my, 0, 4)));
     $end = date("Y-m-t", mktime(0, 0, 0, substr($my, 4), 1, substr($my, 0, 4)));
     $table = DTransactionsModel::selectDlog($start, $end);
     $this->__models['start'] = $start;
     $this->__models['end'] = $end;
     return True;
 }
示例#16
0
 public function preprocess()
 {
     $dbc = $this->connection;
     $settings = $this->config->get('PLUGIN_SETTINGS');
     if (FormLib::get('action') === 'save') {
         $upc = FormLib::get('upc');
         $qty = FormLib::get('qty');
         $dbc->selectDB($settings['ShelfAuditDB']);
         $model = new SaListModel($dbc);
         $model->upc(BarcodeLib::padUPC($upc));
         $model->clear(0);
         $entries = $model->find('date', true);
         if (count($entries) > 0) {
             $entries[0]->tdate(date('Y-m-d H:i:s'));
             $entries[0]->quantity($qty);
             $entries[0]->save();
         } else {
             $model->tdate(date('Y-m-d H:i:s'));
             $model->quantity($qty);
             $model->save();
         }
         echo $qty;
         echo 'quantity updated';
         return false;
     }
     if (FormLib::get('clear') === '1') {
         $table = $settings['ShelfAuditDB'] . $dbc->sep() . 'SaList';
         $res = $dbc->query('
             UPDATE ' . $table . '
             SET clear=1
         ');
         return true;
     }
     $upc = FormLib::get_form_value('upc_in', '');
     if ($upc !== '') {
         $upc = BarcodeLib::padUPC($upc);
         $this->current_item_data['upc'] = $upc;
         $prep = $dbc->prepare('
             SELECT p.description,
                 p.brand,
                 p.size,
                 COALESCE(s.quantity, 0) AS qty
             FROM products AS p
                 LEFT JOIN ' . $settings['ShelfAuditDB'] . $dbc->sep() . 'SaList AS s ON p.upc=s.upc AND s.clear=0
             WHERE p.upc=?
         ');
         $row = $dbc->getRow($prep, array($upc));
         if ($row) {
             $this->current_item_data['desc'] = $row['brand'] . ' ' . $row['description'] . ' ' . $row['size'];
             $this->current_item_data['qty'] = $row['qty'];
         }
     }
     return true;
 }
示例#17
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $this->title = 'Fannie - Product Flag Maintenance';
     $this->header = 'Product Flag Maintenance';
     $this->msgs = array();
     $db = FannieDB::get($FANNIE_OP_DB);
     if (FormLib::get_form_value('addBtn') !== '') {
         $desc = FormLib::get_form_value('new');
         if (empty($desc)) {
             $this->msgs[] = 'Error: no new description given';
         } else {
             $bit = 1;
             $bit_number = 1;
             $chkP = $db->prepare_statement("SELECT bit_number FROM prodFlags WHERE bit_number=?");
             for ($i = 0; $i < 30; $i++) {
                 $chkR = $db->exec_statement($chkP, array($bit_number));
                 if ($db->num_rows($chkR) == 0) {
                     break;
                 }
                 $bit *= 2;
                 $bit_number++;
             }
             if ($bit > 1 << 30) {
                 $this->msgs[] = 'Error: can\'t add more flags';
             } else {
                 $insP = $db->prepare_statement("INSERT INTO prodFlags \n                                (bit_number, description) VALUES (?,?)");
                 $db->exec_statement($insP, array($bit_number, $desc));
             }
         }
     } elseif (FormLib::get_form_value('updateBtn') !== '') {
         $ids = FormLib::get_form_value('mask', array());
         $descs = FormLib::get_form_value('desc', array());
         $active = FormLib::get('active', array());
         $upP = $db->prepare_statement("\n                UPDATE prodFlags \n                SET description=?,\n                    active=?\n                WHERE bit_number=?");
         for ($i = 0; $i < count($ids); $i++) {
             if (isset($descs[$i]) && !empty($descs[$i])) {
                 $a = in_array($ids[$i], $active) ? 1 : 0;
                 $db->exec_statement($upP, array($descs[$i], $a, $ids[$i]));
             }
         }
     } elseif (FormLib::get_form_value('delBtn') !== '') {
         $ids = FormLib::get_form_value('del', array());
         $delP = $db->prepare_statement("DELETE FROM prodFlags WHERE bit_number=?");
         foreach ($ids as $id) {
             $db->exec_statement($delP, array($id));
         }
     }
     for ($i = 1; $i <= count($this->msgs); $i++) {
         $db->logger($this->msgs[$i - 1]);
     }
     return True;
 }
 public function fetch_report_data()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $date1 = $this->form->date1;
     $date2 = $this->form->date2;
     $manu = FormLib::get_form_value('manu', '');
     $type = FormLib::get_form_value('type', '');
     $groupby = FormLib::get_form_value('groupby', 'upc');
     $dlog = DTransactionsModel::selectDlog($date1, $date2);
     $type_condition = "p.brand LIKE ?";
     $args = array('%' . $manu . '%');
     if ($type == 'prefix') {
         $type_condition = 't.upc LIKE ?';
     }
     $query = "";
     $args[] = $date1 . ' 00:00:00';
     $args[] = $date2 . ' 23:59:59';
     switch ($groupby) {
         case 'upc':
             $query = "\n                SELECT t.upc,\n                    p.brand,\n                    p.description, " . DTrans::sumQuantity('t') . " AS qty,\n                    SUM(t.total) AS ttl,\n                    d.dept_no,\n                    d.dept_name,\n                    s.superID\n                FROM {$dlog} AS t " . DTrans::joinProducts('t', 'p', 'INNER') . DTrans::joinDepartments('t', 'd') . "\n                    LEFT JOIN MasterSuperDepts AS s ON d.dept_no = s.dept_ID\n                WHERE {$type_condition}\n                    AND t.tdate BETWEEN ? AND ?\n                GROUP BY t.upc,\n                    p.description,\n                    d.dept_no,\n                    d.dept_name,\n                    s.superID\n                ORDER BY SUM(t.total) DESC";
             break;
         case 'date':
             $query = "\n                SELECT YEAR(t.tdate) AS year,\n                    MONTH(t.tdate) AS month,\n                    DAY(t.tdate) AS day, " . DTrans::sumQuantity('t') . " AS qty,\n                    SUM(t.total) AS ttl\n                FROM {$dlog} AS t " . DTrans::joinProducts('t', 'p', 'INNER') . "\n                WHERE {$type_condition}\n                    AND t.tdate BETWEEN ? AND ?\n                GROUP BY YEAR(t.tdate),\n                    MONTH(t.tdate),\n                    DAY(t.tdate)\n                ORDER BY YEAR(t.tdate),\n                    MONTH(t.tdate),\n                    DAY(t.tdate)";
             break;
         case 'dept':
             $query = "\n                SELECT d.dept_no,\n                    d.dept_name, " . DTrans::sumQuantity('t') . " AS qty,\n                    SUM(t.total) AS ttl,\n                    s.superID\n                FROM {$dlog} AS t " . DTrans::joinProducts('t', 'p', 'INNER') . DTrans::joinDepartments('t', 'd') . "\n                    LEFT JOIN MasterSuperDepts AS s ON d.dept_no=s.dept_ID\n                WHERE {$type_condition}\n                    AND t.tdate BETWEEN ? AND ?\n                GROUP BY d.dept_no,\n                    d.dept_name,\n                    s.superID\n                ORDER BY SUM(t.total) DESC";
             break;
     }
     $prep = $dbc->prepare_statement($query);
     $result = $dbc->exec_statement($prep, $args);
     $ret = array();
     while ($row = $dbc->fetch_array($result)) {
         $record = array();
         if ($groupby == "date") {
             $record[] = $row['month'] . '/' . $row['day'] . '/' . $row['year'];
             $record[] = number_format($row['qty'], 2);
             $record[] = number_format($row['ttl'], 2);
         } else {
             for ($i = 0; $i < $dbc->num_fields($result); $i++) {
                 if ($dbc->field_name($result, $i) == 'qty' || $dbc->field_name($result, $i) == 'ttl') {
                     $row[$i] = sprintf('%.2f', $row[$i]);
                 }
                 $record[] .= $row[$i];
             }
         }
         $ret[] = $record;
     }
     return $ret;
 }
示例#19
0
 function SaveFormData($upc)
 {
     $upc = BarcodeLib::padUPC($upc);
     $ret = '';
     if (FormLib::get_form_value('newshelftag', '') != '') {
         $ret .= "<script type=\"text/javascript\">";
         $ret .= "testwindow= window.open (\"addShelfTag.php?upc={$upc}\", \"New Shelftag\",\"location=0,status=1,scrollbars=1,width=300,height=220\");";
         $ret .= "testwindow.moveTo(50,50);";
         $ret .= "</script>";
     }
     echo $ret;
     // output javascript to result page
     return True;
 }
示例#20
0
 function body_content()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $filter = FormLib::get_form_value('filter', 1);
     $order = FormLib::get_form_value('order', 'num');
     $orderby = '';
     switch ($order) {
         case 'num':
         default:
             $orderby = 'emp_no';
             break;
         case 'name':
             $orderby = 'FirstName';
             break;
         case 'pass':
             $orderby = 'CashierPassword';
             break;
         case 'fes':
             $orderby = 'frontendsecurity';
             break;
     }
     $ret = '<div id="alert-area"></div><div class="form-inline">';
     $ret .= "<label>Showing</label> <select class=\"form-control\"\n            onchange=\"location='ViewCashiersPage.php?filter='+this.value;\">";
     if ($filter == 1) {
         $ret .= "<option value=1 selected>Active Cashiers</option>";
         $ret .= "<option value=0>Disabled Cashiers</option>";
     } else {
         $ret .= "<option value=1>Active Cashiers</option>";
         $ret .= "<option value=0 selected>Disabled Cashiers</option>";
     }
     $ret .= "</select></div><hr />";
     $ret .= "<table class=\"table\"><tr>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=num>#</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=name>Name</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=pass>Password</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=fes>Privileges</th>";
     $ret .= "<th>&nbsp;</th><th>&nbsp;</th></tr>";
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $employees = new EmployeesModel($dbc);
     $employees->EmpActive($filter);
     foreach ($employees->find($orderby) as $emp) {
         $ret .= sprintf("<tr><td>%d</td><td>%s</td><td>%d</td><td>%s</td>", $emp->emp_no(), $emp->FirstName() . ' ' . $emp->LastName(), $emp->CashierPassword(), $emp->frontendsecurity() <= 20 ? 'Regular' : 'Manager');
         $ret .= sprintf("<td><a href=\"CashierEditor.php?emp_no=%d\">%s</a></td>\n                <td><a href=\"\" onclick=\"deleteEmp(%d,%d); return false;\">%s</a></td></tr>", $emp->emp_no(), \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $emp->emp_no(), $filter, \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }
     $ret .= "</table>";
     return $ret;
 }
示例#21
0
 function preprocess()
 {
     $submit = FormLib::get_form_value('function', '');
     if ($submit == 'add') {
         header('Location: TsAdminAdd.php');
         return False;
     } else {
         if ($submit == 'view') {
             $e = FormLib::get_form_value('emp_no');
             $p = FormLib::get_form_value('periodID');
             $url = sprintf('TsAdminView.php?emp_no=%d&periodID=%d', $e, $p);
             header('Location: ' . $url);
             return False;
         }
     }
     return True;
 }
示例#22
0
 function preprocess()
 {
     $this->__routes[] = 'get<pending>';
     $this->__routes[] = 'get<placed>';
     $this->__routes[] = 'post<id><setPlaced>';
     $this->__routes[] = 'get<id><export>';
     $this->__routes[] = 'get<id><receive>';
     $this->__routes[] = 'get<id><sku>';
     $this->__routes[] = 'get<id><recode>';
     $this->__routes[] = 'post<id><sku><recode>';
     $this->__routes[] = 'post<id><sku><qty><cost>';
     $this->__routes[] = 'post<id><sku><upc><brand><description><orderQty><orderCost><receiveQty><receiveCost>';
     if (FormLib::get_form_value('all') === '0') {
         $this->show_all = false;
     }
     return parent::preprocess();
 }
示例#23
0
 function preprocess()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_ARCHIVE_DB;
     $month = FormLib::get_form_value('month', False);
     $year = FormLib::get_form_value('year', False);
     $model = FormLib::get_form_value('model', False);
     if ($month && $year && $model) {
         $class = $model . 'Model';
         if (!class_exists($class)) {
             include_once 'models/' . $class . '.php';
         }
         $con = FannieDB::get($FANNIE_PLUGIN_SETTINGS['WarehouseDatabase']);
         $obj = new $class($con);
         $obj->reload($FANNIE_ARCHIVE_DB, $month, $year);
     }
     return True;
 }
示例#24
0
 public function process_file($linedata)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $dbc = $this->connection;
     $settings = $this->config->get('PLUGIN_SETTINGS');
     $dbc->selectDB($settings['WicDB']);
     $upc_index = $this->get_column_index('upc');
     $desc_index = $this->get_column_index('desc');
     $size_index = $this->get_column_index('size');
     $brand_index = $this->get_column_index('brand');
     if ($desc_index === false && $brand_index === false) {
         $this->error_details = 'Neither brand nor description provided; nothing to import!';
         return false;
     }
     $ret = true;
     $checks = FormLib::get_form_value('checks') == 'yes' ? true : false;
     $insP = $dbc->prepare('
         INSERT INTO WicItems
             (upc, brand, description, size)
         VALUES
             (?, ?, ?, ?)');
     $dbc->query('TRUNCATE TABLE WicItems');
     foreach ($linedata as $line) {
         $upc = $line[$upc_index];
         // upc cleanup
         $upc = str_replace(" ", "", $upc);
         $upc = str_replace("-", "", $upc);
         if (!is_numeric($upc)) {
             continue;
         }
         // skip header(s) or blank rows
         $this->stats['total']++;
         // MN published spreadhsheet is impossibly dumb
         if (strlen($upc) == 12) {
             $upc = substr($upc, 0, strlen($upc) - 1);
         }
         $upc = BarcodeLib::padUPC($upc);
         $brand = $brand_index !== false && isset($line[$brand_index]) ? $line[$brand_index] : '';
         $desc = $desc_index !== false && isset($line[$desc_index]) ? $line[$desc_index] : '';
         $size = $size_index !== false && isset($line[$size_index]) ? $line[$size_index] : '';
         $dbc->execute($insP, array($upc, $brand, $desc, $size));
     }
     return $ret;
 }
示例#25
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $this->ids = FormLib::get_form_value('batchID', 0);
     if (FormLib::get_form_value('submit', False) !== False) {
         $upcs = FormLib::get_form_value('upc', array());
         $descs = FormLib::get_form_value('desc', array());
         $prices = FormLib::get_form_value('price', array());
         $brands = FormLib::get_form_value('brand', array());
         $skus = FormLib::get_form_value('sku', array());
         $sizes = FormLib::get_form_value('size', array());
         $units = FormLib::get_form_value('units', array());
         $vendors = FormLib::get_form_value('vendor', array());
         $ppos = FormLib::get_form_value('ppo', array());
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $tag = new BatchBarcodesModel($dbc);
         for ($i = 0; $i < count($upcs); $i++) {
             $batchID = $this->ids[$i];
             $upc = $upcs[$i];
             $desc = isset($descs[$i]) ? $descs[$i] : '';
             $price = isset($prices[$i]) ? $prices[$i] : 0;
             $brand = isset($brands[$i]) ? $brands[$i] : '';
             $size = isset($sizes[$i]) ? $sizes[$i] : '';
             $sku = isset($skus[$i]) ? $skus[$i] : '';
             $unit = isset($units[$i]) ? $units[$i] : 1;
             $vendor = isset($vendors[$i]) ? $vendors[$i] : '';
             $ppo = isset($ppos[$i]) ? $ppos[$i] : '';
             $count = isset($counts[$i]) ? $counts[$i] : 1;
             $tag->batchID($batchID);
             $tag->upc($upc);
             $tag->description($desc);
             $tag->normal_price($price);
             $tag->brand($brand);
             $tag->sku($sku);
             $tag->size($size);
             $tag->units($unit);
             $tag->vendor($vendor);
             //$tag->pricePerUnit($ppo);
             $tag->save();
         }
         header("Location: BatchShelfTags.php");
         return false;
     }
     return true;
 }
示例#26
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $msg = '';
     $msg_type = '';
     if (FormLib::get_form_value('submit') !== '') {
         $lc = $_REQUEST['newlc'];
         $lc = FormLib::get_form_value('newlc', 0);
         $name = FormLib::get_form_value('newlcname', '');
         if (!is_numeric($lc)) {
             $msg .= $lc . " is not a number";
             $msg_type = 'danger';
         } else {
             $chkP = $dbc->prepare_statement('SELECT * FROM likeCodes WHERE likeCode=?');
             $chk = $dbc->exec_statement($chkP, array($lc));
             if ($dbc->num_rows($chk) > 0) {
                 $upP = $dbc->prepare_statement("UPDATE likeCodes SET\n                        likeCodeDesc=?\n                        WHERE likeCode=?");
                 $upR = $dbc->exec_statement($upP, array($name, $lc));
                 $msg .= "LC #{$lc} renamed {$name}";
                 $msg_type .= 'success';
             } else {
                 $insP = $dbc->prepare_statement('INSERT INTO likeCodes 
                         (likeCode,likeCodeDesc) VALUES (?,?)');
                 $insR = $dbc->exec_statement($insP, array($lc, $name));
                 $msg .= "LC #{$lc} ({$name}) created";
                 $msg_type = 'success';
             }
         }
     } elseif (FormLib::get_form_value('submit2') !== '') {
         $lc = $_REQUEST['lcselect'];
         $lc = FormLib::get_form_value('lcselect', 0);
         $q1 = $dbc->prepare_statement('DELETE FROM likeCodes WHERE likeCode=?');
         $q2 = $dbc->prepare_statement('DELETE FROM upcLike WHERE likeCode=?');
         $dbc->exec_statement($q1, array($lc));
         $dbc->exec_statement($q2, array($lc));
         $msg .= "LC #{$lc} has been deleted<br />";
         $msg_type = 'success';
     }
     if (!empty($msg_type)) {
         $alert = '<div class="alert alert-' . $msg_type . '" role="alert">' . '<button type="button" class="close" data-dismiss="alert">' . '<span>&times;</span></button>' . $msg . '</div>';
         $this->add_onload_command("\$('div.navbar-default').after('{$alert}');");
     }
     return true;
 }
示例#27
-1
 /**
   Lots of options on this report.
 */
 function fetch_report_data()
 {
     global $FANNIE_OP_DB;
     $date1 = FormLib::get_form_value('date1', date('Y-m-d'));
     $date2 = FormLib::get_form_value('date2', date('Y-m-d'));
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $departments = $dbc->tableDefinition('departments');
     $codingQ = 'SELECT o.orderID,
                 i.vendorInvoiceID, 
                 SUM(o.receivedTotalCost) as rtc,
                 MAX(o.receivedDate) AS rdate,
                 CASE WHEN g.name IS NULL THEN \'Non-Local\' ELSE g.name END as originName,
                 v.vendorName
                 FROM PurchaseOrderItems AS o
                 LEFT JOIN PurchaseOrder as i ON o.orderID=i.orderID
                 LEFT JOIN products AS p ON o.internalUPC=p.upc 
                 LEFT JOIN origins AS g ON p.local=g.originID 
                 LEFT JOIN vendors AS v ON i.vendorID=v.vendorID 
             WHERE i.userID=0
                 AND o.receivedDate BETWEEN ? AND ? ';
     $vendorID = FormLib::get('vendorID');
     $args = array($date1 . ' 00:00:00', $date2 . ' 23:59:59');
     if ($vendorID !== '') {
         $codingQ .= ' AND i.vendorID=? ';
         $args[] = $vendorID;
     }
     $codingQ .= 'GROUP BY o.orderID, i.vendorInvoiceID, g.name
                 ORDER BY rdate, i.vendorInvoiceID, g.name';
     $codingP = $dbc->prepare($codingQ);
     $report = array();
     $invoice_sums = array();
     $codingR = $dbc->execute($codingP, $args);
     while ($codingW = $dbc->fetch_row($codingR)) {
         if ($codingW['rtc'] == 0) {
             // skip zero lines (tote charges)
             continue;
         }
         $record = array($codingW['vendorName'], $codingW['vendorInvoiceID'], $codingW['rdate'], 0.0, sprintf('%.2f', $codingW['rtc']), $codingW['originName']);
         if (!isset($invoice_sums[$codingW['vendorInvoiceID']])) {
             $invoice_sums[$codingW['vendorInvoiceID']] = 0;
         }
         $invoice_sums[$codingW['vendorInvoiceID']] += $codingW['rtc'];
         $report[] = $record;
     }
     for ($i = 0; $i < count($report); $i++) {
         $inv = $report[$i][1];
         $report[$i][3] = sprintf('%.2f', $invoice_sums[$inv]);
     }
     return $report;
 }
示例#28
-1
 function results_content()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $id = FormLib::get_form_value('TenderID');
     $tender = new TendersModel($dbc);
     $tender->TenderID($id);
     $tender->delete();
     $ret = "<i>Tender deleted</i>";
     $ret .= "<br /><br />";
     $ret .= '<a href="DeleteTenderPage.php">Delete another</a>';
     $ret .= "&nbsp;&nbsp;&nbsp;&nbsp;";
     $ret .= '<a href="index.php">Back to edit tenders</a>';
     return $ret;
 }
示例#29
-2
 function body_content()
 {
     global $FANNIE_OP_DB, $FANNIE_PLUGIN_SETTINGS;
     $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);
     include './includes/header.html';
     echo "<form action='" . $_SERVER['PHP_SELF'] . "' method=GET>";
     $currentQ = $ts_db->prepare_statement("SELECT periodID \n            FROM {$FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']}.payperiods \n            WHERE " . $ts_db->now() . " BETWEEN periodStart AND periodEnd");
     $currentR = $ts_db->exec_statement($currentQ);
     list($ID) = $ts_db->fetch_row($currentR);
     $query = $ts_db->prepare_statement("SELECT date_format(periodStart, '%M %D, %Y') as periodStart, \n            date_format(periodEnd, '%M %D, %Y') as periodEnd, periodID \n            FROM {$FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']}.payperiods \n            WHERE periodStart < " . $ts_db->now() . " ORDER BY periodID DESC");
     $result = $ts_db->exec_statement($query);
     echo '<div class="form-group">
         <label>Starting Pay Period</label>
         <select name="period" class="form-control">
         <option>Please select a starting pay period.</option>';
     while ($row = $ts_db->fetch_array($result)) {
         echo "<option value=\"" . $row['periodID'] . "\"";
         if ($row['periodID'] == $ID) {
             echo ' SELECTED';
         }
         echo ">(" . $row['periodStart'] . " - " . $row['periodEnd'] . ")</option>";
     }
     echo '</select></div>
         <div class="form-group">
         <button value="export" class="btn btn-default" name="Export">Run</button>
         </div></form>';
     if (FormLib::get_form_value('Export') == 'export') {
         $periodID = FormLib::get_form_value('period', 0);
         $query = $ts_db->prepare_statement("SELECT s.ShiftID as id, \n                CASE WHEN s.NiceName='' OR s.NiceName IS NULL THEN s.ShiftName\n                ELSE s.NiceName END as area\n                FROM (SELECT ShiftID, NiceName, ShiftName, ShiftOrder \n                FROM " . $FANNIE_PLUGIN_SETTINGS['TimesheetDatabase'] . ".shifts WHERE visible = 1) s \n                GROUP BY s.ShiftID ORDER BY s.ShiftOrder");
         // echo $query;
         $result = $ts_db->exec_statement($query);
         echo "<table class=\"table table-bordered table-striped\"><thead>\n<tr>\n                <th>ID</th><th>Area</th><th>Total</th><th>wages</th></tr></thead>\n<tbody>\n";
         $queryP = $ts_db->prepare_statement("\n                SELECT SUM(IF(ID = 31, t.vacation,t.hours)) as total \n                FROM " . $FANNIE_PLUGIN_SETTINGS['TimesheetDatabase'] . ".timesheet t \n                WHERE t.periodID = ? \n                    AND t.area = ?");
         $query2P = $ts_db->prepare_statement("\n                SELECT SUM(e.wage) as agg \n                FROM " . $FANNIE_PLUGIN_SETTINGS['TimesheetDatabase'] . ".TimesheetEmployees e, " . $FANNIE_PLUGIN_SETTINGS['TimesheetDatabase'] . ".timesheet t \n                WHERE t.emp_no = e.timesheetEmployeeID AND t.periodID = ? AND t.area = ?");
         while ($row = $ts_db->fetch_row($result)) {
             echo "<tr><td>" . $row['id'] . "</td><td>" . $row['area'] . "</td><td align='right'>";
             // echo $query1;
             $result1 = $ts_db->exec_statement($queryP, array($periodID, $row['id']));
             $totHrs = $ts_db->fetch_row($result1);
             $tot = $totHrs[0] ? $totHrs[0] : 0;
             echo $tot . "</td>";
             // echo $query2;
             $result2 = $ts_db->exec_statement($query2P, array($periodID, $row['id']));
             $totAgg = $ts_db->fetch_row($result2);
             $agg = $totAgg[0] ? $totAgg[0] : 0;
             // echo "<td align='right'>$agg</td>";
             $wages = $tot * $agg;
             echo "<td align='right'>" . money_format('%#8n', $wages) . "</td></tr>\n";
         }
     }
     echo "</tbody></table>\n";
 }
示例#30
-2
 public function fetch_report_data()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $date1 = FormLib::get_form_value('date1');
     $date2 = FormLib::get_form_value('date2');
     $upc = $this->form->upc;
     if (is_numeric($upc)) {
         $upc = BarcodeLib::padUPC($upc);
     }
     $table = 'prodUpdate';
     $def = $dbc->tableDefinition('prodUpdate');
     if (!isset($def['prodUpdateID'])) {
         // older schema
         $table = 'prodUpdateArchive';
     }
     $query = 'SELECT
                 upc,
                 description,
                 price,
                 salePrice,
                 cost,
                 dept,
                 tax,
                 fs,
                 scale,
                 likeCode,
                 modified,
                 user,
                 forceQty,
                 noDisc,
                 inUse
               FROM ' . $table . '
               WHERE upc = ?';
     $args = array($upc);
     if ($date1 !== '' && $date2 !== '') {
         // optional: restrict report by date
         $query .= ' AND modified BETWEEN ? AND ? ';
         $args[] = $date1 . ' 00:00:00';
         $args[] = $date2 . ' 23:59:59';
     }
     $query .= ' ORDER BY modified DESC';
     $prep = $dbc->prepare_statement($query);
     $result = $dbc->exec_statement($prep, $args);
     $data = array();
     while ($row = $dbc->fetch_row($result)) {
         $record = array($row['modified'], $row['description'], $row['price'], $row['cost'], $row['dept'], $row['tax'], $row['fs'], $row['scale'], $row['forceQty'], $row['noDisc'], $row['user']);
         $data[] = $record;
     }
     return $data;
 }