/**
  * Add or Edit a Reseller Club Contact Record
  *
  * Add a new contact record at Reseller Club, or if it already exists, update it.
  *
  * @param integer $customer_id The customer who this contact belongs to
  * @param ContactDBO $contactDBO Contact DBO
  * @return integer Directi Contact ID
  */
 function addOrEditContact($customerID, $contactDBO)
 {
     if (empty($contactDBO->getBusinessName)) {
         // If no company is provided, set company field to contact name
         $contactDBO->setBusinessName($contactDBO->getName());
     }
     // Find out if this contact already exists
     $contactID = -1;
     $contacts = $this->domContact->listNames($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $customerID);
     if ($contacts != null) {
         foreach ($contacts as $key => $data) {
             if (is_numeric($key)) {
                 if ($data['company'] == $contactDBO->getBusinessName() && $data['name'] == $contactDBO->getName()) {
                     // Contact already exists
                     $contactID = $data['contactid'];
                     break;
                 }
             }
         }
     }
     if ($contactID > 0) {
         // Update contact
         $phone = $this->parse_phone_number($contactDBO->getPhone());
         $fax = $this->parse_phone_number($contactDBO->getFax());
         $result = $this->domContact->mod($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $contactID, $contactDBO->getName(), $contactDBO->getBusinessName(), $contactDBO->getEmail(), $contactDBO->getAddress1(), $contactDBO->getAddress2(), $contactDBO->getAddress3(), $contactDBO->getCity(), $contactDBO->getState(), $contactDBO->getCountry(), $contactDBO->getPostalCode(), $phone['cc'], $phone['number'], $fax['cc'], $fax['number']);
         if ($result['status'] != "Success") {
             print_r($result);
             fatal_error("ResellerClub::addOrEditContact()", "could not modify contact for domain registration at Reseller Club!");
         }
     } else {
         // Add contact
         $phone = $this->parse_phone_number($contactDBO->getPhone());
         $fax = $this->parse_phone_number($contactDBO->getFax());
         $contact_id = $this->domContact->addContact($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $contactDBO->getName(), $contactDBO->getBusinessName(), $contactDBO->getEmail(), $contactDBO->getAddress1(), $contactDBO->getAddress2(), $contactDBO->getAddress3(), $contactDBO->getCity(), $contactDBO->getState(), $contactDBO->getCountry(), $contactDBO->getPostalCode(), $phone['cc'], $phone['number'], $fax['cc'], $fax['number'], $customerID);
         if (!is_numeric($contactID)) {
             fatal_error("RegistrarDirecti::add_edit_contact()", "could not add contact for domain registration at Directi!");
         }
     }
     return $contactID;
 }