N°1976 - Duplicate Service on Customer Contract

This commit is contained in:
acognet
2020-05-18 21:50:22 +02:00
parent 0d1059a8fc
commit 83e3c089a4
6 changed files with 64 additions and 2 deletions

View File

@@ -1627,7 +1627,36 @@ public function PrefillSearchForm(&$aContextParam)
<duplicates>true</duplicates>
</field>
</fields>
<methods/>
<methods>
<method id="DoCheckToWrite">
<static>false</static>
<access>public</access>
<code><![CDATA[
public function DoCheckToWrite()
{
parent::DoCheckToWrite();
$aCustomerContracts = $this->Get("customercontracts_list");
foreach($aCustomerContracts as $sAttCode => $oCustomerContracts)
{
// Recurse inside the subdirectories
$sOql="SELECT lnkCustomerContractToService AS ccs WHERE ccs.customercontract_id=:customercontract_id AND ccs.service_id=:service_id AND ccs.sla_id!=:sla_id";
$aQueryParams['customercontract_id'] = $oCustomerContracts->Get("customercontract_id");
$aQueryParams['service_id'] = $oCustomerContracts->Get("service_id");
$aQueryParams['sla_id'] = $this->Get("id");
$oQuery = DBSearch::FromOQL($sOql, $aQueryParams);
$oResultSql = new DBObjectSet($oQuery);
$oResultSql->OptimizeColumnLoad(['ccs.customercontract_name','ccs.service_name']);
while ($aCurrentRow = $oResultSql->Fetch())
{
$this->m_aCheckIssues[] = Dict::Format('Class:SLA/Error:UniqueLnkCustomerContractToService',$aCurrentRow->Get('customercontract_name'),$aCurrentRow->Get('service_name'));
}
}
}
]]></code>
</method>
</methods>
<presentation>
<details>
<items>

View File

@@ -370,6 +370,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:SLA/Attribute:slts_list+' => 'All the service level targets for this SLA',
'Class:SLA/Attribute:customercontracts_list' => 'Customer contracts',
'Class:SLA/Attribute:customercontracts_list+' => 'All the customer contracts using this SLA',
'Class:SLA/Error:UniqueLnkCustomerContractToService' => 'Could not save link with Customer contract %1$s and service %2$s : already one SLA exist',
));
//

View File

@@ -360,6 +360,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:SLA/Attribute:slts_list+' => '',
'Class:SLA/Attribute:customercontracts_list' => 'Contrats clients',
'Class:SLA/Attribute:customercontracts_list+' => '',
'Class:SLA/Error:UniqueLnkCustomerContractToService' => 'Impossible de sauvegarder le lien avec le contrat client %1$s et le service %2$s : un SLA existe déjà.',
));
//

View File

@@ -1621,7 +1621,36 @@ public function PrefillSearchForm(&$aContextParam)
<duplicates>true</duplicates>
</field>
</fields>
<methods/>
<methods>
<method id="DoCheckToWrite">
<static>false</static>
<access>public</access>
<code><![CDATA[
public function DoCheckToWrite()
{
parent::DoCheckToWrite();
$aCustomerContracts = $this->Get("customercontracts_list");
foreach($aCustomerContracts as $sAttCode => $oCustomerContracts)
{
// Recurse inside the subdirectories
$sOql="SELECT lnkCustomerContractToService AS ccs WHERE ccs.customercontract_id=:customercontract_id AND ccs.service_id=:service_id AND ccs.sla_id!=:sla_id";
$aQueryParams['customercontract_id'] = $oCustomerContracts->Get("customercontract_id");
$aQueryParams['service_id'] = $oCustomerContracts->Get("service_id");
$aQueryParams['sla_id'] = $this->Get("id");
$oQuery = DBSearch::FromOQL($sOql, $aQueryParams);
$oResultSql = new DBObjectSet($oQuery);
$oResultSql->OptimizeColumnLoad(['ccs.customercontract_name','ccs.service_name']);
while ($aCurrentRow = $oResultSql->Fetch())
{
$this->m_aCheckIssues[] = Dict::Format('Class:SLA/Error:UniqueLnkCustomerContractToService',$aCurrentRow->Get('customercontract_name'),$aCurrentRow->Get('service_name'));
}
}
}
]]></code>
</method>
</methods>
<presentation>
<details>
<items>

View File

@@ -360,6 +360,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:SLA/Attribute:slts_list+' => 'All the service level targets for this SLA',
'Class:SLA/Attribute:customercontracts_list' => 'Customer contracts',
'Class:SLA/Attribute:customercontracts_list+' => 'All the customer contracts using this SLA',
'Class:SLA/Error:UniqueLnkCustomerContractToService' => 'Could not save link with Customer contract %1$s and service %2$s : already one SLA exist',
));
//

View File

@@ -350,6 +350,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:SLA/Attribute:slts_list+' => '',
'Class:SLA/Attribute:customercontracts_list' => 'Contrats clients',
'Class:SLA/Attribute:customercontracts_list+' => '',
'Class:SLA/Error:UniqueLnkCustomerContractToService' => 'Impossible de sauvegarder le lien avec le contrat client %1$s et le service %2$s : un SLA existe déjà.',
));
//