/** * Removes a contact and all associated records from the system. * * @param integer contact ID * @return void */ public function delete($contactID) { $sql = sprintf("DELETE FROM\n contact\n WHERE\n contact_id = %s\n AND\n site_id = %s", $this->_db->makeQueryInteger($contactID), $this->_siteID); $this->_db->query($sql); $sql = sprintf("UPDATE\n contact\n SET\n reports_to = -1\n WHERE\n reports_to = %s\n AND\n site_id = %s", $this->_db->makeQueryInteger($contactID), $this->_siteID); $this->_db->query($sql); /* Delete from saved lists. */ $sql = sprintf("DELETE FROM\n saved_list_entry\n WHERE\n data_item_id = %s\n AND\n site_id = %s\n AND\n data_item_type = %s", $this->_db->makeQueryInteger($contactID), $this->_siteID, DATA_ITEM_CONTACT); $this->_db->query($sql); /* Delete extra fields. */ $this->extraFields->deleteValueByDataItemID($contactID); $history = new History($this->_siteID); $history->storeHistoryDeleted(DATA_ITEM_CONTACT, $contactID); }
/** * Removes a candidate and all associated records from the system. * * @param integer Candidate ID to delete. * @return void */ public function delete($candidateID) { /* Delete the candidate from candidate. */ $sql = sprintf("DELETE FROM\n candidate\n WHERE\n candidate_id = %s\n AND\n site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID); $this->_db->query($sql); $history = new History($this->_siteID); $history->storeHistoryDeleted(DATA_ITEM_CANDIDATE, $candidateID); /* Delete pipeline entries from candidate_joborder. */ $sql = sprintf("DELETE FROM\n candidate_joborder\n WHERE\n candidate_id = %s\n AND\n site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID); $this->_db->query($sql); /* Delete pipeline history from candidate_joborder_status_history. */ $sql = sprintf("DELETE FROM\n candidate_joborder_status_history\n WHERE\n candidate_id = %s\n AND\n site_id = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID); $this->_db->query($sql); /* Delete from saved lists. */ $sql = sprintf("DELETE FROM\n saved_list_entry\n WHERE\n data_item_id = %s\n AND\n site_id = %s\n AND\n data_item_type = %s", $this->_db->makeQueryInteger($candidateID), $this->_siteID, DATA_ITEM_CANDIDATE); $this->_db->query($sql); /* Delete attachments. */ $attachments = new Attachments($this->_siteID); $attachmentsRS = $attachments->getAll(DATA_ITEM_CANDIDATE, $candidateID); foreach ($attachmentsRS as $rowNumber => $row) { $attachments->delete($row['attachmentID']); } /* Delete extra fields. */ $this->extraFields->deleteValueByDataItemID($candidateID); }
/** * Removes a company and all associated records from the system. * * @param integer Company ID * @return void */ public function delete($companyID) { /* Delete the company. */ $sql = sprintf("DELETE FROM\n company\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID); $this->_db->query($sql); $history = new History($this->_siteID); $history->storeHistoryDeleted(DATA_ITEM_COMPANY, $companyID); /* Find associated contacts. */ $sql = sprintf("SELECT\n contact_id AS contactID\n FROM\n contact\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID); $contactsRS = $this->_db->getAllAssoc($sql); /* Find associated job orders. */ $sql = sprintf("SELECT\n joborder_id AS jobOrderID\n FROM\n joborder\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID); $jobOrdersRS = $this->_db->getAllAssoc($sql); /* Find associated attachments. */ $attachments = new Attachments($this->_siteID); $attachmentsRS = $attachments->getAll(DATA_ITEM_COMPANY, $companyID); /* Delete associated contacts. */ $contacts = new Contacts($this->_siteID); foreach ($contactsRS as $rowIndex => $row) { $contacts->delete($row['contactID']); } /* Delete associated job orders. */ $jobOrders = new JobOrders($this->_siteID); foreach ($jobOrdersRS as $rowIndex => $row) { $jobOrders->delete($row['jobOrderID']); } /* Delete associated attachments. */ foreach ($attachmentsRS as $rowNumber => $row) { $attachments->delete($row['attachmentID']); } /* Delete from saved lists. */ $sql = sprintf("DELETE FROM\n saved_list_entry\n WHERE\n data_item_id = %s\n AND\n site_id = %s\n AND\n data_item_type = %s", $this->_db->makeQueryInteger($companyID), $this->_siteID, DATA_ITEM_COMPANY); $this->_db->query($sql); /* Delete extra fields. */ $this->extraFields->deleteValueByDataItemID($companyID); }