function list_content() { global $FANNIE_OP_DB, $FANNIE_URL; $dbc = FannieDB::get($FANNIE_OP_DB); $supertype = FormLib::get_form_value('supertype', 'dept'); $manufacturer = FormLib::get_form_value('manufacturer', ''); $mtype = FormLib::get_form_value('mtype', 'prefix'); $deptStart = FormLib::get_form_value('deptStart', 0); $deptEnd = FormLib::get_form_value('deptEnd', 0); $deptMulti = FormLib::get('departments', array()); $subDepts = FormLib::get('subdepts', array()); $super = FormLib::get_form_value('deptSub'); $vendorID = FormLib::get('vendor'); $upc_list = FormLib::get('u', array()); $inUse = FormLib::get('inUse', 1); $store = FormLib::get('store', 0); $sort = FormLib::get_form_value('sort', 'Department'); $order = 'dept_name'; if ($sort === 'UPC') { $order = 'i.upc'; } elseif ($sort === 'Description') { $order = 'i.description, i.upc'; } $ret = 'Report sorted by ' . $sort . '<br />'; if ($supertype == 'dept' && $super === '') { $ret .= 'Department ' . $deptStart . ' to ' . $deptEnd . '<br />'; } else { if ($supertype == 'dept') { $ret .= 'Sub department ' . $super . '<br />'; } else { if ($supertype == 'manu') { $ret .= _('Brand') . ' ' . $manufacturer . '<br />'; } else { if ($supertype == 'vendor') { $vendor = new VendorsModel($dbc); $vendor->vendorID($vendorID); $vendor->load(); $ret .= 'Vendor ' . $vendor->vendorName() . '<br />'; } } } } $ret .= date("F j, Y, g:i a") . '<br />'; $page_url = sprintf('ProductListPage.php?supertype=%s&deptStart=%s&deptEnd=%s&deptSub=%s&manufacturer=%s&mtype=%s&vendor=%d', $supertype, $deptStart, $deptEnd, $super, $manufacturer, $mtype, $vendorID); if (!$this->excel) { $ret .= '<form action="' . filter_input(INPUT_SERVER, 'PHP_SELF') . '" method="post" id="excel-form"> <input type="hidden" name="supertype" value="' . $supertype . '" /> <input type="hidden" name="deptStart" value="' . $deptStart . '" /> <input type="hidden" name="deptEnd" value="' . $deptEnd . '" /> <input type="hidden" name="deptSub" value="' . $super . '" /> <input type="hidden" name="manufacturer" value="' . $manufacturer . '" /> <input type="hidden" name="mtype" value="' . $mtype . '" /> <input type="hidden" name="vendor" value="' . $vendorID . '" /> <input type="hidden" name="inUse" value="' . $inUse . '" /> <input type="hidden" name="excel" value="yes" />'; if (is_array($subDepts)) { foreach ($subDepts as $s) { $ret .= '<input type="hidden" name="subdepts[]" value="' . $s . '" />'; } } if (is_array($upc_list)) { foreach ($upc_list as $u) { $ret .= '<input type="hidden" name="u[]" value="' . $u . '" />'; } } $ret .= '</form>'; $ret .= sprintf('<a href="" onclick="$(\'#excel-form\').submit();return false;">Save to Excel</a> <a href="%s">Back</a><br />', basename(__FILE__)); } /** base select clause and joins **/ $query = "\n SELECT i.upc,\n i.description,\n i.brand,\n d.dept_name as department,\n i.normal_price,\n (CASE WHEN i.tax = 1 THEN 'X' WHEN i.tax=0 THEN '-' ELSE LEFT(t.description,1) END) as Tax, \n (CASE WHEN i.foodstamp = 1 THEN 'X' ELSE '-' END) as FS,\n (CASE WHEN i.discount = 0 THEN '-' ELSE 'X'END) as DISC,\n (CASE WHEN i.scale = 1 THEN 'X' ELSE '-' END) as WGHd,\n (CASE WHEN i.local > 0 AND o.originID IS NULL THEN 'X' \n WHEN i.local > 0 AND o.originID IS NOT NULL THEN LEFT(o.shortName,1) ELSE '-' END) as local,\n COALESCE(v.vendorName, x.distributor) AS distributor,\n i.cost,\n i.store_id,\n l.description AS storeName\n FROM products as i \n LEFT JOIN departments as d ON i.department = d.dept_no\n LEFT JOIN taxrates AS t ON t.id = i.tax\n LEFT JOIN prodExtra as x on i.upc = x.upc\n LEFT JOIN vendors AS v ON i.default_vendor_id=v.vendorID\n LEFT JOIN Stores AS l ON i.store_id=l.storeID\n LEFT JOIN origins AS o ON i.local=o.originID"; /** add extra joins if this lookup requires them **/ if ($supertype == 'dept' && $super !== '') { if ($super >= 0) { $query .= ' LEFT JOIN superdepts AS s ON i.department=s.dept_ID '; } elseif ($super == -2) { $query .= ' LEFT JOIN MasterSuperDepts AS s ON i.department=s.dept_ID '; } } elseif ($supertype == 'vendor') { $query .= ' LEFT JOIN vendors AS z ON z.vendorName=x.distributor '; } /** build where clause and parameters based on the lookup type **/ $query .= ' WHERE 1=1 '; $args = array(); if ($supertype == 'dept' && $super !== '') { if ($super >= 0) { $query .= ' AND s.superID=? '; $args = array($super); } elseif ($super == -2) { $query .= ' AND s.superID <> 0 '; } if ($deptStart != 0 && $deptEnd != 0) { $query .= ' AND i.department BETWEEN ? AND ? '; $args[] = $deptStart; $args[] = $deptEnd; } elseif (count($deptMulti) > 0) { $query .= ' AND i.department IN ('; foreach ($deptMulti as $d) { $query .= '?,'; $args[] = $d; } $query = substr($query, 0, strlen($query) - 1) . ')'; } if (is_array($subDepts) && count($subDepts) > 0) { $query .= ' AND i.subdept IN ('; foreach ($subDepts as $s) { $query .= '?,'; $args[] = $s; } $query = substr($query, 0, strlen($query) - 1) . ')'; } } elseif ($supertype == 'manu' && $mtype == 'prefix') { $query .= ' AND i.upc LIKE ? '; $args = array('%' . $manufacturer . '%'); } elseif ($supertype == 'manu' && $mtype != 'prefix') { $query .= ' AND (i.brand LIKE ? OR x.manufacturer LIKE ?) '; $args = array('%' . $manufacturer . '%', '%' . $manufacturer . '%'); } elseif ($supertype == 'vendor') { $query .= ' AND (i.default_vendor_id=? OR z.vendorID=?) '; $args = array($vendorID, $vendorID); } elseif ($supertype == 'upc') { $inp = ''; foreach ($upc_list as $u) { $inp .= '?,'; $args[] = $u; } $inp = substr($inp, 0, strlen($inp) - 1); $query .= ' AND i.upc IN (' . $inp . ') '; } else { $query .= ' AND i.department BETWEEN ? AND ? '; $args = array($deptStart, $deptEnd); if (is_array($subDepts) && count($subDepts) > 0) { $query .= ' AND i.subdept IN ('; foreach ($subDepts as $s) { $query .= '?,'; $args[] = $s; } } } if ($inUse == 1) { $query .= ' AND i.inUse=1 '; } else { $query .= ' AND i.inUse=0 '; } if ($store > 0) { $query .= ' AND i.store_id=? '; $args[] = $store; } /** finish building query w/ order clause **/ $query .= 'ORDER BY ' . $order; if ($order != "i.upc") { $query .= ",i.upc"; } $prep = $dbc->prepare_statement($query); $result = $dbc->exec_statement($prep, $args); if ($result === false || $dbc->num_rows($result) == 0) { return 'No data found!'; } $ret .= '<table class="table table-striped table-bordered tablesorter small"> <thead> <tr>'; $ret .= "<th>UPC</th><th>Brand</th><th>Description</th><th>Dept</th><th>" . _('Vendor') . "</th><th>Cost</th><th>Price</th>"; $ret .= "<th>Tax</th><th>FS</th><th>Disc</th><th>Wg'd</th><th>Local</th>"; if (!$this->excel && $this->canEditItems !== false) { $ret .= '<th> </th>'; } $ret .= "</tr></thead><tbody>"; $multi = $this->config->get('STORE_MODE') == 'HQ' ? true : false; while ($row = $dbc->fetch_row($result)) { $ret .= '<tr id="' . $row[0] . '">'; $enc = base64_encode($row[1]); if (!$this->excel) { $ret .= "<td align=center class=\"td_upc\"><a href=ItemEditorPage.php?searchupc={$row['0']}>{$row['0']}</a>"; if ($multi) { $ret .= ' (' . substr($row['storeName'], 0, 1) . ')'; } if ($this->canDeleteItems !== false) { $ret .= " <a href=\"\" onclick=\"deleteCheck('{$row['0']}','{$enc}'); return false;\">"; $ret .= \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a>'; } $ret .= '</td>'; $ret .= '<input type="hidden" class="hidden_upc" value="' . $row[0] . '" />'; $ret .= '<input type="hidden" class="hidden_store_id" value="' . $row['store_id'] . '" />'; } else { $ret .= "<td align=center>{$row['0']}</td>"; } $ret .= "<td align=center class=\"td_brand clickable\">{$row['brand']}</td>"; $ret .= "<td align=center class=\"td_desc clickable\">{$row['description']}</td>"; $ret .= "<td align=center class=\"td_dept clickable\">{$row['department']}</td>"; $ret .= "<td align=center class=\"td_supplier clickable\">{$row['distributor']}</td>"; $ret .= "<td align=center class=\"td_cost clickable\">" . sprintf('%.2f', $row['cost']) . "</td>"; $ret .= "<td align=center class=\"td_price clickable\">{$row['normal_price']}</td>"; $ret .= "<td align=center class=td_tax>{$row['Tax']}</td>"; $ret .= "<td align=center class=td_fs>{$row['FS']}</td>"; $ret .= "<td align=center class=td_disc>{$row['DISC']}</td>"; $ret .= "<td align=center class=td_wgt>{$row['WGHd']}</td>"; $ret .= "<td align=center class=td_local>{$row['local']}</td>"; if (!$this->excel && $this->canEditItems !== False) { $ret .= "<td align=center class=td_cmd><a href=\"\" \n class=\"edit-link\"\n onclick=\"edit(\$(this).closest('tr')); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . '</a> <a href="" class="save-link collapse" onclick="save($(this).closest(\'tr\')); return false;">' . \COREPOS\Fannie\API\lib\FannieUI::saveIcon() . '</a></td>'; } $ret .= "</tr>\n"; } $ret .= '</tbody></table>'; if ($this->excel) { header('Content-Type: application/ms-excel'); header('Content-Disposition: attachment; filename="itemList.csv"'); $array = \COREPOS\Fannie\API\data\DataConvert::htmlToArray($ret); $ret = \COREPOS\Fannie\API\data\DataConvert::arrayToCsv($array); } else { $this->add_script('../src/javascript/tablesorter/jquery.tablesorter.min.js'); $this->add_onload_command("\$('.tablesorter').tablesorter();\n"); } return $ret; }
public function get_view() { $dbc = $this->connection; $settings = $this->config->get('PLUGIN_SETTINGS'); $dbc->selectDB($settings['ScheduledEmailDB']); $templates = new ScheduledEmailTemplatesModel($dbc); $ret = '<table class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th> </th> <th> </th> </tr> </thead> <tbody>'; foreach ($templates->find('scheduledEmailTemplateID') as $t) { $ret .= sprintf('<tr> <td>%d</td> <td>%s</td> <td><a class="btn btn-default btn-xs" href="?id=%d">%s</a></td> <td><a class="btn btn-danger btn-xs" href="?_method=delete&id=%d" onclick="return confirm(\'Delete template %s?\');">%s</a></td> </tr>', $t->scheduledEmailTemplateID(), $t->name(), $t->scheduledEmailTemplateID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $t->scheduledEmailTemplateID(), $t->name(), \COREPOS\Fannie\API\lib\FannieUI::deleteIcon()); } $ret .= '</tbody></table>'; $ret .= '<p> <a href="?_method=put" class="btn btn-default">Create New Template</a> </p>'; return $ret; }
private function vendorDeptDisplay($id) { global $FANNIE_OP_DB, $FANNIE_URL; $dbc = FannieDB::get($FANNIE_OP_DB); $v = new VendorsModel($dbc); $v->vendorID($id); $v->load(); $name = $v->vendorName(); $ret = "<strong>Subcategories in {$name}</strong><br />"; $ret .= "<table class=\"table\">"; $ret .= "<tr><th>No.</th><th>Name</th><th>Margin</th><th>POS Dept#</th>\n <th> </th><th> </th></tr>"; $deptQ = $dbc->prepare_statement("\n SELECT d.vendorID,\n deptID,\n name,\n margin,\n testing,\n posDeptID\n FROM vendorDepartments AS d\n WHERE d.vendorID=?\n ORDER BY deptID"); $deptR = $dbc->exec_statement($deptQ, array($id)); while ($row = $dbc->fetch_row($deptR)) { $ret .= sprintf("<tr id=\"row-%d\">\n <td>%d</td>\n <td id=nametd%d>%s</td>\n <td id=margintd%d>%.2f%%</td>\n <td id=posdepttd%d>%d</td>\n <td id=button%d>\n <a href=\"\" onclick=\"edit(%d);return false;\"\n class=\"edit-link\">%s</a>\n <a href=\"\" onclick=\"save(%d);return false;\"\n class=\"save-link collapse\">%s</a>\n </td>\n <td><a href=\"\" onclick=\"deleteCat(%d,'%s');return false\">%s</a></td>\n <td><a href=\"../../reports/VendorCategory/VendorCategoryReport.php?id=%d&category=%d\"\n title=\"View Items in this Category\">\n <span class=\"glyphicon glyphicon-th-list\"></span>\n </a></td>\n </tr>", $row['deptID'], $row['deptID'], $row['deptID'], $row['name'], $row['deptID'], $row['margin'] * 100, $row['deptID'], $row['posDeptID'], $row['deptID'], $row['deptID'], \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $row['deptID'], \COREPOS\Fannie\API\lib\FannieUI::saveIcon(), $row['deptID'], $row['name'], \COREPOS\Fannie\API\lib\FannieUI::deleteIcon(), $id, $row['deptID']); } $ret .= "</table>"; $ret .= '<p><a href="VendorIndexPage.php?vid=' . $id . '" class="btn btn-default">Home</a></p>'; return $ret; }
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> </th><th> </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; }
public function get_view() { $dbc = FannieDB::getReadOnly($this->config->get('OP_DB')); $plans = new EquityPaymentPlansModel($dbc); $ret = '<table class="table table-bordered"> <tr> <th>Name</th> <th>Payment Amount</th> <th>Frequency</th> </tr>'; foreach ($plans->find('name') as $plan) { $ret .= sprintf(' <tr> <td>%s</td> <td>%.2f</td> <td>%s</td> <td><a class="btn btn-default btn-xs" href="%s?id=%d">%s</a></td> </tr>', $plan->name(), $plan->recurringPayment(), $plan->billingCycle(), filter_input(INPUT_SERVER, 'PHP_SELF'), $plan->equityPaymentPlanID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon()); } $ret .= '</table>'; $ret .= '<p> <a href="?_method=put" class="btn btn-default">Create New Plan</a> </p>'; return $ret; }
public function get_view() { $dbc = $this->connection; $settings = $this->config->get('PLUGIN_SETTINGS'); $dbc->selectDB($settings['TimesheetDatabase']); $model = new TimesheetEmployeesModel($dbc); $ret = <<<HTML <table class="table table-bordered table-striped"> <thead> <tr> <th>#</th> <th>First Name</th> <th>Last Name</th> <th>Department</th> <th>Position</th> <th>View/Edit</th> </tr> </thead> <tbody> HTML; $depts = array(); $dModel = new TimesheetDepartmentsModel($dbc); foreach ($dModel->find() as $d) { $depts[$d->timesheetDepartmentID()] = $d->name(); } $shifts = array(); $sModel = new ShiftsModel($dbc); foreach ($sModel->find() as $s) { $shifts[$s->shiftID()] = $s->NiceName(); } foreach ($model->find('timesheetEmployeeID') as $obj) { $ret .= sprintf('<tr> <td>%d</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td><a href="?id=%d" class="btn btn-default btn-xs">%s</a></td> </tr>', $obj->timesheetEmployeeID(), $obj->firstName(), $obj->lastName(), isset($depts[$obj->timesheetDepartmentID()]) ? $depts[$obj->timesheetDepartmentID()] : '?', isset($shifts[$obj->primaryShiftID()]) ? $shifts[$obj->primaryShiftID()] : '?', $obj->timesheetEmployeeID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon()); } $ret .= <<<HTML </tbody> </table> <form class="form-inline" method="post"> <p> <label>Timesheet ID</label> <input type="text" class="form-control" name="newID" placeholder="Optional - omit for automatic ID" title="Optional - omit for automatic ID" /> <button type="submit" class="btn btn-default">Create New Employee</button> </p> HTML; return $ret; }
private function printRow($row) { printf("<tr>\n <td>%s barcodes/shelftags</td>\n <td style='text-align:right;'>%d</td>\n <td><a href=\"\" onclick=\"goToPage('%d');return false;\">Print</a></td>\n <td><a href=\"DeleteShelfTags.php?id=%d\">Clear</a></td>\n <td><a href=\"EditShelfTags.php?id=%d\">" . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . "</td>\n <td><a href=\"SignFromSearch.php?queueID=%d\">Signs</a></td>\n </tr>", $row[1], $row[2], $row[0], $row[0], $row[0], $row[0]); }
function batchListDisplay($filter = '', $mode = '', $maxBatchID = '') { global $FANNIE_URL; $dbc = $this->con; if ($mode === '') { $mode = $this->config->get('BATCH_VIEW', 'all'); } $colors = array('#ffffff', '#ffffcc'); $c = 0; $ret = ""; $ret .= "<b>Display</b>: "; if ($mode != 'pending') { $ret .= "<a href=\"\" onclick=\"changeTimeSlice('pending'); return false;\">Pending</a> | "; } else { $ret .= "Pending | "; } if ($mode != 'current') { $ret .= "<a href=\"\" onclick=\"changeTimeSlice('current'); return false;\">Current</a> | "; } else { $ret .= "Current | "; } if ($mode != 'historical') { $ret .= "<a href=\"\" onclick=\"changeTimeSlice('historical'); return false;\">Historical</a> | "; } else { $ret .= "Historical | "; } if ($mode != 'all') { $ret .= "<a href=\"\" onclick=\"changeTimeSlice('all'); return false;\">All</a>"; } else { $ret .= "All<br />"; } $sort = \COREPOS\Fannie\API\lib\FannieUI::tableSortIcons(); $ret .= '<table class="table tablesorter tablesorter-core"><thead>'; $ret .= "<tr><th bgcolor={$colors[$c]}>Batch Name{$sort}</th>"; $ret .= "<th bgcolor={$colors[$c]}>Type{$sort}</th>"; $ret .= "<th bgcolor={$colors[$c]}>Items{$sort}</th>"; $ret .= "<th bgcolor={$colors[$c]}>Start date{$sort}</th>"; $ret .= "<th bgcolor={$colors[$c]}>End date{$sort}</th>"; $ret .= "<th bgcolor={$colors[$c]}>Owner/Super Dept.{$sort}</th>"; $ret .= "<th colspan=\"3\"> </th></tr></thead><tbody>"; // owner column might be in different places // depending if schema is up to date $ownerclause = "'' as owner FROM batches AS b"; $batchesTable = $dbc->tableDefinition('batches'); $owneralias = ''; if (isset($batchesTable['owner'])) { $ownerclause = 'b.owner FROM batches AS b'; $owneralias = 'b'; } else { if ($dbc->tableExists('batchowner')) { $ownerclause = 'o.owner FROM batches AS b LEFT JOIN batchowner AS o ON b.batchID=o.batchID'; $owneralias = 'o'; } } // the 'all' query // where clause is for str_ireplace below $fetchQ = "SELECT b.batchName,\n b.batchType,\n b.startDate,\n b.endDate,\n b.batchID,\n t.typeDesc,\n COUNT(l.upc) AS items,\n {$ownerclause}\n LEFT JOIN batchType AS t ON b.batchType = t.batchTypeID\n LEFT JOIN batchList AS l ON b.batchID=l.batchID\n WHERE 1=1 "; $args = array(); switch ($mode) { case 'pending': $fetchQ .= ' AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' > 0 '; break; case 'current': $fetchQ .= ' AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' <= 0 AND ' . $dbc->datediff("b.endDate", $dbc->now()) . ' >= 0 '; break; case 'historical': $fetchQ .= ' AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' <= 0 '; break; } // use a filter - only works in 'all' mode if ($filter != '') { $fetchQ .= ' AND ' . $owneralias . '.owner = ? '; $args[] = $filter; } $fetchQ .= ' GROUP BY b.batchName, b.batchType, b.startDate, b.endDate, b.batchID, t.typeDesc, ' . $owneralias . '.owner '; $fetchQ .= ' ORDER BY b.batchID DESC'; $fetchQ = $dbc->add_select_limit($fetchQ, 50); if (is_numeric($maxBatchID)) { $fetchQ = str_replace("WHERE ", "WHERE b.batchID < ? AND ", $fetchQ); array_unshift($args, $maxBatchID); } $fetchR = $dbc->exec_statement($fetchQ, $args); $count = 0; $lastBatchID = 0; while ($fetchW = $dbc->fetch_array($fetchR)) { /** strtotime() and date() are not reciprocal functions date('Y-m-d', strtotime('0000-00-00')) results in -0001-11-30 instead of the expected 0000-00-00 */ if ($fetchW['startDate'] == '0000-00-00 00:00:00') { $fetchW['startDate'] = ''; } if ($fetchW['endDate'] == '0000-00-00 00:00:00') { $fetchW['endDate'] = ''; } $c = ($c + 1) % 2; $id = $fetchW['batchID']; $ret .= '<tr id="batchRow' . $fetchW['batchID'] . '" class="batchRow">'; $ret .= "<td bgcolor={$colors[$c]} id=name{$id}><a id=namelink{$id} \n href=\"EditBatchPage.php?id={$id}\">{$fetchW['batchName']}</a></td>"; $ret .= "<td bgcolor={$colors[$c]} id=type{$id}>" . $fetchW['typeDesc'] . "</td>"; $ret .= "<td bgcolor={$colors[$c]}>" . $fetchW['items'] . "</td>"; $ret .= "<td bgcolor={$colors[$c]} id=startdate{$id}>" . (strtotime($fetchW['startDate']) ? date('Y-m-d', strtotime($fetchW['startDate'])) : '') . "</td>"; $ret .= "<td bgcolor={$colors[$c]} id=enddate{$id}>" . (strtotime($fetchW['endDate']) ? date('Y-m-d', strtotime($fetchW['endDate'])) : '') . "</td>"; $ret .= "<td bgcolor={$colors[$c]} id=owner{$id}>{$fetchW['owner']}</td>"; $ret .= "<td bgcolor={$colors[$c]} id=edit{$id}>\n <a href=\"\" onclick=\"editBatchLine({$id}); return false;\" class=\"batchEditLink btn btn-default btn-xs\">\n " . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . "\n </a>\n <a href=\"\" onclick=\"saveBatchLine({$id}); return false;\" class=\"batchSaveLink btn btn-default btn-xs collapse\">\n " . \COREPOS\Fannie\API\lib\FannieUI::saveIcon() . "\n </a>\n </td>"; $ret .= "<td bgcolor={$colors[$c]}><a href=\"\" class=\"btn btn-danger btn-xs\"\n onclick=\"deleteBatch({$id},'" . str_replace("'", '', $fetchW['batchName']) . "'); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a></td>'; $ret .= "<td bgcolor={$colors[$c]}><a href=\"batchReport.php?batchID={$id}\">Report</a></td>"; $ret .= "</tr>"; $count++; $lastBatchID = $fetchW[4]; } $ret .= "</tbody></table>"; if (is_numeric($maxBatchID)) { $ret .= sprintf("<a href=\"\" \n onclick=\"scroll(0,0); batchListPager('%s','%s',''); return false;\">First page</a>\n | ", $filter, $mode); } if ($count >= 50) { $ret .= sprintf("<a href=\"\" \n onclick=\"scroll(0,0); batchListPager('%s','%s',%d); return false;\">Next page</a>", $filter, $mode, $lastBatchID); } else { $ret .= "Next page"; } return $ret; }
protected function showBatchDisplay($id, $order = 'natural') { global $FANNIE_SERVER_DBMS, $FANNIE_URL; $dbc = $this->connection; $uid = getUID($this->current_user); $uid = ltrim($uid, '0'); $orderby = ''; switch ($order) { case 'upc_a': $orderby = 'ORDER BY b.upc ASC'; break; case 'upc_d': $orderby = 'ORDER BY b.upc DESC'; break; case 'desc_a': $orderby = 'ORDER BY description ASC'; break; case 'desc_d': $orderby = 'ORDER BY description DESC'; break; case 'price_a': $orderby = 'ORDER BY p.normal_price ASC'; break; case 'price_d': $orderby = 'ORDER BY p.normal_price DESC'; break; case 'sale_a': $orderby = 'ORDER BY b.salePrice ASC'; break; case 'sale_d': $orderby = 'ORDER BY b.salePrice DESC'; break; case 'loc_a': $orderby = 'ORDER BY m.super_name,y.subsection,y.shelf_set,y.shelf'; break; case 'loc_d': $orderby = 'ORDER BY m.super_name DESC,y.subsection DESC,y.shelf_set DESC,y.shelf DESC'; break; case 'brand_a': $orderby = 'ORDER BY p.brand ASC'; break; case 'brand_d': $orderby = 'ORDER BY p.brand DESC'; break; case 'natural': default: $orderby = 'ORDER BY b.listID DESC'; break; } $model = new BatchesModel($dbc); $model->batchID($id); $model->load(); $name = $model->batchName(); $type = $model->batchType(); $dtype = $model->discountType(); $start = strtotime($model->startDate()); $end = strtotime($model->endDate()) + 60 * 60 * 24; $typeModel = new BatchTypeModel($dbc); $typeModel->batchTypeID($type); $typeModel->load(); if ($typeModel->editorUI() == 2) { return $this->showPairedBatchDisplay($id, $name); } $limit = $model->transLimit(); $hasLimit = $limit > 0 ? true : false; $saleHeader = "Sale Price"; if ($dtype == 3) { $saleHeader = "\$ Discount"; } elseif ($dtype == 4) { $saleHeader = "% Discount"; } elseif ($dtype == 0) { $saleHeader = "New price"; } $fetchArgs = array(); $fetchQ = "\n SELECT b.upc,\n CASE \n WHEN l.likeCode IS NULL THEN p.description\n ELSE l.likeCodeDesc \n END AS description,\n p.normal_price,\n b.salePrice,\n CASE WHEN c.upc IS NULL then 0 ELSE 1 END as isCut,\n b.quantity,\n b.pricemethod,\n m.super_name, \n y.subsection, \n y.shelf_set, \n y.shelf,\n p.brand\n FROM batchList AS b \n " . DTrans::joinProducts('b') . "\n LEFT JOIN likeCodes AS l ON b.upc = CONCAT('LC',CONVERT(l.likeCode,CHAR))\n LEFT JOIN batchCutPaste AS c ON b.upc=c.upc AND b.batchID=c.batchID\n LEFT JOIN prodPhysicalLocation AS y ON b.upc=y.upc\n LEFT JOIN superDeptNames AS m ON y.section=m.superID\n WHERE b.batchID = ? \n {$orderby}"; $fetchArgs[] = $id; if ($dbc->dbms_name() == "mssql") { $fetchQ = "select b.upc,\n case when l.likecode is null then p.description\n else l.likecodedesc end as description,\n p.normal_price,b.salePrice,\n CASE WHEN c.upc IS NULL then 0 ELSE 1 END as isCut,\n b.quantity,b.pricemethod\n from batchList as b \n " . DTrans::joinProducts('b') . "\n left join likeCodes as l on\n b.upc = 'LC'+convert(varchar,l.likecode)\n left join batchCutPaste as c ON\n b.upc=c.upc AND b.batchID=c.batchID\n where b.batchID = ? {$orderby}"; } $sections = array(); if ($dbc->tableExists('FloorSections')) { $floor = new FloorSectionsModel($dbc); foreach ($floor->find() as $f) { $sections[$f->floorSectionID()] = $f->name(); } $fetchQ = str_replace('y.subsection', 'y.floorSectionID', $fetchQ); } $fetchP = $dbc->prepare_statement($fetchQ); $fetchR = $dbc->exec_statement($fetchP, $fetchArgs); $overlapP = $dbc->prepare(' SELECT b.batchID, b.batchName FROM batchList as l INNER JOIN batches AS b ON b.batchID=l.batchID WHERE l.upc=? AND l.batchID <> ? AND b.discounttype <> 0 AND ( (b.startDate BETWEEN ? AND ?) OR (b.endDate BETWEEN ? AND ?) ) '); $overlap_args = array($model->startDate(), $model->endDate(), $model->startDate(), $model->endDate()); $cpCount = $dbc->prepare_statement("SELECT count(*) FROM batchCutPaste WHERE uid=?"); $res = $dbc->exec_statement($cpCount, array($uid)); $row = $dbc->fetch_row($res); $cpCount = $row[0]; $ret = "<span class=\"newBatchBlack\"><b>Batch name</b>: {$name}</span> | "; $ret .= '<b>Sale Dates</b>: ' . date('Y-m-d', strtotime($model->startDate())) . ' - ' . date('Y-m-d', strtotime($model->endDate())) . '<br />'; if ($this->config->get('STORE_MODE') === 'HQ') { $stores = new StoresModel($dbc); $mapP = $dbc->prepare('SELECT storeID FROM StoreBatchMap WHERE storeID=? AND batchID=?'); foreach ($stores->find('storeID') as $s) { $mapR = $dbc->execute($mapP, array($s->storeID(), $id)); $checked = $mapR && $dbc->numRows($mapR) ? 'checked' : ''; $ret .= sprintf('<label> <input type="checkbox" onchange="toggleStore(%d, %d);" %s /> %s </label> | ', $s->storeID(), $id, $checked, $s->description()); } $ret .= '<br />'; } $ret .= "<a href=\"BatchListPage.php\">Back to batch list</a> | "; $ret .= sprintf('<input type="hidden" id="batch-discount-type" value="%d" />', $model->discountType()); /** Price change batches probably want the upcoming retail rather than the current retail. Current sales will want the current sale price; future sales will want the future sale price. Past sales probably won't print signs under normal circumstances. */ $future_mode = false; if ($model->discountType() == 0) { $future_mode = true; } elseif (strtotime($model->startDate()) >= strtotime(mktime(0, 0, 0, date('n'), date('j'), date('Y')))) { $future_mode = true; } $ret .= sprintf('<input type="hidden" id="batch-future-mode" value="%d" />', $future_mode ? 1 : 0); $ret .= "<a href=\"../../admin/labels/SignFromSearch.php?batch={$id}\">Print Sale Signs</a> | "; $ret .= "<a href=\"BatchSignStylesPage.php?id={$id}\">Sign Pricing</a> | "; $ret .= "<a href=\"{$FANNIE_URL}admin/labels/BatchShelfTags.php?batchID%5B%5D={$id}\">Print Shelf Tags</a> | "; $ret .= "<a href=\"\" onclick=\"generateTags({$id}); return false;\">Auto-tag</a> | "; if ($cpCount > 0) { $ret .= "<a href=\"EditBatchPage.php?id={$id}&paste=1\">Paste Items ({$cpCount})</a> | "; } if ($dtype == 0 || time() >= $start && time() <= $end) { $ret .= "<a href=\"\" onclick=\"forceNow({$id}); return false;\">Force batch</a> | "; } if ($dtype != 0) { $ret .= "<a href=\"\" onclick=\"unsaleNow({$id}); return false;\">Stop Sale</a> "; } if ($dtype == 0) { $ret .= " <a href=\"\" onclick=\"trimPcBatch({$id}); return false;\">Trim Unchanged</a> "; } else { $ret .= " | <span id=\"edit-limit-link\"><a href=\"\" \n onclick=\"editTransLimit(); return false;\">" . ($hasLimit ? 'Edit' : 'Add') . " Limit</a></span>"; $ret .= "<span id=\"save-limit-link\" class=\"collapse\"><a href=\"\" onclick=\"saveTransLimit({$id}); return false;\">Save Limit</a></span>"; $ret .= " <span class=\"form-group form-inline\" id=\"currentLimit\" style=\"color:#000;\">{$limit}</span>"; } $ret .= "<br />"; $ret .= "<table id=yeoldetable class=\"table\">"; $ret .= "<tr>"; if ($orderby != "ORDER BY b.upc ASC") { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=upc_a\">UPC</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=upc_d\">UPC</a></th>"; } if ($orderby != "ORDER BY p.brand ASC") { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=brand_a\">Brand</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=brand_d\">Brand</a></th>"; } if ($orderby != "ORDER BY description ASC") { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=desc_a\">Description</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=desc_d\">Description</a></th>"; } if ($orderby != "ORDER BY p.normal_price DESC") { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=price_d\">Normal Price</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=price_a\">Normal Price</a></th>"; } if ($orderby != "ORDER BY b.salePrice DESC") { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=sale_d\">{$saleHeader}</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=sale_a\">{$saleHeader}</a></th>"; } $ret .= "<th colspan=\"3\"> </th>"; if ($orderby != 'ORDER BY m.super_name,y.subsection,y.shelf_set,y.shelf') { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=loc_a\">Location</a></th>"; } else { $ret .= "<th><a href=\"EditBatchPage.php?id={$id}&sort=loc_d\">Location</a></th>"; } $ret .= "</tr>"; $colors = array('#ffffff', '#ffffcc'); $cur = 0; while ($fetchW = $dbc->fetch_array($fetchR)) { $cur = ($cur + 1) % 2; $ret .= "<tr>"; $fetchW['upc'] = rtrim($fetchW['upc']); if (substr($fetchW['upc'], 0, 2) == "LC") { $likecode = rtrim(substr($fetchW['upc'], 2)); $ret .= "<td bgcolor={$colors[$cur]}>" . $fetchW['upc']; $ret .= " <a href=\"\" onclick=\"\$('.lc-item-{$likecode}').toggle(); return false;\">[+]</a>"; $ret .= "</td>"; } else { $conflict = ''; if ($dtype != 0) { $overlapR = $dbc->execute($overlapP, array_merge(array($fetchW['upc'], $id), $overlap_args)); if ($overlapR && $dbc->numRows($overlapR)) { $overlap = $dbc->fetchRow($overlapR); $conflict = sprintf('<a href="EditBatchPage.php?id=%d" target="_batch%d" title="Conflicts with batch %s" class="btn btn-xs btn-danger"> <span class="glyphicon glyphicon-exclamation-sign"> </span></a>', $overlap['batchID'], $overlap['batchID'], $overlap['batchName']); } } $ret .= "<td bgcolor={$colors[$cur]}><a href=\"{$FANNIE_URL}item/ItemEditorPage.php?searchupc={$fetchW['upc']}\" \n target=\"_new{$fetchW['upc']}\">{$fetchW['upc']}</a>{$conflict}</td>"; } $ret .= "<td bgcolor={$colors[$cur]}>{$fetchW['brand']}</td>"; $ret .= "<td bgcolor={$colors[$cur]}>{$fetchW['description']}</td>"; $ret .= "<td bgcolor={$colors[$cur]}>{$fetchW['normal_price']}</td>"; $qtystr = $fetchW['pricemethod'] > 0 && is_numeric($fetchW['quantity']) && $fetchW['quantity'] > 0 ? $fetchW['quantity'] . " for " : ""; $qty = is_numeric($fetchW['quantity']) && $fetchW['quantity'] > 0 ? $fetchW['quantity'] : 1; $ret .= "<td bgcolor={$colors[$cur]} class=\"\">"; $ret .= '<span id="editable-text-' . $fetchW['upc'] . '">'; $ret .= '<span class="editable-' . $fetchW['upc'] . ($qty == 1 ? ' collapse ' : '') . '"' . ' id="item-qty-' . $fetchW['upc'] . '" data-name="qty">' . $qty . ' for </span>'; $ret .= "<span class=\"editable-{$fetchW['upc']}\" \n id=\"sale-price-{$fetchW['upc']}\" data-name=\"price\">" . sprintf("%.2f</span>", $fetchW['salePrice']); $ret .= '</span>'; $ret .= '<div class="form-group form-inline collapse" id="editable-fields-' . $fetchW['upc'] . '">'; $ret .= '<div class="input-group">'; $ret .= sprintf('<input type="text" class="form-control" name="qty" value="%d" />', $qty); $ret .= '<span class="input-group-addon">for</span>'; $ret .= '<span class="input-group-addon">$</span>'; $ret .= sprintf('<input text="text" class="form-control" name="price" value="%.2f" />', $fetchW['salePrice']); $ret .= '</div></div></td>'; $ret .= "<td bgcolor={$colors[$cur]} id=editLink{$fetchW['upc']}>\n <a href=\"\" class=\"edit\" onclick=\"editUpcPrice('{$fetchW['upc']}'); return false;\">\n " . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . "</a>\n <a href=\"\" class=\"save collapse\" onclick=\"saveUpcPrice('{$fetchW['upc']}'); return false;\">\n " . \COREPOS\Fannie\API\lib\FannieUI::saveIcon() . "</a>\n </td>"; $ret .= "<td bgcolor={$colors[$cur]}><a href=\"\" \n onclick=\"deleteUPC.call(this, {$id}, '{$fetchW['upc']}'); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . "</a>\n </td>"; if ($fetchW['isCut'] == 1) { $ret .= "<td bgcolor={$colors[$cur]} id=cpLink{$fetchW['upc']}>\n <a href=\"\" id=\"unCut{$fetchW['upc']}\" onclick=\"cutItem('{$fetchW['upc']}',{$id},{$uid}, 0); return false;\">Undo</a>\n <a href=\"\" class=\"collapse\" id=\"doCut{$fetchW['upc']}\" onclick=\"cutItem('{$fetchW['upc']}',{$id},{$uid}, 1); return false;\">Cut</a>\n </td>"; } else { $ret .= "<td bgcolor={$colors[$cur]} id=cpLink{$fetchW['upc']}>\n <a href=\"\" class=\"collapse\" id=\"unCut{$fetchW['upc']}\" onclick=\"cutItem('{$fetchW['upc']}',{$id},{$uid},0); return false;\">Undo</a>\n <a href=\"\" id=\"doCut{$fetchW['upc']}\" onclick=\"cutItem('{$fetchW['upc']}',{$id},{$uid},1); return false;\">Cut</a>\n </td>"; } $loc = 'n/a'; if (!empty($fetchW['subsection'])) { $loc = substr($fetchW['super_name'], 0, 4); $loc .= $fetchW['subsection'] . ', '; $loc .= 'Unit ' . $fetchW['shelf_set'] . ', '; $loc .= 'Shelf ' . $fetchW['shelf']; } elseif (!empty($fetchW['floorSectionID'])) { $loc = $sections[$fetchW['floorSectionID']]; } $ret .= "<td bgcolor={$colors[$cur]}>" . $loc . '</td>'; $ret .= '<input type="hidden" class="batch-hidden-upc" value="' . $fetchW['upc'] . '" />'; $ret .= "</tr>"; if (substr($fetchW['upc'], 0, 2) == "LC") { $likecode = rtrim(substr($fetchW['upc'], 2)); $ret .= self::likeToTable($dbc, $likecode, $fetchW['salePrice']); } } $ret .= "</table>"; $ret .= "<input type=hidden id=currentBatchID value={$id} />"; return $ret; }