From a7a001a368a9bcfcd0e7579c71e3d5c0082b1cf6 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 25 Mar 2021 16:32:00 -0500 Subject: [PATCH 001/106] Update ii-activity Twig --- .../items/ii/activity/activity-screen.twig | 50 ------------------- .../twig/items/ii/activity/activity.twig | 18 +++++++ .../twig/items/ii/activity/date-form.twig | 20 +++++--- .../twig/items/ii/activity/display.twig | 18 +++++++ .../twig/items/ii/activity/whse-table.twig | 29 +++++++++++ site/templates/twig/items/ii/display.twig | 4 +- 6 files changed, 79 insertions(+), 60 deletions(-) delete mode 100644 site/templates/twig/items/ii/activity/activity-screen.twig create mode 100644 site/templates/twig/items/ii/activity/activity.twig create mode 100644 site/templates/twig/items/ii/activity/display.twig create mode 100644 site/templates/twig/items/ii/activity/whse-table.twig diff --git a/site/templates/twig/items/ii/activity/activity-screen.twig b/site/templates/twig/items/ii/activity/activity-screen.twig deleted file mode 100644 index 4a25e2878..000000000 --- a/site/templates/twig/items/ii/activity/activity-screen.twig +++ /dev/null @@ -1,50 +0,0 @@ -{% if json['data'] %} - {% for id, warehouse in json['data'] %} -
-

- -

-
- - - - {% for column in json['columns'] %} - - {% endfor %} - - - {% for order in warehouse['orders'] %} - - - - {% for column, properties in json['columns'] %} - - {% endfor %} - - {% endfor %} - -
Docs - {{ column['heading'] }} -
- {% if docm.count_documents_activity(order['tran type'], order['tran reference']) %} - - View Documents for {{ order['tran type'] ~ ' ' ~ order['tran reference']}} - - {% endif %} - - {{ order[column] }} -
-
-
- {% endfor %} -{% else %} -
- {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': 'No Activity Data found starting from ' ~ date} %} -
-
-
-

Enter a new date

- {% include 'items/ii/activity/date-form.twig' %} -
-
-{% endif %} diff --git a/site/templates/twig/items/ii/activity/activity.twig b/site/templates/twig/items/ii/activity/activity.twig new file mode 100644 index 000000000..c25b0980a --- /dev/null +++ b/site/templates/twig/items/ii/activity/activity.twig @@ -0,0 +1,18 @@ +{% if json['data'] %} + {% for id, warehouse in json['data'] %} +
+

+ +

+
+ {% include 'items/ii/activity/whse-table.twig' %} +
+
+ {% endfor %} +{% else %} +
+ {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': 'No Activity Data found starting from ' ~ date} %} +
+

Enter a new date

+ {% include 'items/ii/activity/date-form.twig' %} +{% endif %} diff --git a/site/templates/twig/items/ii/activity/date-form.twig b/site/templates/twig/items/ii/activity/date-form.twig index 1abf93e5d..a5ad02b82 100644 --- a/site/templates/twig/items/ii/activity/date-form.twig +++ b/site/templates/twig/items/ii/activity/date-form.twig @@ -1,9 +1,13 @@ -
- - -
- - {% include 'util/date-picker.twig' with {'name': 'date', 'value': "now"|date_modify("-1 year")|date("m/d/Y") } %} +
+
+ + + +
+ + {% include 'util/date-picker.twig' with {'name': 'date', 'value': startdate } %} +
+ +
- - +
diff --git a/site/templates/twig/items/ii/activity/display.twig b/site/templates/twig/items/ii/activity/display.twig new file mode 100644 index 000000000..8513310f4 --- /dev/null +++ b/site/templates/twig/items/ii/activity/display.twig @@ -0,0 +1,18 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} + {{ json|json_encode()|raw }} +
+ {% include 'items/ii/activity/activity.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/activity/whse-table.twig b/site/templates/twig/items/ii/activity/whse-table.twig new file mode 100644 index 000000000..d0d1580cd --- /dev/null +++ b/site/templates/twig/items/ii/activity/whse-table.twig @@ -0,0 +1,29 @@ + + + + {% for column in json['columns'] %} + + {% endfor %} + + + {% for order in warehouse['orders'] %} + + + + {% for column, properties in json['columns'] %} + + {% endfor %} + + {% endfor %} + +
Docs + {{ column['heading'] }} +
+ {% if docm.count_documents_activity(order['tran type'], order['tran reference']) %} + + View Documents for {{ order['tran type'] ~ ' ' ~ order['tran reference']}} + + {% endif %} + + {{ order[column] }} +
diff --git a/site/templates/twig/items/ii/display.twig b/site/templates/twig/items/ii/display.twig index 8a1037141..ae5a17669 100644 --- a/site/templates/twig/items/ii/display.twig +++ b/site/templates/twig/items/ii/display.twig @@ -17,11 +17,11 @@
{% if page.is_print() %} - Back to Item + Item {% else %} - Back to Item + Item   From 39bc5cd9e0246e732ac4a3a7b638f9ebde03cda5 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 25 Mar 2021 16:32:18 -0500 Subject: [PATCH 002/106] Download Binr Controller --- site/controllers/classes/Mwm/binr/Binr.php | 263 +++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 site/controllers/classes/Mwm/binr/Binr.php diff --git a/site/controllers/classes/Mwm/binr/Binr.php b/site/controllers/classes/Mwm/binr/Binr.php new file mode 100644 index 000000000..6e50b0e62 --- /dev/null +++ b/site/controllers/classes/Mwm/binr/Binr.php @@ -0,0 +1,263 @@ +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 : ''; + }); + } +} From 5d6831642d2a99203392ac1a67a42a33ea503236 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 25 Mar 2021 16:32:39 -0500 Subject: [PATCH 003/106] Remove ii-activity template --- site/modules/Dplus/Dpages/DpagesMii.module | 19 +------- site/templates/ii-activity.php | 54 ---------------------- 2 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 site/templates/ii-activity.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 6b371fa8c..85e6bb23e 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-activity' => array( - 'name' => 'ii-activity', - 'fields' => array(), - ), 'ii-kit' => array( 'name' => 'ii-kit', 'fields' => array(), @@ -131,16 +127,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-activity' => array( - 'template' => 'ii-function', - 'name' => 'activity', - 'title' => 'Activity', - 'summary' => 'View Item Activity', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-act', - 'pw_template' => 'ii-activity', - 'jsoncode' => 'ii-activity' - ), 'ii-components' => array( 'template' => 'ii-function', 'name' => 'components', @@ -368,10 +354,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemactivityURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-activity'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('activity'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-activity.php b/site/templates/ii-activity.php deleted file mode 100644 index cbd105480..000000000 --- a/site/templates/ii-activity.php +++ /dev/null @@ -1,54 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Activity"; - - if ($input->get->date) { - $date = $input->get->text('date'); - $page->title = "$itemID Activity since $date"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemactivityURL($itemID)); - } - $session->activitytry = 0; - $refreshurl = $page->get_itemactivityURL($itemID); - - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $docm = $modules->get('DocumentManagementIi'); - $page->body .= $config->twig->render('items/ii/activity/activity-screen.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'date' => $date, 'itemID' => $itemID, 'docm' => $docm]); - } - } else { - if ($session->activitytry > 3) { - $page->headline = $page->title = "Activity File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->activitytry++; - $session->redirect($page->get_itemactivityURL($itemID)); - } - } - } else { - $form = $config->twig->render('items/ii/activity/date-form.twig', ['page' => $page, 'itemID' => $itemID]); - $page->body .= $config->twig->render('items/ii/requirements/links.twig', ['page' => $page, 'itemID' => $itemID]); - $page->body .= $html->h3('', 'Enter Starting Activity Date'); - $page->body .= $html->div('class=row', $html->div('class=col-sm-6', $form)); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } From d7dcbe1a521c3b25320ed622509cf7135ac45d85 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 08:29:14 -0500 Subject: [PATCH 004/106] Update display.twig --- site/templates/twig/items/ii/activity/display.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/site/templates/twig/items/ii/activity/display.twig b/site/templates/twig/items/ii/activity/display.twig index 8513310f4..20b7cb6d1 100644 --- a/site/templates/twig/items/ii/activity/display.twig +++ b/site/templates/twig/items/ii/activity/display.twig @@ -1,7 +1,6 @@ {% extends 'items/ii/display.twig' %} {% block body %} - {{ json|json_encode()|raw }}
{% include 'items/ii/activity/activity.twig' %}
From fee8e0f3d8311e11896b042b9ea8ddd588547f9e Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 08:29:33 -0500 Subject: [PATCH 005/106] Create and Implement ii-activity controller --- site/controllers/classes/mii/Ii/Activity.php | 163 ++++++++++++++++++ site/controllers/classes/mii/Ii/Ii.php | 7 +- .../vendor/composer/autoload_classmap.php | 2 + .../vendor/composer/autoload_static.php | 2 + site/templates/ii-item.php | 1 + 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 site/controllers/classes/mii/Ii/Activity.php diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php new file mode 100644 index 000000000..738889a6f --- /dev/null +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -0,0 +1,163 @@ +refresh) { + self::requestJson($data, session_id()); + self::pw('session')->redirect(self::activityUrl($data->itemID, $data->date), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + if (empty($data->date) === false) { + return self::activity($data); + } + return self::dateForm($data); + } + + public static function requestJson($vars) { + $fields = ['itemID|text', 'date|data', 'sessionID|text']; + $vars = self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; + $data = ["DBNAME=$db", 'IIACTIVITY', "ITEMID=$vars->itemID"]; + if ($vars->date) { + $dateYmd = date(self::DATE_FORMAT_DPLUS, strtotime($vars->date)); + $data[] = "DATE=$dateYmd"; + } + $requestor = self::pw('modules')->get('DplusRequest'); + $requestor->write_dplusfile($data, $vars->sessionID); + $requestor->cgi_request(self::pw('config')->cgis['default'], $vars->sessionID); + } + + public static function activityUrl($itemID, $date = '', $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('activity'); + $url->query->set('itemID', $itemID); + + if ($date) { + $url->query->set('date', $date); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + return $url->getUrl(); + } + + public static function activity($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $html = ''; + + $page = self::pw('page'); + $config = self::pw('config'); + $pages = self::pw('pages'); + $modules = self::pw('modules'); + $htmlwriter = $modules->get('HtmlWriter'); + $jsonM = $modules->get('JsonDataFiles'); + + $page->headline = "$data->itemID Activity"; + $html .= self::breadCrumbs();; + $html .= self::activityData($data); + return $html; + } + + private static function activityData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text', 'date|date']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID || date(self::DATE_FORMAT, $json['date']) != $data->date) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::activityUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + $session->setFor('ii', 'activity', 0); + $refreshurl = self::activityUrl($data->itemID, $data->date, $refresh = true); + $html .= self::activityDataDisplay($data, $json); + return $html; + } + + if ($session->getFor('ii', 'activity') > 3) { + $page->headline = "Pricing File could not be loaded"; + $html .= self::activityDataDisplay($data, $json); + return $html; + } else { + $session->setFor('ii', 'activity', ($session->getFor('ii', 'activity') + 1)); + $session->redirect(self::activityUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + } + + protected static function activityDataDisplay($data, $json) { + $jsonm = self::getJsonModule(); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Pricing File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $docm = self::pw('modules')->get('DocumentManagementIi'); + $page->refreshurl = self::activityUrl($data->itemID, $data->date, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $html = ''; + $html .= $config->twig->render('items/ii/activity/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->$jsonm, 'docm' => $docm, 'date' => $data->date]); + return $html; + } + + private static function dateForm($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $config = self::pw('config'); + $page = self::pw('page'); + + $iio = self::getIio(); + $options = $iio->useriio(self::pw('user')->loginid); + $startdate = date(self::DATE_FORMAT); + if ($options->daysactivity > 0) { + $startdate = date(self::DATE_FORMAT, strtotime("-$options->daysactivity days")); + } + + if (intval($options->dateactivity) > 0) { + $startdate = date(self::DATE_FORMAT, strtotime($options->dateactivity)); + } + + $page->headline = "II: $data->itemID Activity"; + $html = self::breadCrumbs(); + $html .= '

Enter Starting Activity Date

'; + $html .= $config->twig->render('items/ii/activity/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); + $page->js = $config->twig->render('items/ii/pricing/customer/form.js.twig'); + $config->scripts->append(self::pw('modules')->get('FileHasher')->getHashUrl('scripts/lib/jquery-validate.js')); + return $html; + } + +} diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index a5510a7a7..d3c40fa3c 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -9,6 +9,7 @@ use Controllers\Mii\Ii\Pricing; use Controllers\Mii\Ii\Usage; use Controllers\Mii\Ii\Costing; +use Controllers\Mii\Ii\Activity; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -17,9 +18,9 @@ class Ii extends AbstractController { 'costing' => 'Costing', 'pricing' => 'Pricing', 'usage' => 'Usage', + 'activity' => 'Activity' ]; - public static function item($data) { return Item::index($data); } @@ -44,6 +45,10 @@ public static function costing($data) { return Costing::index($data); } + public static function activity($data) { + return Activity::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 1215f5bd3..1e60a0d7b 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -32,6 +32,7 @@ 'Controllers\\Mci\\Ci' => $baseDir . '/classes/mci/Ci/Ci.php', 'Controllers\\Mii\\Ii' => $baseDir . '/classes/mii/Ii/Ii.php', 'Controllers\\Mii\\IiFunction' => $baseDir . '/classes/mii/Ii/IiFunction.php', + 'Controllers\\Mii\\Ii\\Activity' => $baseDir . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Costing' => $baseDir . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => $baseDir . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', @@ -59,4 +60,5 @@ 'Controllers\\Mso\\SalesOrder' => $baseDir . '/classes/mso/SalesOrder.php', 'Controllers\\Mso\\SalesOrder\\Documents' => $baseDir . '/classes/mso/SalesOrder/Documents.php', 'Controllers\\Mwm\\Menu' => $baseDir . '/classes/Mwm/Menu.php', + 'Controllers\\Wm\\Binr' => $baseDir . '/classes/Mwm/binr/Binr.php', ); diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 49fccdf5f..5cec087ba 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -33,6 +33,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mci\\Ci' => __DIR__ . '/../..' . '/classes/mci/Ci/Ci.php', 'Controllers\\Mii\\Ii' => __DIR__ . '/../..' . '/classes/mii/Ii/Ii.php', 'Controllers\\Mii\\IiFunction' => __DIR__ . '/../..' . '/classes/mii/Ii/IiFunction.php', + 'Controllers\\Mii\\Ii\\Activity' => __DIR__ . '/../..' . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Costing' => __DIR__ . '/../..' . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => __DIR__ . '/../..' . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', @@ -60,6 +61,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mso\\SalesOrder' => __DIR__ . '/../..' . '/classes/mso/SalesOrder.php', 'Controllers\\Mso\\SalesOrder\\Documents' => __DIR__ . '/../..' . '/classes/mso/SalesOrder/Documents.php', 'Controllers\\Mwm\\Menu' => __DIR__ . '/../..' . '/classes/Mwm/Menu.php', + 'Controllers\\Wm\\Binr' => __DIR__ . '/../..' . '/classes/Mwm/binr/Binr.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 9349e4724..f5e6abdde 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -11,6 +11,7 @@ ['GET', 'pricing', Ii::class, 'pricing'], ['GET', 'usage', Ii::class, 'usage'], ['GET', 'costing', Ii::class, 'costing'], + ['GET', 'activity', Ii::class, 'activity'], ]; $router = new Mvc\Router(); From 9914ee2ac3e4c3f3462339e4537ed08b00da5753 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 08:47:49 -0500 Subject: [PATCH 006/106] Display Activity Start Date --- site/templates/twig/items/ii/activity/display.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/site/templates/twig/items/ii/activity/display.twig b/site/templates/twig/items/ii/activity/display.twig index 20b7cb6d1..27822838a 100644 --- a/site/templates/twig/items/ii/activity/display.twig +++ b/site/templates/twig/items/ii/activity/display.twig @@ -2,6 +2,7 @@ {% block body %}
+

Activity since {{ date }}

{% include 'items/ii/activity/activity.twig' %}
{% endblock %} From 6fd297181de38edc2ef3f891482e3455fb263f9b Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 08:47:54 -0500 Subject: [PATCH 007/106] Update activity.twig --- site/templates/twig/items/ii/activity/activity.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/templates/twig/items/ii/activity/activity.twig b/site/templates/twig/items/ii/activity/activity.twig index c25b0980a..6796dfb2e 100644 --- a/site/templates/twig/items/ii/activity/activity.twig +++ b/site/templates/twig/items/ii/activity/activity.twig @@ -1,9 +1,9 @@ {% if json['data'] %} {% for id, warehouse in json['data'] %}
-

+

-

