Skip to content
Snippets Groups Projects
Commit dfdd59d5 authored by Uma's avatar Uma
Browse files

Merge branch 'fix_wb_service_contr_create_2_minutes' into 'master'

fix #1166 service contract create through webservice takes 2 minutes

See merge request !401
parents 4849b099 969491f7
No related branches found
No related tags found
No related merge requests found
......@@ -533,6 +533,9 @@ class ServiceContracts extends CRMEntity {
$contractStatus = $this->column_fields['contract_status'];
$myServiceContractExistADO = $this->db->pquery('SELECT if (EXISTS (select vsc.servicecontractsid from vtiger_servicecontracts vsc WHERE vsc.servicecontractsid = ?), 1, 0) AS ex', array($this->id));
$ServiceContractExistFlag = isset($myServiceContractExistADO->fields['ex']) ? $myServiceContractExistADO->fields['ex'] : "1";
// Update the End date if the status is Complete or if the Used Units reaches/exceeds Total Units
// We need to do this first to make sure Actual duration is computed properly
if($contractStatus == 'Complete' || (!empty($usedUnits) && !empty($totalUnits) && $usedUnits >= $totalUnits)) {
......@@ -542,7 +545,9 @@ class ServiceContracts extends CRMEntity {
}
} else {
$endDate = null;
$this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(null, $this->id));
if ( $ServiceContractExistFlag !== "0") {
$this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(null, $this->id));
}
}
// Calculate the Planned Duration based on Due date and Start date. (in days)
......@@ -575,7 +580,9 @@ class ServiceContracts extends CRMEntity {
if(count($updateCols) > 0) {
$updateQuery = 'UPDATE vtiger_servicecontracts SET '. implode(",", $updateCols) .' WHERE servicecontractsid = ?';
array_push($updateParams, $this->id);
$this->db->pquery($updateQuery, $updateParams);
if ( $ServiceContractExistFlag !== "0") {
$this->db->pquery($updateQuery, $updateParams);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment