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
48
49
50
51
52
53
|
<?php
/**
* @package stock
* @subpackage functions
*/
namespace Bitweaver\Stock;
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 {
$supHash = [
'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,
];
$gContent->storeXref( $supHash );
if( empty( $gContent->mErrors ) ) {
header( 'Location: '.$gContent->getEditUrl() );
die;
}
}
}
$gBitSmarty->assign( 'contactLookupUrl', CONTACT_PKG_URL.'includes/lookup_contact.php' );
$gBitSmarty->assign( 'errors', $gContent->mErrors );
$gBitSystem->display( 'bitpackage:stock/add_supplier.tpl', KernelTools::tra( 'Add Supplier' ), [ 'display_mode' => 'edit' ] );
|