* */ require_once('includes/common.php'); checkLogin('admin'); require_once('includes/SI_Account.php'); $title = ''; $account = new SI_Account(); if($_REQUEST['mode'] == 'add'){ $title = "Add Account"; if($_POST['save']){ $account->updateFromAssocArray($_POST); $account->id = $account->add(); if($account->id !== false){ goBack(); }else{ $error_msg .= "Error adding Account!\n"; debug_message($account->getLastError()); } } }else if($_REQUEST['mode'] == 'edit'){ $title = "Edit Account"; if(empty($_REQUEST['id'])){ $error_msg .= "Error: No ID specified!\n"; }else{ if(!$account->get($_REQUEST['id'])){ $error_msg .= "Error retrieving account information!\n"; debug_message($account->getLastError());
function importQB($data){ global $db_conn; if(!isset($data['Account']) || count($data['Account']) == 0){ return TRUE; } foreach($data['Account'] as $qb_account){ $cur_accounts = $this->retrieveSet("WHERE name = '".$db_conn->escapeString($qb_account['NAME'])."'"); if($cur_accounts === FALSE){ $this->error = "SI_Account::import(): Error looking for account with name of {$qb_account['NAME']}"; return FALSE; } $account = NULL; if(count($cur_accounts) != 1){ // Not found or more than one found so just add a new one $account = new SI_Account(); }else{ $account =& $cur_accounts[0]; } $account->name = $qb_account['NAME']; $account->description = $qb_account['DESC']; $account->type = $qb_account['ACCNTTYPE']; $result = FALSE; if($account->id > 0){ $result = $account->update(); }else{ $result = $account->add(); } if($result === FALSE){ $this->error = "SI_Account::importQB(): Error adding account: ".$account->getLastError(); return FALSE; } } return TRUE; }