summaryrefslogtreecommitdiff
path: root/import/load_sage_contacts.php
blob: a07f9aabad53b78d823e86b40116866bde1d716c (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
48
49
50
51
52
53
<?php
/*
 * Created on 5 Jan 2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

// Initialization
require_once '../../kernel/includes/setup_inc.php';
use Bitweaver\Contact\Contact;
use Bitweaver\KernelTools;

// Is package installed and enabled
$gBitSystem->verifyPackage( 'contact' );

// Now check permissions to access this page
$gBitSystem->verifyPermission('p_contact_admin' );

$contact = new Contact();

$contact->SageDataExpunge();

$row = 0;

$handle = fopen("../data/customers.csv", "r");
if ( $handle == FALSE) {
	$row = -999;
} else {
	while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
		if ( $row ) $contact->SageRecordLoad( $data, 1 );
		$row++;
	}
	fclose($handle);
}

$gBitSmarty->assign( 'customers', $row );
$row = 0;

$handle = fopen("data/suppliers.csv", "r");
if ( $handle == FALSE) {
	$row = -999;
} else {
	while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
		if ( $row ) $contact->SageRecordLoad( $data, 2 );
		$row++;
	}
	fclose($handle);
}

$gBitSmarty->assign( 'suppliers', $row );

$gBitSystem->display( 'bitpackage:contacts/load_sage_contacts.tpl', KernelTools::tra( 'Load results: ' ) );