diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-10 10:40:30 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-10 10:40:30 +0100 |
| commit | 77995206ac8bdbd8129d1daabb02cba599250795 (patch) | |
| tree | a7edaea1c38c77bfc497a86c005c35a98f54d14b /edit_stgrp_item.php | |
| parent | 1aa20fae43178e0164fe9c110c23bd4ba3946de8 (diff) | |
| download | stock-77995206ac8bdbd8129d1daabb02cba599250795.tar.gz stock-77995206ac8bdbd8129d1daabb02cba599250795.tar.bz2 stock-77995206ac8bdbd8129d1daabb02cba599250795.zip | |
stock: add edit_stgrp_item.php/tpl for CKEditor editing of stgrp descriptions; parse_data in view_kitlocker; p_stock_admin edit icon in gallery
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'edit_stgrp_item.php')
| -rw-r--r-- | edit_stgrp_item.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/edit_stgrp_item.php b/edit_stgrp_item.php new file mode 100644 index 0000000..27066cc --- /dev/null +++ b/edit_stgrp_item.php @@ -0,0 +1,57 @@ +<?php +/** + * Edit the data (description) field of a stgrp liberty_xref_item entry. + * @package stock + */ + +namespace Bitweaver\Stock; + +use Bitweaver\KernelTools; + +require_once '../kernel/includes/setup_inc.php'; + +$gBitSystem->verifyPackage( 'stock' ); +$gBitSystem->verifyPermission( 'p_stock_admin' ); + +global $gBitSystem, $gBitSmarty, $gBitDb; + +$item = trim( $_REQUEST['item'] ?? '' ); +if( !preg_match( '/^[A-Z0-9]{2,8}$/', $item ) ) { + $gBitSystem->fatalError( KernelTools::tra( 'Invalid item code.' ) ); +} + +$X = BIT_DB_PREFIX; + +$row = $gBitDb->getRow( + "SELECT `item`, `cross_ref_title`, `data` + FROM `{$X}liberty_xref_item` + WHERE `item` = ? AND `x_group` = 'stgrp' AND `content_type_guid` = 'stock'", + [ $item ] +); +if( !$row ) { + $gBitSystem->fatalError( KernelTools::tra( 'Stock group not found.' ) ); +} + +$errors = []; + +if( !empty( $_POST['fSave'] ) ) { + $data = trim( $_POST['data'] ?? '' ) ?: null; + $gBitDb->query( + "UPDATE `{$X}liberty_xref_item` SET `data` = ? + WHERE `item` = ? AND `x_group` = 'stgrp' AND `content_type_guid` = 'stock'", + [ $data, $item ] + ); + header( 'Location: '.STOCK_PKG_URL.'view_kitlocker.php' ); + die; +} + +if( !empty( $_POST['fCancel'] ) ) { + header( 'Location: '.STOCK_PKG_URL.'view_kitlocker.php' ); + die; +} + +$gBitSmarty->assign( 'stgrpItem', $row ); +$gBitSmarty->assign( 'errors', $errors ); + +$gBitSystem->setBrowserTitle( KernelTools::tra( 'Edit' ).': '.$row['cross_ref_title'] ); +$gBitSystem->display( 'bitpackage:stock/edit_stgrp_item.tpl', null, [ 'display_mode' => 'edit' ] ); |
