summaryrefslogtreecommitdiff
path: root/add_business.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-31 19:45:29 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-31 19:45:29 +0100
commita6d77d28625efe86fe16228cbfdce49d6a5bf6e2 (patch)
treea86423579777e3ae899bdd8a78e232789c5e7c38 /add_business.php
parent73ab0d88e8235556d55b9deb453ae7b74b763436 (diff)
downloadcontact-a6d77d28625efe86fe16228cbfdce49d6a5bf6e2.tar.gz
contact-a6d77d28625efe86fe16228cbfdce49d6a5bf6e2.tar.bz2
contact-a6d77d28625efe86fe16228cbfdce49d6a5bf6e2.zip
Add add_person/add_business flows; tidy contact view/edit for type
- add_person.php + add_person.tpl: minimal form, auto-injects $00 - add_business.php + add_business.tpl: org name + $02+ type checkboxes - menu_contact.tpl: replace generic edit link with Add Person / Add Business - Contact.php: fix title overwrite (org no longer clobbers person name); fix null trim on organisation; fix $00 type xref stored correctly - edit.php: isPerson flag; xref groups loaded; type list filtered $02+ for businesses - edit.tpl: person/business field visibility; tabbed xref block at bottom of Details tab - edit_type_header.tpl: value fixed to {$type.item}; $00/$01 filtered out - display_contact.tpl: person/business field selection; note above addresses; no-addresses fallback removed; allow_edit=false on xref tabs - display_type_header.tpl: heading Personal/Business Contact; $02+ types only - contact_date_bar.tpl: remove Add crossref shortcut (now in edit tabs) - view_xref_*_item.tpl: dates and edit actions gated on $xrefAllowEdit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'add_business.php')
-rw-r--r--add_business.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/add_business.php b/add_business.php
new file mode 100644
index 0000000..4164768
--- /dev/null
+++ b/add_business.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @package contact
+ * @subpackage functions
+ */
+
+use Bitweaver\Contact\Contact;
+use Bitweaver\KernelTools;
+
+require_once '../kernel/includes/setup_inc.php';
+
+global $gBitSystem, $gBitSmarty, $gBitUser;
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+$gContent = new Contact();
+
+if( !empty( $_REQUEST['fCancel'] ) ) {
+ KernelTools::bit_redirect( CONTACT_PKG_URL );
+ die;
+}
+
+if( !empty( $_REQUEST['fSaveContact'] ) ) {
+ $types = [];
+ if( !empty( $_REQUEST['contact_types'] ) && is_array( $_REQUEST['contact_types'] ) ) {
+ foreach( $_REQUEST['contact_types'] as $type ) {
+ if( $type !== '$00' ) {
+ $types[] = $type;
+ }
+ }
+ }
+ $_REQUEST['contact_types'] = $types;
+ if( $gContent->store( $_REQUEST ) ) {
+ KernelTools::bit_redirect( CONTACT_PKG_URL.'edit.php?content_id='.$gContent->mContentId );
+ die;
+ }
+}
+
+// Load all business-relevant types ($01 and above) for optional checkboxes
+$allTypes = $gContent->getXrefSourceList();
+$businessTypes = array_filter( $allTypes, fn($t) => $t['item'] !== '$00' && $t['item'] !== '$01' );
+
+$gBitSmarty->assign( 'gContent', $gContent );
+$gBitSmarty->assign( 'businessTypes', array_values( $businessTypes ) );
+$gBitSmarty->assign( 'errors', $gContent->mErrors );
+
+$gBitSystem->display( 'bitpackage:contact/add_business.tpl', KernelTools::tra( 'Add Business' ), [ 'display_mode' => 'edit' ] );