Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions lib/Candidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ public function update($candidateID, $isActive, $firstName, $middleName, $lastNa
*/
public function delete($candidateID)
{
/* Delete the candidate from candidate. */
/* Delete pipeline entries from candidate_joborder. */
$sql = sprintf(
"DELETE FROM
candidate
candidate_joborder
WHERE
candidate_id = %s
AND
Expand All @@ -382,13 +382,55 @@ public function delete($candidateID)
);
$this->_db->query($sql);

$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_CANDIDATE, $candidateID);
/* Delete pipeline history from candidate_joborder_status_history. */
$sql = sprintf(
"DELETE FROM
candidate_joborder_status_history
WHERE
candidate_id = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($candidateID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete pipeline entries from candidate_joborder. */
/* Delete candidate activity entries. */
$sql = sprintf(
"DELETE FROM
candidate_joborder
activity
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_CANDIDATE,
$this->_db->makeQueryInteger($candidateID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete candidate calendar events. */
$sql = sprintf(
"DELETE FROM
calendar_event
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_CANDIDATE,
$this->_db->makeQueryInteger($candidateID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete candidate tags. */
$sql = sprintf(
"DELETE FROM
candidate_tag
WHERE
candidate_id = %s
AND
Expand All @@ -398,10 +440,10 @@ public function delete($candidateID)
);
$this->_db->query($sql);

/* Delete pipeline history from candidate_joborder_status_history. */
/* Delete candidate questionnaire history. */
$sql = sprintf(
"DELETE FROM
candidate_joborder_status_history
career_portal_questionnaire_history
WHERE
candidate_id = %s
AND
Expand Down Expand Up @@ -453,6 +495,22 @@ public function delete($candidateID)

/* Delete extra fields. */
$this->extraFields->deleteValueByDataItemID($candidateID);

/* Delete the candidate from candidate. */
$sql = sprintf(
"DELETE FROM
candidate
WHERE
candidate_id = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($candidateID),
$this->_siteID
);
$this->_db->query($sql);

$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_CANDIDATE, $candidateID);
}

/**
Expand Down
77 changes: 61 additions & 16 deletions lib/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,6 @@ public function update($companyID, $name, $address, $address2, $city, $state,
*/
public function delete($companyID)
{
/* Delete the company. */
$sql = sprintf(
"DELETE FROM
company
WHERE
company_id = %s
AND
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
Expand Down Expand Up @@ -290,6 +274,51 @@ public function delete($companyID)
$attachments->delete($row['attachmentID']);
}

/* Delete company activity entries. */
$sql = sprintf(
"DELETE FROM
activity
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_COMPANY,
$this->_db->makeQueryInteger($companyID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete company calendar events. */
$sql = sprintf(
"DELETE FROM
calendar_event
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_COMPANY,
$this->_db->makeQueryInteger($companyID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete company departments. */
$sql = sprintf(
"DELETE FROM
company_department
WHERE
company_id = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($companyID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete from saved lists. */
$sql = sprintf(
"DELETE FROM
Expand All @@ -308,6 +337,22 @@ public function delete($companyID)

/* Delete extra fields. */
$this->extraFields->deleteValueByDataItemID($companyID);

/* Delete the company. */
$sql = sprintf(
"DELETE FROM
company
WHERE
company_id = %s
AND
site_id = %s",
$companyID,
$this->_siteID
);
$this->_db->query($sql);

$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_COMPANY, $companyID);
}

/**
Expand Down
79 changes: 75 additions & 4 deletions lib/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,24 @@ public function updateByCompany($companyID, $address, $address2, $city,
public function delete($contactID)
{
$sql = sprintf(
"DELETE FROM
"UPDATE
contact
SET
reports_to = -1
WHERE
reports_to = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($contactID),
$this->_siteID
);
$this->_db->query($sql);

$sql = sprintf(
"UPDATE
joborder
SET
contact_id = -1
WHERE
contact_id = %s
AND
Expand All @@ -370,18 +386,61 @@ public function delete($contactID)

$sql = sprintf(
"UPDATE
contact
company
SET
reports_to = -1
billing_contact = -1
WHERE
reports_to = %s
billing_contact = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($contactID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete contact activity entries. */
$sql = sprintf(
"DELETE FROM
activity
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_CONTACT,
$this->_db->makeQueryInteger($contactID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete contact calendar events. */
$sql = sprintf(
"DELETE FROM
calendar_event
WHERE
data_item_type = %s
AND
data_item_id = %s
AND
site_id = %s",
DATA_ITEM_CONTACT,
$this->_db->makeQueryInteger($contactID),
$this->_siteID
);
$this->_db->query($sql);

/* Delete attachments. */
$attachments = new Attachments($this->_siteID);
$attachmentsRS = $attachments->getAll(
DATA_ITEM_CONTACT, $contactID
);

foreach ($attachmentsRS as $row)
{
$attachments->delete($row['attachmentID']);
}

/* Delete from saved lists. */
$sql = sprintf(
"DELETE FROM
Expand All @@ -401,6 +460,18 @@ public function delete($contactID)
/* Delete extra fields. */
$this->extraFields->deleteValueByDataItemID($contactID);

$sql = sprintf(
"DELETE FROM
contact
WHERE
contact_id = %s
AND
site_id = %s",
$this->_db->makeQueryInteger($contactID),
$this->_siteID
);
$this->_db->query($sql);

$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_CONTACT, $contactID);
}
Expand Down
Loading
Loading