summaryrefslogtreecommitdiff
path: root/add_business.php
blob: 685423d43cc4068f846def3e6cd5eefe07b69033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
 * @package contact
 * @subpackage functions
 */

use Bitweaver\Contact\ContactBusiness;
use Bitweaver\KernelTools;

require_once '../kernel/includes/setup_inc.php';

global $gBitSystem, $gBitSmarty, $gBitUser;

$gBitSystem->verifyPackage( 'contact' );
$gBitSystem->verifyPermission( 'p_contact_update' );

$gContent = new ContactBusiness();

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;
	}
}

// ContactBusiness type markers are $02+ only ($00/$01 live under contactperson/deprecated)
$businessTypes = $gContent->getXrefSourceList();

$gBitSmarty->assign( 'gContent', $gContent );
$gBitSmarty->assign( 'businessTypes', array_values( (array)$businessTypes ) );
$gBitSmarty->assign( 'errors', $gContent->mErrors );

$gBitSystem->display( 'bitpackage:contact/add_business.tpl', KernelTools::tra( 'Add Business' ), [ 'display_mode' => 'edit' ] );