contract obligation contract dependency generate

This commit is contained in:
glovetleong
2021-07-20 21:28:32 +08:00
parent bc1a7091eb
commit f718ecb54f
3 changed files with 46 additions and 8 deletions
+20 -4
View File
@@ -124,11 +124,12 @@ class ContractModule extends BaseController
$contract_obligation = ContractObligationModule::generate($request);
}
// generate contract dependency
// generate contract obligation dependency
foreach ($contract_template_obligation_list as $key => $row) {
$contract_template_obligation_dependency = $row->contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get();
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get();
if (!empty($contract_template_obligation_dependency[0])) {
$contract_obligation = ContractObligation::
@@ -149,10 +150,25 @@ class ContractModule extends BaseController
}
}
// generate contract obligation contract dependency
foreach ($contract_template_obligation_list as $key => $row) {
$contract_template_obligation_contract_dependency = $row->contract_template_obligation_contract_template_dependency()
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get();
if (!empty($contract_template_obligation_contract_dependency[0])) {
$request->request->add([
'contract_template_id' => [$contract_template_obligation_contract_dependency[0]->depend_contract_template_hash_id],
]);
$depend_contract = ContractModule::generate($request);
}
}
// log
ContractModule::makeLog($contract->id, 'user (' . Auth::guard('user-api')->user()->id . ') created');
// DB::commit();
DB::commit();
$query_string = General::getCachePerviousQuery('contract_query');
$data = General::returnData($contract, $query_string);
+16 -3
View File
@@ -15,7 +15,8 @@ class ContractTemplateObligation extends Model
'hash_id',
'contract_template_list',
'contract_template_obligation_dependency_list',
'depend_contract_template_obligation_dependency_list'
'depend_contract_template_obligation_dependency_list',
'contract_template_obligation_contract_template_dependency_list'
];
public function contract_template()
@@ -33,6 +34,11 @@ class ContractTemplateObligation extends Model
return $this->hasMany('App\Models\ContractTemplateObligationDependency', 'depend_contract_template_obligation_id');
}
public function contract_template_obligation_contract_template_dependency()
{
return $this->hasMany('App\Models\ContractTemplateObligationContractTemplateDependency', 'contract_template_obligation_id');
}
public function getHashIdAttribute()
{
return Hasher::encode('contract_template_obligations', $this->id);
@@ -46,17 +52,24 @@ class ContractTemplateObligation extends Model
public function getContractTemplateObligationDependencyListAttribute()
{
return $this->contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation.status.active'))
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
}
public function getDependContractTemplateObligationDependencyListAttribute()
{
return $this->depend_contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation.status.active'))
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
}
public function getContractTemplateObligationContractTemplateDependencyListAttribute()
{
return $this->contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation_contract_template_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list']);
}
public function getUpdatedAtAttribute($date)
{
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
+10 -1
View File
@@ -36,6 +36,7 @@
<tr>
<th>#</th>
<th style="width: 25%">Details</th>
<th>Obligation Template</th>
<th>Status</th>
<th>Created</th>
<th>Actions</th>
@@ -48,6 +49,14 @@
<div><b>Name</b>: {{ contract.name }}</div>
<div><b>Complete Day Range</b>: {{ contract.complete_day_range }}</div>
</td>
<td>
<div v-if="contract.contract_obligation_list" v-for="(obligation, $index) in contract.contract_obligation_list" :key="$index">
<div>-{{ obligation.name }} <small>({{ obligation.sequence }})</small></div>
</div>
<div v-if="!contract.contract_obligation_list[0]">
-
</div>
</td>
<td>
<span :class="'badge badge-' + contract.status[0].color">{{ contract.status[0].name }}</span>
</td>
@@ -107,7 +116,7 @@
status: General.returnAray(General.getURLParam('status[]')),
page: General.getURLParam('page')
}),
colspan: 7,
colspan: 6,
filter_status: false,
loading: true,
contract_list: [],