summaryrefslogtreecommitdiff
path: root/add_supplier.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-31 13:22:53 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-31 13:22:53 +0100
commit3e4d5cb0733efb23627924870d8bc41e691aa9cc (patch)
tree6b382ee4bf2b1ec631222f8fd3b17e7e8f23cd74 /add_supplier.php
parent8c97edc1011e46e52ccecd9e7cc5f1bd9fcadc08 (diff)
downloadstock-3e4d5cb0733efb23627924870d8bc41e691aa9cc.tar.gz
stock-3e4d5cb0733efb23627924870d8bc41e691aa9cc.tar.bz2
stock-3e4d5cb0733efb23627924870d8bc41e691aa9cc.zip
Add supplier xref page; fix STOCKASSEMBLY_CONTENT_TYPE_GUID in StockBase
add_supplier.php + add_supplier.tpl: form to add a #SUP xref record with supplier contact (filtered by $04 type), part number, price and note in one step. view_xref_sup_group.tpl: smartlink updated to "Add supplier" pointing to the new page. StockBase: define STOCKASSEMBLY_CONTENT_TYPE_GUID with guard so it is available when StockAssembly is not loaded (e.g. component view path). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'add_supplier.php')
-rw-r--r--add_supplier.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/add_supplier.php b/add_supplier.php
new file mode 100644
index 0000000..c76f978
--- /dev/null
+++ b/add_supplier.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @package stock
+ * @subpackage functions
+ */
+
+namespace Bitweaver\Stock;
+
+use Bitweaver\Contact\Contact;
+use Bitweaver\KernelTools;
+
+require_once '../kernel/includes/setup_inc.php';
+
+global $gBitSystem, $gBitSmarty, $gBitUser, $gContent;
+
+include_once STOCK_PKG_INCLUDE_PATH.'component_lookup_inc.php';
+
+if( !$gContent->isValid() ) {
+ $gBitSystem->fatalError( 'No valid component specified.' );
+}
+
+$gContent->verifyUpdatePermission();
+
+if( !empty( $_REQUEST['fCancel'] ) ) {
+ header( 'Location: '.$gContent->getEditUrl() );
+ die;
+}
+
+if( !empty( $_REQUEST['fAddSupplier'] ) ) {
+ if( empty( $_REQUEST['supplier_content_id'] ) || !is_numeric( $_REQUEST['supplier_content_id'] ) ) {
+ $gContent->mErrors[] = KernelTools::tra( 'Please select a supplier.' );
+ } else {
+ $gContent->storeXref( [
+ 'content_id' => $gContent->mContentId,
+ 'item' => '#SUP',
+ 'xref' => (int)$_REQUEST['supplier_content_id'],
+ 'xkey' => trim( $_REQUEST['part_number'] ?? '' ),
+ 'xkey_ext' => trim( $_REQUEST['price'] ?? '' ),
+ 'edit' => trim( $_REQUEST['note'] ?? '' ),
+ 'fAddXref' => 1,
+ ] );
+
+ if( empty( $gContent->mErrors ) ) {
+ header( 'Location: '.$gContent->getEditUrl() );
+ die;
+ }
+ }
+}
+
+$contact = new Contact();
+$listHash = [ 'contact_type_guid' => ['$04'], 'sort_mode' => 'title_asc', 'max_records' => 500 ];
+$supplierList = $contact->getList( $listHash );
+
+$gBitSmarty->assign( 'supplierList', $supplierList );
+$gBitSmarty->assign( 'errors', $gContent->mErrors );
+
+$gBitSystem->display( 'bitpackage:stock/add_supplier.tpl', KernelTools::tra( 'Add Supplier' ), [ 'display_mode' => 'edit' ] );