Beispiel #1
0
 echo 'Institution: ' . $bank['institution'] . ' Transit: ' . $bank['transit'] . ' Account: ' . $bank['account'];
 $balf = new BankAccountListFactory();
 $balf->getUserAccountByCompanyIdAndUserId($mapped_row['company_id'], $user_id);
 if ($balf->getRecordCount() == 1) {
     $baf = $balf->getCurrent();
     echo "(U) ";
 } else {
     $baf = new BankAccountFactory();
 }
 $baf->setCompany($mapped_row['company_id']);
 $baf->setUser($user_id);
 if ($bank['institution'] != '') {
     $baf->setInstitution($bank['institution']);
 }
 $baf->setTransit($bank['transit']);
 $baf->setAccount($bank['account']);
 if ($baf->isValid()) {
     $baf->Save();
     echo " \t\t\tSuccess!\n";
 } else {
     echo " \t\t\tFailed!\n";
     $commit_trans = FALSE;
     $e++;
     $errors = $baf->Validator->getErrorsArray();
     if (is_array($errors)) {
         foreach ($errors as $error_arr) {
             echo "      ERROR: " . $error_arr[0] . "\n";
         }
     }
 }
 unset($bank);
         Debug::Text('Specified User', __FILE__, __LINE__, __METHOD__, 10);
         //Specified User
         $baf->setCompany($current_company->getId());
         $baf->setUser($bank_data['user_id']);
     } elseif ($bank_data['company_id'] != '' and $bank_data['user_id'] == '' and $permission->Check('company', 'edit_own_bank')) {
         Debug::Text('Specified Company', __FILE__, __LINE__, __METHOD__, 10);
         //Company bank.
         $baf->setCompany($bank_data['company_id']);
     } else {
         $permission->Redirect(FALSE);
     }
     if (isset($bank_data['institution'])) {
         $baf->setInstitution($bank_data['institution']);
     }
     $baf->setTransit($bank_data['transit']);
     $baf->setAccount($bank_data['account']);
     if ($baf->isValid()) {
         $baf->Save();
         Redirect::Page(URLBuilder::getURL(array('user_id' => $user_id, 'company_id' => $company_id, 'data_saved' => TRUE), Environment::getBaseURL() . '/bank_account/EditBankAccount.php'));
         break;
     }
 default:
     $balf = new BankAccountListFactory();
     $ulf = new UserListFactory();
     if ($user_id == '' and $company_id == '' and $permission->Check('user', 'edit_own_bank')) {
         //Current user
         $balf->getUserAccountByCompanyIdAndUserId($current_company->getId(), $current_user->getId());
         $user_id = $current_user->getId();
         $user_obj = $ulf->getByIdAndCompanyId($user_id, $current_company->getId())->getCurrent();
         $country = $user_obj->getCountry();
     } elseif ($user_id != '' and $permission->Check('user', 'edit_bank')) {