edms2023/resources/views/my-files/xxxindex.blade copy.php

361 lines
17 KiB
PHP

@extends('layouts.list_master')
@section('pageTitle', __('My Files'))
@section('content')
<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="page-header">
<h1 class="page-title">{{ __('My Files') }}</h1>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('dashboard') }}">{{ __('Dashboard') }}</a></li>
<li class="breadcrumb-item active">{{ __('My Fiels') }}</li>
</ol>
</div>
<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">
<h4 class="card-title project-title">
{{ __('Upload New File(s)') }}
</h4>
</div>
<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-my-files') }}" id="add-form" autocomplete="off" enctype="multipart/form-data" class="add-form">
@csrf
<div class="row">
<div class="form-group col-md-8">
<div class="row">
<div class="form-group col-md-6">
<label class="form-control-label" for="directory_id">{{ __('Choose Directory') }}</label>
<select class="form-control" name = "directory_id" id = "directory_id" tabindex = "5">
<option value = "">{{ __('Select Directory') }}</option>
@if($directories)
@foreach($directories->where('parent_id', 0) as $directory)
<option style="" value = "{{ $directory->id }}" {{ old('directory_id') && ($directory->id==old('directory_id')) ? 'selected' : $directory->id==$parent_id ? 'selected' : '' }} >{{ $directory->name }}</option>
@foreach($directories->where('parent_id',$directory->id) as $child_directory)
@include('my-files.directory_list', ['directory'=>$child_directory,'gap'=>' --'])
@endforeach
@endforeach
@endif
</select>
</div>
<div class="form-group col-md-6">
<label class="form-control-label" for="directory_name">{{ __('Create New Directory') }}</label>
<input type="text" class="form-control" id="directory_name" name="directory_name" placeholder="{{ __('Create New Directory') }}" autocomplete="off" tabindex = "6"/>
</div>
</div>
<div class="row">
<div class="from-group col-md-12">
<label class="form-control-label" for="description">{{ __('Description') }}</label>
{{-- <input type="text" class="form-control" id="description" name="description" placeholder="{{ __('Description') }}" autocomplete="off" tabindex = "2"/> --}}
<textarea name="" class="form-control" id="description" name="description" placeholder="{{ __('Description') }}" rows="2"></textarea>
</div>
</div>
</div>
<div class="form-group col-md-4">
<label class="form-control-label" for="mulitplefileuploader">{{ __('File') }}</label>
<div id="mulitplefileuploader">Upload</div>
<div id="status"></div>
<div>
<input type="text" name="file_ids" value="" id="file_ids" class="validate[required]" style="visibility: hidden;">
</div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success" id="uploadBtn"><i class="icon wb-check" aria-hidden="true"></i> {{ __('SAVE') }}</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title project-title">
{{ __('Lists Of File(s)') }}
</h4>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('my-files') }}">{{ __('My File') }}</a></li>
@foreach ($parent_directories as $k=>$v)
@if ($k == $last)
<li class="breadcrumb-item">{{$v}}</li>
@else
<li class="breadcrumb-item active"><a href="{{ route('my-files', base64_encode($k)) }}">{{$v}}</a></li>
@endif
@endforeach
</ol>
</div>
<div class="card-block">
<table class="table table-hover dataTable table-striped w-full" data-plugin="dataTable">
<thead>
<tr>
<th>{{ __('Type') }}</th>
<th>{{ __('File / Directory') }}</th>
<th>{{ __('Description') }}</th>
<th>{{ __('Creation Date') }}</th>
<th>{{ __('Last Modified') }}</th>
<th>{{ __('Action') }}</th>
</tr>
</thead>
<tbody>
@if($directories)
@foreach($directories->where('parent_id', $parent_id) as $directory)
<tr>
<td><a href="{{ route('my-files', base64_encode($directory->id)) }}"><i class="icon wb-folder" aria-hidden="true" style="font-size: 39px; color: #76838f;"></i></a></td>
<td>{{ $directory->name }}</td>
<td>{{ $directory->description }}</td>
<td>{{ $directory->created_at != '' ? date('d-m-Y', strtotime($directory->created_at)) : ''}}</td>
<td>{{ $directory->updated_at != '' ? date('d-m-Y', strtotime($directory->updated_at)) : ''}}</td>
<td><a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="{{ route('my-files', base64_encode($directory->id)) }}" data-toggle="tooltip" data-original-title="{{ __('View') }}"><i class="icon wb-eye" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="#" data-toggle="modal" data-target="#ShareModal{{ ($directory->id) }}">
<i class="icon wb-share" aria-hidden="true" data-toggle="tooltip" data-original-title="{{ __('Share') }}"></i>
</a>&nbsp;&nbsp;
<div class="modal fade text-dark" id="ShareModal{{ ($directory->id) }}">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<form method="post" action="{{ route('share') }}" class="add-form" id="add-form{{ base64_encode($directory->id) }}" autocomplete="off" enctype="multipart/form-data">
@csrf
<input type="hidden" name="type" value="D">
<input type="hidden" name="id" value="{{ ($directory->id) }}">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">{{ __('Share') }}</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-6">
<label class="form-control-label" for="share_to">{{ __('Choose People / Department') }}</label>
<div class="select2-primary">
<select class="form-control select2 validate[required]" name="share_to" id="share_to_{{ base64_encode($directory->id) }}" style="width:100%" tabindex="1">
@include('my-files.share-to-users')
</select>
</div>
</div>
<div class="form-group col-md-6">
<label class="form-control-label" for="permission">{{ __('Choose Permission') }}</label>
<div class="select2-primary">
<select class="form-control select2 validate[required]" name = "permission" id = "permission_{{ base64_encode($directory->id) }}" tabindex = "2" style="width:100%">
<option value = "1">{{ __('Read') }}</option>
<option value = "2">{{ __('Write') }}</option>
<option value = "3">{{ __('Read And Write') }}</option>
</select>
</div>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-success" tabindex="3"><i class="icon wb-check" aria-hidden="true"></i>{{ __('Share') }}</button>
</div>
</form>
</div>
</div>
</div>
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" data-toggle="tooltip" data-original-title="{{ __('Delete') }}" onclick="confirm('Are you sure you want to delete this record? All the related data will be deleted also.') ? '' : event.preventDefault();" href="{{ route('delete-directory', base64_encode($directory->id)) }}"><i class="icon wb-trash" aria-hidden="true"></i></a></td>
</tr>
@endforeach
@endif
@foreach(App\MyFile::where('directory_id', $parent_id)->where('user_id', Auth::user()->id)->where('is_temp', 0)->get() as $myfile)
@if($myfile->files_name && trim($myfile->files_name) !='' && file_exists(public_path($myfile->place_of_the_files.'/'.$myfile->files_name)))
@php
$full_file_path = '/'.$myfile->place_of_the_files.'/'.$myfile->files_name;
$type_array = explode('.', $myfile->files_name);
$type = end($type_array);
@endphp
<tr>
<td><a href="{{ route('view-my-files', base64_encode($myfile->id)) }}"><i class="icon wb-file" aria-hidden="true" style="font-size: 39px; color: #76838f;"></i></a></td>
<td>{{ $myfile->files_name }}</td>
<td>{{ $myfile->description }}</td>
<td>{{ $myfile->created_at != '' ? date('d-m-Y', strtotime($myfile->created_at)) : ''}}</td>
<td>{{ $myfile->updated_at != '' ? date('d-m-Y', strtotime($myfile->updated_at)) : ''}}</td>
<td>
@if(in_array(strtolower($type),['jpeg','png','jpg','pdf', 'gif']))
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="{{ route('view-my-files', base64_encode($myfile->id)) }}" data-toggle="tooltip" data-original-title="{{ __('View') }}" target="_blank" ><i class="icon wb-eye" aria-hidden="true"></i></a>&nbsp;&nbsp;
@endif
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="#" data-toggle="modal" data-target="#ShareModalF{{ ($myfile->id) }}">
<i class="icon wb-share" aria-hidden="true" data-toggle="tooltip" data-original-title="{{ __('Share') }}"></i>
</a>&nbsp;&nbsp;
<div class="modal fade text-dark" id="ShareModalF{{ ($myfile->id) }}">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<form method="post" action="{{ route('share') }}" class="add-form" id="add-form_{{ base64_encode($myfile->id) }}" autocomplete="off" enctype="multipart/form-data">
@csrf
<input type="hidden" name="type" value="F">
<input type="hidden" name="id" value="{{ ($myfile->id) }}">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">{{ __('Share') }}</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-6">
<label class="form-control-label" for="share_to">{{ __('Choose People / Department') }}</label>
<div class="select2-primary">
<select class="form-control select2 validate[required]" name="share_to" id="share_to_{{ base64_encode($myfile->id) }}" style="width:100%" tabindex="1">
@include('document-workflows.create_document_reviewer_options')
</select>
</div>
</div>
<div class="form-group col-md-6">
<label class="form-control-label" for="permission">{{ __('Choose Permission') }}</label>
<div class="select2-primary">
<select class="form-control select2 validate[required]" name = "permission" id = "permission_{{ base64_encode($myfile->id) }}" tabindex = "2" style="width:100%">
<option value = "1">{{ __('Read') }}</option>
<option value = "2">{{ __('Write') }}</option>
<option value = "3">{{ __('Read And Write') }}</option>
</select>
</div>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-success" tabindex="3"><i class="icon wb-check" aria-hidden="true"></i>{{ __('Share') }}</button>
</div>
</form>
</div>
</div>
</div>
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" href="{{ $full_file_path }}" download><i class="icon fa fa-download" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a class="btn btn-sm btn-icon btn-default btn-outline btn-round m-1" onclick="confirm('Are you sure you want to delete this record? All the related data will be deleted also.') ? '' : event.preventDefault();" href="{{ route('delete-file', base64_encode($myfile->id)) }}" data-toggle="tooltip" data-original-title="{{ __('Delete') }}"><i class="icon wb-trash" aria-hidden="true"></i></a></td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<!-- LEFT SECTION -->
<!-- RIGHT SECTION -->
{{-- <div class="col-xxl-3 col-xl-4 col-lg-12 d-none">
<div class="card">
<div class="card-block">
<h4 class="project-option-title">{{ __('Tags') }}</h4>
<a href="#"><span class="badge badge-default badge-outline mr-5 mb-5">Default</span></a>
<a href="#"><span class="badge badge-primary mr-5 mb-5">Primary</span></a>
<a href="#"><span class="badge badge-success mr-5 mb-5">Success</span></a>
<a href="#"><span class="badge badge-info mr-5 mb-5">Info</span></a>
<a href="#"><span class="badge badge-warning mr-5 mb-5">Warning</span></a>
<a href="#"><span class="badge badge-danger mr-5 mb-5">Danger</span></a>
<a href="#"><span class="badge badge-dark mr-5 mb-5">Dark</span></a>
</div>
</div>
</div> --}}
<!-- RIGHT SECTION -->
</div>
</div>
<script type="text/javascript">
$(".select2").select2({width: 'resolve'});
$(".add-form").validationEngine('attach',{scroll:false});
</script>
<script>
$(document).ready(function(){
var settings = {
url: "{{ route('store-files') }}",
method: "POST",
allowedTypes:"{{ $setting->allowed_uploaded_file_type }}",
fileName: "files",
multiple: true,
showDelete: true,
maxFileSize: eval("{{ $setting->user_file_size_limit }}") * 1024 * 1024,
returnType: "json",
dragDropStr: "<span><b>{{ __('Click Or Drop Files To Upload.') }}</b></span>",
abortStr:"{{ __('Delete') }}",
deleteStr:"<?php echo __('Delete') ?>",
uploadStr:"{{ __('Upload') }}",
onSuccess:function(files,data,xhr)
{
// console.log(data);
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>");
}
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-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.
},
}
$("#mulitplefileuploader").uploadFile(settings);
});
</script>
@endsection