diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
| commit | 70c559432ece25dd3def8c64ddb7c1908b4d49e0 (patch) | |
| tree | 9627e43fbe0d0eb082e4d54fa47773cda77e58f7 /admin | |
| parent | 0579f237e179c8815c1c44d9c5cef94ad2a33588 (diff) | |
| download | stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.gz stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.bz2 stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.zip | |
Add xref support, assembly/component views, and import tooling
- add_xref.php, edit_xref.php: xref record add/edit for stock content types
- admin xref group/source pages for stock_assembly and stock_component
- assembly_views/: auto_flow, fixed_grid, position_number, simple_list layouts
- Full assembly and component listing, tree, ordering, and detail pages
- Import tooling (ImportAssembly, ImportComponent, load scripts)
- liberty_plugins for assembly and component data types
- schema_inc.php updated; StockAssembly, StockBase, StockComponent,
StockMovement classes updated with xref group/item/multiple renames
- Templates updated throughout for xref rename (source→item, group→x_group)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'admin')
| -rwxr-xr-x | admin/admin_stock_inc.php | 135 | ||||
| -rw-r--r-- | admin/admin_stockassembly_xref_groups.php | 3 | ||||
| -rw-r--r-- | admin/admin_stockassembly_xref_sources.php | 3 | ||||
| -rw-r--r-- | admin/admin_stockcomponent_xref_groups.php | 3 | ||||
| -rw-r--r-- | admin/admin_stockcomponent_xref_sources.php | 3 | ||||
| -rwxr-xr-x | admin/schema_inc.php | 180 |
6 files changed, 185 insertions, 142 deletions
diff --git a/admin/admin_stock_inc.php b/admin/admin_stock_inc.php index 7ec0ed5..881d6d2 100755 --- a/admin/admin_stock_inc.php +++ b/admin/admin_stock_inc.php @@ -2,131 +2,100 @@ use Bitweaver\KernelTools; -//This holds the checkbox options for what to display on the 'list galleries' page $formGalleryGeneral = [ "stock_menu_text" => [ 'label' => 'Menu Text', 'note' => '', 'type' => 'text', ], -/* Disabled for now - spiderr - "feature_megaupload" => [ - 'label' => 'Use <a href="http://sourceforge.net/projects/megaupload">MegaUpload</a>', - 'note' => 'Upload progress meter that requires Perl and ExecCGI permission', - 'type' => 'checkbox' - ], -*/ - "liberty_offline_thumbnailer" => [ - 'label' => 'Background Thumbnailer', - 'note' => 'Thumbnails will be queued and regenerated by a background command-line script. For more information, see '.STOCK_PKG_PATH.'thumbaniler.php or you can <a href="'.STOCK_PKG_URL.'thumbnailer.php">run it manually</a>', - 'type' => 'checkbox', - ], "stock_show_public_on_upload" => [ - 'label' => 'Show Public Galleries on Upload', - 'note' => 'Enable this if you want to have all public galleries visible when uploading files. This might cause problems on large sites with many public galleries.', + 'label' => 'Show Public Assemblies on Upload', + 'note' => 'Enable this if you want to have all public assemblies visible when adding components. This might cause problems on large sites with many public assemblies.', 'type' => 'checkbox', ], "stock_show_all_to_admins" => [ - 'label' => 'Show all Galleries to Administrators', - 'note' => 'This will allow gallery admins to upload and move around images in all galleries. This might cause problems on large sites with many galleries.', + 'label' => 'Show all Assemblies to Administrators', + 'note' => 'This will allow assembly admins to move components between all assemblies.', 'type' => 'checkbox', ], ]; -if( !$gBitSystem->isPackageActive( 'gigaupload' ) ) { - $formGalleryGeneral["stock_extended_upload_slots"] = [ - 'label' => 'Extended Upload Slots', - 'note' => 'When you enable this, users can enter the title and description of the file when uploading them.', - 'type' => 'checkbox', - ]; -}; $gBitSmarty->assign('formGalleryGeneral', $formGalleryGeneral); $formGalleryListLists = [ "stock_list_title" => [ - 'label' => 'Gallery title', - 'note' => 'List the title of the gallery.', + 'label' => 'Assembly title', + 'note' => 'List the title of the assembly.', ], "stock_list_thumbnail" => [ 'label' => 'Thumbnail', - 'note' => 'Display a small thumbnail associated with a gallery', + 'note' => 'Display a cover thumbnail associated with an assembly', ], "stock_list_description" => [ 'label' => 'Description', - 'note' => 'List the description of a gallery', + 'note' => 'List the description of an assembly', ], "stock_list_user" => [ 'label' => 'Creator', - 'note' => 'List the name of the user who created the gallery', + 'note' => 'List the name of the user who created the assembly', ], "stock_list_hits" => [ 'label' => 'Hits', - 'note' => 'List number of hits this gallery has receieved', + 'note' => 'List number of hits this assembly has received', ], "stock_list_created" => [ 'label' => 'Creation date', - 'note' => 'List the creation date of the gallery', + 'note' => 'List the creation date of the assembly', ], "stock_list_lastmodif" => [ 'label' => 'Last modification', - 'note' => 'List date this gallery was last modified', + 'note' => 'List date this assembly was last modified', ], ]; $gBitSmarty->assign('formGalleryListLists', $formGalleryListLists); -// This holds the checkbox options for what to display on a 'view gallery' page $formGalleryLists = [ "stock_gallery_list_title" => [ - 'label' => 'Gallery title', - 'note' => 'When viewing a gallery, display the title of the gallery', + 'label' => 'Assembly title', + 'note' => 'When viewing an assembly, display the title', ], "stock_gallery_list_description" => [ - 'label' => 'Gallery description', - 'note' => 'When viewing a gallery, display the description of the gallery below the title', + 'label' => 'Assembly description', + 'note' => 'When viewing an assembly, display the description below the title', ], "stock_gallery_list_image_titles" => [ - 'label' => 'Image titles', - 'note' => 'Show image titles underneath each thumbnail', - ], - "stock_gallery_hide_modules" => [ - 'label' => 'Hide modules for galleries', - 'note' => 'When viewing a gallery, hide the left and right module columns', + 'label' => 'Component titles', + 'note' => 'Show component titles in grid layouts', ], "stock_gallery_list_image_descriptions" => [ - 'label' => 'Image description', - 'note' => 'Show image descriptions underneath each thumbnail', - ], - "stock_gallery_div_layout" => [ - 'label' => '<div> based Layout', - 'note' => 'You can use a <div> based layout, which will adjust the number of images in each row to the width of the browser. Please visit the online help for more information.', - 'page' => 'StockPackage', + 'label' => 'Component descriptions', + 'note' => 'Show component descriptions in grid layouts', ], ]; -$gBitSmarty->assign( 'formGalleryLists',$formGalleryLists ); +$gBitSmarty->assign( 'formGalleryLists', $formGalleryLists ); -// This holds the checkbox options for what to display on an 'image details' page $formImageLists = [ - "stock_image_list_title" => [ - 'label' => 'Image title', - 'note' => 'When viewing an image, display the title of the image', + "stock_item_list_desc" => [ + 'label' => 'Component description', + 'note' => 'Show component description in list and position views', ], - "stock_image_list_description" => [ - 'label' => 'Image description', - 'note' => 'When viewing an image, display the description of the image below the title', + "stock_item_list_date" => [ + 'label' => 'Created date', + 'note' => 'Show the date the component was created', ], - "stock_image_hide_modules" => [ - 'label' => 'Hide modules for images', - 'note' => 'When viewing an image, hide the left and right module columns', + "stock_item_list_creator" => [ + 'label' => 'Creator', + 'note' => 'Show the name of the user who created the component', ], - "gallerybar_use_icons" => [ - 'label' => 'Use icons in the gallery bar', - 'note' => 'When viewing an image, show <strong>previous</strong> and <strong>next</strong> links as images instead of words', + "stock_item_list_hits" => [ + 'label' => 'Views', + 'note' => 'Show the view count for each component', ], - "gallery_bar_use_thumbnails" => [ - 'label' => 'Use Thumbnails in gallery bar', - 'note' => 'When viewing an image, show previous and next <strong>thumbnails</strong> with the appropriate links.', + "stock_item_list_attid" => [ + 'label' => 'Plugin tag', + 'note' => 'Show the wiki plugin tag that can be used to embed this component', ], ]; -$gBitSmarty->assign( 'formImageLists', $formImageLists); +$gBitSmarty->assign( 'formImageLists', $formImageLists ); use Bitweaver\Stock\StockAssembly; @@ -134,47 +103,37 @@ $gBitSmarty->assign( 'galleryPaginationTypes', StockAssembly::getAllLayouts() ); $sortOptions = [ '' => KernelTools::tra( 'None' ), - 'lc.title_desc' => KernelTools::tra( 'Image Title' ). ' - '.KernelTools::tra( 'descending' ), - 'lc.title_asc' => KernelTools::tra( 'Image Title' ). ' - '.KernelTools::tra( 'ascending' ), - 'lc.created_desc' => KernelTools::tra( 'Date Uploaded' ).' - '.KernelTools::tra( 'descending' ), - 'lc.created_asc' => KernelTools::tra( 'Date Uploaded' ).' - '.KernelTools::tra( 'ascending' ), - 'lc.last_modified_desc' => KernelTools::tra( 'Last Modified' ).' - '.KernelTools::tra( 'descending' ), - 'lc.last_modified_asc' => KernelTools::tra( 'Last Modified' ).' - '.KernelTools::tra( 'ascending' ), + 'lc.title_desc' => KernelTools::tra( 'Title' ). ' - '.KernelTools::tra( 'descending' ), + 'lc.title_asc' => KernelTools::tra( 'Title' ). ' - '.KernelTools::tra( 'ascending' ), + 'lc.created_desc' => KernelTools::tra( 'Created' ). ' - '.KernelTools::tra( 'descending' ), + 'lc.created_asc' => KernelTools::tra( 'Created' ). ' - '.KernelTools::tra( 'ascending' ), + 'lc.last_modified_desc' => KernelTools::tra( 'Last Modified' ). ' - '.KernelTools::tra( 'descending' ), + 'lc.last_modified_asc' => KernelTools::tra( 'Last Modified' ). ' - '.KernelTools::tra( 'ascending' ), ]; $gBitSmarty->assign( 'sortOptions', $sortOptions ); -$gBitSmarty->assign( 'imageSizes', Bitweaver\Liberty\get_image_size_options( false )); -//vd($_REQUEST); if (!empty($_REQUEST['stockAdminSubmit'])) { - // General Settings - foreach ($formGalleryGeneral as $item=>$data) { + foreach ($formGalleryGeneral as $item => $data) { if( $data['type'] == 'checkbox' ) { simple_set_toggle($item, STOCK_PKG_NAME); } else { - $gBitSystem->storeConfig($item, $_REQUEST[$item], STOCK_PKG_NAME ); + $gBitSystem->storeConfig($item, $_REQUEST[$item], STOCK_PKG_NAME); } } - // Gallery List Display Settings - foreach ($formGalleryListLists as $item=>$data) { + foreach ($formGalleryListLists as $item => $data) { simple_set_toggle($item, STOCK_PKG_NAME); } - // Gallery Display Settings foreach ($formGalleryLists as $item => $data) { simple_set_toggle($item, STOCK_PKG_NAME); } - foreach( [ 'stock_list_thumbnail_size', 'stock_gallery_default_thumbnail_size', 'default_assembly_pagination', 'rows_per_page', 'cols_per_page', 'total_per_page', 'lines_per_page', 'stock_gallery_default_sort_mode' ] as $key ) { + foreach( [ 'default_assembly_pagination', 'rows_per_page', 'cols_per_page', 'total_per_page', 'lines_per_page', 'stock_gallery_default_sort_mode' ] as $key ) { $gBitSystem->storeConfig($key, $_REQUEST[$key], STOCK_PKG_NAME); } - // Image Display Settings foreach ($formImageLists as $item => $data) { simple_set_toggle( $item, STOCK_PKG_NAME ); } - if( !empty( $_REQUEST['default_image_thumbnail_size'] ) ) { - $gBitSystem->storeConfig('stock_image_default_thumbnail_size', $_REQUEST['default_image_thumbnail_size'], STOCK_PKG_NAME ); - } - } diff --git a/admin/admin_stockassembly_xref_groups.php b/admin/admin_stockassembly_xref_groups.php new file mode 100644 index 0000000..4f4af59 --- /dev/null +++ b/admin/admin_stockassembly_xref_groups.php @@ -0,0 +1,3 @@ +<?php +require_once '../../kernel/includes/setup_inc.php'; +header( 'Location: ' . LIBERTY_PKG_URL . 'admin/admin_xref_groups.php?content_type_guid=stockassembly' ); diff --git a/admin/admin_stockassembly_xref_sources.php b/admin/admin_stockassembly_xref_sources.php new file mode 100644 index 0000000..e36b6f0 --- /dev/null +++ b/admin/admin_stockassembly_xref_sources.php @@ -0,0 +1,3 @@ +<?php +require_once '../../kernel/includes/setup_inc.php'; +header( 'Location: ' . LIBERTY_PKG_URL . 'admin/admin_xref_sources.php?content_type_guid=stockassembly' ); diff --git a/admin/admin_stockcomponent_xref_groups.php b/admin/admin_stockcomponent_xref_groups.php new file mode 100644 index 0000000..5a06e98 --- /dev/null +++ b/admin/admin_stockcomponent_xref_groups.php @@ -0,0 +1,3 @@ +<?php +require_once '../../kernel/includes/setup_inc.php'; +header( 'Location: ' . LIBERTY_PKG_URL . 'admin/admin_xref_groups.php?content_type_guid=stockcomponent' ); diff --git a/admin/admin_stockcomponent_xref_sources.php b/admin/admin_stockcomponent_xref_sources.php new file mode 100644 index 0000000..5bafae9 --- /dev/null +++ b/admin/admin_stockcomponent_xref_sources.php @@ -0,0 +1,3 @@ +<?php +require_once '../../kernel/includes/setup_inc.php'; +header( 'Location: ' . LIBERTY_PKG_URL . 'admin/admin_xref_sources.php?content_type_guid=stockcomponent' ); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 1e7006f..002c811 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -7,7 +7,6 @@ $tables = [ content_id I4, rows_per_page I4, cols_per_page I4, - thumbnail_size C(32), preview_content_id I4, component_comment C(1) ", @@ -15,16 +14,32 @@ $tables = [ 'stock_assembly_component_map' => " assembly_content_id I4 NOTNULL, item_content_id I4 NOTNULL, - item_position F + item_position N(10,3), + quantity_value N(10,3) DEFAULT 1, + quantity_item C(8) DEFAULT 'SGL' ", 'stock_component' => " component_id I4 PRIMARY, - content_id I4 NOTNULL, - photo_date I8, - width I4, - height I4 + content_id I4 NOTNULL ", + +'stock_movement' => " + movement_id I4 PRIMARY, + content_id I4 NOTNULL, + direction C(1) DEFAULT 'O', + status C(20) DEFAULT 'draft', + parent_id I4 +", + +'stock_movement_item' => " + movement_content_id I4 NOTNULL, + item_content_id I4 NOTNULL, + item_position N(10,3), + quantity_value N(10,3) DEFAULT 1, + quantity_item C(8) DEFAULT 'SGL' +", + ]; global $gBitInstaller; @@ -34,74 +49,131 @@ foreach( array_keys( $tables ) AS $tableName ) { } $indices = [ - 'stock_assembly_id_idx' => [ 'table' => 'stock_assembly', 'cols' => 'assembly_id', 'opts' => null ], - 'stock_assembly_content_idx' => [ 'table' => 'stock_assembly', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], - 'stock_component_id_idx' => [ 'table' => 'stock_component', 'cols' => 'component_id', 'opts' => null ], - 'stock_component_content_idx'=> [ 'table' => 'stock_component', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], + 'stock_assembly_id_idx' => [ 'table' => 'stock_assembly', 'cols' => 'assembly_id', 'opts' => null ], + 'stock_assembly_content_idx' => [ 'table' => 'stock_assembly', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], + 'stock_map_assembly_idx' => [ 'table' => 'stock_assembly_component_map', 'cols' => 'assembly_content_id', 'opts' => null ], + 'stock_map_item_idx' => [ 'table' => 'stock_assembly_component_map', 'cols' => 'item_content_id', 'opts' => null ], + 'stock_component_id_idx' => [ 'table' => 'stock_component', 'cols' => 'component_id', 'opts' => null ], + 'stock_component_content_idx' => [ 'table' => 'stock_component', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], + 'stock_movement_content_idx' => [ 'table' => 'stock_movement', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], + 'stock_movement_parent_idx' => [ 'table' => 'stock_movement', 'cols' => 'parent_id', 'opts' => null ], + 'stock_movement_item_movement_idx' => [ 'table' => 'stock_movement_item', 'cols' => 'movement_content_id', 'opts' => null ], + 'stock_movement_item_item_idx' => [ 'table' => 'stock_movement_item', 'cols' => 'item_content_id', 'opts' => null ], ]; $gBitInstaller->registerSchemaIndexes( STOCK_PKG_NAME, $indices ); $gBitInstaller->registerPackageInfo( STOCK_PKG_NAME, [ - 'description' => "Stock is a package for managing manufacturing assemblies and components", - 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', + 'description' => 'Stock manages manufacturing assemblies and components with supplier, quantity, and specification tracking.', + 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', ] ); // ### Sequences -$sequences = [ - 'stock_assembly_id_seq' => [ 'start' => 1 ], +$gBitInstaller->registerSchemaSequences( STOCK_PKG_NAME, [ + 'stock_assembly_id_seq' => [ 'start' => 1 ], 'stock_component_id_seq' => [ 'start' => 1 ], -]; -$gBitInstaller->registerSchemaSequences( STOCK_PKG_NAME, $sequences ); + 'stock_movement_id_seq' => [ 'start' => 1 ], +] ); // ### Default Preferences $gBitInstaller->registerPreferences( STOCK_PKG_NAME, [ - [ STOCK_PKG_NAME, 'stock_list_title','y'], - [ STOCK_PKG_NAME, 'stock_list_created','y'], - [ STOCK_PKG_NAME, 'stock_list_user','y'], - [ STOCK_PKG_NAME, 'stock_list_hits','y'], - [ STOCK_PKG_NAME, 'stock_list_thumbnail','y'], - [ STOCK_PKG_NAME, 'stock_list_thumbnail_size','small'], - [ STOCK_PKG_NAME, 'stock_assembly_list_title','y'], - [ STOCK_PKG_NAME, 'stock_assembly_list_description','y'], - [ STOCK_PKG_NAME, 'stock_assembly_list_component_titles','y'], - [ STOCK_PKG_NAME, 'stock_assembly_default_rows_per_page','5'], - [ STOCK_PKG_NAME, 'stock_assembly_default_cols_per_page','3'], - [ STOCK_PKG_NAME, 'stock_assembly_default_thumbnail_size','small'], - [ STOCK_PKG_NAME, 'stock_component_list_title','y'], - [ STOCK_PKG_NAME, 'stock_component_list_description','y'], - [ STOCK_PKG_NAME, 'stock_component_default_thumbnail_size','medium'], - [ STOCK_PKG_NAME, 'stock_menu_text','Stock Assemblies'], - [ STOCK_PKG_NAME, 'stock_show_public_on_upload','n'], - [ STOCK_PKG_NAME, 'stock_show_all_to_admins','n'], + [ STOCK_PKG_NAME, 'stock_menu_text', 'Stock' ], + [ STOCK_PKG_NAME, 'stock_show_public_on_upload', 'n' ], + [ STOCK_PKG_NAME, 'stock_show_all_to_admins', 'n' ], + // Assembly list display + [ STOCK_PKG_NAME, 'stock_list_title', 'y' ], + [ STOCK_PKG_NAME, 'stock_list_thumbnail', 'y' ], + [ STOCK_PKG_NAME, 'stock_list_user', 'y' ], + [ STOCK_PKG_NAME, 'stock_list_created', 'y' ], + [ STOCK_PKG_NAME, 'stock_list_lastmodif', 'n' ], + [ STOCK_PKG_NAME, 'stock_list_hits', 'n' ], + // Assembly view display + [ STOCK_PKG_NAME, 'stock_gallery_list_image_titles', 'y' ], + [ STOCK_PKG_NAME, 'stock_gallery_list_image_descriptions','y' ], + [ STOCK_PKG_NAME, 'stock_gallery_default_sort_mode', '' ], + // Component list display + [ STOCK_PKG_NAME, 'stock_item_list_desc', 'y' ], + [ STOCK_PKG_NAME, 'stock_item_list_date', 'n' ], + [ STOCK_PKG_NAME, 'stock_item_list_creator', 'n' ], + [ STOCK_PKG_NAME, 'stock_item_list_hits', 'n' ], + [ STOCK_PKG_NAME, 'stock_item_list_attid', 'n' ], + // Pagination defaults + [ STOCK_PKG_NAME, 'default_gallery_pagination', 'position_number' ], + [ STOCK_PKG_NAME, 'rows_per_page', '5' ], + [ STOCK_PKG_NAME, 'cols_per_page', '3' ], + [ STOCK_PKG_NAME, 'total_per_page', '20' ], + // Movement statuses + [ STOCK_PKG_NAME, 'stock_movement_statuses', 'draft,pending,complete,cancelled' ], + [ STOCK_PKG_NAME, 'stock_movement_status_draft', 'Draft' ], + [ STOCK_PKG_NAME, 'stock_movement_status_pending', 'Pending' ], + [ STOCK_PKG_NAME, 'stock_movement_status_complete', 'Complete' ], + [ STOCK_PKG_NAME, 'stock_movement_status_cancelled', 'Cancelled' ], ] ); // ### Default User Permissions $gBitInstaller->registerUserPermissions( STOCK_PKG_NAME, [ - ['p_stock_list_assemblies', 'Can list stock assemblies', 'basic', STOCK_PKG_NAME], - ['p_stock_view', 'Can view stock assemblies', 'basic', STOCK_PKG_NAME], - ['p_stock_create', 'Can create a stock assembly', 'registered', STOCK_PKG_NAME], - ['p_stock_update', 'Can update stock assembly', 'editors', STOCK_PKG_NAME], - ['p_stock_upload', 'Can upload components to assembly', 'registered', STOCK_PKG_NAME], - ['p_stock_admin', 'Can admin stock assemblies', 'editors', STOCK_PKG_NAME], - ['p_stock_upload_nonimages', 'Can upload non-image files', 'editors', STOCK_PKG_NAME], - ['p_stock_change_thumb_size', 'Can set the thumbnail size for an assembly', 'editors', STOCK_PKG_NAME], - ['p_stock_create_public_gal', 'Can create public assemblies any user can load components into', 'editors', STOCK_PKG_NAME], - ['p_stock_download_assembly_arc', 'Can download an archived copy of stock assembly', 'registered', STOCK_PKG_NAME], + [ 'p_stock_list_assemblies', 'Can list stock assemblies', 'basic', STOCK_PKG_NAME ], + [ 'p_stock_view', 'Can view stock assemblies and components', 'basic', STOCK_PKG_NAME ], + [ 'p_stock_create', 'Can create stock assemblies and components', 'registered', STOCK_PKG_NAME ], + [ 'p_stock_update', 'Can update stock assemblies and components', 'editors', STOCK_PKG_NAME ], + [ 'p_stock_admin', 'Can administer stock', 'editors', STOCK_PKG_NAME ], + [ 'p_stock_create_public_gal','Can create public assemblies', 'editors', STOCK_PKG_NAME ], ] ); -if( defined( 'RSS_PKG_NAME' )) { - $gBitInstaller->registerPreferences( STOCK_PKG_NAME, [ - [ RSS_PKG_NAME, STOCK_PKG_NAME.'_rss', 'y'], - ]); -} - // ### Register content types $gBitInstaller->registerContentObjects( STOCK_PKG_NAME, [ - 'StockAssembly'=>STOCK_PKG_CLASS_PATH.'StockAssembly.php', - 'StockComponent'=>STOCK_PKG_CLASS_PATH.'StockComponent.php', + 'StockAssembly' => STOCK_PKG_CLASS_PATH.'StockAssembly.php', + 'StockComponent' => STOCK_PKG_CLASS_PATH.'StockComponent.php', ] ); -// Requirements +// ### Requirements $gBitInstaller->registerRequirements( STOCK_PKG_NAME, [ 'liberty' => [ 'min' => '5.0.0' ], -]); +] ); + +// ### Xref seed data +// liberty_xref_group: xref_type, content_type_guid, title, sort_order, role_id, type_href +// liberty_xref_item: item, content_type_guid, xref_type, cross_ref_title, multi, role_id, cross_ref_href, template, data + +$X = BIT_DB_PREFIX; + +// Helper to generate xref_type rows for both content types +$xrefTypes = []; +$xrefItems = []; + +foreach( [ 'stockcomponent', 'stockassembly' ] as $guid ) { + $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('supplier','{$guid}','Supplier', 1,3,'')"; + $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('quantity','{$guid}','Quantity', 2,3,'')"; + $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('values', '{$guid}','Values', 3,3,'')"; + + // Supplier sources — multi=1 (multiple suppliers per item) + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#SUP','{$guid}','supplier','Supplier', 1,3,'../contact/?content_id=','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#PN', '{$guid}','supplier','Part Number', 1,3,'', 'text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#PR', '{$guid}','supplier','Price', 1,3,'', 'text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#URL','{$guid}','supplier','Supplier URL', 1,3,'', 'text',NULL)"; + + // Quantity sources — selectable types multi=0, movement multi=1 + // entry_date on liberty_xref timestamps each MOV row automatically + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SGL','{$guid}','quantity','Single unit', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PCK','{$guid}','quantity','Pack', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','{$guid}','quantity','Sheet (H x W)', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VOL','{$guid}','quantity','Volume', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('MOV','{$guid}','quantity','Stock movement', 1,3,'','text',NULL)"; + + // Values sources — starter catalogue, all multi=0, add more via admin + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('RES','{$guid}','values','Resistance', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('CAP','{$guid}','values','Capacitance', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VLT','{$guid}','values','Voltage', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('TOL','{$guid}','values','Tolerance', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PWR','{$guid}','values','Power', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('CUR','{$guid}','values','Current', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('FRQ','{$guid}','values','Frequency', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('IND','{$guid}','values','Inductance', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('TMP','{$guid}','values','Temperature', 0,3,'','text',NULL)"; + $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PKG','{$guid}','values','Package/Footprint', 0,3,'','text',NULL)"; +} + +// stockmovement xref — requisition reference links +$xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('reference','stockmovement','Reference',1,3,'')"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('REQN','stockmovement','reference','Requisition',1,3,'','text',NULL)"; + +$gBitInstaller->registerSchemaDefault( STOCK_PKG_NAME, array_merge( $xrefTypes, $xrefItems ) ); |
