Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ii mvc #134 #137

Merged
merged 106 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
a7a001a
Update ii-activity Twig
Pauldro Mar 25, 2021
39bc5cd
Download Binr Controller
Pauldro Mar 25, 2021
5d68316
Remove ii-activity template
Pauldro Mar 25, 2021
d7dcbe1
Update display.twig
Pauldro Mar 26, 2021
fee8e0f
Create and Implement ii-activity controller
Pauldro Mar 26, 2021
9914ee2
Display Activity Start Date
Pauldro Mar 26, 2021
6fd2971
Update activity.twig
Pauldro Mar 26, 2021
1f9ab1e
Fix $data->date usage
Pauldro Mar 26, 2021
7bef8ef
Implement Card Display for ii-kit
Pauldro Mar 26, 2021
fd503e9
Remove ii-kit template
Pauldro Mar 26, 2021
dbfa077
Update DpagesMii.module
Pauldro Mar 26, 2021
7dd81d2
Create and Implement II Kit Controller
Pauldro Mar 26, 2021
70bd1e0
style(twig): Update II Bom to use ii display
Pauldro Apr 8, 2021
5f14a04
Update ConfigsIi.module
Pauldro Apr 8, 2021
6a35fcb
feat: add sendRequest function for dplus requests
Pauldro Apr 8, 2021
bc677e0
Update Kit.php
Pauldro Apr 8, 2021
73fc191
refactor: create and implement Ii\Bom controller
Pauldro Apr 8, 2021
aa5e1fa
chore: remove ii-bom template from PW
Pauldro Apr 8, 2021
30a999f
style(twig): update where used to use ii-display
Pauldro Apr 8, 2021
f919e87
Update ii.php
Pauldro Apr 8, 2021
9323329
Update Activity.php
Pauldro Apr 8, 2021
127e6c6
refactor: create and implement Ii\WhereUsed controller
Pauldro Apr 8, 2021
2c65bcd
chore: remove ii-where-used template from PW
Pauldro Apr 8, 2021
c8712f8
Update ii.php
Pauldro Apr 8, 2021
d2d7828
Update display.twig
Pauldro Apr 8, 2021
739bc6d
fix(twig): update ii-breadcrumbs to use |title
Pauldro Apr 8, 2021
ece7ed0
style(twig): update ii-lotserial to use ii-display
Pauldro Apr 8, 2021
5ba9ebf
Update Activity.php
Pauldro Apr 8, 2021
9326b6b
refactor: create and use Ii\Lotserial controller
Pauldro Apr 8, 2021
79f9e81
chore: remove ii-lotserial from PW
Pauldro Apr 8, 2021
6b8d62c
Update Usage.php
Pauldro Apr 9, 2021
d354c15
Update II General Display to use ii-display
Pauldro Apr 9, 2021
6d2f72d
Update warehouses.js.twig
Pauldro Apr 9, 2021
d1b831f
feat: add getFileHasher()
Pauldro Apr 9, 2021
f0ee56b
refactor: Create and Implement Ii\General controller
Pauldro Apr 9, 2021
5ed55e8
chore: remove ii-general template from PW
Pauldro Apr 9, 2021
d6b2bff
refactor: use self::sendRequest() for Data Requests
Pauldro Apr 9, 2021
bb92cc4
refactor: shorten data sanitization
Pauldro Apr 9, 2021
1be1f18
refactor: use inherited self::getFileHasher()
Pauldro Apr 9, 2021
f36687f
Update display.twig
Pauldro Apr 9, 2021
d39a854
refactor: reorganize Ii\Activity
Pauldro Apr 9, 2021
dd5567d
refactor: reorganize Ii\Bom
Pauldro Apr 9, 2021
7dcc522
refactor: reorganize Ii\Costing
Pauldro Apr 9, 2021
7d92ddc
refactor: reorganize Ii\General
Pauldro Apr 9, 2021
6bc2cb9
Create display.twig
Pauldro Apr 9, 2021
4e50e46
Update ii-links.twig
Pauldro Apr 9, 2021
715dae5
Update Activity.php
Pauldro Apr 9, 2021
1adead7
refactor: reorganize Ii\Item
Pauldro Apr 9, 2021
6b316b4
Update Item.php
Pauldro Apr 9, 2021
082c4d7
refactor: reorganize Ii\Kit
Pauldro Apr 9, 2021
ded11c2
refactor: reorganize Ii\Lotserial
Pauldro Apr 9, 2021
ace0c62
refactor: reorganize Ii\Pricing
Pauldro Apr 9, 2021
a4f53ff
Update Pricing.php
Pauldro Apr 9, 2021
f3474b8
Update Activity.php
Pauldro Apr 9, 2021
e09569c
Update Requirements.php
Pauldro Apr 9, 2021
4adc88e
refactor: reorganize Ii\Stock
Pauldro Apr 9, 2021
3750fd0
refactor: reorganize Ii\Usage
Pauldro Apr 9, 2021
1186ea7
Update Usage.php
Pauldro Apr 9, 2021
60ab4dc
refactor: reorganize Ii\WhereUsed
Pauldro Apr 9, 2021
2963344
Implement Ii Display
Pauldro Apr 9, 2021
45d4a8c
Create and Implement Ii\Substitutes
Pauldro Apr 9, 2021
91fab35
chore: remove ii-substitutes
Pauldro Apr 9, 2021
001204b
Update IiFunction.php
Pauldro Apr 9, 2021
2f9f4e1
Update Activity.php
Pauldro Apr 9, 2021
edf64e2
Update Costing.php
Pauldro Apr 9, 2021
5fb03fc
Update whse-table.twig
Pauldro Apr 9, 2021
e8c5cec
Update display.twig
Pauldro Apr 9, 2021
776f81b
style: updatre ii-documents display
Pauldro Apr 9, 2021
2baa5f3
refactor create and implement ii-documents controller
Pauldro Apr 9, 2021
e6a501a
Update DocumentManagementQt.module
Pauldro Apr 12, 2021
304cd42
Update DplusSanitizer.module
Pauldro Apr 12, 2021
0c9c7b3
fix:: fix code for iiQuotes
Pauldro Apr 12, 2021
59efad1
Add ii-quotes and ii-purchase-history document listing
Pauldro Apr 12, 2021
f64462b
Update DocumentManagementIi.module
Pauldro Apr 12, 2021
6631424
Update quotes.twig
Pauldro Apr 12, 2021
296c1b5
Update tr-details.twig
Pauldro Apr 12, 2021
858adb8
Update Documents.php
Pauldro Apr 12, 2021
18193db
Update DocumentManagementIi.module
Pauldro Apr 12, 2021
e01c6e9
FIX: salesorder documents link
Pauldro Apr 12, 2021
e037050
Update Ii.php
Pauldro Apr 12, 2021
19c0bdb
chore: remove ii-documents template
Pauldro Apr 12, 2021
8ad29c0
STYLE: update ii-sales-orders to use ii-display template
Pauldro Apr 12, 2021
3e3f6dc
Update Documents.php
Pauldro Apr 12, 2021
17a74dd
REFACTOR: create and implement Ii\SalesOrders controller
Pauldro Apr 12, 2021
59dbbcf
CHORE: remove ii-sales-orders template
Pauldro Apr 12, 2021
8604c6b
FIX: page.documentsUrlSalesorder -> page.documentListUrl
Pauldro Apr 12, 2021
1302847
CHORE: Add Supplements Section
Pauldro Apr 12, 2021
3fd6262
Update Documents.php
Pauldro Apr 12, 2021
2563acd
STYLE: use ii-display template for ii-sales-history
Pauldro Apr 12, 2021
6ae27ce
REFACTOR: create and implement Ii\SalesHistory controller
Pauldro Apr 12, 2021
c3c1608
CHORE: remove ii-sales-history
Pauldro Apr 12, 2021
f68bdb1
STYLE: use ii-display for ii-quotes
Pauldro Apr 12, 2021
11b4a6f
REFACTOR: Implement Ii\Quotes controller
Pauldro Apr 12, 2021
c3fa304
CHORE: remove ii-quotes template
Pauldro Apr 12, 2021
d4de9f1
STYLE: use ii-display for ii-purchase-orders
Pauldro Apr 12, 2021
b577269
FEAT: purchase order documents URL
Pauldro Apr 12, 2021
08f7d35
REFACTOR: Implement Ii\PurchaseOrders
Pauldro Apr 12, 2021
c7b4f16
CHORE: remove ii-purchase-history
Pauldro Apr 12, 2021
33c74f9
STYLE: use ii-display for ii-purchase-history
Pauldro Apr 12, 2021
c9a49ec
REFACTOR: implement Ii\PurchaseHistory
Pauldro Apr 12, 2021
839e86d
CHORE: remove ii-purchase-history
Pauldro Apr 12, 2021
eebdf26
CHORE: delete init_iipage()
Pauldro Apr 12, 2021
ea0ce92
CHORE: remove itemUrl()
Pauldro Apr 12, 2021
11a76a1
Use page.itemUrl()
Pauldro Apr 12, 2021
47fe269
Update Iio.module
Pauldro Apr 12, 2021
eba5382
FIX: validateVxmUpdateItmCost should be static
Pauldro Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
263 changes: 263 additions & 0 deletions site/controllers/classes/Mwm/binr/Binr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
<?php namespace Controllers\Wm;

