diff options
22 files changed, 72 insertions, 71 deletions
diff --git a/add_component.php b/add_component.php index d33919c..b80f223 100644 --- a/add_component.php +++ b/add_component.php @@ -24,7 +24,7 @@ if( !$gContent->isValid() ) { } $gContent->verifyUpdatePermission(); -$validItems = [ 'SGL' => 'Single unit', 'PCK' => 'Pack', 'SHT' => 'Sheet (H x W)', 'VOL' => 'Volume' ]; +$validItems = [ 'SGL' => 'Single unit', 'PRT' => 'Part', 'SHT' => 'Sheet', 'VOL' => 'Volume' ]; $errors = []; if( !empty( $_REQUEST['fCancel'] ) ) { @@ -60,7 +60,7 @@ if( !empty( $_REQUEST['fAddComponent'] ) ) { // Place new row at end of current BOM $maxXorder = (int)$gBitDb->getOne( "SELECT MAX(`xorder`) FROM `".BIT_DB_PREFIX."liberty_xref` - WHERE `content_id`=? AND `item` IN ('SGL','PCK','SHT','VOL')", + WHERE `content_id`=? AND `item` IN ('SGL','PRT','SHT','VOL')", [ $gContent->mContentId ] ); diff --git a/add_movement_component.php b/add_movement_component.php index 9f2dfa2..56f02a5 100644 --- a/add_movement_component.php +++ b/add_movement_component.php @@ -22,7 +22,7 @@ if( !$gContent->isValid() ) { } $gContent->verifyUpdatePermission(); -$validItems = [ 'SGL' => 'Single unit', 'PCK' => 'Pack', 'SHT' => 'Sheet (H x W)', 'VOL' => 'Volume' ]; +$validItems = [ 'SGL' => 'Single unit', 'PRT' => 'Part', 'SHT' => 'Sheet', 'VOL' => 'Volume' ]; $errors = []; if( !empty( $_REQUEST['fCancel'] ) ) { @@ -55,7 +55,7 @@ if( !empty( $_REQUEST['fAddComponent'] ) ) { $nextXorder = (int)$gBitDb->getOne( "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL')", + WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL')", [ $gContent->mContentId ] ) ?: 1; diff --git a/add_order.php b/add_order.php index 60b4eb3..0722c47 100644 --- a/add_order.php +++ b/add_order.php @@ -67,7 +67,7 @@ if( !empty( $_POST['fCreate'] ) ) { if( !$cid ) continue; $qty = (float)( $qtysPost[$i] ?? 0 ); if( $qty <= 0 ) continue; - $qtype = in_array( $qtyTypesPost[$i] ?? '', [ 'SGL', 'PCK', 'SHT', 'VOL' ] ) + $qtype = in_array( $qtyTypesPost[$i] ?? '', [ 'SGL', 'PRT', 'SHT', 'VOL' ] ) ? $qtyTypesPost[$i] : 'SGL'; $lineHash = [ 'content_id' => $movement->mContentId, @@ -109,7 +109,7 @@ if( $fromPost ) { } foreach( $cids as $i => $cid ) { if( !$cid ) continue; - $qtype = in_array( $types[$i] ?? '', [ 'SGL', 'PCK', 'SHT', 'VOL' ] ) ? $types[$i] : 'SGL'; + $qtype = in_array( $types[$i] ?? '', [ 'SGL', 'PRT', 'SHT', 'VOL' ] ) ? $types[$i] : 'SGL'; $lines[] = [ 'component_id' => $cid, 'title' => $meta[$cid]['title'] ?? '', @@ -159,7 +159,7 @@ if( $fromPost ) { AND mx.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?') AS stock_level FROM `{$X}liberty_content` lc INNER JOIN `{$X}liberty_xref` bom ON bom.`content_id` = ? - AND bom.`item` IN ('SGL','PCK','SHT','VOL') + AND bom.`item` IN ('SGL','PRT','SHT','VOL') AND bom.`xref` = lc.`content_id` WHERE lc.`content_type_guid` = 'stockcomponent' $findSql @@ -188,7 +188,7 @@ if( $fromPost ) { ELSE -CAST(x.`xkey` AS DOUBLE PRECISION) END ) AS stock_level FROM `{$X}liberty_content` lc INNER JOIN `{$X}liberty_xref` x ON x.`xref` = lc.`content_id` - AND x.`item` IN ('SGL','PCK','SHT','VOL') + AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?' INNER JOIN `{$X}liberty_content` mc ON mc.`content_id` = x.`content_id` AND mc.`content_type_guid` = 'stockmovement' diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 0e42764..d76e921 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -122,10 +122,11 @@ $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`, $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`,`template`) VALUES ('quantity','stockcomponent','Quantity',2,3,'','')"; $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`,`template`) VALUES ('values', 'stockcomponent','Values', 4,3,'','')"; -// stockcomponent quantity types — different templates from SA (text/value not bom/bompck) +// stockcomponent quantity types — different templates from SA (text/value not bom/bomprt) $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SGL','stockcomponent','quantity','Single unit', 0,3,'','text', NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PCK','stockcomponent','quantity','Pack', 0,3,'','value',NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockcomponent','quantity','Sheet (H x W)', 0,3,'','text', NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PRT','stockcomponent','quantity','Part',0,3,'','value',NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PCK','stockcomponent','quantity','Pack size', 0,3,'','value',NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockcomponent','quantity','Sheet', 0,3,'','text', NULL)"; $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VOL','stockcomponent','quantity','Volume', 0,3,'','text', NULL)"; // ── 'stock' package-level kitlocker group (sort_order=2) — shared across SA and SC ─── @@ -136,8 +137,8 @@ $xrefTypes[] = "INSERT INTO `{$X}liberty_xref_group` (`x_group`,`content_type_gu // stockassembly quantity types — BOM grid templates $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SGL','stockassembly','quantity','Single unit', 0,3,'','bom', NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PCK','stockassembly','quantity','Pack', 0,3,'','bompck',NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockassembly','quantity','Sheet (H x W)', 0,3,'','bom', NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PRT','stockassembly','quantity','Part',0,3,'','bomprt',NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockassembly','quantity','Sheet', 0,3,'','bom', NULL)"; $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VOL','stockassembly','quantity','Volume', 0,3,'','bom', NULL)"; // Values items — stockcomponent only; starter catalogue, all multi=0, add more via admin @@ -172,11 +173,11 @@ $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`, $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('TRANS','stockmovement','reference','Transfer', 1,3,'','text',NULL)"; $xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('ORDER','stockmovement','reference','Order', 1,3,'','text',NULL)"; -// quantity items — multiple=1, one row per component line; bom/bompck templates -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SGL','stockmovement','quantity','Single unit',1,3,'','bom', NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PCK','stockmovement','quantity','Pack', 1,3,'','bompck',NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockmovement','quantity','Sheet', 1,3,'','bom', NULL)"; -$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VOL','stockmovement','quantity','Volume', 1,3,'','bom', NULL)"; +// quantity items — multiple=1, one row per component line; bom/bomprt templates +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SGL','stockmovement','quantity','Single unit', 1,3,'','bom', NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('PRT','stockmovement','quantity','Part',1,3,'','bomprt',NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SHT','stockmovement','quantity','Sheet', 1,3,'','bom', NULL)"; +$xrefItems[] = "INSERT INTO `{$X}liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VOL','stockmovement','quantity','Volume', 1,3,'','bom', NULL)"; $gBitInstaller->registerSchemaDefault( STOCK_PKG_NAME, array_merge( $xrefTypes, $xrefItems ) ); diff --git a/edit_assembly.php b/edit_assembly.php index 29b2248..812dc7c 100755 --- a/edit_assembly.php +++ b/edit_assembly.php @@ -70,7 +70,7 @@ if( !empty( $_REQUEST['savegallery'] ) ) { $savedBom = STOCK_IMPORT_PATH . $origName . '_bom_' . $gContent->mContentId . '.csv'; move_uploaded_file( $_FILES['csv_file']['tmp_name'], $savedBom ); // Valid BOM unit types (MOV is for movements, not BOM lines) - $validItems = [ 'SGL', 'PCK', 'SHT', 'VOL' ]; + $validItems = [ 'SGL', 'PRT', 'SHT', 'VOL' ]; if( ($fh = fopen( $savedBom, 'r' )) !== false ) { $rowNum = 0; while( ($cols = fgetcsv($fh, 0, ',', '"', '')) !== false ) { diff --git a/edit_movement.php b/edit_movement.php index 816553c..1167efd 100644 --- a/edit_movement.php +++ b/edit_movement.php @@ -21,7 +21,7 @@ if( $gContent->isValid() ) { } // TODO: derive from liberty_xref_item WHERE content_type_guid='stockcomponent' AND x_group='quantity' -$qtyTypes = [ 'SGL', 'PCK', 'SHT', 'VOL' ]; +$qtyTypes = [ 'SGL', 'PRT', 'SHT', 'VOL' ]; // Movement reference types from DB — drives the type selector on create $refTypes = $gBitDb->getAssoc( @@ -134,7 +134,7 @@ if( !empty( $_REQUEST['fSave'] ) ) { } else { $nextXorder = (int)$gBitDb->getOne( "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL')", + WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL')", [ $gContent->mContentId ] ) ?: 1; $qtyHash = [ diff --git a/import/ImportSimpleComponent.php b/import/ImportSimpleComponent.php index 1f87375..891325c 100644 --- a/import/ImportSimpleComponent.php +++ b/import/ImportSimpleComponent.php @@ -9,14 +9,14 @@ * 3 supplier_pn Supplier part number → xref #PN in xkey_ext (optional) * 4 supplier_price Supplier price → xref #PR in xkey (optional) * 5 supplier_url Supplier URL → xref #SUP data (optional) - * 6 qty_type SGL/PCK/SHT/VOL — omit or blank for SGL (optional) - * 7 qty_value Pack size for PCK (pieces per pack); dimensions for SHT (optional) + * 6 qty_type SGL/PRT/PCK/SHT/VOL — omit or blank for SGL (optional) + * 7 qty_value Pack size for PRT/PCK (pieces per pack); dimensions for SHT (optional) * * Supplier name is matched against liberty_content.title for content_type_guid='contact'. * #SUP stores the contact content_id in the xref column; #PN and #PR share xorder=1 * so they are grouped with the #SUP entry as one supplier set. * - * Setting qty_type to PCK/SHT/VOL writes the appropriate xref on the component so that + * Setting qty_type to PRT/PCK/SHT/VOL writes the appropriate xref on the component so that * movement CSV imports pick up the correct default qty type without a manual override. * * Existing components (matched by title) are skipped unless cleared first. @@ -132,8 +132,8 @@ function stockImportSimpleComponent( array $data, int $rowNum ): array { } // Quantity type xref — sets the default qty type used by movement CSV imports - // and the pack size shown in BOM displays (PCK xref xkey = pieces per pack) - if( in_array( $qtyType, [ 'PCK', 'SHT', 'VOL' ] ) ) { + // and the pack size shown in BOM displays (PRT/PCK xref xkey = pieces per pack) + if( in_array( $qtyType, [ 'PRT', 'PCK', 'SHT', 'VOL' ] ) ) { $gBitDb->associateInsert( BIT_DB_PREFIX.'liberty_xref', [ 'xref_id' => $gBitDb->GenID( 'liberty_xref_seq' ), 'content_id' => $contentId, diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php index ab151a4..54342ad 100755 --- a/includes/classes/StockAssembly.php +++ b/includes/classes/StockAssembly.php @@ -4,7 +4,7 @@ * * Stored as a pure liberty_content record (content_type_guid='stockassembly'). * Components are linked via stock_assembly_map with an item_position for ordering. - * BOM quantities live in liberty_xref (x_group='quantity', items SGL/PCK/SHT/VOL). + * BOM quantities live in liberty_xref (x_group='quantity', items SGL/PRT/SHT/VOL). * Assemblies can be nested; breadcrumb/tree queries use a Firebird recursive CTE. * * @package stock @@ -79,7 +79,7 @@ class StockAssembly extends StockBase { * Enrich a BOM xref row with component title, description, and pack size. * * Calls parent for supplier enrichment, then adds xref_title, xref_data, - * pack_size, and pack_size_ext from the linked component's liberty_content + PCK xref. + * part_size, and part_size_ext from the linked component's liberty_content + PCK xref. * * @param array $pXrefInfo Xref display row; modified in place. */ @@ -87,16 +87,16 @@ class StockAssembly extends StockBase { parent::enrichXrefDisplay( $pXrefInfo ); if( !empty( $pXrefInfo['xref'] ) ) { if( $comp = $this->mDb->getRow( - "SELECT lc.`title`, lc.`data`, pck.`xkey` AS `pack_size`, pck.`xkey_ext` AS `pack_size_ext` + "SELECT lc.`title`, lc.`data`, pck.`xkey` AS `part_size`, pck.`xkey_ext` AS `part_size_ext` FROM `".BIT_DB_PREFIX."liberty_content` lc - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PCK' + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PRT' WHERE lc.`content_id` = ?", [ (int)$pXrefInfo['xref'] ] ) ) { $pXrefInfo['xref_title'] = $comp['title']; $pXrefInfo['xref_data'] = $comp['data']; - $pXrefInfo['pack_size'] = $comp['pack_size']; - $pXrefInfo['pack_size_ext'] = $comp['pack_size_ext']; + $pXrefInfo['part_size'] = $comp['part_size']; + $pXrefInfo['part_size_ext'] = $comp['part_size_ext']; } } } @@ -114,9 +114,9 @@ class StockAssembly extends StockBase { $componentIds = array_values( array_unique( array_filter( array_column( $bomGroup->mXrefs, 'xref' ) ) ) ); if( !$componentIds ) return; $components = $this->mDb->getAssoc( - "SELECT lc.`content_id`, lc.`title`, lc.`data`, pck.`xkey` AS `pack_size`, pck.`xkey_ext` AS `pack_size_ext` + "SELECT lc.`content_id`, lc.`title`, lc.`data`, pck.`xkey` AS `part_size`, pck.`xkey_ext` AS `part_size_ext` FROM `".BIT_DB_PREFIX."liberty_content` lc - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PCK' + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` pck ON pck.`content_id` = lc.`content_id` AND pck.`item` = 'PRT' WHERE lc.`content_id` IN (".implode( ',', array_fill( 0, count( $componentIds ), '?' ) ).")", $componentIds ); @@ -124,8 +124,8 @@ class StockAssembly extends StockBase { if( !empty( $row['xref'] ) && isset( $components[$row['xref']] ) ) { $row['xref_title'] = $components[$row['xref']]['title']; $row['xref_data'] = $components[$row['xref']]['data']; - $row['pack_size'] = $components[$row['xref']]['pack_size']; - $row['pack_size_ext'] = $components[$row['xref']]['pack_size_ext']; + $row['part_size'] = $components[$row['xref']]['part_size']; + $row['part_size_ext'] = $components[$row['xref']]['part_size_ext']; } } unset( $row ); diff --git a/includes/classes/StockMovement.php b/includes/classes/StockMovement.php index a880e18..e867460 100644 --- a/includes/classes/StockMovement.php +++ b/includes/classes/StockMovement.php @@ -7,7 +7,7 @@ * TRANS/ORDER = inbound. Status (open vs received) is stored in lc.event_time: * 0 = open, positive Unix timestamp = received. * - * Component lines live in liberty_xref (x_group='quantity', items SGL/PCK/SHT/VOL). + * Component lines live in liberty_xref (x_group='quantity', items SGL/PRT/SHT/VOL). * The reference xref (x_group='reference') carries the from/ref/date/contact data. * * @package stock @@ -249,7 +249,7 @@ class StockMovement extends LibertyContent { /** * Append quantity xrefs from an assembly BOM into this movement, scaled by kit count. * - * Reads SGL/PCK/SHT/VOL xrefs from the assembly and inserts them as new movement + * Reads SGL/PRT/SHT/VOL xrefs from the assembly and inserts them as new movement * quantity lines, starting xorder after any existing items. Safe to call multiple * times (e.g. for multi-assembly requisitions) — lines are only appended. * @@ -264,7 +264,7 @@ class StockMovement extends LibertyContent { $nextXorder = (int)$this->mDb->getOne( "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL')", + WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL')", [ $this->mContentId ] ) ?: 1; @@ -272,7 +272,7 @@ class StockMovement extends LibertyContent { "SELECT x.`xref` AS item_content_id, x.`item` AS quantity_item, CAST(x.`xkey` AS DOUBLE PRECISION) AS quantity_value FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL') + WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?' ORDER BY x.`xorder`", [ $pAssemblyContentId ] @@ -325,7 +325,7 @@ class StockMovement extends LibertyContent { $cmpContentId = $this->verifyId( $pListHash['component_content_id'] ?? 0 ) ? (int)$pListHash['component_content_id'] : 0; if( $cmpContentId ) { $whereSql .= " AND EXISTS (SELECT 1 FROM `".BIT_DB_PREFIX."liberty_xref` xcf - WHERE xcf.`content_id` = lc.`content_id` AND xcf.`item` IN ('SGL','PCK','SHT','VOL') AND xcf.`xref` = $cmpContentId)"; + WHERE xcf.`content_id` = lc.`content_id` AND xcf.`item` IN ('SGL','PRT','SHT','VOL') AND xcf.`xref` = $cmpContentId)"; } if( $this->verifyId( $pListHash['user_id'] ?? 0 ) ) { $whereSql .= " AND lc.`user_id` = ?"; @@ -365,10 +365,10 @@ class StockMovement extends LibertyContent { $X = BIT_DB_PREFIX; $cmpQtySelect = $cmpContentId ? ", (SELECT FIRST 1 x.`item` FROM `{$X}liberty_xref` x - WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('SGL','PCK','SHT','VOL') AND x.`xref` = $cmpContentId + WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xref` = $cmpContentId ORDER BY x.`xorder`) AS cmp_qty_type, (SELECT SUM(CAST(x.`xkey` AS DOUBLE PRECISION)) FROM `{$X}liberty_xref` x - WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('SGL','PCK','SHT','VOL') AND x.`xref` = $cmpContentId) AS cmp_qty" + WHERE x.`content_id` = lc.`content_id` AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xref` = $cmpContentId) AS cmp_qty" : ", CAST(NULL AS VARCHAR(4)) AS cmp_qty_type, CAST(NULL AS DOUBLE PRECISION) AS cmp_qty"; $query = "SELECT lc.`content_id`, lc.`title`, lc.`created`, lc.`last_modified`, lc.`event_time`, @@ -437,7 +437,7 @@ class StockMovement extends LibertyContent { * The reference row updates or creates the REQN/TRANS/ORDER xref. Order date sets * xref.start_date; received date sets lc.event_time. Unknown components are skipped. * - * @param string[] $pQtyTypes Allowed qty type codes (e.g. ['SGL','PCK','SHT','VOL']). + * @param string[] $pQtyTypes Allowed qty type codes (e.g. ['SGL','PRT','SHT','VOL']). * @return array{loaded:int, skipped:int, errors:string[]} */ public function importCsv( array $pQtyTypes ): array { @@ -453,7 +453,7 @@ class StockMovement extends LibertyContent { $nextXorder = (int)$this->mDb->getOne( "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL')", + WHERE x.`content_id` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL')", [ $this->mContentId ] ) ?: 1; diff --git a/list_movements.php b/list_movements.php index 8ae66e4..1172fd3 100644 --- a/list_movements.php +++ b/list_movements.php @@ -19,7 +19,7 @@ $listHash = $_REQUEST; $movementList = $movement->getList( $listHash ); $componentTitle = ''; -$packSize = null; +$partSize = null; if( $componentContentId ) { $componentTitle = $gBitDb->getOne( "SELECT `title` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id` = ?", @@ -27,10 +27,10 @@ if( $componentContentId ) { ) ?: ''; $ps = $gBitDb->getOne( "SELECT CAST(x.`xkey` AS DOUBLE PRECISION) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` = 'PCK'", + WHERE x.`content_id` = ? AND x.`item` = 'PRT'", [ $componentContentId ] ); - $packSize = $ps ? (float)$ps : null; + $partSize = $ps ? (float)$ps : null; } $gBitSmarty->assign( 'listInfo', $listHash['listInfo'] ); @@ -39,6 +39,6 @@ $gBitSmarty->assign( 'filterType', $_REQUEST['ref_type'] ?? '' ); $gBitSmarty->assign( 'assemblyContentId', isset( $_REQUEST['assembly_content_id'] ) && is_numeric( $_REQUEST['assembly_content_id'] ) ? (int)$_REQUEST['assembly_content_id'] : null ); $gBitSmarty->assign( 'componentContentId', $componentContentId ); $gBitSmarty->assign( 'componentTitle', $componentTitle ); -$gBitSmarty->assign( 'packSize', $packSize ); +$gBitSmarty->assign( 'partSize', $partSize ); $gBitSystem->display( 'bitpackage:stock/list_movements.tpl', 'Movements', [ 'display_mode' => 'list' ] ); diff --git a/list_stock.php b/list_stock.php index 75be18e..796161d 100644 --- a/list_stock.php +++ b/list_stock.php @@ -38,7 +38,7 @@ if( $assemblyContentId ) { ORDER BY sup.`xorder`) AS part_number, (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION) FROM `{$X}liberty_xref` pk - WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PCK') AS pack_size, + WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT') AS part_size, (SELECT SUM( CASE WHEN EXISTS ( SELECT 1 FROM `{$X}liberty_xref` r WHERE r.`content_id` = mx.`content_id` AND r.`item` IN ('TRANS','ORDER') @@ -52,7 +52,7 @@ if( $assemblyContentId ) { AND mx.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?') AS stock_level FROM `{$X}liberty_content` lc INNER JOIN `{$X}liberty_xref` bom ON bom.`content_id` = ? - AND bom.`item` IN ('SGL','PCK','SHT','VOL') + AND bom.`item` IN ('SGL','PRT','SHT','VOL') AND bom.`xref` = lc.`content_id` WHERE lc.`content_type_guid` = 'stockcomponent' $findSql @@ -76,7 +76,7 @@ if( $assemblyContentId ) { ORDER BY sup.`xorder`) AS part_number, (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION) FROM `{$X}liberty_xref` pk - WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PCK') AS pack_size, + WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT') AS part_size, SUM( CASE WHEN EXISTS ( SELECT 1 FROM `{$X}liberty_xref` r WHERE r.`content_id` = x.`content_id` AND r.`item` IN ('TRANS','ORDER') @@ -84,7 +84,7 @@ if( $assemblyContentId ) { ELSE -CAST(x.`xkey` AS DOUBLE PRECISION) END ) AS stock_level FROM `{$X}liberty_content` lc INNER JOIN `{$X}liberty_xref` x ON x.`xref` = lc.`content_id` - AND x.`item` IN ('SGL','PCK','SHT','VOL') + AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?' INNER JOIN `{$X}liberty_content` mc ON mc.`content_id` = x.`content_id` AND mc.`content_type_guid` = 'stockmovement' @@ -118,7 +118,7 @@ foreach( $rows as $row ) { $stockList[$cid]['stock'][$row['qty_type']] = [ 'level' => $level, 'bom_qty' => $row['bom_qty'] !== null ? (float)$row['bom_qty'] : null, - 'pack_size' => $row['pack_size'] !== null ? (float)$row['pack_size'] : null, + 'part_size' => $row['part_size'] !== null ? (float)$row['part_size'] : null, ]; } @@ -169,8 +169,8 @@ if( $showShortages && isset( $_REQUEST['format'] ) && $_REQUEST['format'] === 'c foreach( $stockList as $comp ) { if( empty( $comp['part_number'] ) ) continue; foreach( $comp['stock'] as $qtype => $row ) { - $qty = $qtype === 'PCK' && $row['pack_size'] > 0 - ? abs( $row['level'] ) / $row['pack_size'] + $qty = $qtype === 'PRT' && $row['part_size'] > 0 + ? abs( $row['level'] ) / $row['part_size'] : abs( $row['level'] ); fputcsv( $out, [ $comp['part_number'], $qty ], ',', '"', '' ); } diff --git a/templates/component_order.tpl b/templates/component_order.tpl index d2fb2f6..7ca79f7 100755 --- a/templates/component_order.tpl +++ b/templates/component_order.tpl @@ -52,7 +52,7 @@ <td>{$row.xref_data|escape}</td> <td> {$row.xkey|escape} - {if $row.item eq 'PCK' && $row.pack_size} of {$row.pack_size|escape}{if $row.pack_size_ext} {$row.pack_size_ext|escape}{/if}{/if} + {if $row.item eq 'PRT' && $row.part_size} of {$row.part_size|escape}{if $row.part_size_ext} {$row.part_size_ext|escape}{/if}{/if} </td> <td>{$row.xkey_ext|escape}</td> </tr> diff --git a/templates/edit_assembly.tpl b/templates/edit_assembly.tpl index a95afc2..c0b5004 100755 --- a/templates/edit_assembly.tpl +++ b/templates/edit_assembly.tpl @@ -70,7 +70,7 @@ <input type="file" name="csv_file" accept=".csv,text/csv"/> <input type="submit" class="btn btn-default" name="upload_bom_csv" value="{tr}Upload BOM{/tr}"/> </div> - <p class="help-block">{tr}Columns: Component, Order, Quantity, Size (SGL/PCK/SHT/VOL), Ref designators{/tr}</p> + <p class="help-block">{tr}Columns: Component, Order, Quantity, Size (SGL/PRT/SHT/VOL), Ref designators{/tr}</p> {/form} {/if} diff --git a/templates/list_movements.tpl b/templates/list_movements.tpl index fe741ee..a383e00 100644 --- a/templates/list_movements.tpl +++ b/templates/list_movements.tpl @@ -55,7 +55,7 @@ <td><a href="{$mov.display_url|escape}">{$mov.title|escape}</a></td> <td>{$mov.ref_type|escape|default:'—'}</td> {if $componentContentId} - <td class="text-right">{if $mov.cmp_qty_type eq 'PCK' && $packSize > 0}{math equation="q/p" q=$mov.cmp_qty p=$packSize format="%.2f"}{elseif $mov.cmp_qty_type eq 'SHT'}{$mov.cmp_qty|string_format:"%.2f"}{else}{$mov.cmp_qty|string_format:"%.0f"}{/if} {$mov.cmp_qty_type|escape}</td> + <td class="text-right">{if $mov.cmp_qty_type eq 'PRT' && $partSize > 0}{math equation="q/p" q=$mov.cmp_qty p=$partSize format="%.2f"}{elseif $mov.cmp_qty_type eq 'SHT'}{$mov.cmp_qty|string_format:"%.2f"}{else}{$mov.cmp_qty|string_format:"%.0f"}{/if} {$mov.cmp_qty_type|escape}</td> {/if} <td>{if $mov.ref_start_date}{$mov.ref_start_date|bit_short_date}{else}—{/if}</td> <td>{if $mov.event_time}{$mov.event_time|bit_short_date}{else}—{/if}</td> diff --git a/templates/list_stock.tpl b/templates/list_stock.tpl index f42f435..3250427 100644 --- a/templates/list_stock.tpl +++ b/templates/list_stock.tpl @@ -87,11 +87,11 @@ <td rowspan="{$comp.stock|@count}">{$comp.data|escape}</td> <td rowspan="{$comp.stock|@count}">{$comp.part_number|escape}</td> {/if} - {if $showBom}<td class="text-right">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="b*k/p" b=$row.bom_qty k=$kitCount p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.2f"}{else}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.0f"}{/if}</td>{/if} + {if $showBom}<td class="text-right">{if $qtype eq 'PRT' && $row.part_size > 0}{math equation="b*k/p" b=$row.bom_qty k=$kitCount p=$row.part_size format="%.2f"}{elseif $qtype eq 'SHT'}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.2f"}{else}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.0f"}{/if}</td>{/if} <td>{$qtype|escape}</td> - <td class="text-right">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="l/p" l=$row.level p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{$row.level|string_format:"%.2f"}{else}{$row.level|string_format:"%.0f"}{/if}</td> + <td class="text-right">{if $qtype eq 'PRT' && $row.part_size > 0}{math equation="l/p" l=$row.level p=$row.part_size format="%.2f"}{elseif $qtype eq 'SHT'}{$row.level|string_format:"%.2f"}{else}{$row.level|string_format:"%.0f"}{/if}</td> {if $showBom} - <td class="text-right{if $remaining < 0} text-danger{/if}">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="r/p" r=$remaining p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{$remaining|string_format:"%.2f"}{else}{$remaining|string_format:"%.0f"}{/if}</td> + <td class="text-right{if $remaining < 0} text-danger{/if}">{if $qtype eq 'PRT' && $row.part_size > 0}{math equation="r/p" r=$remaining p=$row.part_size format="%.2f"}{elseif $qtype eq 'SHT'}{$remaining|string_format:"%.2f"}{else}{$remaining|string_format:"%.0f"}{/if}</td> {/if} </tr> {/foreach} diff --git a/templates/print_bom.tpl b/templates/print_bom.tpl index e6c28e6..ece3cac 100644 --- a/templates/print_bom.tpl +++ b/templates/print_bom.tpl @@ -42,7 +42,7 @@ <td>{$row.xref_data|escape}</td> <td> {$row.xkey|escape} - {if $row.item eq 'PCK' && $row.pack_size} of {$row.pack_size|escape}{if $row.pack_size_ext} {$row.pack_size_ext|escape}{/if}{/if} + {if $row.item eq 'PRT' && $row.part_size} of {$row.part_size|escape}{if $row.part_size_ext} {$row.part_size_ext|escape}{/if}{/if} </td> <td>{$row.xkey_ext|escape}</td> </tr> diff --git a/templates/stockassembly/edit_xref_bompck_item.tpl b/templates/stockassembly/edit_xref_bomprt_item.tpl index adb401b..dfa783c 100644 --- a/templates/stockassembly/edit_xref_bompck_item.tpl +++ b/templates/stockassembly/edit_xref_bomprt_item.tpl @@ -34,7 +34,7 @@ {forminput} <div class="form-inline"> <input type="text" class="form-control input-small" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" /> - {if $xrefInfo.pack_size} of {$xrefInfo.pack_size|escape}{if $xrefInfo.pack_size_ext} {$xrefInfo.pack_size_ext|escape}{/if}{/if} + {if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if} </div> {/forminput} </div> diff --git a/templates/stockassembly/view_xref_bompck_item.tpl b/templates/stockassembly/view_xref_bomprt_item.tpl index 85dd7ac..002ae89 100644 --- a/templates/stockassembly/view_xref_bompck_item.tpl +++ b/templates/stockassembly/view_xref_bomprt_item.tpl @@ -8,7 +8,7 @@ {/if} </td> <td>{$xrefInfo.xref_data|escape}</td> - <td>{$xrefInfo.xkey|escape}{if $xrefInfo.pack_size} of {$xrefInfo.pack_size|escape}{if $xrefInfo.pack_size_ext} {$xrefInfo.pack_size_ext|escape}{/if}{/if}</td> + <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if}</td> <td>{$xrefInfo.xkey_ext|escape}</td> {if $xrefAllowEdit} <td>{$xrefInfo.start_date|bit_short_date}</td> diff --git a/templates/stockmovement/edit_xref_bompck_item.tpl b/templates/stockmovement/edit_xref_bomprt_item.tpl index bd69cff..26df942 100644 --- a/templates/stockmovement/edit_xref_bompck_item.tpl +++ b/templates/stockmovement/edit_xref_bomprt_item.tpl @@ -24,7 +24,7 @@ {formlabel label="Pieces required" for="xkey"} {forminput} <input type="text" class="form-control input-small" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" /> - {if $xrefInfo.pack_size}<span class="help-block">{tr}of{/tr} {$xrefInfo.pack_size|escape} {tr}per pack{/tr}</span>{/if} + {if $xrefInfo.part_size}<span class="help-block">{tr}of{/tr} {$xrefInfo.part_size|escape} {tr}per pack{/tr}</span>{/if} {/forminput} </div> diff --git a/templates/stockmovement/view_xref_bompck_item.tpl b/templates/stockmovement/view_xref_bomprt_item.tpl index 85dd7ac..002ae89 100644 --- a/templates/stockmovement/view_xref_bompck_item.tpl +++ b/templates/stockmovement/view_xref_bomprt_item.tpl @@ -8,7 +8,7 @@ {/if} </td> <td>{$xrefInfo.xref_data|escape}</td> - <td>{$xrefInfo.xkey|escape}{if $xrefInfo.pack_size} of {$xrefInfo.pack_size|escape}{if $xrefInfo.pack_size_ext} {$xrefInfo.pack_size_ext|escape}{/if}{/if}</td> + <td>{$xrefInfo.xkey|escape}{if $xrefInfo.part_size} of {$xrefInfo.part_size|escape}{if $xrefInfo.part_size_ext} {$xrefInfo.part_size_ext|escape}{/if}{/if}</td> <td>{$xrefInfo.xkey_ext|escape}</td> {if $xrefAllowEdit} <td>{$xrefInfo.start_date|bit_short_date}</td> diff --git a/templates/view_component.tpl b/templates/view_component.tpl index 770005a..102b911 100755 --- a/templates/view_component.tpl +++ b/templates/view_component.tpl @@ -59,7 +59,7 @@ {foreach from=$componentStockLevels key=qtype item=level} <tr{if $level < 0} class="danger"{elseif $level == 0} class="warning"{/if}> <td>{$qtype|escape}</td> - <td class="text-right">{if $qtype eq 'PCK' && $packSize > 0}{math equation="l/p" l=$level p=$packSize format="%.2f"}{elseif $qtype eq 'SHT'}{$level|string_format:"%.2f"}{else}{$level|string_format:"%.0f"}{/if}</td> + <td class="text-right">{if $qtype eq 'PRT' && $partSize > 0}{math equation="l/p" l=$level p=$partSize format="%.2f"}{elseif $qtype eq 'SHT'}{$level|string_format:"%.2f"}{else}{$level|string_format:"%.0f"}{/if}</td> </tr> {/foreach} {else} diff --git a/view_component.php b/view_component.php index f82a5c2..765a269 100755 --- a/view_component.php +++ b/view_component.php @@ -56,7 +56,7 @@ if( $gContent->isValid() ) { FROM `{$X}liberty_xref` x INNER JOIN `{$X}liberty_content` mc ON mc.`content_id` = x.`content_id` AND mc.`content_type_guid` = 'stockmovement' - WHERE x.`xref` = ? AND x.`item` IN ('SGL','PCK','SHT','VOL') + WHERE x.`xref` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL') AND x.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?' GROUP BY x.`item`", [ $gContent->mContentId ] @@ -67,11 +67,11 @@ if( $gContent->isValid() ) { } $ps = $gBitDb->getOne( "SELECT CAST(x.`xkey` AS DOUBLE PRECISION) FROM `".BIT_DB_PREFIX."liberty_xref` x - WHERE x.`content_id` = ? AND x.`item` = 'PCK'", + WHERE x.`content_id` = ? AND x.`item` = 'PRT'", [ $gContent->mContentId ] ); $gBitSmarty->assign( 'componentStockLevels', $stockLevels ); - $gBitSmarty->assign( 'packSize', $ps ? (float)$ps : null ); + $gBitSmarty->assign( 'partSize', $ps ? (float)$ps : null ); } require_once STOCK_PKG_INCLUDE_PATH.'display_stock_component_inc.php'; |