+
{% include 'items/ii/activity/whse-table.twig' %}
From 1f9ab1e6882f042068361780322b325a5eb89092 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 08:48:07 -0500 Subject: [PATCH 008/106] Fix $data->date usage --- site/controllers/classes/mii/Ii/Activity.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index 738889a6f..4e0527d8f 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -24,6 +24,9 @@ public static function index($data) { if ($data->refresh) { self::requestJson($data, session_id()); + if ($data->date) { + $data->date = date(self::DATE_FORMAT, $data->date); + } self::pw('session')->redirect(self::activityUrl($data->itemID, $data->date), $http301 = false); } self::pw('modules')->get('DpagesMii')->init_iipage(); @@ -35,13 +38,13 @@ public static function index($data) { } public static function requestJson($vars) { - $fields = ['itemID|text', 'date|data', 'sessionID|text']; + $fields = ['itemID|text', 'date|date', 'sessionID|text']; $vars = self::sanitizeParametersShort($vars, $fields); $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; $data = ["DBNAME=$db", 'IIACTIVITY', "ITEMID=$vars->itemID"]; if ($vars->date) { - $dateYmd = date(self::DATE_FORMAT_DPLUS, strtotime($vars->date)); + $dateYmd = date(self::DATE_FORMAT_DPLUS, $vars->date); $data[] = "DATE=$dateYmd"; } $requestor = self::pw('modules')->get('DplusRequest'); @@ -87,6 +90,10 @@ public static function activity($data) { private static function activityData($data) { $data = self::sanitizeParametersShort($data, ['itemID|text', 'date|date']); + if ($data->date) { + $data->timestamp = $data->date; + $data->date = date(self::DATE_FORMAT, $data->date); + } $jsonm = self::getJsonModule(); $json = $jsonm->getFile(self::JSONCODE); $page = self::pw('page'); @@ -95,7 +102,7 @@ private static function activityData($data) { $html = ''; if ($jsonm->exists(self::JSONCODE)) { - if ($json['itemid'] != $data->itemID || date(self::DATE_FORMAT, $json['date']) != $data->date) { + if ($json['itemid'] != $data->itemID || $json['date'] != date(self::DATE_FORMAT_DPLUS, $data->timestamp)) { $jsonm->delete(self::JSONCODE); $session->redirect(self::activityUrl($data->itemID, $data->date, $refresh = true), $http301 = false); } From 7bef8ef56205bb97019f06919dce99ab6465973f Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 09:57:19 -0500 Subject: [PATCH 009/106] Implement Card Display for ii-kit --- .../items/ii/components/kit-breakdown.twig | 30 --------- .../twig/items/ii/components/kit-screen.twig | 61 ------------------ .../components/kit/component-breakdown.twig | 15 +++++ .../twig/items/ii/components/kit/display.twig | 36 +++++++++++ .../{kit-form.twig => kit/qty-form.twig} | 5 +- .../twig/items/ii/components/kit/supply.twig | 63 +++++++++++++++++++ 6 files changed, 116 insertions(+), 94 deletions(-) delete mode 100644 site/templates/twig/items/ii/components/kit-breakdown.twig delete mode 100644 site/templates/twig/items/ii/components/kit-screen.twig create mode 100644 site/templates/twig/items/ii/components/kit/component-breakdown.twig create mode 100644 site/templates/twig/items/ii/components/kit/display.twig rename site/templates/twig/items/ii/components/{kit-form.twig => kit/qty-form.twig} (58%) create mode 100644 site/templates/twig/items/ii/components/kit/supply.twig diff --git a/site/templates/twig/items/ii/components/kit-breakdown.twig b/site/templates/twig/items/ii/components/kit-breakdown.twig deleted file mode 100644 index e16cae4f7..000000000 --- a/site/templates/twig/items/ii/components/kit-breakdown.twig +++ /dev/null @@ -1,30 +0,0 @@ -
-
-

Kit Breakdown for {{ itemID }}

-
-
- -
-
-
-
-
- - - - - - - {% for item in items %} - - - - - - {% endfor %} -
ComponentDescriptionUsage Rate
{{ item.itemid }}{{ item.get_description() }}{{ item.usage }}
-
-
-
diff --git a/site/templates/twig/items/ii/components/kit-screen.twig b/site/templates/twig/items/ii/components/kit-screen.twig deleted file mode 100644 index 1c56a854a..000000000 --- a/site/templates/twig/items/ii/components/kit-screen.twig +++ /dev/null @@ -1,61 +0,0 @@ -{% if (json['errormsg']) %} - {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': json['errormsg']} %} -{% else %} -

Kit Qty: {{ json['qtyneeded'] }}

- - {% for component in json['data']['component'] %} -
-
-

{{ component['component item'] }}

-
-
- -
-
-
- - - {% for column in json['columns']['component'] %} - - {% endfor %} - - - - {% for column, properties in json['columns']['component'] %} - - {% endfor %} - - -
- {{ column['heading'] }} -
- {{ component[column] }} -
- - - - {% for column in json['columns']['warehouse'] %} - - {% endfor %} - - - {% for warehouse in component['warehouse'] %} - - {% for column, properties in json['columns']['warehouse'] %} - - {% endfor %} - - {% endfor %} - -
- {{ column['heading'] }} -
- {{ warehouse[column] }} -
-
- {% endfor %} - -
Warehouses that meet the Requirement: {{ json['data']['whse meeting req']|join(', ') }}
-{% endif %} diff --git a/site/templates/twig/items/ii/components/kit/component-breakdown.twig b/site/templates/twig/items/ii/components/kit/component-breakdown.twig new file mode 100644 index 000000000..cbd622220 --- /dev/null +++ b/site/templates/twig/items/ii/components/kit/component-breakdown.twig @@ -0,0 +1,15 @@ +

Components

+ + + + + + + {% for component in components %} + + + + + + {% endfor %} +
ComponentDescriptionUsage Rate
{{ component.itemid }}{{ component.item.description }}{{ component.usage }}
diff --git a/site/templates/twig/items/ii/components/kit/display.twig b/site/templates/twig/items/ii/components/kit/display.twig new file mode 100644 index 000000000..760679f4e --- /dev/null +++ b/site/templates/twig/items/ii/components/kit/display.twig @@ -0,0 +1,36 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ +
+
+ {% include 'items/ii/components/kit/supply.twig' %} +
+
+ {% include 'items/ii/components/kit/component-breakdown.twig' %} +
+
+
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/components/kit-form.twig b/site/templates/twig/items/ii/components/kit/qty-form.twig similarity index 58% rename from site/templates/twig/items/ii/components/kit-form.twig rename to site/templates/twig/items/ii/components/kit/qty-form.twig index 96ca71891..af995af03 100644 --- a/site/templates/twig/items/ii/components/kit-form.twig +++ b/site/templates/twig/items/ii/components/kit/qty-form.twig @@ -1,9 +1,8 @@ -
- +
- +
diff --git a/site/templates/twig/items/ii/components/kit/supply.twig b/site/templates/twig/items/ii/components/kit/supply.twig new file mode 100644 index 000000000..fe5ff88a2 --- /dev/null +++ b/site/templates/twig/items/ii/components/kit/supply.twig @@ -0,0 +1,63 @@ +
+

Kit Qty: {{ json['qtyneeded'] }}

+
+
+ + +{% for component in json['data']['component'] %} +
+
+
{{ component['component item'] }}
+ + +
+
+
+ + + {% for column in json['columns']['component'] %} + + {% endfor %} + + + + {% for column, properties in json['columns']['component'] %} + + {% endfor %} + + +
+ {{ column['heading'] }} +
+ {{ component[column] }} +
+ + + + {% for column in json['columns']['warehouse'] %} + + {% endfor %} + + + {% for warehouse in component['warehouse'] %} + + {% for column, properties in json['columns']['warehouse'] %} + + {% endfor %} + + {% endfor %} + +
+ {{ column['heading'] }} +
+ {{ warehouse[column] }} +
+
+{% endfor %} +
+ +
+
Warehouses that meet the Requirement: {{ json['data']['whse meeting req']|join(', ') }}
+
From fd503e9bd2e6857bda86a4afd586fa66940e0f57 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 09:58:00 -0500 Subject: [PATCH 010/106] Remove ii-kit template --- site/templates/ii-kit.php | 67 ------------------------------------- site/templates/redir/ii.php | 24 ------------- 2 files changed, 91 deletions(-) delete mode 100644 site/templates/ii-kit.php diff --git a/site/templates/ii-kit.php b/site/templates/ii-kit.php deleted file mode 100644 index 3056eb9b9..000000000 --- a/site/templates/ii-kit.php +++ /dev/null @@ -1,67 +0,0 @@ -get('ConfigsIi'); - - if ($lookup_ii->lookup_itm($itemID)) { - $page->title = "$itemID Kit"; - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - - if ($input->get->qty) { - $module_json = $modules->get('JsonDataFiles'); - $page->jsoncode = "$page->jsoncode-$config_ii->option_components"; - - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemkitURL($itemID)); - } - $session->kittry = 0; - $refreshurl = $page->get_itemkitURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - $query_kit = KitQuery::create(); - $query_kit->filterByItemid($itemID); - - if ($query_kit->count()) { - $kit_items = KitItemsQuery::create()->filterByKititemid($itemID)->find(); - $page->body .= $config->twig->render('items/ii/components/kit-breakdown.twig', ['page' => $page, 'itemID' => $itemID, 'items' => $kit_items]); - } - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render('items/ii/components/kit-screen.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'itemID' => $itemID]); - } - } else { - if ($session->kittry > 3) { - $page->headline = $page->title = "Kit File could not be loaded"; - $page->body = $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->kittry++; - $session->redirect($page->get_itemkitURL($itemID)); - } - } - } else { - if ($config_ii->option_components == 'kit') { - $title = "Enter Kit Qty needed"; - $form = $config->twig->render('items/ii/components/kit-form.twig', ['page' => $page, 'itemID' => $itemID]); - } else { - $title = ''; - $form = $config_ii->option_components; - } - - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID]); - $page->body .= $html->h3('', $title); - $page->body .= $html->div('class=row', $html->div('class=col-sm-6', $form)); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 3933440ae..e85e70556 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-activity': - * Request II Activity JSON file - * Response: Creates II Activity JSON file - * DBNAME=$dplusdb - * IIACTIVITY - * ITEMID=$itemID - * break; * case 'ii-components': * Request II Components JSON file * Response: Creates II Components JSON file @@ -121,23 +114,6 @@ $session->loc = $url; } break; - case 'ii-activity': - $data = array("DBNAME=$dplusdb", 'IIACTIVITY', "ITEMID=$itemID"); - $date = $input->$requestmethod->text('date'); - - if (!empty($date)) { - $date_ymd = date('Ymd', strtotime($date)); - $data[] = "DATE=$date_ymd"; - } - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('date', $date); - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-activity')->httpUrl."?itemID=$itemID&date=$date"; - $session->loc = $url; - } - break; case 'ii-components': $config_ii = $modules->get('ConfigsIi'); $data = array("DBNAME=$dplusdb"); From dbfa077a89a770979df9f7dcdc16eef9efb46cd7 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 09:58:12 -0500 Subject: [PATCH 011/106] Update DpagesMii.module --- site/modules/Dplus/Dpages/DpagesMii.module | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 85e6bb23e..2c7fa6045 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-kit' => array( - 'name' => 'ii-kit', - 'fields' => array(), - ), 'ii-bom' => array( 'name' => 'ii-bom', 'fields' => array(), @@ -137,16 +133,6 @@ class DpagesMii extends Dpages implements Module { 'pw_template' => 'ii-components', 'jsoncode' => 'ii-components' ), - 'ii-kit' => array( - 'template' => 'ii-function', - 'name' => 'kit', - 'title' => 'Kit', - 'summary' => 'View Item Kit', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-kit', - 'pw_template' => 'ii-kit', - 'jsoncode' => 'ii-components' - ), 'ii-bom' => array( 'template' => 'ii-function', 'name' => 'bom', @@ -373,8 +359,8 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemkitURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-kit'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('kit'); $url->query->set('itemID', $itemID); $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); From 7dd81d25b58d055ad56b6252528e6be82ce82616 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Mar 2021 09:58:30 -0500 Subject: [PATCH 012/106] Create and Implement II Kit Controller --- site/controllers/classes/mii/Ii/Activity.php | 7 +- site/controllers/classes/mii/Ii/Ii.php | 8 +- site/controllers/classes/mii/Ii/Kit.php | 149 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 6 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/Kit.php diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index 4e0527d8f..1ee855cc7 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -1,8 +1,6 @@ getFor('ii', 'activity') > 3) { - $page->headline = "Pricing File could not be loaded"; + $page->headline = "Activity File could not be loaded"; $html .= self::activityDataDisplay($data, $json); return $html; } else { @@ -127,7 +125,7 @@ protected static function activityDataDisplay($data, $json) { $config = self::pw('config'); if ($jsonm->exists(self::JSONCODE) === false) { - return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Pricing File Not Found']); + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Activity File Not Found']); } if ($json['error']) { @@ -162,7 +160,6 @@ private static function dateForm($data) { $html = self::breadCrumbs(); $html .= '

Enter Starting Activity Date

'; $html .= $config->twig->render('items/ii/activity/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); - $page->js = $config->twig->render('items/ii/pricing/customer/form.js.twig'); $config->scripts->append(self::pw('modules')->get('FileHasher')->getHashUrl('scripts/lib/jquery-validate.js')); return $html; } diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index d3c40fa3c..9b666821c 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -10,6 +10,7 @@ use Controllers\Mii\Ii\Usage; use Controllers\Mii\Ii\Costing; use Controllers\Mii\Ii\Activity; +use Controllers\Mii\Ii\Kit; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -18,7 +19,8 @@ class Ii extends AbstractController { 'costing' => 'Costing', 'pricing' => 'Pricing', 'usage' => 'Usage', - 'activity' => 'Activity' + 'activity' => 'Activity', + 'kit' => 'Kit' ]; public static function item($data) { @@ -49,6 +51,10 @@ public static function activity($data) { return Activity::index($data); } + public static function kit($data) { + return Kit::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/classes/mii/Ii/Kit.php b/site/controllers/classes/mii/Ii/Kit.php new file mode 100644 index 000000000..05ed64f24 --- /dev/null +++ b/site/controllers/classes/mii/Ii/Kit.php @@ -0,0 +1,149 @@ +refresh) { + self::requestJson($data, session_id()); + self::pw('session')->redirect(self::kitUrl($data->itemID, $data->qty), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + if (empty($data->qty) === false) { + return self::kit($data); + } + return self::qtyForm($data); + } + + public static function requestJson($vars) { + $fields = ['itemID|text', 'qty|int', 'sessionID|text']; + $vars = self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; + $data = ["DBNAME=$db", 'IIKIT', "ITEMID=$vars->itemID", "QTYNEEDED=$vars->qty"]; + $requestor = self::pw('modules')->get('DplusRequest'); + $requestor->write_dplusfile($data, $vars->sessionID); + $requestor->cgi_request(self::pw('config')->cgis['default'], $vars->sessionID); + } + + public static function kitUrl($itemID, $qty = 0, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('kit'); + $url->query->set('itemID', $itemID); + + if ($qty) { + $url->query->set('qty', $qty); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + return $url->getUrl(); + } + + public static function kit($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $html = ''; + + $page = self::pw('page'); + $config = self::pw('config'); + $pages = self::pw('pages'); + $modules = self::pw('modules'); + $htmlwriter = $modules->get('HtmlWriter'); + $jsonM = $modules->get('JsonDataFiles'); + + $page->headline = "II: $data->itemID Kit"; + $html .= self::breadCrumbs();; + $html .= self::kitData($data); + return $html; + } + + private static function kitData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text', 'qty|int']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::kitUrl($data->itemID, $data->qty, $refresh = true), $http301 = false); + } + $session->setFor('ii', 'kit', 0); + $refreshurl = self::kitUrl($data->itemID, $data->qty, $refresh = true); + $html .= self::kitDataDisplay($data, $json); + return $html; + } + + if ($session->getFor('ii', 'kit') > 3) { + $page->headline = "Kit File could not be loaded"; + $html .= self::kitDataDisplay($data, $json); + return $html; + } else { + $session->setFor('ii', 'kit', ($session->getFor('ii', 'kit') + 1)); + $session->redirect(self::kitUrl($data->itemID, $data->qty, $refresh = true), $http301 = false); + } + } + + protected static function kitDataDisplay($data, $json) { + $jsonm = self::getJsonModule(); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Kit File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::kitUrl($data->itemID, $data->qty, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $html = ''; + $components = InvKitComponentQuery::create()->filterByKitid($data->itemID)->find(); + $html .= $config->twig->render('items/ii/components/kit/display.twig', ['item' => self::getItmItem($data->itemID), 'components' => $components, 'json' => $json, 'module_json' => $jsonm->jsonm,]); + return $html; + } + + private static function qtyForm($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $config = self::pw('config'); + $page = self::pw('page'); + + $page->headline = "II: $data->itemID Kit"; + $html = self::breadCrumbs(); + $html .= $config->twig->render('items/ii/components/kit/qty-form.twig', ['itemID' => $data->itemID]); + //$page->js = $config->twig->render('items/ii/pricing/customer/form.js.twig'); + $config->scripts->append(self::pw('modules')->get('FileHasher')->getHashUrl('scripts/lib/jquery-validate.js')); + return $html; + } + +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 1e60a0d7b..636df3f64 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -35,6 +35,7 @@ 'Controllers\\Mii\\Ii\\Activity' => $baseDir . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Costing' => $baseDir . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => $baseDir . '/classes/mii/Ii/Item.php', + 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 5cec087ba..de93f5c29 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -36,6 +36,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Activity' => __DIR__ . '/../..' . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Costing' => __DIR__ . '/../..' . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => __DIR__ . '/../..' . '/classes/mii/Ii/Item.php', + 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index f5e6abdde..ad8c100b8 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -12,6 +12,7 @@ ['GET', 'usage', Ii::class, 'usage'], ['GET', 'costing', Ii::class, 'costing'], ['GET', 'activity', Ii::class, 'activity'], + ['GET', 'kit', Ii::class, 'kit'], ]; $router = new Mvc\Router(); From 70bd1e0ecb5e336c6bc4be247e3027a32dd0590e Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:48:01 -0500 Subject: [PATCH 013/106] style(twig): Update II Bom to use ii display --- .../components/bom-consolidated-screen.twig | 63 ------------- .../twig/items/ii/components/bom-form.twig | 16 ---- .../ii/components/bom-single-screen.twig | 63 ------------- .../twig/items/ii/components/bom/display.twig | 31 +++++++ .../items/ii/components/bom/qty-form.twig | 20 +++++ .../twig/items/ii/components/bom/supply.twig | 58 ++++++++++++ .../items/ii/components/kit/qty-form.twig | 2 +- .../twig/items/ii/components/kit/supply.twig | 90 +++++++++---------- site/templates/twig/items/ii/display.twig | 37 ++++---- 9 files changed, 173 insertions(+), 207 deletions(-) delete mode 100644 site/templates/twig/items/ii/components/bom-consolidated-screen.twig delete mode 100644 site/templates/twig/items/ii/components/bom-form.twig delete mode 100644 site/templates/twig/items/ii/components/bom-single-screen.twig create mode 100644 site/templates/twig/items/ii/components/bom/display.twig create mode 100644 site/templates/twig/items/ii/components/bom/qty-form.twig create mode 100644 site/templates/twig/items/ii/components/bom/supply.twig diff --git a/site/templates/twig/items/ii/components/bom-consolidated-screen.twig b/site/templates/twig/items/ii/components/bom-consolidated-screen.twig deleted file mode 100644 index e5c1becda..000000000 --- a/site/templates/twig/items/ii/components/bom-consolidated-screen.twig +++ /dev/null @@ -1,63 +0,0 @@ -
-
- - - - - - - - - -
Bom Type Single
Qty {{ json['qtyneeded'] }}
-
-
-{% if (json['errormsg']) %} - {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': json['errormsg']} %} -{% else %} - {% for component in json['data']['components'] %} -

{{ component['component item'] }}

- - - - {% for column in json['columns']['component'] %} - - {% endfor %} - - - - {% for column, properties in json['columns']['component'] %} - - {% endfor %} - - -
- {{ column['heading'] }} -
- {{ component[column] }} -
- - - - {% for column in json['columns']['warehouse'] %} - - {% endfor %} - - - {% for warehouse in component['warehouse'] %} - - {% for column, properties in json['columns']['warehouse'] %} - - {% endfor %} - - {% endfor %} - -
- {{ column['heading'] }} -
- {{ warehouse[column] }} -
- -
Warehouses that meet the Requirement: {{ json['data']['whse meeting req']|join(', ') }}
- {% endfor %} -{% endif %} diff --git a/site/templates/twig/items/ii/components/bom-form.twig b/site/templates/twig/items/ii/components/bom-form.twig deleted file mode 100644 index 9e41ae8ce..000000000 --- a/site/templates/twig/items/ii/components/bom-form.twig +++ /dev/null @@ -1,16 +0,0 @@ -
- - -
- - -
-
- - -
- -
diff --git a/site/templates/twig/items/ii/components/bom-single-screen.twig b/site/templates/twig/items/ii/components/bom-single-screen.twig deleted file mode 100644 index e5c1becda..000000000 --- a/site/templates/twig/items/ii/components/bom-single-screen.twig +++ /dev/null @@ -1,63 +0,0 @@ -
-
- - - - - - - - - -
Bom Type Single
Qty {{ json['qtyneeded'] }}
-
-
-{% if (json['errormsg']) %} - {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': json['errormsg']} %} -{% else %} - {% for component in json['data']['components'] %} -

{{ component['component item'] }}

- - - - {% for column in json['columns']['component'] %} - - {% endfor %} - - - - {% for column, properties in json['columns']['component'] %} - - {% endfor %} - - -
- {{ column['heading'] }} -
- {{ component[column] }} -
- - - - {% for column in json['columns']['warehouse'] %} - - {% endfor %} - - - {% for warehouse in component['warehouse'] %} - - {% for column, properties in json['columns']['warehouse'] %} - - {% endfor %} - - {% endfor %} - -
- {{ column['heading'] }} -
- {{ warehouse[column] }} -
- -
Warehouses that meet the Requirement: {{ json['data']['whse meeting req']|join(', ') }}
- {% endfor %} -{% endif %} diff --git a/site/templates/twig/items/ii/components/bom/display.twig b/site/templates/twig/items/ii/components/bom/display.twig new file mode 100644 index 000000000..5acc89245 --- /dev/null +++ b/site/templates/twig/items/ii/components/bom/display.twig @@ -0,0 +1,31 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+
+
+ BoM Type: {{ type|capitalize }} +
+
+ Qty: {{ json['qtyneeded'] }} +
+ +
+
+ + {% include 'items/ii/components/bom/supply.twig' %} +{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/components/bom/qty-form.twig b/site/templates/twig/items/ii/components/bom/qty-form.twig new file mode 100644 index 000000000..3689a9c4e --- /dev/null +++ b/site/templates/twig/items/ii/components/bom/qty-form.twig @@ -0,0 +1,20 @@ +
+
+
+ +
+ + +
+
+ + +
+ +
+
+
diff --git a/site/templates/twig/items/ii/components/bom/supply.twig b/site/templates/twig/items/ii/components/bom/supply.twig new file mode 100644 index 000000000..cc262efdb --- /dev/null +++ b/site/templates/twig/items/ii/components/bom/supply.twig @@ -0,0 +1,58 @@ +
+ {% for component in json['data']['component'] %} +
+
+
{{ component['component item'] }}
+ + +
+
+
+ + + {% for column in json['columns']['component'] %} + + {% endfor %} + + + + {% for column, properties in json['columns']['component'] %} + + {% endfor %} + + +
+ {{ column['heading'] }} +
+ {{ component[column] }} +
+ + + + {% for column in json['columns']['warehouse'] %} + + {% endfor %} + + + {% for warehouse in component['warehouse'] %} + + {% for column, properties in json['columns']['warehouse'] %} + + {% endfor %} + + {% endfor %} + +
+ {{ column['heading'] }} +
+ {{ warehouse[column] }} +
+
+ {% endfor %} +
+ +
+
Warehouses that meet the Requirement: {{ json['data']['whse meeting req']|join(', ') }}
+
diff --git a/site/templates/twig/items/ii/components/kit/qty-form.twig b/site/templates/twig/items/ii/components/kit/qty-form.twig index af995af03..aa50a3aa8 100644 --- a/site/templates/twig/items/ii/components/kit/qty-form.twig +++ b/site/templates/twig/items/ii/components/kit/qty-form.twig @@ -4,5 +4,5 @@
- + diff --git a/site/templates/twig/items/ii/components/kit/supply.twig b/site/templates/twig/items/ii/components/kit/supply.twig index fe5ff88a2..53d5b200f 100644 --- a/site/templates/twig/items/ii/components/kit/supply.twig +++ b/site/templates/twig/items/ii/components/kit/supply.twig @@ -2,60 +2,58 @@

Kit Qty: {{ json['qtyneeded'] }}

+ {% for component in json['data']['component'] %} +
+
+
{{ component['component item'] }}
- -{% for component in json['data']['component'] %} -
-
-
{{ component['component item'] }}
- - + +
-
-
- - - {% for column in json['columns']['component'] %} - - {% endfor %} - - - - {% for column, properties in json['columns']['component'] %} - +
+
- {{ column['heading'] }} -
- {{ component[column] }} -
+ + {% for column in json['columns']['component'] %} + {% endfor %} - - -
+ {{ column['heading'] }} +
- - - - {% for column in json['columns']['warehouse'] %} - - {% endfor %} - - - {% for warehouse in component['warehouse'] %} + + - {% for column, properties in json['columns']['warehouse'] %} + {% for column, properties in json['columns']['component'] %} {% endfor %} - {% endfor %} - -
- {{ column['heading'] }} -
- {{ warehouse[column] }} + {{ component[column] }}
-
-{% endfor %} + + + + + + {% for column in json['columns']['warehouse'] %} + + {% endfor %} + + + {% for warehouse in component['warehouse'] %} + + {% for column, properties in json['columns']['warehouse'] %} + + {% endfor %} + + {% endfor %} + +
+ {{ column['heading'] }} +
+ {{ warehouse[column] }} +
+
+ {% endfor %}
diff --git a/site/templates/twig/items/ii/display.twig b/site/templates/twig/items/ii/display.twig index ae5a17669..859918a39 100644 --- a/site/templates/twig/items/ii/display.twig +++ b/site/templates/twig/items/ii/display.twig @@ -2,7 +2,7 @@ {% block header %}
-
+
Item ID:
@@ -14,28 +14,29 @@ {% block links %}
-
- {% if page.is_print() %} - - Item - - {% else %} - +
+
+ Item -   - - Print - -   - {% if page.refreshurl %} +
+
+ {% if page.is_print() == false %} + + Print + + {% endif %} +
+
+ {% if page.is_print() == false and page.refreshurl %} - Refresh Data + Refresh -   - Data Current as of {{ page.lastmodified|date('m/d/Y h:i A') }} {% endif %} - {% endif %} +
+
+ Data Timestamp: {{ page.lastmodified|date('m/d/Y h:i A') }} +
From 5f14a0457101dbb84eb759132d7151e18e9e91c5 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:48:11 -0500 Subject: [PATCH 014/106] Update ConfigsIi.module --- site/modules/Dplus/Configs/ConfigsIi.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/modules/Dplus/Configs/ConfigsIi.module b/site/modules/Dplus/Configs/ConfigsIi.module index 18ca4abf0..4d7811ab4 100644 --- a/site/modules/Dplus/Configs/ConfigsIi.module +++ b/site/modules/Dplus/Configs/ConfigsIi.module @@ -12,8 +12,8 @@ class ConfigsIi extends Process implements ConfigurableModule { 'option_components' => array( 'type' => 'select', 'label' => 'Kit or BOM', - 'description' => 'Break Down Compnenents as Kit or BOM', - 'notes' => "Break Down Compnenents as Kit or BOM", + 'description' => 'Break Down Components as Kit or BOM', + 'notes' => "Break Down Components as Kit or BOM", 'options' => array('kit' => 'Kit', 'bom' => 'BOM') ) ); From 6a35fcb179885507992c9d8cf279dd52f4b090b2 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:49:36 -0500 Subject: [PATCH 015/106] feat: add sendRequest function for dplus requests --- site/controllers/classes/mii/Ii/IiFunction.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/IiFunction.php b/site/controllers/classes/mii/Ii/IiFunction.php index 072fee4cd..13bc2ddbf 100644 --- a/site/controllers/classes/mii/Ii/IiFunction.php +++ b/site/controllers/classes/mii/Ii/IiFunction.php @@ -95,7 +95,14 @@ public static function getItmItem($itemID) { public static function requestIiItem($itemID, $sessionID = '') { $sessionID = $sessionID ? $sessionID : session_id(); $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; - $data = array("DBNAME=$db", 'IISELECT', "ITEMID=$itemID"); + $data = array('IISELECT', "ITEMID=$itemID"); + self::sendRequest($data, $sessionID); + } + + protected static function sendRequest(array $data, $sessionID = '') { + $sessionID = $sessionID ? $sessionID : session_id(); + $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; + $data = array_merge(["DBNAME=$db"], $data); $requestor = self::pw('modules')->get('DplusRequest'); $requestor->write_dplusfile($data, $sessionID); $requestor->cgi_request(self::pw('config')->cgis['default'], $sessionID); From bc677e03b868f347cd10696f2e8ef368fbf0a2a1 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:49:56 -0500 Subject: [PATCH 016/106] Update Kit.php --- site/controllers/classes/mii/Ii/Kit.php | 1 - 1 file changed, 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Kit.php b/site/controllers/classes/mii/Ii/Kit.php index 05ed64f24..c1fff11fa 100644 --- a/site/controllers/classes/mii/Ii/Kit.php +++ b/site/controllers/classes/mii/Ii/Kit.php @@ -23,7 +23,6 @@ public static function index($data) { return self::alertInvalidItemPermissions($data); } - if ($data->refresh) { self::requestJson($data, session_id()); self::pw('session')->redirect(self::kitUrl($data->itemID, $data->qty), $http301 = false); From 73fc191af6a4ed03a9e0c68fd4e6c1653b6680f4 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:51:19 -0500 Subject: [PATCH 017/106] refactor: create and implement Ii\Bom controller --- site/controllers/classes/mii/Ii/Bom.php | 147 ++++++++++++++++++ site/controllers/classes/mii/Ii/Ii.php | 8 +- .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/modules/Dplus/Dpages/DpagesMii.module | 42 +---- site/templates/ii-item.php | 1 + 6 files changed, 160 insertions(+), 40 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/Bom.php diff --git a/site/controllers/classes/mii/Ii/Bom.php b/site/controllers/classes/mii/Ii/Bom.php new file mode 100644 index 000000000..6a768121e --- /dev/null +++ b/site/controllers/classes/mii/Ii/Bom.php @@ -0,0 +1,147 @@ +refresh) { + self::requestJson($data, session_id()); + self::pw('session')->redirect(self::bomUrl($data->itemID, $data->qty, $data->type), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + if (empty($data->qty) === false || empty($data->type) === false) { + return self::bom($data); + } + return self::qtyForm($data); + } + + public static function requestJson($vars) { + $fields = ['itemID|text', 'qty|int', 'sessionID|text', 'type|text']; + $vars = self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $type = $data->type == 'consolidated' ? 'IIBOMCONS' : 'IIBOMSINGLE'; + $data = [$type,"ITEMID=$vars->itemID","QTYNEEDED=$vars->qty"]; + self::sendRequest($data, $vars->sessionID); + } + + public static function bomUrl($itemID, $qty = 0, $type = '', $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('bom'); + $url->query->set('itemID', $itemID); + + if ($qty) { + $url->query->set('qty', $qty); + + if ($type) { + $url->query->set('type', $type); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + } + return $url->getUrl(); + } + + public static function bom($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text', 'qty|int', 'type|text']); + $html = ''; + + $page = self::pw('page'); + $config = self::pw('config'); + $pages = self::pw('pages'); + $modules = self::pw('modules'); + $htmlwriter = $modules->get('HtmlWriter'); + $jsonM = $modules->get('JsonDataFiles'); + + $page->headline = "II: $data->itemID BoM"; + $html .= self::breadCrumbs();; + $html .= self::bomData($data); + return $html; + } + + private static function bomData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text', 'qty|int', 'type|text']); + $jsonm = self::getJsonModule(); + $jsoncode = self::JSONCODE . "-$data->type"; + $json = $jsonm->getFile($jsoncode); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists($jsoncode)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete($jsoncode); + $session->redirect(self::bomUrl($data->itemID, $data->qty, $data->type, $refresh = true), $http301 = false); + } + $session->setFor('ii', 'bom', 0); + $refreshurl = self::bomUrl($data->itemID, $data->qty, $data->type, $refresh = true); + $html .= self::bomDataDisplay($data, $json); + return $html; + } + + if ($session->getFor('ii', 'bom') > 3) { + $page->headline = "BoM File could not be loaded"; + $html .= self::bomDataDisplay($data, $json); + return $html; + } else { + $session->setFor('ii', 'bom', ($session->getFor('ii', 'bom') + 1)); + $session->redirect(self::bomUrl($data->itemID, $data->qty, $data->type, $refresh = true), $http301 = false); + } + } + + protected static function bomDataDisplay($data, $json) { + $jsonm = self::getJsonModule(); + $config = self::pw('config'); + $jsoncode = self::JSONCODE . "-$data->type"; + + if ($jsonm->exists($jsoncode) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'BoM File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::bomUrl($data->itemID, $data->qty, $data->type, $refresh = true); + $page->lastmodified = $jsonm->lastModified($jsoncode); + $html = ''; + $html .= $config->twig->render('items/ii/components/bom/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->jsonm, 'type' => $data->type]); + return $html; + } + + private static function qtyForm($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $config = self::pw('config'); + $page = self::pw('page'); + + $page->headline = "II: $data->itemID BoM"; + $html = self::breadCrumbs(); + $html .= $config->twig->render('items/ii/components/bom/qty-form.twig', ['itemID' => $data->itemID]); + $config->scripts->append(self::pw('modules')->get('FileHasher')->getHashUrl('scripts/lib/jquery-validate.js')); + return $html; + } + +} diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 9b666821c..1dc0b7a04 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -11,6 +11,7 @@ use Controllers\Mii\Ii\Costing; use Controllers\Mii\Ii\Activity; use Controllers\Mii\Ii\Kit; +use Controllers\Mii\Ii\Bom; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -20,7 +21,8 @@ class Ii extends AbstractController { 'pricing' => 'Pricing', 'usage' => 'Usage', 'activity' => 'Activity', - 'kit' => 'Kit' + 'kit' => 'Kit', + 'bom' => 'BoM' ]; public static function item($data) { @@ -55,6 +57,10 @@ public static function kit($data) { return Kit::index($data); } + public static function bom($data) { + return Bom::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 636df3f64..d08b3595e 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -33,6 +33,7 @@ 'Controllers\\Mii\\Ii' => $baseDir . '/classes/mii/Ii/Ii.php', 'Controllers\\Mii\\IiFunction' => $baseDir . '/classes/mii/Ii/IiFunction.php', 'Controllers\\Mii\\Ii\\Activity' => $baseDir . '/classes/mii/Ii/Activity.php', + 'Controllers\\Mii\\Ii\\Bom' => $baseDir . '/classes/mii/Ii/Bom.php', 'Controllers\\Mii\\Ii\\Costing' => $baseDir . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => $baseDir . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index de93f5c29..6f2e91d67 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -34,6 +34,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii' => __DIR__ . '/../..' . '/classes/mii/Ii/Ii.php', 'Controllers\\Mii\\IiFunction' => __DIR__ . '/../..' . '/classes/mii/Ii/IiFunction.php', 'Controllers\\Mii\\Ii\\Activity' => __DIR__ . '/../..' . '/classes/mii/Ii/Activity.php', + 'Controllers\\Mii\\Ii\\Bom' => __DIR__ . '/../..' . '/classes/mii/Ii/Bom.php', 'Controllers\\Mii\\Ii\\Costing' => __DIR__ . '/../..' . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => __DIR__ . '/../..' . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 2c7fa6045..a4f6d5c56 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-bom' => array( - 'name' => 'ii-bom', - 'fields' => array(), - ), 'ii-where-used' => array( 'name' => 'ii-where-used', 'fields' => array(), @@ -123,26 +119,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-components' => array( - 'template' => 'ii-function', - 'name' => 'components', - 'title' => 'Components', - 'summary' => 'View Item Components', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-bom', - 'pw_template' => 'ii-components', - 'jsoncode' => 'ii-components' - ), - 'ii-bom' => array( - 'template' => 'ii-function', - 'name' => 'bom', - 'title' => 'BOM', - 'summary' => 'View Item BOM', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-bom', - 'pw_template' => 'ii-bom', - 'jsoncode' => 'ii-components' - ), 'ii-where-used' => array( 'template' => 'ii-function', 'name' => 'where-used', @@ -345,34 +321,22 @@ class DpagesMii extends Dpages implements Module { $url->query->set('itemID', $itemID); $event->return = $url->getUrl(); }); - - $this->addHook('Page::get_itemcomponentsURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-components'); - $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); - $event->return = $url->getUrl(); - }); - + $this->addHook('Page::get_itemkitURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); $url->path->add('kit'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); $this->addHook('Page::get_itembomURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-bom'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('bom'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index ad8c100b8..483a36eb1 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -13,6 +13,7 @@ ['GET', 'costing', Ii::class, 'costing'], ['GET', 'activity', Ii::class, 'activity'], ['GET', 'kit', Ii::class, 'kit'], + ['GET', 'bom', Ii::class, 'bom'], ]; $router = new Mvc\Router(); From aa5e1fa05fb745d2edf850249651d1ff0bd82eb9 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 13:53:18 -0500 Subject: [PATCH 018/106] chore: remove ii-bom template from PW --- site/templates/ii-bom.php | 59 ---------------------- site/templates/ii-components.php | 87 -------------------------------- 2 files changed, 146 deletions(-) delete mode 100644 site/templates/ii-bom.php delete mode 100644 site/templates/ii-components.php diff --git a/site/templates/ii-bom.php b/site/templates/ii-bom.php deleted file mode 100644 index d58d728d9..000000000 --- a/site/templates/ii-bom.php +++ /dev/null @@ -1,59 +0,0 @@ -get('ConfigsIi'); - - if ($lookup_ii->lookup_itm($itemID)) { - $page->title = "$itemID BOM"; - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - - if ($input->get->qty) { - $module_json = $modules->get('JsonDataFiles'); - - $bomtype = $input->get->text('bomtype'); - $page->jsoncode = "$page->jsoncode-$config_ii->option_components-$bomtype"; - - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itembomURL($itemID)); - } - $session->activitytry = 0; - $refreshurl = $page->get_itembomURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - $bomtype = $input->get->text('bomtype'); - $page->jsoncode = "$page->jsoncode-$config_ii->option_components-$bomtype"; - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render("items/ii/components/bom-$bomtype-screen.twig", ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'itemID' => $itemID]); - } - } else { - if ($session->activitytry > 3) { - $page->headline = $page->title = "BOM File could not be loaded"; - $page->body = $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->activitytry++; - $session->redirect($page->get_itembomURL($itemID)); - } - } - } else { - $title = "Enter BOM Qty needed"; - $form = $config->twig->render('items/ii/components/bom-form.twig', ['page' => $page, 'itemID' => $itemID]); - - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID]); - $page->body .= $html->h3('', $title); - $page->body .= $html->div('class=row', $html->div('class=col-sm-6', $form)); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/ii-components.php b/site/templates/ii-components.php deleted file mode 100644 index 1258b8446..000000000 --- a/site/templates/ii-components.php +++ /dev/null @@ -1,87 +0,0 @@ -get('ConfigsIi'); - - if ($lookup_ii->lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Components"; - - if ($input->get->qty) { - $module_json = $modules->get('JsonDataFiles'); - - if ($config_ii->option_components == 'kit') { - $page->jsoncode = "$page->jsoncode-$config_ii->option_components"; - } elseif ($config_ii->option_components == 'bom') { - $bomtype = $input->get->text('bomtype'); - $page->jsoncode = "$page->jsoncode-$config_ii->option_components-$bomtype"; - } - - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemcomponentsURL($itemID)); - } - $session->activitytry = 0; - $refreshurl = $page->get_itemcomponentsURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($config_ii->option_components == 'kit') { - $query_kit = KitQuery::create(); - $query_kit->filterByItemid($itemID); - - if ($query_kit->count()) { - $kit_items = KitItemsQuery::create()->filterByKititemid($itemID)->find(); - $page->body .= $config->twig->render('items/ii/components/kit-breakdown.twig', ['page' => $page, 'itemID' => $itemID, 'items' => $kit_items]); - } - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render('items/ii/components/kit-screen.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'itemID' => $itemID]); - } - } elseif ($config_ii->option_components == 'bom') { - $bomtype = $input->get->text('bomtype'); - $page->jsoncode = "$page->jsoncode-$config_ii->option_components-$bomtype"; - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render("items/ii/components/bom-$bomtype-screen.twig", ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'itemID' => $itemID]); - } - } - } else { - if ($session->activitytry > 3) { - $page->headline = $page->title = "Components File could not be loaded"; - $page->body = $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->activitytry++; - $session->redirect($page->get_itemcomponentsURL($itemID)); - } - } - } else { - if ($config_ii->option_components == 'kit') { - $title = "Enter Kit Qty needed"; - $form = $config->twig->render('items/ii/components/kit-form.twig', ['page' => $page, 'itemID' => $itemID]); - } elseif ($config_ii->option_components == 'bom') { - $title = "Enter BOM Qty needed"; - $form = $config->twig->render('items/ii/components/bom-form.twig', ['page' => $page, 'itemID' => $itemID]); - } else { - $title = ''; - $form = $config_ii->option_components; - } - - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID]); - $page->body .= $html->h3('', $title); - $page->body .= $html->div('class=row', $html->div('class=col-sm-6', $form)); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } From 30a999fd96dc2e0d6b6059271587d3360c7de1f7 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:32:17 -0500 Subject: [PATCH 019/106] style(twig): update where used to use ii-display --- .../twig/items/ii/where-used/bom.twig | 1 - .../twig/items/ii/where-used/display.twig | 25 +++++++++++++++++++ .../twig/items/ii/where-used/kit.twig | 1 - .../twig/items/ii/where-used/where-used.twig | 11 -------- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 site/templates/twig/items/ii/where-used/display.twig delete mode 100644 site/templates/twig/items/ii/where-used/where-used.twig diff --git a/site/templates/twig/items/ii/where-used/bom.twig b/site/templates/twig/items/ii/where-used/bom.twig index fca2c141b..e2555e8df 100644 --- a/site/templates/twig/items/ii/where-used/bom.twig +++ b/site/templates/twig/items/ii/where-used/bom.twig @@ -1,4 +1,3 @@ -

BOM

{% for column in json['columns']['bom'] %} diff --git a/site/templates/twig/items/ii/where-used/display.twig b/site/templates/twig/items/ii/where-used/display.twig new file mode 100644 index 000000000..47755ddc8 --- /dev/null +++ b/site/templates/twig/items/ii/where-used/display.twig @@ -0,0 +1,25 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% if json['data']['kit'] %} +

Kits

+ {% include 'items/ii/where-used/kit.twig' %} + {% endif %} + + {% if json['data']['bom'] %} +

BoMs

+ {% include 'items/ii/where-used/bom.twig' %} + {% endif %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/where-used/kit.twig b/site/templates/twig/items/ii/where-used/kit.twig index cf5d23086..b0f011c68 100644 --- a/site/templates/twig/items/ii/where-used/kit.twig +++ b/site/templates/twig/items/ii/where-used/kit.twig @@ -1,4 +1,3 @@ -

Kits

{% for column in json['columns']['kit'] %} diff --git a/site/templates/twig/items/ii/where-used/where-used.twig b/site/templates/twig/items/ii/where-used/where-used.twig deleted file mode 100644 index ff35ea3d1..000000000 --- a/site/templates/twig/items/ii/where-used/where-used.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% if json['error'] %} - {% include 'util/alert.twig' with {'type': 'warning','iconclass': 'fa fa-warning fa-2x', 'title': 'Error!', 'message': json['errormsg']} %} -{% else %} - {% if json['data']['kit'] %} - {% include 'items/ii/where-used/kit.twig' %} - {% endif %} - - {% if json['data']['bom'] %} - {% include 'items/ii/where-used/bom.twig' %} - {% endif %} -{% endif %} From f919e87c4a2cc62e51d310f4bafdae53cd5515eb Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:32:38 -0500 Subject: [PATCH 020/106] Update ii.php --- site/templates/redir/ii.php | 88 ------------------------------------- 1 file changed, 88 deletions(-) diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index e85e70556..7a0d3ea05 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,16 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-components': - * Request II Components JSON file - * Response: Creates II Components JSON file - * DBNAME=$dplusdb - * IIKIT - * IIBOMSINGLE - * IIBOMCONS - * ITEMID=$itemID - * QTYNEEDED=$qty - * break; * case 'ii-where-used': * Request II Where Used JSON file * Response: Creates II Where Used JSON file @@ -114,84 +104,6 @@ $session->loc = $url; } break; - case 'ii-components': - $config_ii = $modules->get('ConfigsIi'); - $data = array("DBNAME=$dplusdb"); - $qty = $input->$requestmethod->int('qty'); - - if ($config_ii->option_components == 'kit') { - $data[] = 'IIKIT'; - } elseif ($config_ii->option_components == 'bom') { - $bomtype = $input->$requestmethod->text('bomtype'); - if ($bomtype == 'single') { - $data[] = 'IIBOMSINGLE'; - } else { - $data[] = 'IIBOMCONS'; - } - } - - $data[] = "ITEMID=$itemID"; - $data[] = "QTYNEEDED=$qty"; - - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('qty', $qty); - if ($config_ii->option_components == 'bom') { - $url->query->set('bomtype', $bomtype); - } - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-components')->httpUrl."?itemID=$itemID&qty=$qty"; - if ($config_ii->option_components == 'bom') { - $url .= "&bomtype=$bomtype"; - } - $session->loc = $url; - } - break; - case 'ii-kit': - $config_ii = $modules->get('ConfigsIi'); - $data = array("DBNAME=$dplusdb"); - $qty = $input->$requestmethod->int('qty'); - - $data[] = 'IIKIT'; - $data[] = "ITEMID=$itemID"; - $data[] = "QTYNEEDED=$qty"; - - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('qty', $qty); - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-kit')->httpUrl."?itemID=$itemID&qty=$qty"; - $session->loc = $url; - } - break; - case 'ii-bom': - $config_ii = $modules->get('ConfigsIi'); - $data = array("DBNAME=$dplusdb"); - $qty = $input->$requestmethod->int('qty'); - - $bomtype = $input->$requestmethod->text('bomtype'); - if ($bomtype == 'single') { - $data[] = 'IIBOMSINGLE'; - } else { - $data[] = 'IIBOMCONS'; - } - - $data[] = "ITEMID=$itemID"; - $data[] = "QTYNEEDED=$qty"; - - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('qty', $qty); - $url->query->set('bomtype', $bomtype); - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-bom')->httpUrl."?itemID=$itemID&qty=$qty"; - $url .= "&bomtype=$bomtype"; - $session->loc = $url; - } - break; case 'ii-where-used': $data = array("DBNAME=$dplusdb", 'IIWHEREUSED', "ITEMID=$itemID"); From 93233296615449c03e5d4783c4feca9bdf49e1e8 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:32:44 -0500 Subject: [PATCH 021/106] Update Activity.php --- site/controllers/classes/mii/Ii/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index 1ee855cc7..fee7d6ce9 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -80,7 +80,7 @@ public static function activity($data) { $htmlwriter = $modules->get('HtmlWriter'); $jsonM = $modules->get('JsonDataFiles'); - $page->headline = "$data->itemID Activity"; + $page->headline = "II: $data->itemID Activity"; $html .= self::breadCrumbs();; $html .= self::activityData($data); return $html; From 127e6c64508c0da5b2589e4060050d1123367217 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:33:12 -0500 Subject: [PATCH 022/106] refactor: create and implement Ii\WhereUsed controller --- site/controllers/classes/mii/Ii/Ii.php | 8 +- site/controllers/classes/mii/Ii/WhereUsed.php | 118 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 site/controllers/classes/mii/Ii/WhereUsed.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 1dc0b7a04..45d441d72 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -12,6 +12,7 @@ use Controllers\Mii\Ii\Activity; use Controllers\Mii\Ii\Kit; use Controllers\Mii\Ii\Bom; +use Controllers\Mii\Ii\WhereUsed; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -22,7 +23,8 @@ class Ii extends AbstractController { 'usage' => 'Usage', 'activity' => 'Activity', 'kit' => 'Kit', - 'bom' => 'BoM' + 'bom' => 'BoM', + 'where-used' => 'Where Used', ]; public static function item($data) { @@ -61,6 +63,10 @@ public static function bom($data) { return Bom::index($data); } + public static function whereUsed($data) { + return WhereUsed::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/classes/mii/Ii/WhereUsed.php b/site/controllers/classes/mii/Ii/WhereUsed.php new file mode 100644 index 000000000..e2fc22d2d --- /dev/null +++ b/site/controllers/classes/mii/Ii/WhereUsed.php @@ -0,0 +1,118 @@ +refresh) { + self::requestJson($data, session_id()); + self::pw('session')->redirect(self::whereUsedUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + return self::whereUsed($data); + } + + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IIWHEREUSED', "ITEMID=$vars->itemID"]; + self::sendRequest($data, $vars->sessionID); + } + + public static function whereUsedUrl($itemID, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('where-used'); + $url->query->set('itemID', $itemID); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + return $url->getUrl(); + } + + public static function whereUsed($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $html = ''; + + $page = self::pw('page'); + $config = self::pw('config'); + $pages = self::pw('pages'); + $modules = self::pw('modules'); + $htmlwriter = $modules->get('HtmlWriter'); + $jsonM = $modules->get('JsonDataFiles'); + + $page->headline = "II: $data->itemID Where Used"; + $html .= self::breadCrumbs();; + $html .= self::whereUsedData($data); + return $html; + } + + private static function whereUsedData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::whereUsedUrl($data->itemID, $refresh = true), $http301 = false); + } + $session->setFor('ii', 'where-used', 0); + $refreshurl = self::whereUsedUrl($data->itemID, $refresh = true); + $html .= self::whereUsedDisplay($data, $json); + return $html; + } + + if ($session->getFor('ii', 'where-used') > 3) { + $page->headline = "Where Used File could not be loaded"; + $html .= self::whereUsedDisplay($data, $json); + return $html; + } else { + $session->setFor('ii', 'where-used', ($session->getFor('ii', 'where-used') + 1)); + $session->redirect(self::whereUsedUrl($data->itemID, $refresh = true), $http301 = false); + } + } + + protected static function whereUsedDisplay($data, $json) { + $jsonm = self::getJsonModule(); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Where Used File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::whereUsedUrl($data->itemID, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $html = ''; + $html .= $config->twig->render('items/ii/where-used/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->$jsonm]); + return $html; + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index d08b3595e..3d6eee8d4 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -41,6 +41,7 @@ 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Usage' => $baseDir . '/classes/mii/Ii/Usage.php', + 'Controllers\\Mii\\Ii\\WhereUsed' => $baseDir . '/classes/mii/Ii/WhereUsed.php', 'Controllers\\Min\\Itm\\Costing' => $baseDir . '/classes/min/itm/Costing.php', 'Controllers\\Min\\Itm\\Itm' => $baseDir . '/classes/min/itm/Itm.php', 'Controllers\\Min\\Itm\\ItmFunction' => $baseDir . '/classes/min/itm/ItmFunction.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 6f2e91d67..d0be403ed 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -42,6 +42,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Usage' => __DIR__ . '/../..' . '/classes/mii/Ii/Usage.php', + 'Controllers\\Mii\\Ii\\WhereUsed' => __DIR__ . '/../..' . '/classes/mii/Ii/WhereUsed.php', 'Controllers\\Min\\Itm\\Costing' => __DIR__ . '/../..' . '/classes/min/itm/Costing.php', 'Controllers\\Min\\Itm\\Itm' => __DIR__ . '/../..' . '/classes/min/itm/Itm.php', 'Controllers\\Min\\Itm\\ItmFunction' => __DIR__ . '/../..' . '/classes/min/itm/ItmFunction.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 483a36eb1..e3c4e0bb1 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -14,6 +14,7 @@ ['GET', 'activity', Ii::class, 'activity'], ['GET', 'kit', Ii::class, 'kit'], ['GET', 'bom', Ii::class, 'bom'], + ['GET', 'where-used', Ii::class, 'whereUsed'], ]; $router = new Mvc\Router(); From 2c65bcd111b47d07347af541c11c296e45a0b2c7 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:36:16 -0500 Subject: [PATCH 023/106] chore: remove ii-where-used template from PW --- site/modules/Dplus/Dpages/DpagesMii.module | 21 ++--------- site/templates/ii-where-used.php | 43 ---------------------- 2 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 site/templates/ii-where-used.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index a4f6d5c56..6eed29def 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-where-used' => array( - 'name' => 'ii-where-used', - 'fields' => array(), - ), 'ii-lotserial' => array( 'name' => 'ii-lotserial', 'fields' => array(), @@ -119,16 +115,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-where-used' => array( - 'template' => 'ii-function', - 'name' => 'where-used', - 'title' => 'Where Used', - 'summary' => 'View Item Where Used', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-use', - 'pw_template' => 'ii-where-used', - 'jsoncode' => 'ii-whereused' - ), 'ii-lotserial' => array( 'template' => 'ii-function', 'name' => 'lotserial', @@ -321,7 +307,7 @@ class DpagesMii extends Dpages implements Module { $url->query->set('itemID', $itemID); $event->return = $url->getUrl(); }); - + $this->addHook('Page::get_itemkitURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); @@ -343,10 +329,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemwhereusedURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-where-used'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('where-used'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-where-used.php b/site/templates/ii-where-used.php deleted file mode 100644 index 75c3eedea..000000000 --- a/site/templates/ii-where-used.php +++ /dev/null @@ -1,43 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Where Used"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemwhereusedURL($itemID)); - } - $session->whereusedtry = 0; - - $refreshurl = $page->get_itemwhereusedURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render('items/ii/where-used/where-used.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json]); - } - } else { - if ($session->whereusedtry > 3) { - $page->headline = $page->title = "Where Used File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->whereusedtry++; - $session->redirect($page->get_itemwhereusedURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } From c8712f8d2a4ce74641b73376866dbe25175f6349 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:36:58 -0500 Subject: [PATCH 024/106] Update ii.php --- site/templates/redir/ii.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 7a0d3ea05..bcca6713e 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-where-used': - * Request II Where Used JSON file - * Response: Creates II Where Used JSON file - * DBNAME=$dplusdb - * IIWHEREUSED - * ITEMID=$itemID - * break; * case 'ii-lotserial': * Request II Lot / Serial JSON file * Response: Creates II Lot / Serial JSON file @@ -104,16 +97,6 @@ $session->loc = $url; } break; - case 'ii-where-used': - $data = array("DBNAME=$dplusdb", 'IIWHEREUSED', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-where-used')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-lotserial': $data = array("DBNAME=$dplusdb", 'IILOTSER', "ITEMID=$itemID"); From d2d782881323e4d8bae150cdda2938ec792a5062 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:58:38 -0500 Subject: [PATCH 025/106] Update display.twig --- site/templates/twig/items/ii/where-used/display.twig | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/site/templates/twig/items/ii/where-used/display.twig b/site/templates/twig/items/ii/where-used/display.twig index 47755ddc8..d6c9ece67 100644 --- a/site/templates/twig/items/ii/where-used/display.twig +++ b/site/templates/twig/items/ii/where-used/display.twig @@ -15,11 +15,5 @@ {% endblock %} {% block footer %} - + {% endblock %} From 739bc6d4b3dbf409c7ff11aa7657808c280c0ec3 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:59:10 -0500 Subject: [PATCH 026/106] fix(twig): update ii-breadcrumbs to use |title --- site/templates/twig/items/ii/bread-crumbs.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/templates/twig/items/ii/bread-crumbs.twig b/site/templates/twig/items/ii/bread-crumbs.twig index 374e953e6..0ba6e14f7 100644 --- a/site/templates/twig/items/ii/bread-crumbs.twig +++ b/site/templates/twig/items/ii/bread-crumbs.twig @@ -14,7 +14,7 @@ {% if segments[1] == 'pricing' and input.get.offsetExists('custID') %} {% else %} {% endif %} {% endif %} From ece7ed0f37f9921effedbd815a806c4ff5e4bdfa Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 14:59:56 -0500 Subject: [PATCH 027/106] style(twig): update ii-lotserial to use ii-display --- site/templates/twig/items/ii/lotserial/display.twig | 12 ++++++++++++ .../templates/twig/items/ii/lotserial/lotserial.twig | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 site/templates/twig/items/ii/lotserial/display.twig diff --git a/site/templates/twig/items/ii/lotserial/display.twig b/site/templates/twig/items/ii/lotserial/display.twig new file mode 100644 index 000000000..42948051d --- /dev/null +++ b/site/templates/twig/items/ii/lotserial/display.twig @@ -0,0 +1,12 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+

Available Lot / Serial Numbers

+ {% include 'items/ii/lotserial/lotserial.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/lotserial/lotserial.twig b/site/templates/twig/items/ii/lotserial/lotserial.twig index 29f2a82c2..5241f8963 100644 --- a/site/templates/twig/items/ii/lotserial/lotserial.twig +++ b/site/templates/twig/items/ii/lotserial/lotserial.twig @@ -1,4 +1,3 @@ -

Available Lot / Serial Numbers

{% for x in 1..blueprint['lots']['rowcount'] %} From 5ba9ebf981109ea2caab70c2840aac778bf58e94 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 15:00:06 -0500 Subject: [PATCH 028/106] Update Activity.php --- site/controllers/classes/mii/Ii/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index fee7d6ce9..d4cef4311 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -136,7 +136,7 @@ protected static function activityDataDisplay($data, $json) { $page->refreshurl = self::activityUrl($data->itemID, $data->date, $refresh = true); $page->lastmodified = $jsonm->lastModified(self::JSONCODE); $html = ''; - $html .= $config->twig->render('items/ii/activity/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->$jsonm, 'docm' => $docm, 'date' => $data->date]); + $html .= $config->twig->render('items/ii/activity/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->jsonm, 'docm' => $docm, 'date' => $data->date]); return $html; } From 9326b6bdc87205f551eaa3084152761b61e69277 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 15:00:27 -0500 Subject: [PATCH 029/106] refactor: create and use Ii\Lotserial controller --- site/controllers/classes/mii/Ii/Ii.php | 6 + site/controllers/classes/mii/Ii/Lotserial.php | 122 ++++++++++++++++++ site/controllers/classes/mii/Ii/WhereUsed.php | 4 +- .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/Lotserial.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 45d441d72..ee2848d57 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -13,6 +13,7 @@ use Controllers\Mii\Ii\Kit; use Controllers\Mii\Ii\Bom; use Controllers\Mii\Ii\WhereUsed; +use Controllers\Mii\Ii\Lotserial; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -25,6 +26,7 @@ class Ii extends AbstractController { 'kit' => 'Kit', 'bom' => 'BoM', 'where-used' => 'Where Used', + 'lotserial' => 'Lot / Serial' ]; public static function item($data) { @@ -67,6 +69,10 @@ public static function whereUsed($data) { return WhereUsed::index($data); } + public static function lotserial($data) { + return Lotserial::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/classes/mii/Ii/Lotserial.php b/site/controllers/classes/mii/Ii/Lotserial.php new file mode 100644 index 000000000..f6ddedbb7 --- /dev/null +++ b/site/controllers/classes/mii/Ii/Lotserial.php @@ -0,0 +1,122 @@ +refresh) { + self::requestJson($data); + self::pw('session')->redirect(self::lotserialUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + return self::lotserial($data); + } + + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IILOTSER', "ITEMID=$vars->itemID"]; + self::sendRequest($data, $vars->sessionID); + } + + public static function lotserialUrl($itemID, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('lotserial'); + $url->query->set('itemID', $itemID); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + return $url->getUrl(); + } + + public static function lotserial($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $html = ''; + + $page = self::pw('page'); + $config = self::pw('config'); + $pages = self::pw('pages'); + $modules = self::pw('modules'); + $htmlwriter = $modules->get('HtmlWriter'); + $jsonM = $modules->get('JsonDataFiles'); + + $page->headline = "II: $data->itemID Lot / Serial"; + $html .= self::breadCrumbs();; + $html .= self::lotserialData($data); + return $html; + } + + private static function lotserialData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::lotserialUrl($data->itemID, $refresh = true), $http301 = false); + } + $session->setFor('ii', 'lotserial', 0); + $refreshurl = self::lotserialUrl($data->itemID, $refresh = true); + $html .= self::lotserialDisplay($data, $json); + return $html; + } + + if ($session->getFor('ii', 'lotserial') > 3) { + $page->headline = "Lot / Serial File could not be loaded"; + $html .= self::lotserialDisplay($data, $json); + return $html; + } else { + $session->setFor('ii', 'lotserial', ($session->getFor('ii', 'lotserial') + 1)); + $session->redirect(self::lotserialUrl($data->itemID, $refresh = true), $http301 = false); + } + } + + protected static function lotserialDisplay($data, $json) { + $jsonm = self::getJsonModule(); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Lot / Serial File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::lotserialUrl($data->itemID, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $html = ''; + $html .= $config->twig->render('items/ii/lotserial/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm]); + return $html; + } +} diff --git a/site/controllers/classes/mii/Ii/WhereUsed.php b/site/controllers/classes/mii/Ii/WhereUsed.php index e2fc22d2d..582f8ea57 100644 --- a/site/controllers/classes/mii/Ii/WhereUsed.php +++ b/site/controllers/classes/mii/Ii/WhereUsed.php @@ -19,7 +19,7 @@ public static function index($data) { } if ($data->refresh) { - self::requestJson($data, session_id()); + self::requestJson($data); self::pw('session')->redirect(self::whereUsedUrl($data->itemID), $http301 = false); } self::pw('modules')->get('DpagesMii')->init_iipage(); @@ -112,7 +112,7 @@ protected static function whereUsedDisplay($data, $json) { $page->refreshurl = self::whereUsedUrl($data->itemID, $refresh = true); $page->lastmodified = $jsonm->lastModified(self::JSONCODE); $html = ''; - $html .= $config->twig->render('items/ii/where-used/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->$jsonm]); + $html .= $config->twig->render('items/ii/where-used/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->jsonm]); return $html; } } diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 3d6eee8d4..61c54d66c 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -37,6 +37,7 @@ 'Controllers\\Mii\\Ii\\Costing' => $baseDir . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => $baseDir . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', + 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index d0be403ed..d1400b717 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -38,6 +38,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Costing' => __DIR__ . '/../..' . '/classes/mii/Ii/Costing.php', 'Controllers\\Mii\\Ii\\Item' => __DIR__ . '/../..' . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', + 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index e3c4e0bb1..8b4f91add 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -15,6 +15,7 @@ ['GET', 'kit', Ii::class, 'kit'], ['GET', 'bom', Ii::class, 'bom'], ['GET', 'where-used', Ii::class, 'whereUsed'], + ['GET', 'lotserial', Ii::class, 'lotserial'], ]; $router = new Mvc\Router(); From 79f9e81018b4022a69d5f1b04cb5b323cd1cd88b Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Apr 2021 15:03:35 -0500 Subject: [PATCH 030/106] chore: remove ii-lotserial from PW --- site/modules/Dplus/Dpages/DpagesMii.module | 19 +--------- site/templates/ii-lotserial.php | 44 ---------------------- site/templates/redir/ii.php | 17 --------- 3 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 site/templates/ii-lotserial.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 6eed29def..8df9c4e18 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-lotserial' => array( - 'name' => 'ii-lotserial', - 'fields' => array(), - ), 'ii-substitutes' => array( 'name' => 'ii-substitutes', 'fields' => array(), @@ -115,16 +111,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-lotserial' => array( - 'template' => 'ii-function', - 'name' => 'lotserial', - 'title' => 'Lot Serial', - 'summary' => 'View Item Lot Serial', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-lot', - 'pw_template' => 'ii-lotserial', - 'jsoncode' => 'ii-lotserial' - ), 'ii-general' => array( 'template' => 'ii-function', 'name' => 'general', @@ -338,10 +324,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemlotserialURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-lotserial'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('lotserial'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-lotserial.php b/site/templates/ii-lotserial.php deleted file mode 100644 index 5a1d1ea81..000000000 --- a/site/templates/ii-lotserial.php +++ /dev/null @@ -1,44 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Lot / Serial"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemlotserialURL($itemID)); - } - $session->lotserialtry = 0; - $formatter = new Dplus\ScreenFormatters\Ii\Lotserial(); - $refreshurl = $page->get_itemlotserialURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $formatter->init_formatter(); - $page->body .= $config->twig->render('items/ii/lotserial/lotserial.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint()]); - } - } else { - if ($session->lotserialtry > 3) { - $page->headline = $page->title = "Lot Serial File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->lotserialtry++; - $session->redirect($page->get_itemlotserialURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index bcca6713e..923c326a6 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-lotserial': - * Request II Lot / Serial JSON file - * Response: Creates II Lot / Serial JSON file - * DBNAME=$dplusdb - * IILOTSER - * ITEMID=$itemID - * break; * case 'ii-general': * Request II General JSON file * Response: Creates II General JSON file @@ -97,16 +90,6 @@ $session->loc = $url; } break; - case 'ii-lotserial': - $data = array("DBNAME=$dplusdb", 'IILOTSER', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-lotserial')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-general': // does not call ii-misc, ii-notes $data = array("DBNAME=$dplusdb", 'IIGENERAL', "ITEMID=$itemID"); From 6b8d62c7205526957bd207d21b3a5d9c6261993e Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 08:38:01 -0500 Subject: [PATCH 031/106] Update Usage.php --- site/controllers/classes/mii/Ii/Usage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Usage.php b/site/controllers/classes/mii/Ii/Usage.php index b9090471f..03d6e0fbf 100644 --- a/site/controllers/classes/mii/Ii/Usage.php +++ b/site/controllers/classes/mii/Ii/Usage.php @@ -124,5 +124,4 @@ protected static function usageDataDisplay($data, $json) { $page->js = $config->twig->render('items/ii/usage/warehouses.js.twig', ['json' => $json, 'module_json' => $jsonm->jsonm, 'module_usage' => $usagem]); return $html; } - } From d354c15ccf6d71fc98635e89ef0fe20b2b982be0 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 08:38:27 -0500 Subject: [PATCH 032/106] Update II General Display to use ii-display --- .../twig/items/ii/general/display.twig | 47 +++++++++++++++++++ .../twig/items/ii/general/links.twig | 3 -- .../twig/items/ii/general/usage.twig | 8 +++- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 site/templates/twig/items/ii/general/display.twig diff --git a/site/templates/twig/items/ii/general/display.twig b/site/templates/twig/items/ii/general/display.twig new file mode 100644 index 000000000..c59d29c73 --- /dev/null +++ b/site/templates/twig/items/ii/general/display.twig @@ -0,0 +1,47 @@ +{% extends 'items/ii/display.twig' %} + +{# + var Description / Instance of + ------------------------------------------------- + html WireData + html.usage string(HTML) + html.notes string(HTML) + html.misc string(HTML) +#} + +{% block body %} +
+ +
+
+ {{ html.usage|raw }} +
+
+ {{ html.notes|raw }} +
+
+ {{ html.misc|raw }} +
+
+
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/general/links.twig b/site/templates/twig/items/ii/general/links.twig index f6cb00210..f20edf697 100644 --- a/site/templates/twig/items/ii/general/links.twig +++ b/site/templates/twig/items/ii/general/links.twig @@ -1,7 +1,4 @@
- + - +
Sale UoMSale UoM {{ json['sale uom'] }}
Base PriceBase Price {{ json['base price'] }}
From 45d4a8cf228f4c50f3692c76e0d1ba26c95e0fa5 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 15:09:42 -0500 Subject: [PATCH 061/106] Create and Implement Ii\Substitutes --- site/controllers/classes/mii/Ii/Ii.php | 6 + .../classes/mii/Ii/Substitutes.php | 119 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 5 files changed, 128 insertions(+) create mode 100644 site/controllers/classes/mii/Ii/Substitutes.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 965710d52..55c5b1185 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -15,6 +15,7 @@ use Controllers\Mii\Ii\WhereUsed; use Controllers\Mii\Ii\Lotserial; use Controllers\Mii\Ii\General; +use Controllers\Mii\Ii\Substitutes; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -29,6 +30,7 @@ class Ii extends AbstractController { 'where-used' => 'Where Used', 'lotserial' => 'Lot / Serial', 'general' => 'General', + 'substitutes' => 'Substitutes', ]; public static function item($data) { @@ -79,6 +81,10 @@ public static function general($data) { return General::index($data); } + public static function substitutes($data) { + return Substitutes::index($data); + } + public static function init() { $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { diff --git a/site/controllers/classes/mii/Ii/Substitutes.php b/site/controllers/classes/mii/Ii/Substitutes.php new file mode 100644 index 000000000..87378675e --- /dev/null +++ b/site/controllers/classes/mii/Ii/Substitutes.php @@ -0,0 +1,119 @@ +refresh) { + self::requestJson($data); + self::pw('session')->redirect($refreshurl = self::substitutesUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + return self::substitutes($data); + } + + public static function substitutes($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $data = self::sanitizeParametersShort($data, ['itemID|text']); + + self::getData($data); + $page = self::pw('page'); + $page->headline = "$data->itemID Costing"; + $html = ''; + $html .= self::breadCrumbs(); + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + self::sanitizeParametersShort($vars, ['itemID|text', 'sessionID|text']); + $vars->sessionID = $vars->sessionID ? $vars->sessionID : session_id(); + $data = array('IISUB', "ITEMID=$vars->itemID"); + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function substitutesUrl($itemID = '', $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('substitutes'); + + if ($itemID) { + $url->query->set('itemID', $itemID); + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $session = self::pw('session'); + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::substitutesUrl($data->itemID, $refreshdata = true), $http301 = false); + } + $session->setFor('ii', 'substitutes', 0); + return true; + } + + if ($session->getFor('ii', 'substitutes') > 3) { + return false; + } + $session->setFor('ii', 'substitutes', ($session->getFor('ii', 'substitutes') + 1)); + $session->redirect(self::substitutesUrl($data->itemID, $refreshdata = true), $http301 = false); + } + +/* ============================================================= + 5. Displays +============================================================= */ + protected static function display($data) { + $config = self::pw('config'); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Substitutes File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::substitutesUrl($data->itemID, $refreshdata = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + return $config->twig->render('items/ii/substitutes/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'module_json' => $jsonm->jsonm]); + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index f7e3f5a49..3e6edf2aa 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -42,6 +42,7 @@ 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', + 'Controllers\\Mii\\Ii\\Substitutes' => $baseDir . '/classes/mii/Ii/Substitutes.php', 'Controllers\\Mii\\Ii\\Usage' => $baseDir . '/classes/mii/Ii/Usage.php', 'Controllers\\Mii\\Ii\\WhereUsed' => $baseDir . '/classes/mii/Ii/WhereUsed.php', 'Controllers\\Min\\Itm\\Costing' => $baseDir . '/classes/min/itm/Costing.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index b789459fa..f1ff50b6f 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -43,6 +43,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', + 'Controllers\\Mii\\Ii\\Substitutes' => __DIR__ . '/../..' . '/classes/mii/Ii/Substitutes.php', 'Controllers\\Mii\\Ii\\Usage' => __DIR__ . '/../..' . '/classes/mii/Ii/Usage.php', 'Controllers\\Mii\\Ii\\WhereUsed' => __DIR__ . '/../..' . '/classes/mii/Ii/WhereUsed.php', 'Controllers\\Min\\Itm\\Costing' => __DIR__ . '/../..' . '/classes/min/itm/Costing.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 5027d7a16..47bb1979b 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -17,6 +17,7 @@ ['GET', 'where-used', Ii::class, 'whereUsed'], ['GET', 'lotserial', Ii::class, 'lotserial'], ['GET', 'general', Ii::class, 'general'], + ['GET', 'substitutes', Ii::class, 'substitutes'], ]; $router = new Mvc\Router(); From 91fab356e50073f5f8a3f5692016b0a5c8aa08f1 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 15:11:37 -0500 Subject: [PATCH 062/106] chore: remove ii-substitutes --- site/modules/Dplus/Dpages/DpagesMii.module | 19 +--------- site/templates/ii-substitutes.php | 43 ---------------------- site/templates/redir/ii.php | 17 --------- 3 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 site/templates/ii-substitutes.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 623b91152..830a946e7 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-substitutes' => array( - 'name' => 'ii-substitutes', - 'fields' => array(), - ), 'ii-documents' => array( 'name' => 'ii-documents', 'fields' => array(), @@ -111,16 +107,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-substitutes' => array( - 'template' => 'ii-function', - 'name' => 'substitutes', - 'title' => 'Substitutes', - 'summary' => 'View Item Substitutes', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-sub', - 'pw_template' => 'ii-substitutes', - 'jsoncode' => 'ii-substitutes' - ), 'ii-documents' => array( 'template' => 'ii-function', 'name' => 'documents', @@ -332,10 +318,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemsubstitutesURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-substitutes'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('substitutes'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-substitutes.php b/site/templates/ii-substitutes.php deleted file mode 100644 index 82ab5c968..000000000 --- a/site/templates/ii-substitutes.php +++ /dev/null @@ -1,43 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Substitutes"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemsubstitutesURL($itemID)); - } - $session->substitutestry = 0; - - $refreshurl = $page->get_itemsubstitutesURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $page->body .= $config->twig->render('items/ii/substitutes/substitutes.twig', ['page' => $page, 'json' => $json, 'module_json' => $module_json]); - } - } else { - if ($session->substitutestry > 3) { - $page->headline = $page->title = "Substitutes File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->substitutestry++; - $session->redirect($page->get_itemsubstitutesURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 8f87f40ee..78c9d47cf 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-substitutes': - * Request II Substitutes JSON file - * Response: Creates II Substitutes JSON file - * DBNAME=$dplusdb - * IISUB - * ITEMID=$itemID - * break; * case 'ii-documents': * Request II Documents JSON file * Response: Creates II Documents JSON file @@ -69,16 +62,6 @@ $session->loc = $url; } break; - case 'ii-substitutes': - $data = array("DBNAME=$dplusdb", 'IISUB', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-substitutes')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-documents': $desc = ItemMasterItemQuery::create()->select(ItemMasterItem::get_aliasproperty('desc'))->findOneByItemid($itemID); $data = array("DBNAME=$dplusdb", 'DOCVIEW', "FLD1CD=IT", "FLD1DATA=$itemID", "FLD1DESC=$desc"); From 001204b0191575da3662cc77b02db97b1931c27b Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 15:14:23 -0500 Subject: [PATCH 063/106] Update IiFunction.php --- .../controllers/classes/mii/Ii/IiFunction.php | 79 +++++++++++-------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/site/controllers/classes/mii/Ii/IiFunction.php b/site/controllers/classes/mii/Ii/IiFunction.php index bc73ae46e..2a03a7e30 100644 --- a/site/controllers/classes/mii/Ii/IiFunction.php +++ b/site/controllers/classes/mii/Ii/IiFunction.php @@ -21,21 +21,10 @@ abstract class IiFunction extends AbstractController { private static $jsonm; private static $filehasher; - protected static function alertInvalidItemPermissions($data) { - self::sanitizeParametersShort($data, ['itemID|text']); - if (empty($data->itemID) === false && self::validateItemid($data->itemID) === false) { - return self::pw('config')->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => "Item $data->itemID could not be found"]); - } - if (self::validateUserPermission($data) === false) { - return self::pw('config')->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => "You don't have Permission for this Function"]); - } - return ''; - } - - protected static function breadCrumbs() { - return self::pw('config')->twig->render('items/ii/bread-crumbs.twig'); - } +/* ============================================================= + Validations +============================================================= */ protected static function validateItemidPermission($data) { self::sanitizeParametersShort($data, ['itemID|text']); @@ -68,6 +57,35 @@ protected static function validateUserPermission($data) { return true; } +/* ============================================================= + Data Requests +============================================================= */ + public static function requestIiItem($itemID, $sessionID = '') { + $sessionID = $sessionID ? $sessionID : session_id(); + $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; + $data = array('IISELECT', "ITEMID=$itemID"); + self::sendRequest($data, $sessionID); + } + + protected static function sendRequest(array $data, $sessionID = '') { + $sessionID = $sessionID ? $sessionID : session_id(); + $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; + $data = array_merge(["DBNAME=$db"], $data); + $requestor = self::pw('modules')->get('DplusRequest'); + $requestor->write_dplusfile($data, $sessionID); + $requestor->cgi_request(self::pw('config')->cgis['default'], $sessionID); + } + +/* ============================================================= + Classes, Module Getters +============================================================= */ + protected static function getFileHasher() { + if (empty(self::$filehasher)) { + self::$filehasher = self::pw('modules')->get('FileHasher'); + } + return self::$filehasher; + } + public static function getValidator() { if (empty(self::$validator)) { self::$validator = new MinValidator(); @@ -93,26 +111,21 @@ public static function getItmItem($itemID) { return self::pw('modules')->get('Itm')->item($itemID); } - public static function requestIiItem($itemID, $sessionID = '') { - $sessionID = $sessionID ? $sessionID : session_id(); - $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; - $data = array('IISELECT', "ITEMID=$itemID"); - self::sendRequest($data, $sessionID); - } - - protected static function sendRequest(array $data, $sessionID = '') { - $sessionID = $sessionID ? $sessionID : session_id(); - $db = self::pw('modules')->get('DplusOnlineDatabase')->db_name; - $data = array_merge(["DBNAME=$db"], $data); - $requestor = self::pw('modules')->get('DplusRequest'); - $requestor->write_dplusfile($data, $sessionID); - $requestor->cgi_request(self::pw('config')->cgis['default'], $sessionID); +/* ============================================================= + Displays +============================================================= */ + protected static function alertInvalidItemPermissions($data) { + self::sanitizeParametersShort($data, ['itemID|text']); + if (empty($data->itemID) === false && self::validateItemid($data->itemID) === false) { + return self::pw('config')->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => "Item $data->itemID could not be found"]); + } + if (self::validateUserPermission($data) === false) { + return self::pw('config')->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => "You don't have Permission for this Function"]); + } + return ''; } - protected static function getFileHasher() { - if (empty(self::$filehasher)) { - self::$filehasher = self::pw('modules')->get('FileHasher'); - } - return self::$filehasher; + protected static function breadCrumbs() { + return self::pw('config')->twig->render('items/ii/bread-crumbs.twig'); } } From 2f9f4e1e17c78e7e140789f7e9bc9d53fc805076 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:07 -0500 Subject: [PATCH 064/106] Update Activity.php --- site/controllers/classes/mii/Ii/Activity.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index 26b426838..f182b3807 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -120,6 +120,7 @@ private static function getData($data) { 5. Displays ============================================================= */ protected static function display($data) { + self::init(); self::sanitizeParametersShort($data, ['itemID|text', 'date|text']); $jsonm = self::getJsonModule(); $json = $jsonm->getFile(self::JSONCODE); @@ -164,4 +165,19 @@ private static function dateForm($data) { $config->scripts->append(self::getFileHasher()->getHashUrl('scripts/lib/jquery-validate.js')); return $html; } + + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $type = $event->arguments(1); + $reference = $event->arguments(2); + + $url = new Purl(Documents::documentsUrl($itemID, 'ACT')); + $url->query->set('type', $type); + $url->query->set('reference', $reference); + $event->return = $url->getUrl(); + }); + } } From edf64e20ada5ccb54a755afdf87417f19055cfbe Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:11 -0500 Subject: [PATCH 065/106] Update Costing.php --- site/controllers/classes/mii/Ii/Costing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Costing.php b/site/controllers/classes/mii/Ii/Costing.php index e7d632ee7..0d53f6fea 100644 --- a/site/controllers/classes/mii/Ii/Costing.php +++ b/site/controllers/classes/mii/Ii/Costing.php @@ -38,7 +38,7 @@ public static function costing($data) { self::getData($data); $page = self::pw('page'); - $page->headline = "$data->itemID Costing"; + $page->headline = "II: $data->itemID Costing"; $html = ''; $html .= self::breadCrumbs(); $html .= self::display($data); From 5fb03fc1d5ed9bf8dab17f6be85dc84c751fd427 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:19 -0500 Subject: [PATCH 066/106] Update whse-table.twig --- site/templates/twig/items/ii/activity/whse-table.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/twig/items/ii/activity/whse-table.twig b/site/templates/twig/items/ii/activity/whse-table.twig index d0d1580cd..f6956efc0 100644 --- a/site/templates/twig/items/ii/activity/whse-table.twig +++ b/site/templates/twig/items/ii/activity/whse-table.twig @@ -12,7 +12,7 @@ {% if docm.count_documents_activity(order['tran type'], order['tran reference']) %} - + View Documents for {{ order['tran type'] ~ ' ' ~ order['tran reference']}} {% endif %} From e8c5cec6b1e8d845ff53f73ee433f884657ac065 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:24 -0500 Subject: [PATCH 067/106] Update display.twig --- site/templates/twig/items/ii/display.twig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/site/templates/twig/items/ii/display.twig b/site/templates/twig/items/ii/display.twig index 859918a39..9e721cc95 100644 --- a/site/templates/twig/items/ii/display.twig +++ b/site/templates/twig/items/ii/display.twig @@ -28,14 +28,16 @@ {% endif %}
- {% if page.is_print() == false and page.refreshurl %} + {% if page.is_print() == false and page.has('refreshurl') %} Refresh {% endif %}
- Data Timestamp: {{ page.lastmodified|date('m/d/Y h:i A') }} + {% if page.has('lastmodified') %} + Data Timestamp: {{ page.lastmodified|date('m/d/Y h:i A') }} + {% endif %}
From 776f81b8152941bfe024e7493cbd98c1cb189843 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:39 -0500 Subject: [PATCH 068/106] style: updatre ii-documents display --- .../twig/items/ii/documents/display.twig | 27 +++++++++++++++++++ .../twig/items/ii/documents/list.twig | 24 +++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 site/templates/twig/items/ii/documents/display.twig create mode 100644 site/templates/twig/items/ii/documents/list.twig diff --git a/site/templates/twig/items/ii/documents/display.twig b/site/templates/twig/items/ii/documents/display.twig new file mode 100644 index 000000000..ee198e82b --- /dev/null +++ b/site/templates/twig/items/ii/documents/display.twig @@ -0,0 +1,27 @@ +{% extends 'items/ii/display.twig' %} + +{# + var Description / Instance of + ------------------------------------------------- + list WireData + list.title string(HTML) + list.documents Document[] + list.returnUrl string(HTML) + list.returnTitle string(HTML) +#} + +{% block body %} +
+
+

{{ list.title }}

+ + Item {{ list.returnTitle }} + +
+
+ {% include 'items/ii/documents/list.twig' %} +{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/documents/list.twig b/site/templates/twig/items/ii/documents/list.twig new file mode 100644 index 000000000..fa6b28a93 --- /dev/null +++ b/site/templates/twig/items/ii/documents/list.twig @@ -0,0 +1,24 @@ +
+ + + + + + + + + {% for document in list.documents %} + + + + + + + + {% endfor %} +
TitleFilenameFolderDateTime
{{ document.title }} + + {{ document.filename }} + + {{ document.get_folderdescription() }}{{ document.date|convertdate("m/d/Y") }}{{ (document.date ~ document.time[:4])|convertdate("h:i A") }}
+
From 2baa5f30dd441368e7e969086b74bf713799dc11 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Apr 2021 16:26:59 -0500 Subject: [PATCH 069/106] refactor create and implement ii-documents controller --- site/controllers/classes/mii/Ii/Documents.php | 140 ++++++++++++++++++ site/controllers/classes/mii/Ii/Ii.php | 6 + .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + .../DocumentManagementIi.module | 16 +- .../DocumentManagementSo.module | 2 +- site/templates/ii-item.php | 1 + 7 files changed, 152 insertions(+), 15 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/Documents.php diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php new file mode 100644 index 000000000..3c1b76422 --- /dev/null +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -0,0 +1,140 @@ +folder && $data->document) { + $docm = self::pw('modules')->get('DocumentManagementIi'); + $docm->move_document($data->folder, $data->document); + + if ($docm->is_filewebaccessible($data->document)) { + self::pw('session')->redirect(self::pw('config')->url_webdocs.$data->document, $http301 = false); + } + } + + self::pw('modules')->get('DpagesMii')->init_iipage(); + return self::documents($data); + } + + public static function documents($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + $fields = ['itemID|text']; + self::sanitizeParametersShort($data, $fields); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Documents"; + $html = ''; + $html .= self::breadCrumbs(); + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + # NONE + +/* ============================================================= + 3. URLs +============================================================= */ + public static function documentsUrl($itemID, $folder = '', $document = '') { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('documents'); + $url->query->set('itemID', $itemID); + + if ($folder) { + $url->query->set('folder', $folder); + if ($document) { + $url->query->set('document', $document); + } + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + # NONE +/* ============================================================= + 5. Displays +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + $m->addHook('Page(pw_template=ii-item)::documentUrl', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $folder = $event->arguments(1); + $document = $event->arguments(2); + $event->return = self::documentsUrl($itemID, $folder, $document); + }); + } + private static function createList($itemID) { + $list = new WireData(); + $list->itemid = $itemID; + $list->title = ''; + $list->documents = []; + $list->returnUrl = ''; + $list->returnTitle = ''; + return $list; + } + protected static function display($data) { + self::init(); + self::sanitizeParametersShort($data, ['itemID|text', 'folder|text']); + $list = self::createList($data->itemID); + + $docm = self::pw('modules')->get('DocumentManagementIi'); + + switch ($data->folder) { + case 'SO': + case 'AR': + self::sanitizeParametersShort($data, ['ordn|ordn']); + $docm = self::pw('modules')->get('DocumentManagementSo'); + $list->title = "Sales Order #$data->ordn Documents"; + $list->returnTitle = "Sales Orders"; + $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-orders')->url."?itemID=$data->itemID"; + $list->documents = $docm->count_documents($data->ordn) ? $docm->get_documents($data->ordn) : []; + break; + case 'ACT': // Item Activity + self::sanitizeParametersShort($data, ['type|text', 'reference|text']); + $list->title = "$data->type $data->reference Documents"; + $list->documents = $docm->get_documents_activity($data->type, $data->reference); + + $list->returnUrl = Activity::activityUrl($data->itemID); + break; + case 'QT': + + break; + case 'AP': + + break; + case 'PO': + + break; + } + + return self::pw('config')->twig->render('items/ii/documents/display.twig', ['item' => self::getItmItem($data->itemID), 'list' => $list]); + } +} diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 55c5b1185..76cc74ab9 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -16,6 +16,7 @@ use Controllers\Mii\Ii\Lotserial; use Controllers\Mii\Ii\General; use Controllers\Mii\Ii\Substitutes; +use Controllers\Mii\Ii\Documents; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -31,6 +32,7 @@ class Ii extends AbstractController { 'lotserial' => 'Lot / Serial', 'general' => 'General', 'substitutes' => 'Substitutes', + 'documents' => 'Documents', ]; public static function item($data) { @@ -84,6 +86,10 @@ public static function general($data) { public static function substitutes($data) { return Substitutes::index($data); } + + public static function documents($data) { + return Documents::index($data); + } public static function init() { $m = self::pw('modules')->get('DpagesMii'); diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 3e6edf2aa..a1c0a99a7 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -35,6 +35,7 @@ 'Controllers\\Mii\\Ii\\Activity' => $baseDir . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Bom' => $baseDir . '/classes/mii/Ii/Bom.php', 'Controllers\\Mii\\Ii\\Costing' => $baseDir . '/classes/mii/Ii/Costing.php', + 'Controllers\\Mii\\Ii\\Documents' => $baseDir . '/classes/mii/Ii/Documents.php', 'Controllers\\Mii\\Ii\\General' => $baseDir . '/classes/mii/Ii/General.php', 'Controllers\\Mii\\Ii\\Item' => $baseDir . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index f1ff50b6f..92c43a4ac 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -36,6 +36,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Activity' => __DIR__ . '/../..' . '/classes/mii/Ii/Activity.php', 'Controllers\\Mii\\Ii\\Bom' => __DIR__ . '/../..' . '/classes/mii/Ii/Bom.php', 'Controllers\\Mii\\Ii\\Costing' => __DIR__ . '/../..' . '/classes/mii/Ii/Costing.php', + 'Controllers\\Mii\\Ii\\Documents' => __DIR__ . '/../..' . '/classes/mii/Ii/Documents.php', 'Controllers\\Mii\\Ii\\General' => __DIR__ . '/../..' . '/classes/mii/Ii/General.php', 'Controllers\\Mii\\Ii\\Item' => __DIR__ . '/../..' . '/classes/mii/Ii/Item.php', 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module index a4f39af56..ab8029d91 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module @@ -105,9 +105,9 @@ class DocumentManagementIi extends DocumentManagement implements Module { if (in_array($type, self::ACTIVITY_TYPES_SO)) { $ref = $this->determine_reference($reference, self::PREFIX_REF_SO); - $docs_query->filterByTag(self::TAG_SALESORDER); $ref = SalesOrder::get_paddedordernumber($ref); - $docs_query->filterByReference1($ref); + $docm = $this->wire('modules')->get('DocumentManagementSo'); + $docm->filter_sales($docs_query, $ref); } elseif (in_array($type, self::ACTIVITY_TYPES_PO)) { $ref = $this->determine_reference($reference, self::PREFIX_REF_PO); $docs_query->filterByTag(self::TAG_VENDORPO); @@ -300,18 +300,6 @@ class DocumentManagementIi extends DocumentManagement implements Module { $event->return = $url->getUrl(); }); - $this->addHook('Page(pw_template=ii-activity)::documentsview_activity', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $type = $event->arguments(1); - $reference = $event->arguments(2); - - $url = new Url($this->get_ii_docs_folderURL($itemID, 'ACT')); - $url->query->set('type', $type); - $url->query->set('reference', $reference); - $event->return = $url->getUrl(); - }); - $this->addHook('Page(pw_template=ii-item)::item_image_exists', function($event) { $page = $event->object; $itemID = $event->arguments(0); diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementSo.module b/site/modules/Dplus/DocumentManagement/DocumentManagementSo.module index 24541da74..1cf9c8783 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementSo.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementSo.module @@ -48,7 +48,7 @@ class DocumentManagementSo extends DocumentManagement implements Module { * @param string $ordn Sales Order # * @return void */ - protected function filter_sales(DocumentQuery $docs_query, $ordn) { + public function filter_sales(DocumentQuery $docs_query, $ordn) { $ordn = SalesOrder::get_paddedordernumber($ordn); $this->columns = new WireData(); $this->columns->tag = Document::get_aliasproperty('tag'); diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 47bb1979b..5bb4844eb 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -18,6 +18,7 @@ ['GET', 'lotserial', Ii::class, 'lotserial'], ['GET', 'general', Ii::class, 'general'], ['GET', 'substitutes', Ii::class, 'substitutes'], + ['GET', 'documents', Ii::class, 'documents'], ]; $router = new Mvc\Router(); From e6a501ac1974b1f023c53e187411897646e09c01 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:58:05 -0500 Subject: [PATCH 070/106] Update DocumentManagementQt.module --- .../DocumentManagement/DocumentManagementQt.module | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementQt.module b/site/modules/Dplus/DocumentManagement/DocumentManagementQt.module index e95113651..39180ef39 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementQt.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementQt.module @@ -3,10 +3,6 @@ use Purl\Url; use DocumentFolderQuery, DocumentFolder; use DocumentQuery, Document; -use SalesOrderQuery, SalesOrder; -use SalesOrderDetailQuery, SalesOrderDetail; -use SalesHistoryQuery, SalesHistory; -use SalesHistoryDetailQuery, SalesHistoryDetail; /** * Document Management Quotes @@ -23,7 +19,7 @@ class DocumentManagementQt extends DocumentManagement implements Module { public function get_documents($qnbr) { $docs_query = DocumentQuery::create(); $docs_query->filterByTag(self::TAG_QUOTE); - $docs_query->filterByReference1($qnbr); + $docs_query->filterByReference1($this->qnbr($qnbr)); return $docs_query->find(); } @@ -36,10 +32,14 @@ class DocumentManagementQt extends DocumentManagement implements Module { public function count_documents($qnbr) { $docs_query = DocumentQuery::create(); $docs_query->filterByTag(self::TAG_QUOTE); - $docs_query->filterByReference1($qnbr); + $docs_query->filterByReference1($this->qnbr($qnbr)); return $docs_query->count(); } + public function qnbr($qnbr) { + return substr($qnbr, -4); + } + /* ============================================================= URL Functions ============================================================= */ From 304cd42c075d375fc480e3af96b64680ff029039 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:58:08 -0500 Subject: [PATCH 071/106] Update DplusSanitizer.module --- site/modules/Dplus/DplusSanitizer.module | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/site/modules/Dplus/DplusSanitizer.module b/site/modules/Dplus/DplusSanitizer.module index fc45ff202..e8cdf1426 100644 --- a/site/modules/Dplus/DplusSanitizer.module +++ b/site/modules/Dplus/DplusSanitizer.module @@ -1,6 +1,6 @@ return = $ponbr; }); + + $this->addHook('Sanitizer::qnbr', function(HookEvent $event) { + $sanitizer = $event->object; + $value = $event->arguments(0); + $qnbr = str_pad($value, Quote::LENGTH , "0", STR_PAD_LEFT); + $event->return = $qnbr; + }); } public static function getModuleInfo() { From 0c9c7b3eda781e9fe30f9ec58eb1d0bafa099534 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:58:25 -0500 Subject: [PATCH 072/106] fix:: fix code for iiQuotes --- site/modules/Dplus/ScreenFormatters/src/ii/Quotes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/modules/Dplus/ScreenFormatters/src/ii/Quotes.php b/site/modules/Dplus/ScreenFormatters/src/ii/Quotes.php index c8914298c..83a329497 100644 --- a/site/modules/Dplus/ScreenFormatters/src/ii/Quotes.php +++ b/site/modules/Dplus/ScreenFormatters/src/ii/Quotes.php @@ -4,8 +4,8 @@ class Quotes extends ScreenFormatter { const URI = 'ii:quotes'; - - protected $code = 'ii-purchase-orders'; + + protected $code = 'ii-quotes'; /** * Key Value array of Sections that exist I.E. header => Header, detail => Detail From 59efad1d4af4ae9ce215133a086da9f04c748be7 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:58:54 -0500 Subject: [PATCH 073/106] Add ii-quotes and ii-purchase-history document listing --- site/controllers/classes/mii/Ii/Documents.php | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 3c1b76422..83bb5313c 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -74,6 +74,18 @@ public static function documentsUrl($itemID, $folder = '', $document = '') { return $url->getUrl(); } + public static function documentsUrlQuote($itemID, $qnbr) { + $url = new Purl(self::documentsUrl($itemID, 'QT')); + $url->query->set('qnbr', $qnbr); + return $url->getUrl(); + } + + public static function documentsUrlQuote($itemID, $invnbr) { + $url = new Purl(self::documentsUrl($itemID, 'AP')); + $url->query->set('invnbr', $invnbr); + return $url->getUrl(); + } + /* ============================================================= 4. Data Retrieval ============================================================= */ @@ -83,6 +95,7 @@ public static function documentsUrl($itemID, $folder = '', $document = '') { ============================================================= */ public static function init() { $m = self::pw('modules')->get('DpagesMii'); + $m->addHook('Page(pw_template=ii-item)::documentUrl', function($event) { $page = $event->object; $itemID = $event->arguments(0); @@ -90,7 +103,22 @@ public static function init() { $document = $event->arguments(2); $event->return = self::documentsUrl($itemID, $folder, $document); }); + + $m->addHook('Page(pw_template=ii-item|ii-quotes)::documentsUrlQuote', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $qnbr = $event->arguments(1); + $event->return = self::documentsUrlQuote($itemID, $qnbr); + }); + + $m->addHook('Page(pw_template=ii-item)::documentsUrlApInvoice', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $invnbr = $event->arguments(1); + $event->return = self::documentsUrlApInvoice($itemID, $invnbr); + }); } + private static function createList($itemID) { $list = new WireData(); $list->itemid = $itemID; @@ -100,6 +128,7 @@ private static function createList($itemID) { $list->returnTitle = ''; return $list; } + protected static function display($data) { self::init(); self::sanitizeParametersShort($data, ['itemID|text', 'folder|text']); @@ -114,21 +143,33 @@ protected static function display($data) { $docm = self::pw('modules')->get('DocumentManagementSo'); $list->title = "Sales Order #$data->ordn Documents"; $list->returnTitle = "Sales Orders"; + // TODO: ii sales orders url $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-orders')->url."?itemID=$data->itemID"; $list->documents = $docm->count_documents($data->ordn) ? $docm->get_documents($data->ordn) : []; break; case 'ACT': // Item Activity self::sanitizeParametersShort($data, ['type|text', 'reference|text']); $list->title = "$data->type $data->reference Documents"; + $list->returnTitle = "Activity"; $list->documents = $docm->get_documents_activity($data->type, $data->reference); - $list->returnUrl = Activity::activityUrl($data->itemID); break; case 'QT': - + self::sanitizeParametersShort($data, ['qnbr|qnbr']); + $docm = self::pw('modules')->get('DocumentManagementQt'); + $list->title = "Quote #$data->qnbr Documents"; + $list->returnTitle = "Quotes"; + $list->documents = $docm->get_documents($data->qnbr); + // TODO: ii quotes + $list->returnUrl = self::pw('pages')->get('pw_template=ii-quotes')->url."?itemID=$data->itemID"; break; case 'AP': - + self::sanitizeParametersShort($data, ['invnbr|ponbr']); + $docm = self::pw('modules')->get('DocumentManagementPo'); + $list->title = "AP Invoice #$data->invnbr Documents"; + $list->returnTitle = "AP Invoices"; + $list->documents = $docm->get_documents_invoice($data->invnbr); + $list->returnUrl = self::pw('pages')->get('pw_template=ii-purchase-history')->url."?itemID=$data->itemID"; break; case 'PO': From f64462bb907eab674409d04a221bc84d59edde01 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:59:00 -0500 Subject: [PATCH 074/106] Update DocumentManagementIi.module --- .../DocumentManagement/DocumentManagementIi.module | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module index ab8029d91..c58bcba89 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module @@ -201,7 +201,8 @@ class DocumentManagementIi extends DocumentManagement implements Module { * @return string */ public function get_ii_docs_folderURL($itemID, $folder) { - $url = new Url($this->wire('pages')->get('pw_template=ii-documents')->url); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('documents'); $url->query->set('itemID', $itemID); $url->query->set('folder', $folder); return $url->getUrl(); @@ -273,16 +274,7 @@ class DocumentManagementIi extends DocumentManagement implements Module { $event->return = $url->getUrl(); }); - $this->addHook('Page(pw_template=ii-quotes)::documentsview_quote', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $qnbr = $event->arguments(1); - $url = new Url($this->get_ii_docs_folderURL($itemID, self::TAG_QUOTE)); - $url->query->set('qnbr', $qnbr); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page(pw_template=ii-purchase-history)::documentsview_apinvoice', function($event) { + $this->addHook('Page(pw_template=ii-purchase-history)::documentsUrlApInvoice', function($event) { $page = $event->object; $itemID = $event->arguments(0); $invnbr = $event->arguments(1); From 66314249c71cdf3d345bda39d770812ca5a3999e Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:59:15 -0500 Subject: [PATCH 075/106] Update quotes.twig --- site/templates/twig/items/ii/quotes/quotes.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/twig/items/ii/quotes/quotes.twig b/site/templates/twig/items/ii/quotes/quotes.twig index b6936d162..d88632ff3 100644 --- a/site/templates/twig/items/ii/quotes/quotes.twig +++ b/site/templates/twig/items/ii/quotes/quotes.twig @@ -50,7 +50,7 @@ {% if i == 1 and quote['Quote ID'] %}   {% if docm.count_documents(quote['Quote ID']) %} - + View Documents for Quote # {{ quote['Quote ID'] }} {% endif %} From 296c1b5e3a1eafc8edef0c177625de246710d5a1 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 09:59:19 -0500 Subject: [PATCH 076/106] Update tr-details.twig --- .../twig/items/ii/purchase-history/table/tr-details.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/twig/items/ii/purchase-history/table/tr-details.twig b/site/templates/twig/items/ii/purchase-history/table/tr-details.twig index 89edec803..e7afd6164 100644 --- a/site/templates/twig/items/ii/purchase-history/table/tr-details.twig +++ b/site/templates/twig/items/ii/purchase-history/table/tr-details.twig @@ -12,7 +12,7 @@ {% if i == 1 and invoice['Purchase Order Number'] %} {% if docm.count_documents_invoice(invoice['Purchase Order Number']) %} - + View Documents for PO # {{ invoice['Purchase Order Number'] }} {% endif %} From 858adb833123795f2faa69db5581ff1389901168 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:14:04 -0500 Subject: [PATCH 077/106] Update Documents.php --- site/controllers/classes/mii/Ii/Documents.php | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 83bb5313c..febd4491d 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -5,6 +5,7 @@ use ProcessWire\WireData; // Dplus Validators use Dplus\CodeValidators\Min as MinValidator; +use Dplus\CodeValidators\Mso as MsoValidator; // Mvc Controllers use Controllers\Mii\IiFunction; @@ -80,12 +81,21 @@ public static function documentsUrlQuote($itemID, $qnbr) { return $url->getUrl(); } - public static function documentsUrlQuote($itemID, $invnbr) { + public static function documentsUrlApInvoice($itemID, $invnbr) { $url = new Purl(self::documentsUrl($itemID, 'AP')); $url->query->set('invnbr', $invnbr); return $url->getUrl(); } + public static function documentsUrlSalesorder($itemID, $ordn, $date = '') { + $url = new Purl(self::documentsUrl($itemID, 'AR')); + $url->query->set('ordn', $ordn); + if ($date) { + $url->query->set('date', $date); + } + return $url->getUrl(); + } + /* ============================================================= 4. Data Retrieval ============================================================= */ @@ -117,6 +127,14 @@ public static function init() { $invnbr = $event->arguments(1); $event->return = self::documentsUrlApInvoice($itemID, $invnbr); }); + + $m->addHook('Page(pw_template=ii-item)::documentsUrlSalesorder', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $ordn = $event->arguments(1); + $date = $event->arguments(2); + $event->return = self::documentsUrlApSalesorder($itemID, $ordn, $date); + }); } private static function createList($itemID) { @@ -139,12 +157,22 @@ protected static function display($data) { switch ($data->folder) { case 'SO': case 'AR': - self::sanitizeParametersShort($data, ['ordn|ordn']); + self::sanitizeParametersShort($data, ['ordn|ordn', 'date|text']); $docm = self::pw('modules')->get('DocumentManagementSo'); $list->title = "Sales Order #$data->ordn Documents"; - $list->returnTitle = "Sales Orders"; + // TODO: ii sales orders url - $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-orders')->url."?itemID=$data->itemID"; + $validate = new MsoValidator(); + if ($validate->order($data->ordn)) { + $list->returnTitle = "Sales Orders"; + $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-orders')->url."?itemID=$data->itemID"; + } + + if ($validate->invoice($data->ordn)) { + $list->returnTitle = "Sales History"; + $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-history')->url."?itemID=$data->itemID"; + } + $list->documents = $docm->count_documents($data->ordn) ? $docm->get_documents($data->ordn) : []; break; case 'ACT': // Item Activity @@ -169,10 +197,22 @@ protected static function display($data) { $list->title = "AP Invoice #$data->invnbr Documents"; $list->returnTitle = "AP Invoices"; $list->documents = $docm->get_documents_invoice($data->invnbr); + // TODO: ii purchase history $list->returnUrl = self::pw('pages')->get('pw_template=ii-purchase-history')->url."?itemID=$data->itemID"; break; case 'PO': - + self::sanitizeParametersShort($data, ['ponbr|ponbr']); + $docm = self::pw('modules')->get('DocumentManagementPo'); + $list->title = "Purchase Order #$data->invnbr Documents"; + $list->returnTitle = "Purchase Orders"; + $list->documents = $docm->get_documents_po($data->ponbr); + // TODO: ii purchase orders + $list->returnUrl = self::pw('pages')->get('pw_template=ii-purchase-history')->url."?itemID=$data->itemID"; + break; + default: + $list->title = ""; + $list->returnTitle = ""; + $list->documents = $docm->get_documents_item($data->itemID); break; } From 18193db11b7ba08c5efd004acdb53d642cf1e102 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:14:12 -0500 Subject: [PATCH 078/106] Update DocumentManagementIi.module --- .../Dplus/DocumentManagement/DocumentManagementIi.module | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module index c58bcba89..85b6aa4b6 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module @@ -257,11 +257,10 @@ class DocumentManagementIi extends DocumentManagement implements Module { $event->return = $this->get_ii_documentURL($itemID, $folder, $document); }); - $this->addHook('Page(pw_template=ii-sales-orders|ii-sales-history)::documentsview_salesorder', function($event) { + $this->addHook('Page(pw_template=ii-sales-orders|ii-sales-history)::documentsUrlSalesorder', function($event) { $page = $event->object; $itemID = $event->arguments(0); $ordn = $event->arguments(1); - $lotserial = $event->arguments(2); $url = new Url($this->get_ii_docs_folderURL($itemID, self::TAG_SALESORDER)); $url->query->set('ordn', $ordn); From e01c6e92338bcef2405270de4b92ce5036c05f53 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:14:36 -0500 Subject: [PATCH 079/106] FIX: salesorder documents link --- site/templates/twig/items/ii/sales-history/sales-history.twig | 2 +- site/templates/twig/items/ii/sales-orders/sales-orders.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/site/templates/twig/items/ii/sales-history/sales-history.twig b/site/templates/twig/items/ii/sales-history/sales-history.twig index 76e51d9c3..fd69cde49 100644 --- a/site/templates/twig/items/ii/sales-history/sales-history.twig +++ b/site/templates/twig/items/ii/sales-history/sales-history.twig @@ -51,7 +51,7 @@ {{ module_formatter.format_celldata(invoice, column) }}   {% if i == 1 and invoice['Invoice Number'] %} {% if document_management.count_documents(invoice['Invoice Number']) == 0 %} - + View Documents for Order # {{ invoice['Invoice Number'] }} {% endif %} diff --git a/site/templates/twig/items/ii/sales-orders/sales-orders.twig b/site/templates/twig/items/ii/sales-orders/sales-orders.twig index 7882cf764..37f791f2d 100644 --- a/site/templates/twig/items/ii/sales-orders/sales-orders.twig +++ b/site/templates/twig/items/ii/sales-orders/sales-orders.twig @@ -48,7 +48,7 @@ {{ module_formatter.format_celldata(order, column) }}   {% if i == 1 and order['Sales Order Number'] %} {% if docm.count_documents(order['Sales Order Number']) %} - + View Documents for Order # {{ order['Sales Order Number'] }} {% endif %} From e037050c1430d359134215a839b820c6ae144da7 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:14:42 -0500 Subject: [PATCH 080/106] Update Ii.php --- site/controllers/classes/mii/Ii/Ii.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 76cc74ab9..99c66700a 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -86,12 +86,14 @@ public static function general($data) { public static function substitutes($data) { return Substitutes::index($data); } - + public static function documents($data) { return Documents::index($data); } public static function init() { + Documents::init(); + $m = self::pw('modules')->get('DpagesMii'); $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { $user = self::pw('user'); From 19c0bdb3607fac964b0ea105233d029a15f61664 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:18:38 -0500 Subject: [PATCH 081/106] chore: remove ii-documents template --- site/modules/Dplus/Dpages/DpagesMii.module | 19 +--- site/templates/ii-documents.php | 100 --------------------- site/templates/redir/ii.php | 20 ----- 3 files changed, 2 insertions(+), 137 deletions(-) delete mode 100644 site/templates/ii-documents.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 830a946e7..83d1917f9 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-documents' => array( - 'name' => 'ii-documents', - 'fields' => array(), - ), 'ii-sales-orders' => array( 'name' => 'ii-sales-orders', 'fields' => array(), @@ -107,16 +103,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-documents' => array( - 'template' => 'ii-function', - 'name' => 'documents', - 'title' => 'Documents', - 'summary' => 'View Item Substitutes', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-doc', - 'pw_template' => 'ii-documents', - 'jsoncode' => 'ii-documents' - ), 'ii-sales-orders' => array( 'template' => 'ii-function', 'name' => 'sales-orders', @@ -327,10 +313,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemdocumentsURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-documents'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('documents'); $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-documents.php b/site/templates/ii-documents.php deleted file mode 100644 index 26e0899e0..000000000 --- a/site/templates/ii-documents.php +++ /dev/null @@ -1,100 +0,0 @@ -get('HtmlWriter'); - - if ($lookup_ii->lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Documents"; - $docm = $modules->get('DocumentManagementIi'); - $html = $modules->get('HtmlWriter'); - - if ($input->get->document && $input->get->folder) { - $folder = $input->get->text('folder'); - $filename = $input->get->text('document'); - $docm->move_document($folder, $filename); - - if ($docm->is_filewebaccessible($filename)) { - $session->redirect($config->url_webdocs.$filename); - } - } - - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID]); - - if ($input->get->folder) { - $folder = $input->get->text('folder'); - - switch ($folder) { - case 'SO': - $docm = $modules->get('DocumentManagementSo'); - $ordn = SalesOrder::get_paddedordernumber($input->get->text('ordn')); - $page->title = "Sales Order #$ordn Documents"; - $documents = $docm->count_documents($ordn) ? $docm->get_documents($ordn) : array(); - - $href = $pages->get('pw_template=ii-sales-orders')->url."?itemID=$itemID"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Sales Orders")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - case 'AR': - $docm = $modules->get('DocumentManagementSo'); - $ordn = SalesOrder::get_paddedordernumber($input->get->text('ordn')); - $date = $input->get->text('date'); - $page->title = "Sales Order #$ordn Documents"; - $documents = $docm->count_documents($ordn) ? $docm->get_documents($ordn) : array(); - $href = $pages->get('pw_template=ii-sales-history')->url."?itemID=$itemID&date=$date"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Sales History")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - case 'ACT': // Item Activity - $type = $input->get->text('type'); - $reference = $input->get->text('reference'); - $page->title = "$type $reference Documents"; - $documents = $docm->get_documents_activity($type, $reference); - - $href = $pages->get('pw_template=ii-activity')->url."?itemID=$itemID"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Activity")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - case 'QT': - $qnbr = $input->get->text('qnbr'); - $page->title = "Quote #$qnbr Documents"; - $docm = $modules->get('DocumentManagementQt'); - $documents = $docm->get_documents($qnbr); - - $href = $pages->get('pw_template=ii-quotes')->url."?itemID=$itemID"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Quotes")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - case 'AP': - $docm = $modules->get('DocumentManagementPo'); - $invnbr = PurchaseOrder::get_paddedponumber($input->get->text('invnbr')); - $page->title = "AP Invoice #$invnbr Documents"; - $documents = $docm->get_documents_invoice($invnbr); - - $href = $pages->get('pw_template=ii-purchase-history')->url."?itemID=$itemID"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Purchase History")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - case 'PO': - $docm = $modules->get('DocumentManagementPo'); - $ponbr = PurchaseOrder::get_paddedponumber($input->get->text('ponbr')); - $page->title = "Purchase Order #$ponbr Documents"; - $documents = $docm->get_documents_po($ponbr); - - $href = $pages->get('pw_template=ii-purchase-orders')->url."?itemID=$itemID"; - $page->body .= $html->div('class=mb-3', $html->a("href=$href|class=btn btn-secondary", $html->icon('fa fa-arrow-left') . " Back to Item Purchase Orders")); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - break; - } - } else { - $documents = $docm->get_documents_item($itemID); - $page->body .= $config->twig->render('items/ii/documents/documents-dm.twig', ['page' => $page, 'documents' => $documents, 'docm' => $docm, 'itemID' => $itemID]); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 78c9d47cf..156d0477b 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,15 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-documents': - * Request II Documents JSON file - * Response: Creates II Documents JSON file - * DBNAME=$dplusdb - * DOCVIEW - * FLD1CD=IT - * FLD1DATA=$itemID - * FLD1DESC=$desc - * break; * case 'ii-sales-orders': * Request II Sales Orders JSON file * Response: Creates II Sales Orders JSON file @@ -62,17 +53,6 @@ $session->loc = $url; } break; - case 'ii-documents': - $desc = ItemMasterItemQuery::create()->select(ItemMasterItem::get_aliasproperty('desc'))->findOneByItemid($itemID); - $data = array("DBNAME=$dplusdb", 'DOCVIEW', "FLD1CD=IT", "FLD1DATA=$itemID", "FLD1DESC=$desc"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-documents')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-sales-orders': $data = array("DBNAME=$dplusdb", 'IISALESORDR', "ITEMID=$itemID"); From 8ad29c0c7f05767f97670dc5d399308734b87272 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:43:27 -0500 Subject: [PATCH 082/106] STYLE: update ii-sales-orders to use ii-display template --- .../twig/items/ii/sales-orders/display.twig | 11 +++++++ .../items/ii/sales-orders/sales-orders.twig | 30 ++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 site/templates/twig/items/ii/sales-orders/display.twig diff --git a/site/templates/twig/items/ii/sales-orders/display.twig b/site/templates/twig/items/ii/sales-orders/display.twig new file mode 100644 index 000000000..8edf0362c --- /dev/null +++ b/site/templates/twig/items/ii/sales-orders/display.twig @@ -0,0 +1,11 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% include 'items/ii/sales-orders/sales-orders.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/sales-orders/sales-orders.twig b/site/templates/twig/items/ii/sales-orders/sales-orders.twig index 37f791f2d..66f289d4b 100644 --- a/site/templates/twig/items/ii/sales-orders/sales-orders.twig +++ b/site/templates/twig/items/ii/sales-orders/sales-orders.twig @@ -1,12 +1,14 @@ {% for id, warehouse in json['data'] %} -
-
-

{{ warehouse['Whse Name'] }}

-
-
- +
+
+
+

{{ warehouse['Whse Name'] }}

+
+
+ +
@@ -20,7 +22,7 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -44,11 +46,11 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(order, column) }}   + + {{ formatter.format_celldata(order, column) }}   {% if i == 1 and order['Sales Order Number'] %} {% if docm.count_documents(order['Sales Order Number']) %} - + View Documents for Order # {{ order['Sales Order Number'] }} {% endif %} @@ -76,8 +78,8 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(order, column) }} + + {{ formatter.format_celldata(order, column) }} {% else %} {% if columncount < blueprint['cols'] %} From 3e3f6dcb82c26852133f6edc13c20459b179d81e Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:43:38 -0500 Subject: [PATCH 083/106] Update Documents.php --- site/controllers/classes/mii/Ii/Documents.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index febd4491d..02e7c9b39 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -133,7 +133,7 @@ public static function init() { $itemID = $event->arguments(0); $ordn = $event->arguments(1); $date = $event->arguments(2); - $event->return = self::documentsUrlApSalesorder($itemID, $ordn, $date); + $event->return = self::documentsUrlSalesorder($itemID, $ordn, $date); }); } @@ -165,7 +165,7 @@ protected static function display($data) { $validate = new MsoValidator(); if ($validate->order($data->ordn)) { $list->returnTitle = "Sales Orders"; - $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-orders')->url."?itemID=$data->itemID"; + $list->returnUrl = SalesOrders::ordersUrl($data->itemID); } if ($validate->invoice($data->ordn)) { From 17a74dd0e907390168093d9ac9d2d805953645d7 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:44:14 -0500 Subject: [PATCH 084/106] REFACTOR: create and implement Ii\SalesOrders controller --- site/controllers/classes/mii/Ii/Ii.php | 6 + .../classes/mii/Ii/SalesOrders.php | 124 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + 4 files changed, 132 insertions(+) create mode 100644 site/controllers/classes/mii/Ii/SalesOrders.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 99c66700a..d3ab320e9 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -17,6 +17,7 @@ use Controllers\Mii\Ii\General; use Controllers\Mii\Ii\Substitutes; use Controllers\Mii\Ii\Documents; +use Controllers\Mii\Ii\SalesOrders; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -33,6 +34,7 @@ class Ii extends AbstractController { 'general' => 'General', 'substitutes' => 'Substitutes', 'documents' => 'Documents', + 'sales-orders' => 'Sales Orders', ]; public static function item($data) { @@ -91,6 +93,10 @@ public static function documents($data) { return Documents::index($data); } + public static function salesOrders($data) { + return SalesOrders::index($data); + } + public static function init() { Documents::init(); diff --git a/site/controllers/classes/mii/Ii/SalesOrders.php b/site/controllers/classes/mii/Ii/SalesOrders.php new file mode 100644 index 000000000..306ccc7d4 --- /dev/null +++ b/site/controllers/classes/mii/Ii/SalesOrders.php @@ -0,0 +1,124 @@ +refresh) { + self::requestJson($data); + self::pw('session')->redirect(self::ordersUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + return self::orders($data); + } + + public static function orders($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + self::sanitizeParametersShort($data, ['itemID|text']); + self::getData($data); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Sales Orders"; + $html = ''; + $html .= self::breadCrumbs();; + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IISALESORDR', "ITEMID=$vars->itemID"]; + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function ordersUrl($itemID, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('sales-orders'); + $url->query->set('itemID', $itemID); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::ordersUrl($data->itemID, $refresh = true), $http301 = false); + } + return true; + } + + if ($session->getFor('ii', 'sales-orders') > 3) { + return false; + } else { + $session->setFor('ii', 'sales-orders', ($session->getFor('ii', 'sales-orders') + 1)); + $session->redirect(self::ordersUrl($data->itemID, $refresh = true), $http301 = false); + } + } + + protected static function display($data) { + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Sales Orders File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::ordersUrl($data->itemID, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $docm = self::pw('modules')->get('DocumentManagementSo'); + return $config->twig->render('items/ii/sales-orders/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index a1c0a99a7..e811a238e 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -42,6 +42,7 @@ 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', + 'Controllers\\Mii\\Ii\\SalesOrders' => $baseDir . '/classes/mii/Ii/SalesOrders.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Substitutes' => $baseDir . '/classes/mii/Ii/Substitutes.php', 'Controllers\\Mii\\Ii\\Usage' => $baseDir . '/classes/mii/Ii/Usage.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 92c43a4ac..66929f3e2 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -43,6 +43,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', + 'Controllers\\Mii\\Ii\\SalesOrders' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesOrders.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Substitutes' => __DIR__ . '/../..' . '/classes/mii/Ii/Substitutes.php', 'Controllers\\Mii\\Ii\\Usage' => __DIR__ . '/../..' . '/classes/mii/Ii/Usage.php', From 59dbbcf656d50dc6ed801cab2702d795d0afefd3 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 10:46:45 -0500 Subject: [PATCH 085/106] CHORE: remove ii-sales-orders template --- site/modules/Dplus/Dpages/DpagesMii.module | 19 +-------- site/templates/ii-item.php | 1 + site/templates/ii-sales-orders.php | 46 ---------------------- site/templates/redir/ii.php | 17 -------- 4 files changed, 3 insertions(+), 80 deletions(-) delete mode 100644 site/templates/ii-sales-orders.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 83d1917f9..078a7faf0 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -38,10 +38,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-item', 'fields' => array(), ), - 'ii-sales-orders' => array( - 'name' => 'ii-sales-orders', - 'fields' => array(), - ), 'ii-sales-history' => array( 'name' => 'ii-sales-history', 'fields' => array(), @@ -103,16 +99,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-sales-orders' => array( - 'template' => 'ii-function', - 'name' => 'sales-orders', - 'title' => 'Sales Orders', - 'summary' => 'View Item Sales Orders', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-sor', - 'pw_template' => 'ii-sales-orders', - 'jsoncode' => 'ii-sales-orders' - ), 'ii-sales-history' => array( 'template' => 'ii-function', 'name' => 'sales-history', @@ -323,10 +309,9 @@ class DpagesMii extends Dpages implements Module { $p = $event->object; $itemID = $event->arguments(0); $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-sales-orders'); - $url->query->set('itemID', $itemID); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('sales-orders'); $url->query->set('page', $p->fullURL->getUrl()); - $event->return = $url->getUrl(); }); $this->addHook('Page::get_itemsaleshistoryURL', function($event) { diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 5bb4844eb..d7c6fd29c 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -19,6 +19,7 @@ ['GET', 'general', Ii::class, 'general'], ['GET', 'substitutes', Ii::class, 'substitutes'], ['GET', 'documents', Ii::class, 'documents'], + ['GET', 'sales-orders', Ii::class, 'salesOrders'], ]; $router = new Mvc\Router(); diff --git a/site/templates/ii-sales-orders.php b/site/templates/ii-sales-orders.php deleted file mode 100644 index 77a4f585a..000000000 --- a/site/templates/ii-sales-orders.php +++ /dev/null @@ -1,46 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Sales Orders"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemsalesordersURL($itemID)); - } - $session->salesorderstry = 0; - - $refreshurl = $page->get_itemsalesordersURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $module_formatter = new Dplus\ScreenFormatters\Ii\SalesOrders();; - $module_formatter->init_formatter(); - $docm = $modules->get('DocumentManagementSo'); - $page->body .= $config->twig->render('items/ii/sales-orders/sales-orders.twig', ['page' => $page, 'itemID' => $itemID, 'json' => $json, 'module_formatter' => $module_formatter, 'blueprint' => $module_formatter->get_tableblueprint(), 'docm' => $docm]); - } - } else { - if ($session->salesorderstry > 3) { - $page->headline = $page->title = "Sales Orders File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->salesorderstry++; - $session->redirect($page->get_itemsalesordersURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 156d0477b..7be3656e0 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-sales-orders': - * Request II Sales Orders JSON file - * Response: Creates II Sales Orders JSON file - * DBNAME=$dplusdb - * IISALESORDR - * ITEMID=$itemID - * break; * case 'ii-sales-history': * Request II Sales History JSON file * Response: Creates II Sales History JSON file @@ -53,16 +46,6 @@ $session->loc = $url; } break; - case 'ii-sales-orders': - $data = array("DBNAME=$dplusdb", 'IISALESORDR', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-sales-orders')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-sales-history': $data = array("DBNAME=$dplusdb", 'IISALESHIST', "ITEMID=$itemID"); $date = $input->$requestmethod->text('date'); From 8604c6b0dd69729a484ee802bb3eb33edbeb0ef5 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:32:13 -0500 Subject: [PATCH 086/106] FIX: page.documentsUrlSalesorder -> page.documentListUrl --- site/templates/twig/items/ii/sales-orders/sales-orders.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/twig/items/ii/sales-orders/sales-orders.twig b/site/templates/twig/items/ii/sales-orders/sales-orders.twig index 66f289d4b..75052e7a4 100644 --- a/site/templates/twig/items/ii/sales-orders/sales-orders.twig +++ b/site/templates/twig/items/ii/sales-orders/sales-orders.twig @@ -50,7 +50,7 @@ {{ formatter.format_celldata(order, column) }}   {% if i == 1 and order['Sales Order Number'] %} {% if docm.count_documents(order['Sales Order Number']) %} - + View Documents for Order # {{ order['Sales Order Number'] }} {% endif %} From 13028475135d2754f6c901dfa3b38fa76f51bae0 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:34:26 -0500 Subject: [PATCH 087/106] CHORE: Add Supplements Section --- .../classes/mii/Ii/SalesOrders.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/site/controllers/classes/mii/Ii/SalesOrders.php b/site/controllers/classes/mii/Ii/SalesOrders.php index 306ccc7d4..d7709940a 100644 --- a/site/controllers/classes/mii/Ii/SalesOrders.php +++ b/site/controllers/classes/mii/Ii/SalesOrders.php @@ -101,7 +101,11 @@ private static function getData($data) { } } - protected static function display($data) { +/* ============================================================= + 5. Displays +============================================================= */ + private static function display($data) { + self::init(); $jsonm = self::getJsonModule(); $json = $jsonm->getFile(self::JSONCODE); $config = self::pw('config'); @@ -121,4 +125,17 @@ protected static function display($data) { $docm = self::pw('modules')->get('DocumentManagementSo'); return $config->twig->render('items/ii/sales-orders/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $itemID = $event->arguments(0); + $ordn = $event->arguments(1); + $event->return = Documents::documentsUrlSalesorder($itemID, $ordn); + }); + } } From 3fd62623216fa9a166f5c02a245e0099d71a4c6c Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:34:31 -0500 Subject: [PATCH 088/106] Update Documents.php --- site/controllers/classes/mii/Ii/Documents.php | 87 +++++++++---------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 02e7c9b39..4be5c6d27 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -103,51 +103,7 @@ public static function documentsUrlSalesorder($itemID, $ordn, $date = '') { /* ============================================================= 5. Displays ============================================================= */ - public static function init() { - $m = self::pw('modules')->get('DpagesMii'); - - $m->addHook('Page(pw_template=ii-item)::documentUrl', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $folder = $event->arguments(1); - $document = $event->arguments(2); - $event->return = self::documentsUrl($itemID, $folder, $document); - }); - - $m->addHook('Page(pw_template=ii-item|ii-quotes)::documentsUrlQuote', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $qnbr = $event->arguments(1); - $event->return = self::documentsUrlQuote($itemID, $qnbr); - }); - - $m->addHook('Page(pw_template=ii-item)::documentsUrlApInvoice', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $invnbr = $event->arguments(1); - $event->return = self::documentsUrlApInvoice($itemID, $invnbr); - }); - - $m->addHook('Page(pw_template=ii-item)::documentsUrlSalesorder', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $ordn = $event->arguments(1); - $date = $event->arguments(2); - $event->return = self::documentsUrlSalesorder($itemID, $ordn, $date); - }); - } - - private static function createList($itemID) { - $list = new WireData(); - $list->itemid = $itemID; - $list->title = ''; - $list->documents = []; - $list->returnUrl = ''; - $list->returnTitle = ''; - return $list; - } - - protected static function display($data) { + private static function display($data) { self::init(); self::sanitizeParametersShort($data, ['itemID|text', 'folder|text']); $list = self::createList($data->itemID); @@ -170,7 +126,7 @@ protected static function display($data) { if ($validate->invoice($data->ordn)) { $list->returnTitle = "Sales History"; - $list->returnUrl = self::pw('pages')->get('pw_template=ii-sales-history')->url."?itemID=$data->itemID"; + $list->returnUrl = SalesHistory::historyUrl($data->itemID, $data->date); } $list->documents = $docm->count_documents($data->ordn) ? $docm->get_documents($data->ordn) : []; @@ -218,4 +174,43 @@ protected static function display($data) { return self::pw('config')->twig->render('items/ii/documents/display.twig', ['item' => self::getItmItem($data->itemID), 'list' => $list]); } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentUrl', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $folder = $event->arguments(1); + $document = $event->arguments(2); + $event->return = self::documentsUrl($itemID, $folder, $document); + }); + + $m->addHook('Page(pw_template=ii-item)::documentsUrlQuote', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $qnbr = $event->arguments(1); + $event->return = self::documentsUrlQuote($itemID, $qnbr); + }); + + $m->addHook('Page(pw_template=ii-item)::documentsUrlApInvoice', function($event) { + $page = $event->object; + $itemID = $event->arguments(0); + $invnbr = $event->arguments(1); + $event->return = self::documentsUrlApInvoice($itemID, $invnbr); + }); + } + + private static function createList($itemID) { + $list = new WireData(); + $list->itemid = $itemID; + $list->title = ''; + $list->documents = []; + $list->returnUrl = ''; + $list->returnTitle = ''; + return $list; + } } From 2563acd8e06f19e80e612d83581b396811550e47 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:35:11 -0500 Subject: [PATCH 089/106] STYLE: use ii-display template for ii-sales-history --- .../twig/items/ii/sales-history/display.twig | 11 +++++++++++ .../items/ii/sales-history/sales-history.twig | 18 +++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 site/templates/twig/items/ii/sales-history/display.twig diff --git a/site/templates/twig/items/ii/sales-history/display.twig b/site/templates/twig/items/ii/sales-history/display.twig new file mode 100644 index 000000000..7ce82b719 --- /dev/null +++ b/site/templates/twig/items/ii/sales-history/display.twig @@ -0,0 +1,11 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% include 'items/ii/sales-history/sales-history.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/sales-history/sales-history.twig b/site/templates/twig/items/ii/sales-history/sales-history.twig index fd69cde49..9b2700c81 100644 --- a/site/templates/twig/items/ii/sales-history/sales-history.twig +++ b/site/templates/twig/items/ii/sales-history/sales-history.twig @@ -23,7 +23,7 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -47,11 +47,11 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(invoice, column) }}   + + {{ formatter.format_celldata(invoice, column) }}   {% if i == 1 and invoice['Invoice Number'] %} {% if document_management.count_documents(invoice['Invoice Number']) == 0 %} - + View Documents for Order # {{ invoice['Invoice Number'] }} {% endif %} @@ -77,7 +77,7 @@ {% if blueprint['lotserial']['rows'][x]['columns'][i] %} {% set column = blueprint['lotserial']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -100,8 +100,8 @@ {% if blueprint['lotserial']['rows'][x]['columns'][i] %} {% set column = blueprint['lotserial']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(lot, column) }} + + {{ formatter.format_celldata(lot, column) }} {% else %} {% if columncount < blueprint['cols'] %} @@ -127,8 +127,8 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(invoice, column) }} + + {{ formatter.format_celldata(invoice, column) }} {% else %} {% if columncount < blueprint['cols'] %} From 6ae27ceb95cd8314d4e0eb9af92346ca9512b083 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:35:43 -0500 Subject: [PATCH 090/106] REFACTOR: create and implement Ii\SalesHistory controller --- site/controllers/classes/mii/Ii/Ii.php | 6 + .../classes/mii/Ii/SalesHistory.php | 187 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 5 files changed, 196 insertions(+) create mode 100644 site/controllers/classes/mii/Ii/SalesHistory.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index d3ab320e9..5ae0ea2c5 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -18,6 +18,7 @@ use Controllers\Mii\Ii\Substitutes; use Controllers\Mii\Ii\Documents; use Controllers\Mii\Ii\SalesOrders; +use Controllers\Mii\Ii\SalesHistory; class Ii extends AbstractController { const SUBFUNCTIONS = [ @@ -35,6 +36,7 @@ class Ii extends AbstractController { 'substitutes' => 'Substitutes', 'documents' => 'Documents', 'sales-orders' => 'Sales Orders', + 'sales-history' => 'Sales History', ]; public static function item($data) { @@ -97,6 +99,10 @@ public static function salesOrders($data) { return SalesOrders::index($data); } + public static function salesHistory($data) { + return SalesHistory::index($data); + } + public static function init() { Documents::init(); diff --git a/site/controllers/classes/mii/Ii/SalesHistory.php b/site/controllers/classes/mii/Ii/SalesHistory.php new file mode 100644 index 000000000..f115d5ca2 --- /dev/null +++ b/site/controllers/classes/mii/Ii/SalesHistory.php @@ -0,0 +1,187 @@ +refresh) { + if ($data->date) { + self::requestJson($data); + $data->date = date(self::DATE_FORMAT, $data->date); + } + self::pw('session')->redirect(self::historyUrl($data->itemID, $data->date), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + if (empty($data->date) === false) { + return self::history($data); + } + return self::dateForm($data); + } + + public static function history($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + self::sanitizeParametersShort($data, ['itemID|text', 'date|text']); + self::getData($data); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Sales History"; + $html = ''; + $html .= self::breadCrumbs();; + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text', 'date|date']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IISALESHIST', "ITEMID=$vars->itemID"]; + if ($vars->date) { + $dateYmd = date(self::DATE_FORMAT_DPLUS, $vars->date); + $data[] = "DATE=$dateYmd"; + } + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function historyUrl($itemID, $date, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('sales-history'); + $url->query->set('itemID', $itemID); + + if ($date) { + $url->query->set('date', $date); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + self::sanitizeParametersShort($data, ['itemID|text', 'date|date']); + if ($data->date) { + $data->timestamp = $data->date; + $data->date = date(self::DATE_FORMAT, $data->date); + } + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID || $json['date'] != date(self::DATE_FORMAT_DPLUS, $data->timestamp)) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::historyUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + return true; + } + + if ($session->getFor('ii', 'sales-history') > 3) { + return false; + } else { + $session->setFor('ii', 'sales-history', ($session->getFor('ii', 'sales-history') + 1)); + $session->redirect(self::historyUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + } + +/* ============================================================= + 5. Displays +============================================================= */ + protected static function display($data) { + self::init(); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Sales Orders File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::historyUrl($data->itemID, $data->date, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $docm = self::pw('modules')->get('DocumentManagementSo'); + return $config->twig->render('items/ii/sales-history/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + } + + private static function dateForm($data) { + self::sanitizeParametersShort($data, ['itemID|text']); + $config = self::pw('config'); + $page = self::pw('page'); + $iio = self::getIio(); + + $options = $iio->useriio(self::pw('user')->loginid); + $startdate = date(self::DATE_FORMAT); + + if ($options->dayssaleshistory > 0) { + $startdate = date(self::DATE_FORMAT, strtotime("-$options->dayssaleshistory days")); + } + + if (intval($options->datesaleshistory) > 0) { + $startdate = date(self::DATE_FORMAT, strtotime($options->datesaleshistory)); + } + + $page->headline = "II: $data->itemID Sales History"; + $html = self::breadCrumbs(); + $html .= '

Enter Starting History Date

'; + $html .= $config->twig->render('items/ii/sales-history/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); + $config->scripts->append(self::getFileHasher()->getHashUrl('scripts/lib/jquery-validate.js')); + return $html; + } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $itemID = $event->arguments(0); + $ordn = $event->arguments(1); + $date = $event->arguments(2); + $event->return = Documents::documentsUrlSalesorder($itemID, $ordn, $date); + }); + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index e811a238e..5b7312234 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -42,6 +42,7 @@ 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', + 'Controllers\\Mii\\Ii\\SalesHistory' => $baseDir . '/classes/mii/Ii/SalesHistory.php', 'Controllers\\Mii\\Ii\\SalesOrders' => $baseDir . '/classes/mii/Ii/SalesOrders.php', 'Controllers\\Mii\\Ii\\Stock' => $baseDir . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Substitutes' => $baseDir . '/classes/mii/Ii/Substitutes.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 66929f3e2..51a61f25d 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -43,6 +43,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', + 'Controllers\\Mii\\Ii\\SalesHistory' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesHistory.php', 'Controllers\\Mii\\Ii\\SalesOrders' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesOrders.php', 'Controllers\\Mii\\Ii\\Stock' => __DIR__ . '/../..' . '/classes/mii/Ii/Stock.php', 'Controllers\\Mii\\Ii\\Substitutes' => __DIR__ . '/../..' . '/classes/mii/Ii/Substitutes.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index d7c6fd29c..d2b1a9f03 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -20,6 +20,7 @@ ['GET', 'substitutes', Ii::class, 'substitutes'], ['GET', 'documents', Ii::class, 'documents'], ['GET', 'sales-orders', Ii::class, 'salesOrders'], + ['GET', 'sales-history', Ii::class, 'salesHistory'], ]; $router = new Mvc\Router(); From c3c1608cc9c68ebfc8a62c362b41345dda971473 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:39:50 -0500 Subject: [PATCH 091/106] CHORE: remove ii-sales-history --- site/modules/Dplus/Dpages/DpagesMii.module | 20 ++------ site/templates/ii-sales-history.php | 53 ---------------------- site/templates/redir/ii.php | 25 ---------- 3 files changed, 4 insertions(+), 94 deletions(-) delete mode 100644 site/templates/ii-sales-history.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 078a7faf0..b1fc7e047 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -99,16 +99,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-sales-history' => array( - 'template' => 'ii-function', - 'name' => 'sales-history', - 'title' => 'Sales History', - 'summary' => 'View Item Sales History', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-sht', - 'pw_template' => 'ii-sales-history', - 'jsoncode' => 'ii-sales-history' - ), 'ii-quotes' => array( 'template' => 'ii-function', 'name' => 'quotes', @@ -308,21 +298,19 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemsalesordersURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); $url->path->add('sales-orders'); - $url->query->set('page', $p->fullURL->getUrl()); + $url->query->set('itemID', $itemID); + $event->return = $url->getUrl(); }); $this->addHook('Page::get_itemsaleshistoryURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); $date = $event->arguments(1); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-sales-history'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('sales-history'); $url->query->set('itemID', $itemID); - $url->query->set('date', $date); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-sales-history.php b/site/templates/ii-sales-history.php deleted file mode 100644 index e0253f298..000000000 --- a/site/templates/ii-sales-history.php +++ /dev/null @@ -1,53 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Sales History"; - - if ($input->get->date) { - $date = $input->get->text('date'); - $page->title .= " starting from $date"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemsaleshistoryURL($itemID)); - } - $session->saleshistorytry = 0; - - $refreshurl = $page->get_itemsaleshistoryURL($itemID, $date); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $module_formatter = new Dplus\ScreenFormatters\Ii\SalesHistory(); - $module_formatter->init_formatter(); - $docm = $modules->get('DocumentManagementSo'); - $page->body .= $config->twig->render('items/ii/sales-history/sales-history.twig', ['page' => $page, 'itemID' => $itemID, 'json' => $json, 'module_formatter' => $module_formatter, 'blueprint' => $module_formatter->get_tableblueprint(), 'docm' => $docm]); - } - } else { - if ($session->saleshistorytry > 3) { - $page->headline = $page->title = "Sales History File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->saleshistorytry++; - $session->redirect($page->get_itemsaleshistoryURL($itemID, $date)); - } - } - } else { - $page->body .= $config->twig->render('items/ii/sales-history/date-form.twig', ['page' => $page, 'itemID' => $itemID]); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 7be3656e0..4a455ea8d 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -22,13 +22,6 @@ * IISELECT * ITEMID=$itemID * break; - * case 'ii-sales-history': - * Request II Sales History JSON file - * Response: Creates II Sales History JSON file - * DBNAME=$dplusdb - * IISALESHIST - * ITEMID=$itemID - * break; * } **/ @@ -46,24 +39,6 @@ $session->loc = $url; } break; - case 'ii-sales-history': - $data = array("DBNAME=$dplusdb", 'IISALESHIST', "ITEMID=$itemID"); - $date = $input->$requestmethod->text('date'); - - if (!empty($date)) { - $date_ymd = date('Ymd', strtotime($date)); - $data[] = "DATE=$date_ymd"; - } - - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('date', $date); - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-sales-history')->httpUrl."?itemID=$itemID&date=$date"; - $session->loc = $url; - } - break; case 'ii-quotes': $data = array("DBNAME=$dplusdb", 'IIQUOTE', "ITEMID=$itemID"); From f68bdb1da04cbd6f2d42de01cc018035d0edf115 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:53:23 -0500 Subject: [PATCH 092/106] STYLE: use ii-display for ii-quotes --- site/templates/twig/items/ii/quotes/display.twig | 11 +++++++++++ site/templates/twig/items/ii/quotes/quotes.twig | 14 +++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 site/templates/twig/items/ii/quotes/display.twig diff --git a/site/templates/twig/items/ii/quotes/display.twig b/site/templates/twig/items/ii/quotes/display.twig new file mode 100644 index 000000000..c42e83d40 --- /dev/null +++ b/site/templates/twig/items/ii/quotes/display.twig @@ -0,0 +1,11 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% include 'items/ii/quotes/quotes.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/quotes/quotes.twig b/site/templates/twig/items/ii/quotes/quotes.twig index d88632ff3..10734787f 100644 --- a/site/templates/twig/items/ii/quotes/quotes.twig +++ b/site/templates/twig/items/ii/quotes/quotes.twig @@ -20,7 +20,7 @@ {% if blueprint['header']['rows'][x]['columns'][i] %} {% set column = blueprint['header']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -44,13 +44,13 @@ {% if blueprint['header']['rows'][x]['columns'][i] %} {% set column = blueprint['header']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(quote, column) }} + + {{ formatter.format_celldata(quote, column) }} {% if i == 1 and quote['Quote ID'] %}   {% if docm.count_documents(quote['Quote ID']) %} - + View Documents for Quote # {{ quote['Quote ID'] }} {% endif %} @@ -75,7 +75,7 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -97,8 +97,8 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(detail, column) }} + + {{ formatter.format_celldata(detail, column) }} {% else %} {% if columncount < blueprint['cols'] %} From 11b4a6fd0440514bb335cd66c6cf6faa98bd4268 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:53:59 -0500 Subject: [PATCH 093/106] REFACTOR: Implement Ii\Quotes controller --- site/controllers/classes/mii/Ii/Documents.php | 4 +- site/controllers/classes/mii/Ii/Ii.php | 5 + site/controllers/classes/mii/Ii/Quotes.php | 141 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 6 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/Quotes.php diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 4be5c6d27..727741fc7 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -117,7 +117,6 @@ private static function display($data) { $docm = self::pw('modules')->get('DocumentManagementSo'); $list->title = "Sales Order #$data->ordn Documents"; - // TODO: ii sales orders url $validate = new MsoValidator(); if ($validate->order($data->ordn)) { $list->returnTitle = "Sales Orders"; @@ -144,8 +143,7 @@ private static function display($data) { $list->title = "Quote #$data->qnbr Documents"; $list->returnTitle = "Quotes"; $list->documents = $docm->get_documents($data->qnbr); - // TODO: ii quotes - $list->returnUrl = self::pw('pages')->get('pw_template=ii-quotes')->url."?itemID=$data->itemID"; + $list->returnUrl = Quotes::quotesUrl($data->itemID); break; case 'AP': self::sanitizeParametersShort($data, ['invnbr|ponbr']); diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 5ae0ea2c5..94ca946cc 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -3,6 +3,7 @@ use Purl\Url as Purl; // Mvc Controllers use Mvc\Controllers\AbstractController; +use Controllers\Mii\Ii as Sub; use Controllers\Mii\Ii\Item; use Controllers\Mii\Ii\Stock; use Controllers\Mii\Ii\Requirements; @@ -103,6 +104,10 @@ public static function salesHistory($data) { return SalesHistory::index($data); } + public static function quotes($data) { + return Sub\Quotes::index($data); + } + public static function init() { Documents::init(); diff --git a/site/controllers/classes/mii/Ii/Quotes.php b/site/controllers/classes/mii/Ii/Quotes.php new file mode 100644 index 000000000..67d40d88f --- /dev/null +++ b/site/controllers/classes/mii/Ii/Quotes.php @@ -0,0 +1,141 @@ +refresh) { + self::requestJson($data); + self::pw('session')->redirect(self::quotesUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + return self::quotes($data); + } + + public static function quotes($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + self::sanitizeParametersShort($data, ['itemID|text']); + self::getData($data); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Quotes"; + $html = ''; + $html .= self::breadCrumbs();; + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IIQUOTE', "ITEMID=$vars->itemID"]; + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function quotesUrl($itemID, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('quotes'); + $url->query->set('itemID', $itemID); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::quotesUrl($data->itemID, $refresh = true), $http301 = false); + } + return true; + } + + if ($session->getFor('ii', 'quotes') > 3) { + return false; + } else { + $session->setFor('ii', 'quotes', ($session->getFor('ii', 'quotes') + 1)); + $session->redirect(self::quotesUrl($data->itemID, $refresh = true), $http301 = false); + } + } + +/* ============================================================= + 5. Displays +============================================================= */ + private static function display($data) { + self::init(); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Quotes File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::quotesUrl($data->itemID, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $docm = self::pw('modules')->get('DocumentManagementQt'); + return $config->twig->render('items/ii/quotes/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $itemID = $event->arguments(0); + $qnbr = $event->arguments(1); + $event->return = Documents::documentsUrlQuote($itemID, $qnbr); + }); + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 5b7312234..a590e9196 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -41,6 +41,7 @@ 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\Quotes' => $baseDir . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\SalesHistory' => $baseDir . '/classes/mii/Ii/SalesHistory.php', 'Controllers\\Mii\\Ii\\SalesOrders' => $baseDir . '/classes/mii/Ii/SalesOrders.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 51a61f25d..2d3e2deb3 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -42,6 +42,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\Quotes' => __DIR__ . '/../..' . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\SalesHistory' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesHistory.php', 'Controllers\\Mii\\Ii\\SalesOrders' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesOrders.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index d2b1a9f03..36e483511 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -21,6 +21,7 @@ ['GET', 'documents', Ii::class, 'documents'], ['GET', 'sales-orders', Ii::class, 'salesOrders'], ['GET', 'sales-history', Ii::class, 'salesHistory'], + ['GET', 'quotes', Ii::class, 'quotes'], ]; $router = new Mvc\Router(); From c3fa304a5cd25a690f0d533a355cc204cec8118e Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 14:56:50 -0500 Subject: [PATCH 094/106] CHORE: remove ii-quotes template --- site/modules/Dplus/Dpages/DpagesMii.module | 21 +--------- site/templates/ii-quotes.php | 47 ---------------------- site/templates/redir/ii.php | 10 ----- 3 files changed, 2 insertions(+), 76 deletions(-) delete mode 100644 site/templates/ii-quotes.php diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index b1fc7e047..b350b5d85 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -42,10 +42,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-sales-history', 'fields' => array(), ), - 'ii-quotes' => array( - 'name' => 'ii-quotes', - 'fields' => array(), - ), 'ii-purchase-orders' => array( 'name' => 'ii-purchase-orders', 'fields' => array(), @@ -99,16 +95,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-quotes' => array( - 'template' => 'ii-function', - 'name' => 'quotes', - 'title' => 'Quotes', - 'summary' => 'View Item Quotes', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-qte', - 'pw_template' => 'ii-quotes', - 'jsoncode' => 'ii-quotes' - ), 'ii-purchase-orders' => array( 'template' => 'ii-function', 'name' => 'purchase-orders', @@ -317,12 +303,9 @@ class DpagesMii extends Dpages implements Module { $this->addHook('Page::get_itemquotesURL', function($event) { $p = $event->object; $itemID = $event->arguments(0); - $date = $event->arguments(1); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-quotes'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('quotes'); $url->query->set('itemID', $itemID); - $url->query->set('date', $date); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-quotes.php b/site/templates/ii-quotes.php deleted file mode 100644 index ff7ed3363..000000000 --- a/site/templates/ii-quotes.php +++ /dev/null @@ -1,47 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Quotes"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemquotesURL($itemID)); - } - $session->quotestry = 0; - - $refreshurl = $page->get_itemquotesURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $module_formatter = new Dplus\ScreenFormatters\Ii\Quotes(); - $module_formatter->init_formatter(); - $refreshurl = $page->get_itemquotesURL($itemID); - $docm = $modules->get('DocumentManagementQt'); - $page->body .= $config->twig->render('items/ii/quotes/quotes.twig', ['page' => $page, 'itemID' => $itemID, 'json' => $json, 'module_formatter' => $module_formatter, 'blueprint' => $module_formatter->get_tableblueprint(), 'docm' => $docm]); - } - } else { - if ($session->quotestry > 3) { - $page->headline = $page->title = "Quotes File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->quotestry++; - $session->redirect($page->get_itemquotesURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index 4a455ea8d..fe4321950 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -39,16 +39,6 @@ $session->loc = $url; } break; - case 'ii-quotes': - $data = array("DBNAME=$dplusdb", 'IIQUOTE', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-quotes')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-purchase-orders': $data = array("DBNAME=$dplusdb", 'IIPURCHORDR', "ITEMID=$itemID"); From d4de9f188c5e1da8111062d02bc5c254d6c4212c Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:08:53 -0500 Subject: [PATCH 095/106] STYLE: use ii-display for ii-purchase-orders --- .../twig/items/ii/purchase-orders/display.twig | 11 +++++++++++ .../items/ii/purchase-orders/purchase-orders.twig | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 site/templates/twig/items/ii/purchase-orders/display.twig diff --git a/site/templates/twig/items/ii/purchase-orders/display.twig b/site/templates/twig/items/ii/purchase-orders/display.twig new file mode 100644 index 000000000..5062baaca --- /dev/null +++ b/site/templates/twig/items/ii/purchase-orders/display.twig @@ -0,0 +1,11 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% include 'items/ii/purchase-orders/purchase-orders.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/purchase-orders/purchase-orders.twig b/site/templates/twig/items/ii/purchase-orders/purchase-orders.twig index ac71248d7..48c883210 100644 --- a/site/templates/twig/items/ii/purchase-orders/purchase-orders.twig +++ b/site/templates/twig/items/ii/purchase-orders/purchase-orders.twig @@ -20,7 +20,7 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - + {{ column['label'] }} {% else %} @@ -44,12 +44,12 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(order, column) }}   + + {{ formatter.format_celldata(order, column) }}   {% if order['Order Number'] and column['id'] == 'Order Number' %} {% if docm.count_documents_po(order['Order Number']) %} - + View Documents for PO # {{ order['Order Number'] }} {% endif %} @@ -77,8 +77,8 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(order, column) }} + + {{ formatter.format_celldata(order, column) }} {% else %} {% if columncount < blueprint['cols'] %} From b577269b2edc42db8b7414e861afc9608297ded8 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:09:23 -0500 Subject: [PATCH 096/106] FEAT: purchase order documents URL --- site/controllers/classes/mii/Ii/Documents.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 727741fc7..00a955f01 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -96,6 +96,13 @@ public static function documentsUrlSalesorder($itemID, $ordn, $date = '') { return $url->getUrl(); } + public static function documentsUrlPurchaseorder($itemID, $ponbr) { + $url = new Purl(self::documentsUrl($itemID, 'PO')); + $url->query->set('ponbr', $ponbr); + return $url->getUrl(); + } + + /* ============================================================= 4. Data Retrieval ============================================================= */ @@ -157,11 +164,10 @@ private static function display($data) { case 'PO': self::sanitizeParametersShort($data, ['ponbr|ponbr']); $docm = self::pw('modules')->get('DocumentManagementPo'); - $list->title = "Purchase Order #$data->invnbr Documents"; + $list->title = "Purchase Order #$data->ponbr Documents"; $list->returnTitle = "Purchase Orders"; $list->documents = $docm->get_documents_po($data->ponbr); - // TODO: ii purchase orders - $list->returnUrl = self::pw('pages')->get('pw_template=ii-purchase-history')->url."?itemID=$data->itemID"; + $list->returnUrl = PurchaseOrders::ordersUrl($data->itemID); break; default: $list->title = ""; @@ -187,13 +193,6 @@ public static function init() { $event->return = self::documentsUrl($itemID, $folder, $document); }); - $m->addHook('Page(pw_template=ii-item)::documentsUrlQuote', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $qnbr = $event->arguments(1); - $event->return = self::documentsUrlQuote($itemID, $qnbr); - }); - $m->addHook('Page(pw_template=ii-item)::documentsUrlApInvoice', function($event) { $page = $event->object; $itemID = $event->arguments(0); From 08f7d3524efbd8a318fbcc9404a2c93f41fb0704 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:10:03 -0500 Subject: [PATCH 097/106] REFACTOR: Implement Ii\PurchaseOrders --- site/controllers/classes/mii/Ii/Ii.php | 6 + .../classes/mii/Ii/PurchaseOrders.php | 141 ++++++++++++++++++ .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + .../DocumentManagementIi.module | 24 --- site/templates/ii-item.php | 1 + 6 files changed, 150 insertions(+), 24 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/PurchaseOrders.php diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 94ca946cc..8e86fc52f 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -38,6 +38,8 @@ class Ii extends AbstractController { 'documents' => 'Documents', 'sales-orders' => 'Sales Orders', 'sales-history' => 'Sales History', + 'quotes' => 'Quotes', + 'purchase-orders' => 'Purchase Orders', ]; public static function item($data) { @@ -108,6 +110,10 @@ public static function quotes($data) { return Sub\Quotes::index($data); } + public static function purchaseOrders($data) { + return Sub\PurchaseOrders::index($data); + } + public static function init() { Documents::init(); diff --git a/site/controllers/classes/mii/Ii/PurchaseOrders.php b/site/controllers/classes/mii/Ii/PurchaseOrders.php new file mode 100644 index 000000000..a9f90ba44 --- /dev/null +++ b/site/controllers/classes/mii/Ii/PurchaseOrders.php @@ -0,0 +1,141 @@ +refresh) { + self::requestJson($data); + self::pw('session')->redirect(self::ordersUrl($data->itemID), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + return self::orders($data); + } + + public static function orders($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + self::sanitizeParametersShort($data, ['itemID|text']); + self::getData($data); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Purchase Orders"; + $html = ''; + $html .= self::breadCrumbs();; + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IIPURCHORDR', "ITEMID=$vars->itemID"]; + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function ordersUrl($itemID, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('purchase-orders'); + $url->query->set('itemID', $itemID); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + $data = self::sanitizeParametersShort($data, ['itemID|text']); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::ordersUrl($data->itemID, $refresh = true), $http301 = false); + } + return true; + } + + if ($session->getFor('ii', 'purchase-orders') > 3) { + return false; + } else { + $session->setFor('ii', 'purchase-orders', ($session->getFor('ii', 'purchase-orders') + 1)); + $session->redirect(self::ordersUrl($data->itemID, $refresh = true), $http301 = false); + } + } + +/* ============================================================= + 5. Displays +============================================================= */ + private static function display($data) { + self::init(); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Purchase Orders File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::ordersUrl($data->itemID, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $docm = self::pw('modules')->get('DocumentManagementPo'); + return $config->twig->render('items/ii/purchase-orders/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $itemID = $event->arguments(0); + $ponbr = $event->arguments(1); + $event->return = Documents::documentsUrlPurchaseorder($itemID, $ponbr); + }); + } +} diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index a590e9196..80194f1fe 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -41,6 +41,7 @@ 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\PurchaseOrders' => $baseDir . '/classes/mii/Ii/PurchaseOrders.php', 'Controllers\\Mii\\Ii\\Quotes' => $baseDir . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\SalesHistory' => $baseDir . '/classes/mii/Ii/SalesHistory.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index 2d3e2deb3..bfa32a264 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -42,6 +42,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\PurchaseOrders' => __DIR__ . '/../..' . '/classes/mii/Ii/PurchaseOrders.php', 'Controllers\\Mii\\Ii\\Quotes' => __DIR__ . '/../..' . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', 'Controllers\\Mii\\Ii\\SalesHistory' => __DIR__ . '/../..' . '/classes/mii/Ii/SalesHistory.php', diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module index 85b6aa4b6..eb7be0db8 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module @@ -249,30 +249,6 @@ class DocumentManagementIi extends DocumentManagement implements Module { } public function init() { - $this->addHook('Page(pw_template=ii-documents)::documentload', function($event) { - $page = $event->object; - $folder = $event->arguments(0); - $document = $event->arguments(1); - $itemID = $event->arguments(2); - $event->return = $this->get_ii_documentURL($itemID, $folder, $document); - }); - - $this->addHook('Page(pw_template=ii-sales-orders|ii-sales-history)::documentsUrlSalesorder', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $ordn = $event->arguments(1); - $url = new Url($this->get_ii_docs_folderURL($itemID, self::TAG_SALESORDER)); - $url->query->set('ordn', $ordn); - - if (SalesHistoryQuery::create()->filterByOrdernumber(SalesOrder::get_paddedordernumber($ordn))->count()) { - $date = $page->fullURL->query->get('date'); - $url->query->set('date', $date); - $url->query->set('folder', self::TAG_ARINVOICE); - } - - $event->return = $url->getUrl(); - }); - $this->addHook('Page(pw_template=ii-purchase-history)::documentsUrlApInvoice', function($event) { $page = $event->object; $itemID = $event->arguments(0); diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 36e483511..3202c6ef5 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -22,6 +22,7 @@ ['GET', 'sales-orders', Ii::class, 'salesOrders'], ['GET', 'sales-history', Ii::class, 'salesHistory'], ['GET', 'quotes', Ii::class, 'quotes'], + ['GET', 'purchase-orders', Ii::class, 'purchaseOrders'], ]; $router = new Mvc\Router(); From c7b4f16edd9a5aaf67a433b5e173886e68e0ffff Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:13:05 -0500 Subject: [PATCH 098/106] CHORE: remove ii-purchase-history --- .../classes/mii/Ii/PurchaseHistory.php | 187 ++++++++++++++++++ site/modules/Dplus/Dpages/DpagesMii.module | 20 +- site/templates/ii-purchase-orders.php | 46 ----- site/templates/redir/ii.php | 10 - 4 files changed, 189 insertions(+), 74 deletions(-) create mode 100644 site/controllers/classes/mii/Ii/PurchaseHistory.php delete mode 100644 site/templates/ii-purchase-orders.php diff --git a/site/controllers/classes/mii/Ii/PurchaseHistory.php b/site/controllers/classes/mii/Ii/PurchaseHistory.php new file mode 100644 index 000000000..798669e20 --- /dev/null +++ b/site/controllers/classes/mii/Ii/PurchaseHistory.php @@ -0,0 +1,187 @@ +refresh) { + if ($data->date) { + self::requestJson($data); + $data->date = date(self::DATE_FORMAT, $data->date); + } + self::pw('session')->redirect(self::historyUrl($data->itemID, $data->date), $http301 = false); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + + if (empty($data->date) === false) { + return self::history($data); + } + return self::dateForm($data); + } + + public static function history($data) { + if (self::validateItemidPermission($data) === false) { + return self::alertInvalidItemPermissions($data); + } + self::pw('modules')->get('DpagesMii')->init_iipage(); + self::sanitizeParametersShort($data, ['itemID|text', 'date|text']); + self::getData($data); + + $page = self::pw('page'); + $page->headline = "II: $data->itemID Sales History"; + $html = ''; + $html .= self::breadCrumbs();; + $html .= self::display($data); + return $html; + } + +/* ============================================================= + 2. Data Requests +============================================================= */ + public static function requestJson($vars) { + $fields = ['itemID|text', 'sessionID|text', 'date|date']; + self::sanitizeParametersShort($vars, $fields); + $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); + $data = ['IISALESHIST', "ITEMID=$vars->itemID"]; + if ($vars->date) { + $dateYmd = date(self::DATE_FORMAT_DPLUS, $vars->date); + $data[] = "DATE=$dateYmd"; + } + self::sendRequest($data, $vars->sessionID); + } + +/* ============================================================= + 3. URLs +============================================================= */ + public static function historyUrl($itemID, $date, $refreshdata = false) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->path->add('sales-history'); + $url->query->set('itemID', $itemID); + + if ($date) { + $url->query->set('date', $date); + + if ($refreshdata) { + $url->query->set('refresh', 'true'); + } + } + return $url->getUrl(); + } + +/* ============================================================= + 4. Data Retrieval +============================================================= */ + private static function getData($data) { + self::sanitizeParametersShort($data, ['itemID|text', 'date|date']); + if ($data->date) { + $data->timestamp = $data->date; + $data->date = date(self::DATE_FORMAT, $data->date); + } + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $page = self::pw('page'); + $config = self::pw('config'); + $session = self::pw('session'); + $html = ''; + + if ($jsonm->exists(self::JSONCODE)) { + if ($json['itemid'] != $data->itemID || $json['date'] != date(self::DATE_FORMAT_DPLUS, $data->timestamp)) { + $jsonm->delete(self::JSONCODE); + $session->redirect(self::historyUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + return true; + } + + if ($session->getFor('ii', 'sales-history') > 3) { + return false; + } else { + $session->setFor('ii', 'sales-history', ($session->getFor('ii', 'sales-history') + 1)); + $session->redirect(self::historyUrl($data->itemID, $data->date, $refresh = true), $http301 = false); + } + } + +/* ============================================================= + 5. Displays +============================================================= */ + protected static function display($data) { + self::init(); + $jsonm = self::getJsonModule(); + $json = $jsonm->getFile(self::JSONCODE); + $config = self::pw('config'); + + if ($jsonm->exists(self::JSONCODE) === false) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => 'Sales Orders File Not Found']); + } + + if ($json['error']) { + return $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); + } + $page = self::pw('page'); + $page->refreshurl = self::historyUrl($data->itemID, $data->date, $refresh = true); + $page->lastmodified = $jsonm->lastModified(self::JSONCODE); + $formatter = new Formatter(); + $formatter->init_formatter(); + $docm = self::pw('modules')->get('DocumentManagementSo'); + return $config->twig->render('items/ii/sales-history/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + } + + private static function dateForm($data) { + self::sanitizeParametersShort($data, ['itemID|text']); + $config = self::pw('config'); + $page = self::pw('page'); + $iio = self::getIio(); + + $options = $iio->useriio(self::pw('user')->loginid); + $startdate = date(self::DATE_FORMAT); + + if ($options->dayssaleshistory > 0) { + $startdate = date(self::DATE_FORMAT, strtotime("-$options->dayssaleshistory days")); + } + + if (intval($options->datesaleshistory) > 0) { + $startdate = date(self::DATE_FORMAT, strtotime($options->datesaleshistory)); + } + + $page->headline = "II: $data->itemID Sales History"; + $html = self::breadCrumbs(); + $html .= '

Enter Starting History Date

'; + $html .= $config->twig->render('items/ii/sales-history/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); + $config->scripts->append(self::getFileHasher()->getHashUrl('scripts/lib/jquery-validate.js')); + return $html; + } + +/* ============================================================= + 6. Supplements +============================================================= */ + public static function init() { + $m = self::pw('modules')->get('DpagesMii'); + + $m->addHook('Page(pw_template=ii-item)::documentListUrl', function($event) { + $itemID = $event->arguments(0); + $ordn = $event->arguments(1); + $date = $event->arguments(2); + $event->return = Documents::documentsUrlSalesorder($itemID, $ordn, $date); + }); + } +} diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index b350b5d85..b7daddfdb 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -42,10 +42,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-sales-history', 'fields' => array(), ), - 'ii-purchase-orders' => array( - 'name' => 'ii-purchase-orders', - 'fields' => array(), - ), 'ii-purchase-history' => array( 'name' => 'ii-purchase-history', 'fields' => array(), @@ -95,16 +91,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-purchase-orders' => array( - 'template' => 'ii-function', - 'name' => 'purchase-orders', - 'title' => 'Purchase Orders', - 'summary' => 'View Item Purchase Orders', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-pur', - 'pw_template' => 'ii-purchase-orders', - 'jsoncode' => 'ii-purchase-orders' - ), 'ii-purchase-history' => array( 'template' => 'ii-function', 'name' => 'purchase-history', @@ -313,11 +299,9 @@ class DpagesMii extends Dpages implements Module { $p = $event->object; $itemID = $event->arguments(0); $date = $event->arguments(1); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-purchase-orders'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('purchase-orders'); $url->query->set('itemID', $itemID); - $url->query->set('date', $date); - $url->query->set('page', $p->fullURL->getUrl()); $event->return = $url->getUrl(); }); diff --git a/site/templates/ii-purchase-orders.php b/site/templates/ii-purchase-orders.php deleted file mode 100644 index 609e558d3..000000000 --- a/site/templates/ii-purchase-orders.php +++ /dev/null @@ -1,46 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Purchase Orders"; - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->get_itemquotesURL($itemID)); - } - $session->purchaseorderstry = 0; - - $refreshurl = $page->get_itempurchaseordersURL($itemID); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $module_formatter = new Dplus\ScreenFormatters\Ii\PurchaseOrders(); - $module_formatter->init_formatter(); - $docm = $modules->get('DocumentManagementPo'); - $page->body .= $config->twig->render('items/ii/purchase-orders/purchase-orders.twig', ['page' => $page, 'itemID' => $itemID, 'json' => $json, 'module_formatter' => $module_formatter, 'blueprint' => $module_formatter->get_tableblueprint(), 'docm' => $docm]); - } - } else { - if ($session->purchaseorderstry > 3) { - $page->headline = $page->title = "Purchase Orders File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->purchaseorderstry++; - $session->redirect($page->get_itempurchaseordersURL($itemID)); - } - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index fe4321950..d01d2fcfa 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -39,16 +39,6 @@ $session->loc = $url; } break; - case 'ii-purchase-orders': - $data = array("DBNAME=$dplusdb", 'IIPURCHORDR', "ITEMID=$itemID"); - - if ($input->$requestmethod->page) { - $session->loc = $input->$requestmethod->text('page'); - } else { - $url = $pages->get('pw_template=ii-purchase-orders')->httpUrl."?itemID=$itemID"; - $session->loc = $url; - } - break; case 'ii-purchase-history': $data = array("DBNAME=$dplusdb", 'IIPURCHHIST', "ITEMID=$itemID"); From 33c74f924921974dc78743bc6e7f25d2793e1209 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:40:53 -0500 Subject: [PATCH 099/106] STYLE: use ii-display for ii-purchase-history --- site/templates/twig/items/ii/activity/date-form.twig | 2 +- .../twig/items/ii/purchase-history/date-form.twig | 8 +++----- .../twig/items/ii/purchase-history/display.twig | 11 +++++++++++ .../items/ii/purchase-history/table/tr-details.twig | 6 +++--- .../items/ii/purchase-history/table/tr-totals.twig | 4 ++-- .../twig/items/ii/sales-history/date-form.twig | 8 +++----- 6 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 site/templates/twig/items/ii/purchase-history/display.twig diff --git a/site/templates/twig/items/ii/activity/date-form.twig b/site/templates/twig/items/ii/activity/date-form.twig index a5ad02b82..0f4d48034 100644 --- a/site/templates/twig/items/ii/activity/date-form.twig +++ b/site/templates/twig/items/ii/activity/date-form.twig @@ -4,7 +4,7 @@
- + {% include 'util/date-picker.twig' with {'name': 'date', 'value': startdate } %}
diff --git a/site/templates/twig/items/ii/purchase-history/date-form.twig b/site/templates/twig/items/ii/purchase-history/date-form.twig index f17456eec..981569560 100644 --- a/site/templates/twig/items/ii/purchase-history/date-form.twig +++ b/site/templates/twig/items/ii/purchase-history/date-form.twig @@ -1,11 +1,9 @@
-
- + -
- - {% include 'util/date-picker.twig' with {'name': 'date', 'value': "now"|date_modify("-1 year")|date("m/d/Y") } %} + + {% include 'util/date-picker.twig' with {'name': 'date', 'value': startdate } %}
diff --git a/site/templates/twig/items/ii/purchase-history/display.twig b/site/templates/twig/items/ii/purchase-history/display.twig new file mode 100644 index 000000000..fd456a04f --- /dev/null +++ b/site/templates/twig/items/ii/purchase-history/display.twig @@ -0,0 +1,11 @@ +{% extends 'items/ii/display.twig' %} + +{% block body %} +
+ {% include 'items/ii/purchase-history/purchase-history.twig' %} +
+{% endblock %} + +{% block footer %} + +{% endblock %} diff --git a/site/templates/twig/items/ii/purchase-history/table/tr-details.twig b/site/templates/twig/items/ii/purchase-history/table/tr-details.twig index e7afd6164..28b0f370c 100644 --- a/site/templates/twig/items/ii/purchase-history/table/tr-details.twig +++ b/site/templates/twig/items/ii/purchase-history/table/tr-details.twig @@ -7,12 +7,12 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(invoice, column) }}   + + {{ formatter.format_celldata(invoice, column) }}   {% if i == 1 and invoice['Purchase Order Number'] %} {% if docm.count_documents_invoice(invoice['Purchase Order Number']) %} - + View Documents for PO # {{ invoice['Purchase Order Number'] }} {% endif %} diff --git a/site/templates/twig/items/ii/purchase-history/table/tr-totals.twig b/site/templates/twig/items/ii/purchase-history/table/tr-totals.twig index 0346d7213..43c26985c 100644 --- a/site/templates/twig/items/ii/purchase-history/table/tr-totals.twig +++ b/site/templates/twig/items/ii/purchase-history/table/tr-totals.twig @@ -7,8 +7,8 @@ {% if blueprint['detail']['rows'][x]['columns'][i] %} {% set column = blueprint['detail']['rows'][x]['columns'][i] %} {% set colspan = column['col-length'] %} - - {{ module_formatter.format_celldata(invoice, column) }} + + {{ formatter.format_celldata(invoice, column) }} {% else %} {% if columncount < blueprint['cols'] %} diff --git a/site/templates/twig/items/ii/sales-history/date-form.twig b/site/templates/twig/items/ii/sales-history/date-form.twig index 9148874c1..584ccae5b 100644 --- a/site/templates/twig/items/ii/sales-history/date-form.twig +++ b/site/templates/twig/items/ii/sales-history/date-form.twig @@ -1,11 +1,9 @@
-
- + -
- - {% include 'util/date-picker.twig' with {'name': 'date', 'value': "now"|date_modify("-1 year")|date("m/d/Y") } %} + + {% include 'util/date-picker.twig' with {'name': 'date', 'value': startdate } %}
From c9a49ec2442319b02eae3d55ed77771ee8cc2de4 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 15:41:18 -0500 Subject: [PATCH 100/106] REFACTOR: implement Ii\PurchaseHistory --- site/controllers/classes/mii/Ii/Documents.php | 17 ++++------- site/controllers/classes/mii/Ii/Ii.php | 5 ++++ .../classes/mii/Ii/PurchaseHistory.php | 28 +++++++++---------- .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + site/templates/ii-item.php | 1 + 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 00a955f01..04d9daedc 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -81,9 +81,12 @@ public static function documentsUrlQuote($itemID, $qnbr) { return $url->getUrl(); } - public static function documentsUrlApInvoice($itemID, $invnbr) { + public static function documentsUrlApInvoice($itemID, $invnbr, $date = '') { $url = new Purl(self::documentsUrl($itemID, 'AP')); $url->query->set('invnbr', $invnbr); + if ($date) { + $url->query->set('date', $date); + } return $url->getUrl(); } @@ -153,13 +156,12 @@ private static function display($data) { $list->returnUrl = Quotes::quotesUrl($data->itemID); break; case 'AP': - self::sanitizeParametersShort($data, ['invnbr|ponbr']); + self::sanitizeParametersShort($data, ['invnbr|ponbr', 'date|text']); $docm = self::pw('modules')->get('DocumentManagementPo'); $list->title = "AP Invoice #$data->invnbr Documents"; $list->returnTitle = "AP Invoices"; $list->documents = $docm->get_documents_invoice($data->invnbr); - // TODO: ii purchase history - $list->returnUrl = self::pw('pages')->get('pw_template=ii-purchase-history')->url."?itemID=$data->itemID"; + $list->returnUrl = PurchaseHistory::historyUrl($data->itemID, $data->date); break; case 'PO': self::sanitizeParametersShort($data, ['ponbr|ponbr']); @@ -192,13 +194,6 @@ public static function init() { $document = $event->arguments(2); $event->return = self::documentsUrl($itemID, $folder, $document); }); - - $m->addHook('Page(pw_template=ii-item)::documentsUrlApInvoice', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $invnbr = $event->arguments(1); - $event->return = self::documentsUrlApInvoice($itemID, $invnbr); - }); } private static function createList($itemID) { diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 8e86fc52f..984eca923 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -40,6 +40,7 @@ class Ii extends AbstractController { 'sales-history' => 'Sales History', 'quotes' => 'Quotes', 'purchase-orders' => 'Purchase Orders', + 'purchase-history' => 'Purchase History', ]; public static function item($data) { @@ -114,6 +115,10 @@ public static function purchaseOrders($data) { return Sub\PurchaseOrders::index($data); } + public static function purchaseHistory($data) { + return Sub\PurchaseHistory::index($data); + } + public static function init() { Documents::init(); diff --git a/site/controllers/classes/mii/Ii/PurchaseHistory.php b/site/controllers/classes/mii/Ii/PurchaseHistory.php index 798669e20..ee1714803 100644 --- a/site/controllers/classes/mii/Ii/PurchaseHistory.php +++ b/site/controllers/classes/mii/Ii/PurchaseHistory.php @@ -49,7 +49,7 @@ public static function history($data) { self::getData($data); $page = self::pw('page'); - $page->headline = "II: $data->itemID Sales History"; + $page->headline = "II: $data->itemID Purchase History"; $html = ''; $html .= self::breadCrumbs();; $html .= self::display($data); @@ -63,7 +63,7 @@ public static function requestJson($vars) { $fields = ['itemID|text', 'sessionID|text', 'date|date']; self::sanitizeParametersShort($vars, $fields); $vars->sessionID = empty($vars->sessionID) === false ? $vars->sessionID : session_id(); - $data = ['IISALESHIST', "ITEMID=$vars->itemID"]; + $data = ['IIPURCHHIST', "ITEMID=$vars->itemID"]; if ($vars->date) { $dateYmd = date(self::DATE_FORMAT_DPLUS, $vars->date); $data[] = "DATE=$dateYmd"; @@ -76,7 +76,7 @@ public static function requestJson($vars) { ============================================================= */ public static function historyUrl($itemID, $date, $refreshdata = false) { $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); - $url->path->add('sales-history'); + $url->path->add('purchase-history'); $url->query->set('itemID', $itemID); if ($date) { @@ -113,10 +113,10 @@ private static function getData($data) { return true; } - if ($session->getFor('ii', 'sales-history') > 3) { + if ($session->getFor('ii', 'purchase-history') > 3) { return false; } else { - $session->setFor('ii', 'sales-history', ($session->getFor('ii', 'sales-history') + 1)); + $session->setFor('ii', 'purchase-history', ($session->getFor('ii', 'purchase-history') + 1)); $session->redirect(self::historyUrl($data->itemID, $data->date, $refresh = true), $http301 = false); } } @@ -142,8 +142,8 @@ protected static function display($data) { $page->lastmodified = $jsonm->lastModified(self::JSONCODE); $formatter = new Formatter(); $formatter->init_formatter(); - $docm = self::pw('modules')->get('DocumentManagementSo'); - return $config->twig->render('items/ii/sales-history/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); + $docm = self::pw('modules')->get('DocumentManagementPo'); + return $config->twig->render('items/ii/purchase-history/display.twig', ['item' => self::getItmItem($data->itemID), 'json' => $json, 'formatter' => $formatter, 'blueprint' => $formatter->get_tableblueprint(), 'module_json' => $jsonm->jsonm, 'docm' => $docm]); } private static function dateForm($data) { @@ -155,18 +155,18 @@ private static function dateForm($data) { $options = $iio->useriio(self::pw('user')->loginid); $startdate = date(self::DATE_FORMAT); - if ($options->dayssaleshistory > 0) { - $startdate = date(self::DATE_FORMAT, strtotime("-$options->dayssaleshistory days")); + if ($options->dayspurchasehistory > 0) { + $startdate = date(self::DATE_FORMAT, strtotime("-$options->dayspurchasehistory days")); } - if (intval($options->datesaleshistory) > 0) { - $startdate = date(self::DATE_FORMAT, strtotime($options->datesaleshistory)); + if (intval($options->datepurchasehistory) > 0) { + $startdate = date(self::DATE_FORMAT, strtotime($options->datepurchasehistory)); } - $page->headline = "II: $data->itemID Sales History"; + $page->headline = "II: $data->itemID Purchase History"; $html = self::breadCrumbs(); $html .= '

Enter Starting History Date

'; - $html .= $config->twig->render('items/ii/sales-history/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); + $html .= $config->twig->render('items/ii/purchase-history/date-form.twig', ['itemID' => $data->itemID, 'startdate' => $startdate]); $config->scripts->append(self::getFileHasher()->getHashUrl('scripts/lib/jquery-validate.js')); return $html; } @@ -181,7 +181,7 @@ public static function init() { $itemID = $event->arguments(0); $ordn = $event->arguments(1); $date = $event->arguments(2); - $event->return = Documents::documentsUrlSalesorder($itemID, $ordn, $date); + $event->return = Documents::documentsUrlApInvoice($itemID, $ordn, $date); }); } } diff --git a/site/controllers/vendor/composer/autoload_classmap.php b/site/controllers/vendor/composer/autoload_classmap.php index 80194f1fe..e79c8ec2f 100644 --- a/site/controllers/vendor/composer/autoload_classmap.php +++ b/site/controllers/vendor/composer/autoload_classmap.php @@ -41,6 +41,7 @@ 'Controllers\\Mii\\Ii\\Kit' => $baseDir . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => $baseDir . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => $baseDir . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\PurchaseHistory' => $baseDir . '/classes/mii/Ii/PurchaseHistory.php', 'Controllers\\Mii\\Ii\\PurchaseOrders' => $baseDir . '/classes/mii/Ii/PurchaseOrders.php', 'Controllers\\Mii\\Ii\\Quotes' => $baseDir . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => $baseDir . '/classes/mii/Ii/Requirements.php', diff --git a/site/controllers/vendor/composer/autoload_static.php b/site/controllers/vendor/composer/autoload_static.php index bfa32a264..27b98969b 100644 --- a/site/controllers/vendor/composer/autoload_static.php +++ b/site/controllers/vendor/composer/autoload_static.php @@ -42,6 +42,7 @@ class ComposerStaticInit0137f8e60248be1bc1b37e9c1c6812dd 'Controllers\\Mii\\Ii\\Kit' => __DIR__ . '/../..' . '/classes/mii/Ii/Kit.php', 'Controllers\\Mii\\Ii\\Lotserial' => __DIR__ . '/../..' . '/classes/mii/Ii/Lotserial.php', 'Controllers\\Mii\\Ii\\Pricing' => __DIR__ . '/../..' . '/classes/mii/Ii/Pricing.php', + 'Controllers\\Mii\\Ii\\PurchaseHistory' => __DIR__ . '/../..' . '/classes/mii/Ii/PurchaseHistory.php', 'Controllers\\Mii\\Ii\\PurchaseOrders' => __DIR__ . '/../..' . '/classes/mii/Ii/PurchaseOrders.php', 'Controllers\\Mii\\Ii\\Quotes' => __DIR__ . '/../..' . '/classes/mii/Ii/Quotes.php', 'Controllers\\Mii\\Ii\\Requirements' => __DIR__ . '/../..' . '/classes/mii/Ii/Requirements.php', diff --git a/site/templates/ii-item.php b/site/templates/ii-item.php index 3202c6ef5..54d9ea142 100644 --- a/site/templates/ii-item.php +++ b/site/templates/ii-item.php @@ -23,6 +23,7 @@ ['GET', 'sales-history', Ii::class, 'salesHistory'], ['GET', 'quotes', Ii::class, 'quotes'], ['GET', 'purchase-orders', Ii::class, 'purchaseOrders'], + ['GET', 'purchase-history', Ii::class, 'purchaseHistory'], ]; $router = new Mvc\Router(); From 839e86d111407e5dd77549b36e8ffb90ca0db45a Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 16:01:01 -0500 Subject: [PATCH 101/106] CHORE: remove ii-purchase-history --- .../DocumentManagementIi.module | 17 ------ site/modules/Dplus/Dpages/DpagesMii.module | 18 +------ site/templates/ii-purchase-history.php | 52 ------------------- site/templates/redir/ii.php | 19 ------- 4 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 site/templates/ii-purchase-history.php diff --git a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module index eb7be0db8..87703a6d9 100644 --- a/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module +++ b/site/modules/Dplus/DocumentManagement/DocumentManagementIi.module @@ -249,23 +249,6 @@ class DocumentManagementIi extends DocumentManagement implements Module { } public function init() { - $this->addHook('Page(pw_template=ii-purchase-history)::documentsUrlApInvoice', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $invnbr = $event->arguments(1); - $url = new Url($this->get_ii_docs_folderURL($itemID, self::TAG_APINVOICE)); - $url->query->set('invnbr', $invnbr); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page(pw_template=ii-purchase-orders)::documentsview_purchaseorder', function($event) { - $page = $event->object; - $itemID = $event->arguments(0); - $ponbr = $event->arguments(1); - $url = new Url($this->get_ii_docs_folderURL($itemID, self::TAG_VENDORPO)); - $url->query->set('ponbr', $ponbr); - $event->return = $url->getUrl(); - }); $this->addHook('Page(pw_template=ii-item)::item_image_exists', function($event) { $page = $event->object; diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index b7daddfdb..6a70edb1e 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -42,10 +42,6 @@ class DpagesMii extends Dpages implements Module { 'name' => 'ii-sales-history', 'fields' => array(), ), - 'ii-purchase-history' => array( - 'name' => 'ii-purchase-history', - 'fields' => array(), - ), 'ii-item-lookup' => array( 'name' => 'ii-item-lookup', 'fields' => array(), @@ -91,16 +87,6 @@ class DpagesMii extends Dpages implements Module { 'dplus_function' => 'ii', 'pw_template' => 'ii-item' ), - 'ii-purchase-history' => array( - 'template' => 'ii-function', - 'name' => 'purchase-history', - 'title' => 'Purchase History', - 'summary' => 'View Item Purchase History', - 'parent' => '/mii/ii/', - 'dplus_function' => 'ii-pht', - 'pw_template' => 'ii-purchase-history', - 'jsoncode' => 'ii-purchase-history' - ), 'ii-item-lookup' => array( 'template' => 'dplus-json', 'name' => 'Item Lookup', @@ -309,8 +295,8 @@ class DpagesMii extends Dpages implements Module { $p = $event->object; $itemID = $event->arguments(0); $date = $event->arguments(1); - $url = new Url($p->parent('template=dplus-menu')->child('template=redir')->url); - $url->query->set('action','ii-purchase-history'); + $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); + $url->path->add('purchase-history'); $url->query->set('itemID', $itemID); $url->query->set('date', $date); $url->query->set('page', $p->fullURL->getUrl()); diff --git a/site/templates/ii-purchase-history.php b/site/templates/ii-purchase-history.php deleted file mode 100644 index 15ce61f6c..000000000 --- a/site/templates/ii-purchase-history.php +++ /dev/null @@ -1,52 +0,0 @@ -lookup_itm($itemID)) { - $page->show_breadcrumbs = false; - $page->body .= $config->twig->render('items/ii/bread-crumbs.twig', ['page' => $page, 'item' => $item]); - $page->title = "$itemID Purchase History"; - - if ($input->get->date) { - $date = $input->get->text('date'); - - $module_json = $modules->get('JsonDataFiles'); - $json = $module_json->get_file(session_id(), $page->jsoncode); - - if ($module_json->file_exists(session_id(), $page->jsoncode)) { - if ($json['itemid'] != $itemID) { - $module_json->remove_file(session_id(), $page->jsoncode); - $session->redirect($page->url_itemID($itemID)); - } - $session->purchasehistorytry = 0; - - $refreshurl = $page->get_itempurchasehistoryURL($itemID, $date); - $page->body .= $config->twig->render('items/ii/ii-links.twig', ['page' => $page, 'itemID' => $itemID, 'lastmodified' => $module_json->file_modified(session_id(), $page->jsoncode), 'refreshurl' => $refreshurl]); - - if ($json['error']) { - $page->body .= $config->twig->render('util/alert.twig', ['type' => 'danger', 'title' => 'Error!', 'iconclass' => 'fa fa-warning fa-2x', 'message' => $json['errormsg']]); - } else { - $module_formatter = new Dplus\ScreenFormatters\Ii\PurchaseHistory(); - $module_formatter->init_formatter(); - $docm = $modules->get('DocumentManagementPo'); - $page->body .= $config->twig->render('items/ii/purchase-history/purchase-history.twig', ['page' => $page, 'itemID' => $itemID, 'json' => $json, 'module_formatter' => $module_formatter, 'blueprint' => $module_formatter->get_tableblueprint(), 'docm' => $docm]); - } - } else { - if ($session->purchasehistorytry > 3) { - $page->headline = $page->title = "Purchase History File could not be loaded"; - $page->body .= $config->twig->render('util/error-page.twig', ['title' => $page->title, 'msg' => $module_json->get_error()]); - } else { - $session->purchasehistorytry++; - $session->redirect($page->get_itempurchasehistoryURL($itemID, $date)); - } - } - } else { - $page->body .= $config->twig->render('items/ii/purchase-history/date-form.twig', ['page' => $page, 'itemID' => $itemID]); - } - } - - if ($page->print) { - $page->show_title = true; - include __DIR__ . "/blank-page.php"; - } else { - include __DIR__ . "/basic-page.php"; - } diff --git a/site/templates/redir/ii.php b/site/templates/redir/ii.php index d01d2fcfa..d13c7f366 100644 --- a/site/templates/redir/ii.php +++ b/site/templates/redir/ii.php @@ -39,25 +39,6 @@ $session->loc = $url; } break; - case 'ii-purchase-history': - $data = array("DBNAME=$dplusdb", 'IIPURCHHIST', "ITEMID=$itemID"); - - $date = $input->$requestmethod->text('date'); - - if (!empty($date)) { - $date_ymd = date('Ymd', strtotime($date)); - $data[] = "DATE=$date_ymd"; - } - - if ($input->$requestmethod->page) { - $url = new Purl\Url($input->$requestmethod->text('page')); - $url->query->set('date', $date); - $session->loc = $url->getUrl(); - } else { - $url = $pages->get('pw_template=ii-purchase-history')->httpUrl."?itemID=$itemID&date=$date"; - $session->loc = $url; - } - break; case 'item-search': $q = strtoupper($input->$requestmethod->text('q')); $custID = !empty($input->$requestmethod->custID) ? $input->$requestmethod->text('custID') : $config->defaultweb; From eebdf269e47094a1ef85812161aaf4e6d0deaa34 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 16:12:12 -0500 Subject: [PATCH 102/106] CHORE: delete init_iipage() --- site/modules/Dplus/Dpages/DpagesMii.module | 214 --------------------- 1 file changed, 214 deletions(-) diff --git a/site/modules/Dplus/Dpages/DpagesMii.module b/site/modules/Dplus/Dpages/DpagesMii.module index 6a70edb1e..3d346e23d 100644 --- a/site/modules/Dplus/Dpages/DpagesMii.module +++ b/site/modules/Dplus/Dpages/DpagesMii.module @@ -98,220 +98,6 @@ class DpagesMii extends Dpages implements Module { ) ); - public function init_iipage() { - $this->addHook('Page(pw_template=ii-item)::children_user_allowed', function($event) { - $user = $this->wire('user'); - $event->return = $this->get_ii_user_allowed_functions($user); - }); - - $this->addHook('Page::url_itemID', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($p->url); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_redirURL', function($event) { - $p = $event->object; - $event->return = $p->parent('template=dplus-menu')->child('template=redir')->url; - }); - - $this->addHook('Page::get_itempageURL', function($event) { - $itemID = $event->arguments(0); - $event->return = $this->get_ii_itemURL($itemID); - }); - - $this->addHook('Page::get_itemURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemstockURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('stock'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemrequirementsURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('requirements'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itempricingURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $custID = $event->arguments(1); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('requirements'); - $url->query->set('itemID', $itemID); - if ($custID) { - $url->query->set('custID', $custID); - } - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemcostingURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('costing'); - $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemusageURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('usage'); - $url->query->set('itemID', $itemID); - $url->query->set('page', $p->fullURL->getUrl()); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemactivityURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('activity'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemkitURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('kit'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itembomURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('bom'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemwhereusedURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('where-used'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemlotserialURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('lotserial'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemgeneralURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('general'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemsubstitutesURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('substitutes'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemdocumentsURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('documents'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemsalesordersURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('sales-orders'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemsaleshistoryURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $date = $event->arguments(1); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('sales-history'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itemquotesURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('quotes'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itempurchaseordersURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $date = $event->arguments(1); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('purchase-orders'); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_itempurchasehistoryURL', function($event) { - $p = $event->object; - $itemID = $event->arguments(0); - $date = $event->arguments(1); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->path->add('purchase-history'); - $url->query->set('itemID', $itemID); - $url->query->set('date', $date); - $url->query->set('page', $p->fullURL->getUrl()); - $event->return = $url->getUrl(); - }); - - $this->addHook('Page::get_backURL', function($event) { - $p = $event->object; - $itemID = $p->fullURL->query->get('itemID'); - $url = new Url($this->wire('pages')->get('pw_template=ii-item')->url); - $url->query->set('itemID', $itemID); - $event->return = $url->getUrl(); - }); - } - /* ============================================================= Supplemental Functions ============================================================= */ From ea0ce9215fde7b8f648c3f9d8f027ba0fbd72716 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 16:19:10 -0500 Subject: [PATCH 103/106] CHORE: remove itemUrl() --- site/controllers/classes/mii/Ii/Activity.php | 2 -- site/controllers/classes/mii/Ii/Bom.php | 2 -- site/controllers/classes/mii/Ii/Costing.php | 2 -- site/controllers/classes/mii/Ii/Documents.php | 3 --- site/controllers/classes/mii/Ii/General.php | 3 --- site/controllers/classes/mii/Ii/Item.php | 4 +--- site/controllers/classes/mii/Ii/Kit.php | 2 -- site/controllers/classes/mii/Ii/Lotserial.php | 2 -- site/controllers/classes/mii/Ii/Pricing.php | 2 -- site/controllers/classes/mii/Ii/PurchaseHistory.php | 2 -- site/controllers/classes/mii/Ii/PurchaseOrders.php | 3 --- site/controllers/classes/mii/Ii/Quotes.php | 3 --- site/controllers/classes/mii/Ii/Requirements.php | 2 -- site/controllers/classes/mii/Ii/SalesHistory.php | 2 -- site/controllers/classes/mii/Ii/SalesOrders.php | 3 --- site/controllers/classes/mii/Ii/Stock.php | 2 -- site/controllers/classes/mii/Ii/Substitutes.php | 2 -- site/controllers/classes/mii/Ii/Usage.php | 2 -- site/controllers/classes/mii/Ii/WhereUsed.php | 3 --- 19 files changed, 1 insertion(+), 45 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Activity.php b/site/controllers/classes/mii/Ii/Activity.php index f182b3807..14516f098 100644 --- a/site/controllers/classes/mii/Ii/Activity.php +++ b/site/controllers/classes/mii/Ii/Activity.php @@ -30,7 +30,6 @@ public static function index($data) { } self::pw('session')->redirect(self::activityUrl($data->itemID, $data->date), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->date) === false) { return self::activity($data); @@ -42,7 +41,6 @@ public static function activity($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Bom.php b/site/controllers/classes/mii/Ii/Bom.php index 474734069..cbd1f1e15 100644 --- a/site/controllers/classes/mii/Ii/Bom.php +++ b/site/controllers/classes/mii/Ii/Bom.php @@ -27,7 +27,6 @@ public static function index($data) { self::requestJson($data, session_id()); self::pw('session')->redirect(self::bomUrl($data->itemID, $data->qty, $data->type), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->qty) === false || empty($data->type) === false) { return self::bom($data); @@ -39,7 +38,6 @@ public static function bom($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); $data = self::sanitizeParametersShort($data, ['itemID|text', 'qty|int', 'type|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Costing.php b/site/controllers/classes/mii/Ii/Costing.php index 0d53f6fea..09d0e1b4f 100644 --- a/site/controllers/classes/mii/Ii/Costing.php +++ b/site/controllers/classes/mii/Ii/Costing.php @@ -25,7 +25,6 @@ public static function index($data) { self::requestJson($data->itemID, session_id()); self::pw('session')->redirect($refreshurl = self::costingUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::costing($data); } @@ -33,7 +32,6 @@ public static function costing($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); $data = self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Documents.php b/site/controllers/classes/mii/Ii/Documents.php index 04d9daedc..610bd5d79 100644 --- a/site/controllers/classes/mii/Ii/Documents.php +++ b/site/controllers/classes/mii/Ii/Documents.php @@ -32,8 +32,6 @@ public static function index($data) { self::pw('session')->redirect(self::pw('config')->url_webdocs.$data->document, $http301 = false); } } - - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::documents($data); } @@ -41,7 +39,6 @@ public static function documents($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); $fields = ['itemID|text']; self::sanitizeParametersShort($data, $fields); diff --git a/site/controllers/classes/mii/Ii/General.php b/site/controllers/classes/mii/Ii/General.php index 3d2d8b865..4fd505d93 100644 --- a/site/controllers/classes/mii/Ii/General.php +++ b/site/controllers/classes/mii/Ii/General.php @@ -30,8 +30,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::generalUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); - return self::general($data); } @@ -39,7 +37,6 @@ public static function general($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); $page = self::pw('page'); diff --git a/site/controllers/classes/mii/Ii/Item.php b/site/controllers/classes/mii/Ii/Item.php index 7997dce41..6922bd063 100644 --- a/site/controllers/classes/mii/Ii/Item.php +++ b/site/controllers/classes/mii/Ii/Item.php @@ -38,7 +38,7 @@ public static function index($data) { if (self::validateUserPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); + if (empty($data->itemID) === false) { if ($data->refresh) { self::requestIiItem($data->itemID); @@ -53,7 +53,6 @@ public static function item($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); @@ -122,7 +121,6 @@ public static function list($data) { if (self::validateUserPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['q|text']); $page = self::pw('page'); $pricingM = self::pw('modules')->get('ItemPricing'); diff --git a/site/controllers/classes/mii/Ii/Kit.php b/site/controllers/classes/mii/Ii/Kit.php index 04f4ce3c6..59b6d6a49 100644 --- a/site/controllers/classes/mii/Ii/Kit.php +++ b/site/controllers/classes/mii/Ii/Kit.php @@ -30,7 +30,6 @@ public static function index($data) { self::requestJson($data, session_id()); self::pw('session')->redirect(self::kitUrl($data->itemID, $data->qty), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->qty) === false) { return self::kit($data); @@ -42,7 +41,6 @@ public static function kit($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Lotserial.php b/site/controllers/classes/mii/Ii/Lotserial.php index b02b67f89..c77ae6d70 100644 --- a/site/controllers/classes/mii/Ii/Lotserial.php +++ b/site/controllers/classes/mii/Ii/Lotserial.php @@ -27,7 +27,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::lotserialUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::lotserial($data); } @@ -36,7 +35,6 @@ public static function lotserial($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Pricing.php b/site/controllers/classes/mii/Ii/Pricing.php index ea15bfa99..4497d50e7 100644 --- a/site/controllers/classes/mii/Ii/Pricing.php +++ b/site/controllers/classes/mii/Ii/Pricing.php @@ -27,7 +27,6 @@ public static function index($data) { self::requestJson($data, session_id()); self::pw('session')->redirect(self::pricingUrl($data->itemID, $data->custID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->custID) === false) { return self::pricing($data); @@ -39,7 +38,6 @@ public static function pricing($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/PurchaseHistory.php b/site/controllers/classes/mii/Ii/PurchaseHistory.php index ee1714803..b0e8ca37b 100644 --- a/site/controllers/classes/mii/Ii/PurchaseHistory.php +++ b/site/controllers/classes/mii/Ii/PurchaseHistory.php @@ -32,7 +32,6 @@ public static function index($data) { } self::pw('session')->redirect(self::historyUrl($data->itemID, $data->date), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->date) === false) { return self::history($data); @@ -44,7 +43,6 @@ public static function history($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text', 'date|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/PurchaseOrders.php b/site/controllers/classes/mii/Ii/PurchaseOrders.php index a9f90ba44..388769ae0 100644 --- a/site/controllers/classes/mii/Ii/PurchaseOrders.php +++ b/site/controllers/classes/mii/Ii/PurchaseOrders.php @@ -27,8 +27,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::ordersUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); - return self::orders($data); } @@ -36,7 +34,6 @@ public static function orders($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Quotes.php b/site/controllers/classes/mii/Ii/Quotes.php index 67d40d88f..5bc6558ca 100644 --- a/site/controllers/classes/mii/Ii/Quotes.php +++ b/site/controllers/classes/mii/Ii/Quotes.php @@ -27,8 +27,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::quotesUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); - return self::quotes($data); } @@ -36,7 +34,6 @@ public static function quotes($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Requirements.php b/site/controllers/classes/mii/Ii/Requirements.php index 430f6a44a..cc17049ce 100644 --- a/site/controllers/classes/mii/Ii/Requirements.php +++ b/site/controllers/classes/mii/Ii/Requirements.php @@ -27,7 +27,6 @@ public static function index($data) { self::requestJson($data, session_id()); self::pw('session')->redirect($refreshurl = self::requirementsUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::requirements($data); } @@ -35,7 +34,6 @@ public static function requirements($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/SalesHistory.php b/site/controllers/classes/mii/Ii/SalesHistory.php index f115d5ca2..75aa68006 100644 --- a/site/controllers/classes/mii/Ii/SalesHistory.php +++ b/site/controllers/classes/mii/Ii/SalesHistory.php @@ -32,7 +32,6 @@ public static function index($data) { } self::pw('session')->redirect(self::historyUrl($data->itemID, $data->date), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); if (empty($data->date) === false) { return self::history($data); @@ -44,7 +43,6 @@ public static function history($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text', 'date|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/SalesOrders.php b/site/controllers/classes/mii/Ii/SalesOrders.php index d7709940a..95bfbdb89 100644 --- a/site/controllers/classes/mii/Ii/SalesOrders.php +++ b/site/controllers/classes/mii/Ii/SalesOrders.php @@ -27,8 +27,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::ordersUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); - return self::orders($data); } @@ -36,7 +34,6 @@ public static function orders($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Stock.php b/site/controllers/classes/mii/Ii/Stock.php index d505257ae..24b308ebe 100644 --- a/site/controllers/classes/mii/Ii/Stock.php +++ b/site/controllers/classes/mii/Ii/Stock.php @@ -25,7 +25,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::stockUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::stock($data); } @@ -33,7 +32,6 @@ public static function stock($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Substitutes.php b/site/controllers/classes/mii/Ii/Substitutes.php index 87378675e..8233d88b5 100644 --- a/site/controllers/classes/mii/Ii/Substitutes.php +++ b/site/controllers/classes/mii/Ii/Substitutes.php @@ -25,7 +25,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect($refreshurl = self::substitutesUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::substitutes($data); } @@ -33,7 +32,6 @@ public static function substitutes($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); $data = self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/Usage.php b/site/controllers/classes/mii/Ii/Usage.php index 0322a31f1..c024c264c 100644 --- a/site/controllers/classes/mii/Ii/Usage.php +++ b/site/controllers/classes/mii/Ii/Usage.php @@ -25,7 +25,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect($refreshurl = self::usageUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); return self::usage($data); } @@ -33,7 +32,6 @@ public static function usage($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); diff --git a/site/controllers/classes/mii/Ii/WhereUsed.php b/site/controllers/classes/mii/Ii/WhereUsed.php index bbf7cb135..6c4be5527 100644 --- a/site/controllers/classes/mii/Ii/WhereUsed.php +++ b/site/controllers/classes/mii/Ii/WhereUsed.php @@ -25,8 +25,6 @@ public static function index($data) { self::requestJson($data); self::pw('session')->redirect(self::whereUsedUrl($data->itemID), $http301 = false); } - self::pw('modules')->get('DpagesMii')->init_iipage(); - return self::whereUsed($data); } @@ -34,7 +32,6 @@ public static function whereUsed($data) { if (self::validateItemidPermission($data) === false) { return self::alertInvalidItemPermissions($data); } - self::pw('modules')->get('DpagesMii')->init_iipage(); self::sanitizeParametersShort($data, ['itemID|text']); self::getData($data); From 11a76a17a0c6419b397c6b22aafcbf3f55354c33 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 16:20:55 -0500 Subject: [PATCH 104/106] Use page.itemUrl() --- site/controllers/classes/mii/Ii/Ii.php | 10 +++++++++- site/templates/twig/items/ii/bread-crumbs.twig | 2 +- site/templates/twig/items/ii/display.twig | 2 +- site/templates/twig/items/ii/ii-links.twig | 4 ++-- site/templates/twig/items/ii/item/display.twig | 2 +- site/templates/twig/items/ii/item/stock.twig | 2 +- site/templates/twig/items/ii/toolbar.twig | 9 +-------- site/templates/twig/items/item-list.twig | 14 ++++---------- 8 files changed, 20 insertions(+), 25 deletions(-) diff --git a/site/controllers/classes/mii/Ii/Ii.php b/site/controllers/classes/mii/Ii/Ii.php index 984eca923..02a187b5d 100644 --- a/site/controllers/classes/mii/Ii/Ii.php +++ b/site/controllers/classes/mii/Ii/Ii.php @@ -123,7 +123,7 @@ public static function init() { Documents::init(); $m = self::pw('modules')->get('DpagesMii'); - $m->addHook('Page(pw_template=ii-item)::subfunctions2', function($event) { + $m->addHook('Page(pw_template=ii-item)::subfunctions', function($event) { $user = self::pw('user'); $allowed = []; $iio = Item::getIio(); @@ -134,12 +134,14 @@ public static function init() { } $event->return = $allowed; }); + $m->addHook('Page(pw_template=ii-item)::subfunctionURL', function($event) { $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); $url->path->add($event->arguments(1)); $url->query->set('itemID', $event->arguments(0)); $event->return = $url->getUrl(); }); + $m->addHook('Page(pw_template=ii-item)::subfunctionTitle', function($event) { $title = $event->arguments(0); if (array_key_exists($event->arguments(0), self::SUBFUNCTIONS)) { @@ -147,5 +149,11 @@ public static function init() { } $event->return = $title; }); + + $m->addHook('Page(pw_template=ii-item)::itemUrl', function($event) { + $url = new Purl(self::pw('pages')->get('pw_template=ii-item')->url); + $url->query->set('itemID', $event->arguments(0)); + $event->return = $url->getUrl(); + }); } } diff --git a/site/templates/twig/items/ii/bread-crumbs.twig b/site/templates/twig/items/ii/bread-crumbs.twig index 0ba6e14f7..2182f00ef 100644 --- a/site/templates/twig/items/ii/bread-crumbs.twig +++ b/site/templates/twig/items/ii/bread-crumbs.twig @@ -6,7 +6,7 @@ II {% set segments = input.urlSegments() %} {% if segments|length == 1 %} diff --git a/site/templates/twig/items/ii/display.twig b/site/templates/twig/items/ii/display.twig index 9e721cc95..9da7e690e 100644 --- a/site/templates/twig/items/ii/display.twig +++ b/site/templates/twig/items/ii/display.twig @@ -16,7 +16,7 @@
diff --git a/site/templates/twig/items/ii/ii-links.twig b/site/templates/twig/items/ii/ii-links.twig index 5495fbd0d..2f877d7b2 100644 --- a/site/templates/twig/items/ii/ii-links.twig +++ b/site/templates/twig/items/ii/ii-links.twig @@ -1,10 +1,10 @@
{% if page.is_print() %} - + Back to Item {% else %} - + Back to Item   diff --git a/site/templates/twig/items/ii/item/display.twig b/site/templates/twig/items/ii/item/display.twig index 5588436d9..907468534 100644 --- a/site/templates/twig/items/ii/item/display.twig +++ b/site/templates/twig/items/ii/item/display.twig @@ -3,7 +3,7 @@ {% include 'items/ii/toolbar.twig' %}
- {% include 'items/ii/item/ii-links.twig' with {'itemID': item.itemid, 'lastmodified': page.lastmodified, 'refreshurl': page.get_itemURL(item.itemid)} %} + {% include 'items/ii/item/ii-links.twig' with {'itemID': item.itemid, 'lastmodified': page.lastmodified, 'refreshurl': page.itemURL(item.itemid)} %} {{ html.item|raw }} {% include 'items/ii/item/item-data.twig' %} {{ html.stock|raw }} diff --git a/site/templates/twig/items/ii/item/stock.twig b/site/templates/twig/items/ii/item/stock.twig index 939bb94fc..c0afd71da 100644 --- a/site/templates/twig/items/ii/item/stock.twig +++ b/site/templates/twig/items/ii/item/stock.twig @@ -36,7 +36,7 @@ {% if json['columns']['Item ID'] %} {% if column['id']|lower == 'item id' and item[column['id']] != json['itemid'] %} - + {{ module_formatter.format_celldata(item, column) }} {% else %} diff --git a/site/templates/twig/items/ii/toolbar.twig b/site/templates/twig/items/ii/toolbar.twig index 5b5a8e56f..c91215079 100644 --- a/site/templates/twig/items/ii/toolbar.twig +++ b/site/templates/twig/items/ii/toolbar.twig @@ -1,18 +1,11 @@ diff --git a/site/templates/twig/items/item-list.twig b/site/templates/twig/items/item-list.twig index 20a0dba7e..790e658fc 100644 --- a/site/templates/twig/items/item-list.twig +++ b/site/templates/twig/items/item-list.twig @@ -11,16 +11,10 @@ - - + + {% if pricing %} - + {% endif %} @@ -29,7 +23,7 @@ {% for item in items %} From 47fe269d83f51ee5e50f1c2e50ef89e509d6a8c7 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 12 Apr 2021 16:20:58 -0500 Subject: [PATCH 105/106] Update Iio.module --- site/modules/Dplus/Mii/Iio/Iio.module | 34 ++------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/site/modules/Dplus/Mii/Iio/Iio.module b/site/modules/Dplus/Mii/Iio/Iio.module index f8a5e9861..2b0257480 100644 --- a/site/modules/Dplus/Mii/Iio/Iio.module +++ b/site/modules/Dplus/Mii/Iio/Iio.module @@ -14,29 +14,6 @@ class Iio extends WireData implements Module { const RESPONSE_TEMPLATE = 'User {key} permissions were {not} {crud}'; const RECORDLOCKER_FUNCTION = 'iio'; - const TEMPLATES_II = [ - 'ii-pricing', - 'ii-activity', - 'ii-bom', - 'ii-kit', - 'ii-components', - 'ii-costing', - 'ii-documents', - 'ii-general', - 'ii-lotserial', - 'ii-pricing', - 'ii-purchase-history', - 'ii-purchase-orders', - 'ii-quotes', - 'ii-requirements', - 'ii-sales-history', - 'ii-sales-orders', - 'ii-stock', - 'ii-substitutes', - 'ii-usage', - 'ii-where-used', - ]; - const TEMPLATES_PERMISSIONS = [ 'ii-pricing' => 'pricing', 'ii-activity' => 'activity', @@ -577,11 +554,9 @@ class Iio extends WireData implements Module { public function ii_subfunctions(User $user) { $permitted = $user->permitted_ii(); if (empty($permitted)) { - return new PageArray(); + return []; } - $p = $this->wire('pages')->get('pw_template=ii-item'); - $templates = implode('|', $this->permissions_to_templates($permitted)); - return $p->children("pw_template=$templates"); + return $user->permitted_ii(); } /** @@ -681,11 +656,6 @@ class Iio extends WireData implements Module { $event->return = $permission->permitted(); }); - $this->addHook("Page(pw_template=ii-item)::subfunctions", function($event) { - $user = $this->wire('user'); - $event->return = $this->ii_subfunctions($user); - }); - $this->addHook("Page(pw_template=iio)::iioURL", function($event) { $userID = $event->arguments(0); $focus = $event->arguments(1); From eba538212c8f73e73e3929dbb859182b35bd56e4 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 13 Apr 2021 08:39:58 -0500 Subject: [PATCH 106/106] FIX: validateVxmUpdateItmCost should be static --- site/controllers/classes/ajax/json/Map.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/controllers/classes/ajax/json/Map.php b/site/controllers/classes/ajax/json/Map.php index 09be642df..fe76e8084 100644 --- a/site/controllers/classes/ajax/json/Map.php +++ b/site/controllers/classes/ajax/json/Map.php @@ -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]; @@ -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']) {
- Item ID - - Description - Item IDDescription - Available - Available
- + {{ item.itemid }}