edms2023/resources/views/document-workflows/details.blade.php

512 lines
22 KiB
PHP

@extends('layouts.list_master')
@section('pageTitle', __('View Document'))
@section('content')
@php
if($workflow_document->workflow_type_id == 1)
$type_para = "Incoming";
elseif($workflow_document->workflow_type_id == 2)
$type_para = "Outgoing";
elseif($workflow_document->workflow_type_id == 3)
$type_para = "Internal";
else
$type_para = "Incoming";
@endphp
<link rel="stylesheet" href="{{ asset('global/vendor/select2/select2.css') }}">
<link rel="stylesheet" href="{{ asset('global/file-upload/uploadfile.css') }}">
<script src="{{ asset('global/vendor/select2/select2.full.min.js') }}"></script>
<script src="{{ asset('global/file-upload/jquery.form.js') }}"></script>
<script src="{{ asset('global/file-upload/jquery.uploadfile.js') }}"></script>
<div class="p-4 pb-0">
<ul class="nav nav-pills bg-dark" id="view-tabs">
<li class="nav-item ">
<a class=" nav-link active" id="view_document" href="#view_document_tab" data-toggle="tab" onclick="get_html('view_document')">{{ __('View Document') }}</a>
</li>
@if($workflow_document->is_workflow_free !=1)
<li class="nav-item">
<a class=" nav-link" id="view_workflow" href="#view_workflow_tab" data-toggle="tab" onclick="get_html('view_workflow')">{{ __('View Workflow') }}</a>
</li>
@endif
<li class="nav-item">
<a class=" nav-link" id="related_documents" href="#related_documents_tab" onclick="get_html('related_documents')" data-toggle="tab">{{ __('View Related Documents') }}</a>
</li>
@if ($workflow_document->hasSenderAPI())
<li class="nav-item">
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="{{ route('transfers.create', base64_encode($workflow_document->id)) }}" data-toggle="tooltip" target="_blank" data-original-title="{{ __('API')}}" style="color:white"><i class="fa fa-plane" aria-hidden="true"></i></a>
</li>
@endif
@php
$user_process = App\WorkflowDocumentProcess::where('workflow_document_id', '=', $workflow_document->id)->where('user_id', Auth::user()->id)->where('status', '=', 'P')->orderBy('id', 'desc')->first();
$user_last_process = App\WorkflowDocumentProcess::where('workflow_document_id', '=', $workflow_document->id) ->where('user_type', '=', 'R')->orderBy('id', 'desc')->first();
$user_last_process_actioned = App\WorkflowDocumentProcess::where('workflow_document_id', '=', $workflow_document->id) ->where('user_type', '=', 'R')->where('status', '!=', 'P')->orderBy('id', 'desc')->first();
$userAsSupporter = App\WorkflowDocumentUser::where('workflow_document_id', '=', $workflow_document->id)->where('user_type','=','S')->where('status', '=', 'Y')->where('user_id', '=', Auth::user()->id)->first();
@endphp
@if(isset($user_process) && $type_para == "Incoming" && $document_user->role_id <> 5)
@php
$document_user = App\User::join('role_user', 'users.id', '=', 'role_user.user_id')
->join('roles', 'role_user.role_id', '=', 'roles.id')
->where('users.id', '=', Auth::user()->id)
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
->first();
@endphp
<li class="nav-item">
<a class=" nav-link" id="delegate_document" href="#delegate_document_tab" data-toggle="tab" onclick="get_html('delegate_document')">{{ __('Delegate') }}</a>
</li>
@endif
@if($workflow_document->is_rejected == 0 && in_array($type_para,['Outgoing','Internal']) && $user_last_process->status != 'A' && ($user_last_process->user_id == Auth::user()->id || ($userAsSupporter !== null && $userAsSupporter->is_approved =='P')))
<li class="nav-item">
<a class=" nav-link" id="approval" href="#approval_tab" data-toggle="tab">{{ $workflow_document->creator_id == Auth::user()->id ? __('Edit') : __('Approval') }}</a>
</li>
@endif
@if($type_para == "Incoming")
@php
$document_user_process = App\WorkflowDocumentProcess::where('workflow_document_id', '=', $workflow_document->id)->where('user_id', Auth::user()->id)->orderBy('id', 'desc')->first();
@endphp
@if(check_permissions(1) === true)
<li class="nav-item">
<a class=" nav-link" href="{{ route('edit_registry_document', base64_encode($workflow_document->id)) }}">{{ __('Edit') }}</a>
</li>
@elseif($userAsSupporter !== null)
<li class="nav-item">
<a class=" nav-link" href="{{ route('edit_supporter_document', base64_encode($workflow_document->id)) }}">{{ __('Edit') }}</a>
</li>
@elseif((!isset($document_user_process) || $document_user_process->status=='P' ) && $workflow_document->status != 'Complete')
@endif
@if((!isset($document_user_process) || $document_user_process->status=='P' ) && $workflow_document->status != 'Complete' && $userAsSupporter === null && check_permissions(1) !== true && $document_user->role_id <> 1)
<li class="nav-item">
<a class=" nav-link" href="{{ route('reply_document', base64_encode($workflow_document->id)) }}">{{ __('Reply') }}</a>
</li>
@endif
@if($document_user->role_id <> 1 && $document_user->department_id <> 7 && (!isset($document_user_process) || $document_user_process->status=='P' ) && $userAsSupporter === null && check_permissions(1) !== true)
<li class="nav-item">
<a class="nav-link" href="javascript:void(0);" data-toggle="modal" data-target="#myModal{{ $workflow_document->id }}">{{ __('Return') }}</a>
</li>
<!-- The Modal -->
<div class="modal fade" id="myModal{{ $workflow_document->id }}">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form method="post" action="{{ route('store_return', base64_encode($workflow_document->id)) }}" class="add-form" autocomplete="off" enctype="multipart/form-data">
@csrf
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">{{ __('Return Document Workflow') }}</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="row">
<div class="form-group col-md-12">
<label class="form-control-label" for="comment">{{ __('Comments') }}</label>
<textarea class="form-control validate[required]" name = "comment" maxlength="{{ $setting->comment_text_limit }}">{{ old('comment') ? old('comment') : '' }}</textarea>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-success"><i class="icon wb-check" aria-hidden="true"></i>{{ __('Return') }}</button>
</div>
</form>
</div>
</div>
</div>
@endif
@if($document_user->department_id <> 7 && (!isset($document_user_process) || $document_user_process->status=='P' ) && $userAsSupporter === null)
<li class="nav-item">
<a class="nav-link" href="javascript:void(0);" data-toggle="modal" data-target="#myCompleteModal{{ $workflow_document->id }}">{{ __('Complete') }}</a>
</li>
<!-- The Modal -->
<div class="modal fade" id="myCompleteModal{{ $workflow_document->id }}" data-backdrop="true" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form method="post" action="{{ route('store_complete', base64_encode($workflow_document->id)) }}" class="add-form" autocomplete="off" enctype="multipart/form-data">
@csrf
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">{{ __('Complete Document Workflow') }}</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="row">
<div class="form-group col-md-12">
<label class="form-control-label" for="comment">{{ __('Comments') }}</label>
<textarea class="form-control validate[required]" name = "comment" maxlength="{{ $setting->comment_text_limit }}">{{ old('comment') ? old('comment') : '' }}</textarea>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-success"><i class="icon wb-check" aria-hidden="true"></i>{{ __('Save') }}</button>
</div>
</form>
</div>
</div>
</div>
@endif
@endif
</ul>
</div>
<div class="tab-content">
<div id="view_document_tab" class="container tab-pane active p-0">
</div>
<div id="view_workflow_tab" class="container tab-pane p-0">
</div>
<div id="related_documents_tab" class="container tab-pane p-0">
</div>
<div id="delegate_document_tab" class="container tab-pane p-0">
</div>
@if(in_array($type_para,['Outgoing','Internal']))
<div id="approval_tab" class="container tab-pane p-0">
<div class="page-header">
<h1 class="page-title">{{ __('Approval For Document Workflow') }}</h1>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="javascript: void(0);">{{ __('Dashboard') }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('documents', $type_para) }}">{{ __('Document') }}</a></li>
<li class="breadcrumb-item active">{{ __('Approval For Document Workflow') }}</li>
</ol>
<div class="page-header-actions">
<a class="btn btn-dark" href="{{ route('documents', $type_para) }}">
<i class="icon wb-arrow-left" aria-hidden="true"></i>
<span class="hidden-sm-down">{{ __('Back To '.$type_para.' Document') }}</span>
</a>
</div>
</div>
<style type="text/css">
.files input {
outline: 2px dashed #92b0b3;
padding: 200px 0px 85px 50%;
text-align: center !important;
margin: 0;
width: 100% !important;
}
.files input:focus{
outline: 2px dashed #92b0b3;
}
.files{ position:relative}
.color input{ background-color:#f1f1f1;}
.files:before {
position: absolute;
bottom: 20px;
left: 0; pointer-events: none;
width: 100%;
right: 0;
height: 150px;
content: " {{ __('Click Or Drop Files To Upload.') }} ";
display: block;
margin: 0 auto;
color: #76838f;
text-transform: capitalize;
text-align: center;
background: white;
font-size: 24px;
}
</style>
<div class="page-content">
<div class="row">
<!-- LEFT SECTION -->
<div class="col-xxl-12 col-xl-12 col-lg-12">
<div class="card">
<div class="card-block">
@if($errors->any())
<div class="alert alert-danger">
@foreach($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
</div>
@endif
<form method="post" action="{{ route('store_approval', base64_encode($workflow_document->id)) }}" id="add-form" class="add-form" class="approved_section" autocomplete="off" enctype="multipart/form-data">
@csrf
<div class="row {{ $workflow_document->creator_id == Auth::user()->id ? 'd-none' : ''}}">
@if($document_user->role_id == 2 && $userAsSupporter === null )
<div class="form-group col-md-12" id="finalize_field">
<div class="checkbox-custom checkbox-default">
<input type="checkbox" id="finalize" name="finalize" autocomplete="off" value="1"/>
<label for="finalize">{{ __('Do you want to finalize this document workflow?') }}</label>
</div>
</div>
@endif
<div class="form-group chenge-width col-md-{{ $workflow_document->its_reply !=1 && $document_user->role_id != 1 && $userAsSupporter === null ? '6' : '12'}}">
<label class="form-control-label">{{ __('Is It Approved?') }}</label>
<div class="select2-primary">
<select class="form-control validate[required] is_approved select2" name="is_approved" style="width:100%">
<option value = "1">{{ __('Yes') }}</option>
<option value = "0">{{ __('No') }}</option>
</select>
</div>
</div>
@if($workflow_document->its_reply!=1 && $document_user->role_id != 1 && $userAsSupporter === null )
<div class="form-group col-md-6 approver">
<label class="form-control-label" for="approver_id">{{ __('Assign As Approver') }}</label>
<div class="select2-primary">
<select class="form-control validate[required] select2" name="approver_id" id="approver_id" style="width:100%">
<option value = ''>-- Select a approver --</option>
@include('document-workflows.create_document_reviewer_options')
</select>
</div>
</div>
@endif
</div>
<div class="row comment_section">
<div class="form-group col-md-{{ $userAsSupporter === null ? '6' : '12'}}">
<label class="form-control-label">{{ __('Comments') }}</label>
<textarea class="form-control validate[required]" name = "comment" maxlength="{{ $setting->comment_text_limit }}">{{ old('comment') ? old('comment') : '' }}</textarea>
</div>
@if( $userAsSupporter === null )
<div class="form-group col-md-6">
<label class="form-control-label" for="scanned_documents">{{ __('Attach Documents') }}</label>
<div id="mulitplefileuploaderApp">Upload</div>
<div id="status"></div>
<div>
<input type="text" name="file_ids" value="" id="file_ids" style="visibility: hidden;" {{ isset($user_last_process_actioned) && $user_last_process_actioned->status == 'R' ? 'class="validate[required]"' :''}}>
</div>
<div class="file-wrap container-fluid">
<div class="file-list row row-lg" id="scanned_documents_priview">
@php
$workflow_files = App\WorkflowDocumentFile::where('workflow_document_id', $workflow_document->id)->where('status', 'Y')->get();
@endphp
@if(!empty($workflow_files))
@foreach($workflow_files as $key => $workflow_file)
@if($workflow_file->document_name && trim($workflow_file->document_name)!='' && file_exists(public_path($workflow_file->place_of_the_documents.'/'.$workflow_file->document_name)))
<div class="col-md-12 mt-10 px-2 removeFileParent"><div class="bg-light p-2">{{ $workflow_file->document_name }}</div></div>
@endif
@endforeach
@endif
</div>
</div>
</div>
@endif
</div>
<div class="form-group">
<button type="submit" class="btn btn-success" id="uploadBtn"><i class="icon wb-check" aria-hidden="true"></i> {{ $document_user->role_id == 1 || $userAsSupporter !== null ? __("Approved") : __('Send for Approval') }}</button>&nbsp;&nbsp;&nbsp;&nbsp;
@if( $userAsSupporter === null )
<a href="{{ route('reject-workflow', base64_encode($workflow_document->id)) }}" onclick="confirm('<?php echo __('Are you sure to Reject the Process?') ?>') ? '' : event.preventDefault();"><button type="button" class="btn btn-danger" id="rejectBtn"><i class="icon wb-check" aria-hidden="true"></i> {{ __("Reject") }}</button></a>
@endif
</div>
</form>
</div>
</div>
</div>
<!-- LEFT SECTION -->
</div>
</div>
<script>
$("#finalize").click(function(){
if($(this).prop('checked')==true)
{
@if($workflow_document->its_reply!=1 && $document_user->role_id != 1)
$(".approver").hide();
$(".chenge-width").addClass('col-md-12').removeClass('col-md-6');
@endif
$('#uploadBtn').html('<i class="icon wb-check" aria-hidden="true"></i> {{ __("Approved") }}');
$("#uploadBtn").removeAttr('disabled');
}
else
{
@if($workflow_document->its_reply!=1 && $document_user->role_id != 1)
$(".approver").show();
$(".chenge-width").addClass('col-md-6').removeClass('col-md-12');
@endif
$('#uploadBtn').html('<i class="icon wb-check" aria-hidden="true"></i> {{ __("Send for Approval") }}');
}
})
$('.is_approved').change( function(){
var thisVal = $(this).val();
if(thisVal == 0)
{
$('#uploadBtn').html('<i class="icon wb-check" aria-hidden="true"></i> {{ __("Return") }}');
$('#uploadBtn').removeClass('btn-success');
$('#uploadBtn').addClass('btn-warning');
$("#uploadBtn").removeAttr('disabled');
@if($document_user->role_id == 2 && $userAsSupporter === null )
$("#finalize_field").hide();
@endif
$(".approver").hide();
$(".chenge-width").addClass('col-md-12').removeClass('col-md-6');
}
else
{
$('#uploadBtn').html('<i class="icon wb-check" aria-hidden="true"></i> {{ $document_user->role_id == 1 || $userAsSupporter !== null ? __("Approved") : __("Send for Approval") }}');
$('#uploadBtn').removeClass('btn-warning');
$('#uploadBtn').addClass('btn-success');
@if($document_user->role_id == 2 && $userAsSupporter === null )
$("#finalize_field").show();
@endif
$(".approver").show();
$(".chenge-width").addClass('col-md-6').removeClass('col-md-12');
}
})
@if($workflow_document->its_reply!=1 && $document_user->role_id != 1 && $workflow_document->creator_id != Auth::user()->id && $userAsSupporter === null )
$("#uploadBtn").attr('disabled','disabled');
@endif;
$('#approver_id').change( function(){
if($(this).val()!=''){
$("#uploadBtn").removeAttr('disabled');
}else{
$("#uploadBtn").attr('disabled','disabled');
}
});
</script>
</div>
@endif
</div>
<style type="text/css">
.nav-link:hover {
background-color: #eb6709;
}
.formErrorContent{color:red;}
div#myCompleteModal11{
z-index: 2000 !important;
}
</style>
<script>
var urlVal= window.location.href;
if(urlVal.lastIndexOf('#')>0)
{
var hassVal= urlVal.substring(urlVal.lastIndexOf('#') + 1).toLowerCase();
$(".nav-link").removeClass('active');
$(".tab-pane").removeClass('active');
$("#"+hassVal).addClass('active');
$("#"+hassVal+"_tab").addClass('active');
get_html('view_document');
}
else
{
get_html('view_document');
}
function get_html(hassVal){
if(hassVal=='view_document')
{
$.get('{{ route("view_document", base64_encode($workflow_document->id)) }}', {}, function(data){
$("#"+hassVal+"_tab").html(data);
});
}
else if(hassVal=='view_workflow')
{
$.get('{{ route("view_workflow", base64_encode($workflow_document->id)) }}', {}, function(data){
$("#"+hassVal+"_tab").html(data);
});
}
else if(hassVal=='related_documents')
{
$.get('{{ route("related_documents", base64_encode($workflow_document->id)) }}', {}, function(data){
$("#"+hassVal+"_tab").html(data);
});
}
else if(hassVal=='delegate_document')
{
$.get('{{ route("view_delegate_document", base64_encode($workflow_document->id)) }}', {}, function(data){
$("#"+hassVal+"_tab").html(data);
});
}
};
</script>
<script>
$(".select2").select2({width: 'resolve'});
$(".add-form").validationEngine('attach',{scroll:false});
</script>
<script>
$(document).ready(function(){
var settings = {
url: "{{ route('store-process-files') }}",
method: "POST",
allowedTypes:"{{ $setting->allowed_uploaded_file_type }}",
fileName: "files",
multiple: true,
showDelete: true,
returnType: "json",
dragDropStr: "<span><b>{{ __('Click Or Drop Files To Upload.') }}</b></span>",
abortStr:"<?php echo __('Delete') ?>",
deleteStr:"<?php echo __('Delete') ?>",
uploadStr:"<?php echo __('Upload') ?>",
onSuccess:function(files,data,xhr)
{
var pre_id_val = document.getElementById("file_ids").value;
if(data && data.length > 0)
{
$.each(data, function(key, val){
if(pre_id_val != '')
{
pre_id_val += ";" + val.data.id ;
}
else
{
pre_id_val = val.data.id ;
}
});
}
document.getElementById("file_ids").value = pre_id_val;
if(data!="")
{
$("#status").html("<font color='green'><?php echo __('Upload is success') ?></font>");
}
else
{
$("#status").html("<font color='red'><?php echo __('Upload is Failed') ?></font>");
}
document.getElementById("file_ids").nextSibling.remove();
setTimeout(function(){
$("#status").html("");
}, 5000);
},
onError: function(files,status,errMsg)
{
$("#status").html("<font color='red'><?php echo __('Upload is Failed') ?></font>");
setTimeout(function(){
$("#status").html("");
}, 5000);
},
deleteCallback: function (data, pd) {
$.ajax({
cache: false,
url: "{{ route('store-process-files-delete') }}",
data: data[0]['data'],
type: "POST",
success: function(textStatus)
{
if(data[0]['data']['id'] !== null){
var new_id_val='';
var old_id_val = document.getElementById("file_ids").value;
var current_id = data[0]['data']['id'];
if(old_id_val.indexOf(current_id+';') > 0){
new_id_val = old_id_val.replace(current_id+';','');
}else if(old_id_val.indexOf(';'+current_id) > 0){
new_id_val = old_id_val.replace(';'+current_id,'');
}else if(old_id_val.indexOf(current_id) > 0){
new_id_val = old_id_val.replace(current_id,'');
}
document.getElementById("file_ids").value = new_id_val;
$("#status").html("<font color='red'>"+textStatus+"</font>");
setTimeout(function(){
$("#status").html("");
}, 5000);
}
}
});
pd.statusbar.hide(); //You choice.
},
}
$("#mulitplefileuploaderApp").uploadFile(settings);
$('#view-tabs a[href="#{{ old('tab') }}"]').trigger('click');
});
</script>
@endsection