public function showEditForm($upc, $display_mode = 1, $expand_mode = 1) { $FANNIE_URL = FannieConfig::config('URL'); $upc = BarcodeLib::padUPC($upc); $ret = '<div id="ProdUserFieldset" class="panel panel-default">'; $ret .= "<div class=\"panel-heading\">\n <a href=\"\" onclick=\"\$('#ProdUserFieldsetContent').toggle();return false;\">\n Sign/Web Info</a>\n </div>"; $css = $expand_mode == 1 ? '' : ' collapse'; $ret .= '<div id="ProdUserFieldsetContent" class="panel-body' . $css . '">'; $dbc = $this->db(); $model = new ProductUserModel($dbc); $model->upc($upc); $model->load(); $loc = new ProdPhysicalLocationModel($dbc); $loc->upc($upc); $loc->load(); $sections = new FloorSectionsModel($dbc); $prod = new ProductsModel($dbc); $prod->upc($upc); $prod->load(); $ret .= '<div class="col-sm-6">'; $ret .= '<div class="row form-group">' . '<label class="col-sm-1">Brand</label> ' . '<div class="col-sm-8">' . '<input type="text" class="form-control" id="lf_brand" name="lf_brand" value="' . $model->brand() . '" />' . '</div>' . '<div class="col-sm-3">' . ' <a href="" onclick="createSign(); return false;">Make Sign</a>' . '</div>' . '</div>'; $ret .= '<div class="row form-group">' . '<label class="col-sm-1">Desc.</label> ' . '<div class="col-sm-8">' . '<textarea class="form-control" rows="2" id="lf_desc" name="lf_desc">' . $model->description() . '</textarea>' . '</div>' . '</div>'; $ret .= '<div class="row form-group">' . '<label class="small col-sm-1">Sign Ct.</label> ' . '<div class="col-sm-8">' . '<input type="number" class="form-control price-field" name="sign-count" value="' . $model->signCount() . '" />' . '</div>' . '</div>'; $ret .= '<div class="row form-group"> <label tile="Location on the floor" class="col-sm-1">Loc.</label> <div class="col-sm-8"> <select name="floor-id" class="form-control"> <option value="0">n/a</option>'; foreach ($sections->find('name') as $section) { $ret .= sprintf('<option %s value="%d">%s</option>', $loc->floorSectionID() == $section->floorSectionID() ? 'selected' : '', $section->floorSectionID(), $section->name()); } $ret .= '</select> </div> <div class="col-sm-3 text-left"> <a href="mapping/FloorSectionsPage.php" target="_blank">Add more</a> </div> </div>'; $otherOriginBlock = '<div class=row> <div class=col-sm-1 /> <div class=col-sm-8> <select name=otherOrigin[] class=form-control><option value=0>n/a</option>'; $ret .= '<div class="row form-group">' . '<label class="col-sm-1"><a href="' . $FANNIE_URL . 'item/origins/OriginEditor.php">Origin</a></label>' . '<div class="col-sm-8">' . ' <select name="origin" class="form-control">' . '<option value="0">n/a</option>'; $origins = new OriginsModel($dbc); $origins->local(0); foreach ($origins->find('name') as $o) { $ret .= sprintf('<option %s value="%d">%s</option>', $prod->current_origin_id() == $o->originID() ? 'selected' : '', $o->originID(), $o->name()); $otherOriginBlock .= sprintf('<option value=%d>%s</option>', $o->originID(), $o->name()); } $ret .= '</select></div>'; $otherOriginBlock .= '</div></div>'; $ret .= '<div class="col-sm-3 text-left">'; $ret .= ' <a href="" onclick="$(\'#originsBeforeMe\').before(\'' . $otherOriginBlock . '\'); return false;">Add more</a>'; $ret .= '</div></div>'; $mapP = 'SELECT originID FROM ProductOriginsMap WHERE upc=? AND originID <> ?'; $mapR = $dbc->execute($mapP, array($upc, $prod->current_origin_id())); while ($mapW = $dbc->fetch_row($mapR)) { $ret .= '<div class="form-group form-inline"> <select name="otherOrigin[]" class="form-control"><option value="0">n/a</option>'; foreach ($origins->find('name') as $o) { $ret .= sprintf('<option %s value="%d">%s</option>', $mapW['originID'] == $o->originID() ? 'selected' : '', $o->originID(), $o->name()); } $ret .= '</select></div>'; } $ret .= '<div id="originsBeforeMe"></div>'; $ret .= '</div>'; $ret .= '<div class="col-sm-6">'; $ret .= '<div class="form-group"><label>Ad Text</label></div>'; $ret .= '<div class="form-group"> <textarea name="lf_text" class="form-control" rows="8" cols="45">' . str_replace('<br />', "\n", $model->long_text()) . '</textarea></div>'; $ret .= '</div>'; $ret .= '</div>'; $ret .= '</div>'; 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; }