} } }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()); } } if($_POST['save']){ $account->updateFromAssocArray($_POST); if($account->update()){ goBack(); }else{ $error_msg .= "Error updating Account!\n"; debug_message($account->getLastError()); } } }else if($_REQUEST['mode'] == 'delete'){ $title = "Delete Account"; if(!$account->get($_REQUEST['id'])){ $error_msg .= "Error retrieving account information!\n"; debug_message($account->getLastError()); } if($_POST['confirm']){
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; }