use stdClass;
// Purl Library
use Purl\Url as Purl;
// Dplus Model
use WarehouseQuery, Warehouse;
// Dpluso Model
use BininfoQuery, Bininfo;
use WhsesessionQuery, Whsesession;
// ProcessWire Classes, Modules
use ProcessWire\Page, ProcessWire\Module, Processwire\SearchInventory, Processwire\WarehouseManagement;
// Dplus Classes
use Dplus\Wm\Binr as BinrCRUD;
// Mvc Controllers
use Mvc\Controllers\AbstractController;

class Binr extends AbstractController {
/** @var SearchInventory **/
private static $inventory;

/** @var WarehouseManagement **/
private static $whsem;

/** @var Warehouse **/
private static $warehouse;

/** @var Whsesession **/
private static $whsesession;

public static function index($data) {
$fields = ['scan|text', 'action|text', 'frombin|text', 'tobin|text'];
$data = self::sanitizeParametersShort($data, $fields);

if (empty($data->action) === false) {
return self::handleCRUD($data);
}

if (empty($data->scan) === false) {
return self::handleScan($data);
}

if (empty($data->serialnbr) === false || empty($data->lotnbr) === false || empty($data->itemID) === false) {
return self::handleItem($data);
}

return self::searchItemForm($data);
}

public static function handleCRUD($data) {
$data = self::sanitizeParametersShort($data, ['action|text', 'scan|text']);

switch ($data->action) {
case 'inventory-search':
$whsem = self::getWarehouseManagement();
$whsem->requestInventorySearch(strtoupper($data->scan));
$url = new Purl(self::pw('page')->url);
$url->query->set('scan', $data->scan);
self::pw('session')->redirect($url->getUrl(), $http301 = false);
break;
case 'bin-reassign';
$data = self::sanitizeParametersShort($data, ['itemID|text', 'frombin|text', 'tobin|text', 'serialnbr|text', 'lotnbr|text', 'qty|float']);
$binr = new BinrCRUD();
$binr->requestBinReassignment($data);
$params = explode('&', self::pw('input')->queryString());
$url = new Purl(self::pw('page')->url);
if (array_key_exists('frombin', $params)) {
$url->query->set('frombin', $params['frombin']);
}
if (array_key_exists('tobin', $params)) {
$url->query->set('tobin', $params['tobin']);
}
self::pw('session')->redirect($url->getUrl(), $http301 = false);
break;
}
}

public static function handleScan($data) {
$fields = ['scan|text', 'action|text', 'frombin|text', 'tobin|text', 'binID|text'];
$data = self::sanitizeParametersShort($data, $fields);

if (empty($data->action) === false) {
return self::handleCRUD($data);
}
$html = '';
$config = self::pw('config');
$modules = self::pw('modules');
$config->binr = $modules->get('ConfigsBinr');
/** @var SearchInventory **/
$inventory = self::getInventorySearch();
$resultscount = $inventory->query()->count();

if ($resultscount === 0) {
return $config->twig->render('warehouse/binr/inventory-results.twig', ['items' => []]);
}

if ($resultscount === 1) {
$item = $inventory->query()->findOne();
$url = self::pw('page')->binr_itemURL($item);
self::pw('session')->redirect($url, $http301 = false);
}

// Multiple Items - count the number Distinct Item IDs
$countItemids = $inventory->count_itemids_distinct($data->binID);

if ($countItemids === 1) {
return self::handleScanInventorySingleItemid($data);
}
$items = $inventory->get_items_distinct($data->binID);
return $config->twig->render('warehouse/binr/inventory-results.twig', ['resultscount' => $resultscount, 'items' => $items]);
}

private static function handleScanInventorySingleItemid($data) {
$fields = ['scan|text', 'action|text', 'frombin|text', 'tobin|text', 'binID|text'];
$data = self::sanitizeParametersShort($data, $fields);
$inventory = self::getInventorySearch();
$config = self::pw('config');

$q = $inventory->query();
if ($data->binID) {
$q->filterByBin($data->binID);
}
$item = $q->findOne();

if ($item->is_lotted() === false && $item->is_serialized() === false) {
$whsem = self::getWarehouseManagement();
$whsem->requestItemBins($item->itemid);
$url = new Purl(self::pw('page')->url);
$url->query->set('itemID', $item->itemid);
self::pw('session')->redirect($url->getUrl(), $http301 = false);
}

// If Item is Lotted / Serialized show results to choose which lot or serial to move
$countLotserial = $inventory->count_itemid_records($item->itemid, $data->binID);
$items = $inventory->get_items_distinct($data->binID);
$warehouse = self::getCurrentUserWarehouse();

if ($config->twigloader->exists("warehouse/binr/$config->company/inventory-results.twig")) {
return $config->twig->render("warehouse/binr/$config->company/inventory-results.twig", ['config' => $config->binr, 'resultscount' => $countLotserial, 'items' => $items, 'warehouse' => $warehouse, 'inventory' => $inventory]);
}
return $config->twig->render('warehouse/binr/inventory-results.twig', ['config' => $config->binr, 'resultscount' => $countLotserial, 'items' => $items, 'warehouse' => $warehouse, 'inventory' => $inventory]);
}

private static function handleItem($data) {
$fields = ['lotnbr|text', 'serialnbr|text', 'itemID|text', 'binID|text'];
$data = self::sanitizeParametersShort($data, $fields);
$page = self::pw('page');
$config = self::pw('config');
$warehouse = self::getCurrentUserWarehouse();
$inventory = self::getInventorySearch();
$whsesession = self::getWhseSession();

if ($data->lotnbr) {
$page->scan = $data->lotnbr;
$resultscount = $inventory->count_lotserial_records($data->lotnbr, $data->binID);
}
if ($data->serialnbr) {
$page->scan = $data->serialnbr;
$resultscount = $inventory->count_lotserial_records($data->serialnbr, $data->binID);
}
if ($data->itemID) {
$page->scan = $data->itemID;
$resultscount = $inventory->count_lotserial_records($data->itemID, $data->binID);
}

if ($resultscount > 1) {
$items = $inventory->get_items_distinct();
return $config->twig->render('warehouse/binr/inventory-results.twig', ['resultscount' => $resultscount, 'items' => $items, 'inventory' => $inventory]);
}

$html = '';

if (empty(self::pw('session')->get('binr')) === false) {
$html .= $config->twig->render('warehouse/binr/binr-result.twig', ['whsesession' => $whsesession, 'nexturl' => $page->url]);
self::pw('session')->remove('binr');
return $html;
}

// $resultscount == 1

// Prepare Binr Form
$item = $data->lotnbr || $data->serialnbr ? $inventory->get_lotserial($page->scan, $data->binID) : $inventory->get_invsearch_by_itemid($page->scan, $data->binID);
$currentbins = BininfoQuery::create()->filterByItem(session_id(), $item)->select_bin_qty()->find();
// 1. Binr form
$page->formurl = $page->parent('template=warehouse-menu')->child('template=redir')->url;
$html .= $config->twig->render('warehouse/binr/binr-form.twig', ['config' => $config->binr, 'whsesession' => $whsesession, 'item' => $item, 'inventory' => $inventory]);
// 2. Choose From Bin Modal
$html .= $config->twig->render('warehouse/binr/from-bins-modal.twig', ['config' => $config->binr, 'item' => $item, 'bins' => $currentbins]);
// 3. Choose To Bin Modals
$html .= $config->twig->render('warehouse/binr/to-bins-modal.twig', ['config' => $config->binr, 'currentbins' => $currentbins, 'warehouse' => $warehouse, 'item' => $item, 'inventory' => $inventory]);
// 4. Warehouse Config JS
$bins = $warehouse->get_bins();
$availablebins = BininfoQuery::create()->filterBySessionItemid(session_id(), $item->itemID)->find()->toArray('Bin');
$jsconfig = array('warehouse' => array('id' => $whsesession->whseid, 'binarrangement' => $warehouse->get_binarrangementdescription(), 'bins' => $bins));
$html .= $config->twig->render('util/js-variables.twig', ['variables' => array('warehouse' => $jsconfig, 'validfrombins' => $availablebins)]);
return $html;
}

private static function searchItemForm($data) {
$page = self::pw('page');
$config = self::pw('config');
$page->formurl = $page->url;
return $config->twig->render('warehouse/item-form.twig');
}

public static function getWarehouseManagement() {
if (empty(self::$whsem)) {
self::$whsem = self::pw('modules')->get('WarehouseManagement');
}
return self::$whsem;
}

public static function getInventorySearch() {
if (empty(self::$inventory)) {
self::$inventory = self::pw('modules')->get('SearchInventory');
}
return self::$inventory;
}

public static function getCurrentUserWarehouse() {
if (empty(self::$warehouse)) {
self::$warehouse = WarehouseQuery::create()->findOneById(self::pw('user')->whseid);
}
return self::$warehouse;
}

public static function getWhseSession() {
if (empty(self::$whsesession)) {
self::$whsesession = WhsesessionQuery::create()->findOneBySessionid(session_id());
}
return self::$whsesession;
}

public static function init() {
$wm = self::pw('modules')->get('WarehouseManagement');
$wm->addHook('Page::binr_itemURL', function($event) {
$p = $event->object;
$item = $event->arguments(0);
$url = new Purl($p->parent('template=warehouse-menu')->child('template=redir')->url);
$url->query->set('action','search-item-bins');
$url->query->set('itemID', $item->itemid);
$url->query->set($item->get_itemtypeproperty(), $item->get_itemidentifier());
$url->query->set('binID', $item->bin);
$url->query->set('page', $p->fullURL->getUrl());
$event->return = $url->getUrl();
});

$wm->addHookProperty('Page::scan', function($event) {
$p = $event->object;
$event->return = !empty($p->scan) ? $p->scan : false;
});

$wm->addHookProperty('Page::tobin', function($event) {
$p = $event->object;
$event->return = !empty($p->tobin) ? $p->tobin : '';
});

$wm->addHookProperty('Page::frombin', function($event) {
$p = $event->object;
$event->return = !empty($p->frombin) ? $p->frombin : '';
});
}
}
6 changes: 3 additions & 3 deletions site/controllers/classes/ajax/json/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function getVxmByItemid($data) {
return $response;
}

public function validateVxmUpdateItmCost($data) {
public static function validateVxmUpdateItmCost($data) {
$fields = ['vendorID|text', 'vendoritemID|text', 'itemID|text', 'ordercode|text'];
$data = self::sanitizeParametersShort($data, $fields);
$response = ['allow' => false, 'confirm' => false];
Expand All @@ -149,8 +149,8 @@ public function validateVxmUpdateItmCost($data) {
$vxm = self::pw('modules')->get('XrefVxm');
$vxm->init_configs();
$xref = $vxm->xref($data->vendorID, $data->vendoritemID, $data->itemID);
if (array_key_exists($ordercode, ItemXrefVendor::OPTIONS_POORDERCODE)) {
$xref->setPo_ordercode($ordercode);
if (array_key_exists($data->ordercode, ItemXrefVendor::OPTIONS_POORDERCODE)) {
$xref->setPo_ordercode($data->ordercode);
}
$response['allow'] = $vxm->allow_itm_cost_update_xref($xref);
if ($response['allow']) {
Expand Down
Loading