Laravel
Ajax variable casting with php:
let insertedConsortiumData = {!! json_encode($data["insertedConsortiumData"]) !!};
------------------------------------------------------------------------------------------------------------------------------------------------
Ajax datatable with parameter:
let url = '{{route('equipment-status-datatable')}}';
let oTable = $('#searchResultTable').DataTable({
processing: true,
serverSide: true,
order: [],
ajax: {
url: url,
'type': 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
data: function (d) {
d.status = $('#status').val();
d.load_capacity_id = $('#load_capacity_id').val();
}
},
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex'},
{data: 'load_capacity', name: 'load_capacity', searchable: true},
{data: 'equip_name', name: 'equip_name', searchable: true},
{data: 'manufacturer_name', name: 'manufacturer_name', searchable: true},
{data: 'equip_model', name: 'equip_model', searchable: true},
{data: 'action', name: 'action', searchable: true},
]
});------------------------------------------------------------------------------------------------------------------------------------------------
Ajax Form submit+ add parameter to url + add attribute :
$('#search-form').on('submit', function (e) {
e.preventDefault();
oTable.draw();
$('#hide_show').show();
let status = $('#status').val();
let load = $('#load_capacity_id').val();
let processUrl = '{{url('/report/render/RPT_EQUIPMENT_STATUS?xdo=/~weblogic/EQMS/RPT_EQUIPMENT_STATUS.xdo&p_status=:param1&p_load_capacity_id=:param2&type=pdf&filename=RPT_EQUIPMENT_STATUS')}}';
processUrl = processUrl.replace(':param1', status);
processUrl = processUrl.replace(':param2', load);
let urlString = processUrl.replace(/&/g, '&');
$("#go_there").attr("href", urlString);
//let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?status="+ status+ "&load="+ load;
//window.history.pushState({ path: newurl }, '', newurl);
});------------------------------------------------------------------------------------------------------------------------------------------------
Ajax Date Convert:
function convertDate(inputFormat) {
function pad(s) {
return (s < 10) ? '0' + s : s;
}
var d = new Date(inputFormat)
return [d.getFullYear(), pad(d.getMonth() + 1), pad(d.getDate())].join('-')
}------------------------------------------------------------------------------------------------------------------------------------------------
Ajax Msg vanish:
@if(Session::has('message'))
<div
class="alert {{Session::get('m-class') ? Session::get('m-class') : 'alert-danger'}} show"
role="alert">
{{ Session::get('message') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
window.setTimeout(function () {
$(".alert").fadeTo(500, 0).slideUp(500, function () {
$(this).remove();
});
}, 4000);
------------------------------------------------------------------------------------------------------------------------------------------------
Ajax scroll page top:
var eqr_id = '{{isset($mData->eqr_id) ? $mData->eqr_id : ''}}';
if (eqr_id) {
$("html, body").animate({scrollTop: $(document).height()}, 1000);
}
------------------------------------------------------------------------------------------------------------------------------------------------
Ajax attr:
$('#workshop_id').prop('disabled', true);$("#workflow_form").attr('action', '{{ route('repair-diagnosis-dtl-post') }}');
------------------------------------------------------------------------------------------------------------------------------------------------
Populate table using ajax:
function getData(r_r_mst_id, r_r_d_id) {
let myModal = $('#status-show');
$('#malfunction_resolve_date').prop('disabled', false);
$('#send_service_yn').prop('disabled', true);
$('#w_t_id').prop('disabled', true);
$('#workshop_id').prop('disabled', true);
$('#malfunction_resolve_date').val('');
$("#w_t_id").val('').trigger('change');
$("#workshop_id").val('').trigger('change');
$.ajax({
url: APP_URL + '/get-emp-data/' + r_r_mst_id + '/' + r_r_d_id,
success: function (msg) {
$("#malfunction_resolve_yn").val('').trigger('change');
let repair_diagnosis_emp = msg.repair_diagnosis_emp;
let repair_diagnosis_dtl = msg.repair_diagnosis_dtl;
let repair_diagnosis_mst = msg.repair_diagnosis_mst;
if (repair_diagnosis_mst) {
$("#r_d_mst_id").val(repair_diagnosis_mst.r_d_id);
}
if (repair_diagnosis_dtl) {
$("#malfunction_resolve_yn").select2("val", repair_diagnosis_dtl.malfunction_resolve_yn);
if (repair_diagnosis_dtl.malfunction_resolve_date) {
$("#malfunction_resolve_date").val(convertDate(repair_diagnosis_dtl.malfunction_resolve_date));
}
$("#send_service_yn").select2("val", repair_diagnosis_dtl.send_service_yn);
$("#w_t_id").select2("val", repair_diagnosis_dtl.assigned_ws_type_id);
setSelectDb(repair_diagnosis_dtl.assigned_ws_type_id, repair_diagnosis_dtl.assigned_ws_id);
$("#r_d_dtl_id").val(repair_diagnosis_dtl.r_d_dtl_id);
}
$('#malfunction_type').val('');
$('#malfunction_desc').val('');
$('#malfunction_id').val('');
if (msg.repair_request_dtl) {
$("#r_r_mst_id").val(msg.repair_request_dtl.r_r_mst_id);
$("#r_r_d_id").val(msg.repair_request_dtl.r_r_d_id);
$('#malfunction_type').val(msg.repair_request_dtl.malfunction);
$('#malfunction_desc').val(msg.repair_request_dtl.malfunction_other);
$('#malfunction_id').val(msg.repair_request_dtl.malfunction_id);
}
if (repair_diagnosis_emp.length !== 0) {
let markup = '';
$("#table-dtl > tbody").html("");
$.each(repair_diagnosis_emp, function (i) {
markup += "<tr role='row'>" +
"<td aria-colindex='1' role='cell' class='text-center'>" +
"<input type='checkbox' name='record' value='" + repair_diagnosis_emp[i].r_d_e_id + "+" + repair_diagnosis_emp[i].r_d_mst_id + "+" + repair_diagnosis_emp[i].r_d_dtl_id + "'>" +
"<input type='hidden' name='tab_emp_id[]' value='" + repair_diagnosis_emp[i].emp_id + "'>" +
"</td><td aria-colindex='2' role='cell' class='text-center'>" + repair_diagnosis_emp[i].emp_name + "</td></tr>";
});
$("#table-dtl tbody").html(markup);
}else{
$('#disable-portion').hide();
}
}
});
WEB PART:
Route::get('/get-emp-data/{r_r_mst_id}/{r_r_d_id}','Eqms\RepairDiagnosisController@getDtlData')->name("get-emp-data");
CONTROLLER PART:
public function getDtlData($r_r_mst_id, $r_r_d_id)
{
$repair_diagnosis_emp = [];
$repair_diagnosis_mst = DB::table("repair_diagnosis_mst")
->select("r_d_id", "r_d_no", "r_d_date", "r_r_mst_id")
->orderBy("insert_date","DESC")
->where("r_r_mst_id", "=", $r_r_mst_id)
->first();
$repair_diagnosis_dtl = DB::table("repair_diagnosis_dtl")
->select("r_d_dtl_id", "r_d_mst_id", "r_r_mst_id", "r_r_dtl_id", "equip_id", "equip_no", "r_r_date", "malfunction_id", "malfunction", "malfunction_resolve_yn", "malfunction_resolve_date", "send_service_yn", "assigned_ws_id", "assigned_ws_name", "assigned_ws_type_id", "assigned_ws_type")
->orderBy("insert_date","DESC")
->where("r_r_mst_id", "=", $r_r_mst_id)
->where("r_r_dtl_id", "=", $r_r_d_id)
->first();
if($repair_diagnosis_dtl!=null){
$repair_diagnosis_emp = DB::table("repair_diagnosis_emp")
->select("r_d_e_id", "r_d_dtl_id", "r_d_mst_id", "emp_id", "emp_code", "emp_name")
->orderBy("insert_date","DESC")
->where("r_d_mst_id", "=", $repair_diagnosis_dtl->r_d_mst_id)
->where("r_d_dtl_id", "=", $repair_diagnosis_dtl->r_d_dtl_id)
->get();
}
$repair_request_dtl = DB::table("repair_request_dtl")
->select("r_r_d_id","r_r_mst_id","malfunction_id","malfunction","malfunction_other")
->orderBy("insert_date","DESC")
->where("r_r_mst_id", "=", $r_r_mst_id)
->where("r_r_d_id", "=", $r_r_d_id)
->first();
return response(
[
'repair_request_dtl' => $repair_request_dtl,
'repair_diagnosis_dtl' => $repair_diagnosis_dtl,
'repair_diagnosis_mst' => $repair_diagnosis_mst,
'repair_diagnosis_emp' => $repair_diagnosis_emp,
]
);
}
------------------------------------------------------------------------------------------------------------------------------------------------
ajax split using special charecter:
let input = $('#operation_date').val();
let fields = input.split('-');
let day = fields[0];
let month = fields[1];------------------------------------------------------------------------------------------------------------------------------------------------
Email pattern + maxlenght chk+ input lower case:
<div class="col-md-3 mt-1">
<label>Email</label>
<input type="email" autocomplete="off"
placeholder="Email"
name="bo_email"
pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}"
class="form-control"
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
maxlength="75"
oninput="this.value = this.value.toLowerCase()" //////oninput="this.value = this.value.toUpperCase()"
value="{{isset($data->bo_email) ? $data->bo_email : ''}}"
>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
<div class="col-md-3 mt-1">
<div class="form-group">
<label class="mb-1 required">Active?</label>
<div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio"
name="active_yn" id="reporter_outsider_no1" checked
value="{{ \App\Enums\YesNoFlag::YES }}"
@if(isset($data->active_yn) && $data->active_yn == "Y") checked @endif
@if(isset($data->active_yn) && $data->active_yn == "N") disabled @endif/>
<label class="form-check-label">Yes</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio"
name="active_yn"
id="reporter_cpa_no1" value="{{ \App\Enums\YesNoFlag::NO }}"
@if(isset($data->active_yn) && $data->active_yn == "N") checked @endif
@if(isset($data->active_yn) && $data->active_yn == "N") disabled @endif/>
<label class="form-check-label">No</label>
</div>
</div>
</div>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
Route in button:
<a type="reset" href="{{route("berth-operator-index")}}"
class="btn btn-light-secondary mb-1"> Back</a>
<button type="submit" name="save" onclick="return confirm('Are you sure?')" class="btn btn btn-dark shadow mr-1 mb-1"> {{ isset($data->id)?'Update':'Save' }} </button>
<button onclick="$('#new_party').toggle('slow')"
class="btn btn-secondary mb-1 mr-1 hvr-underline-reveal mt-2"
type="button">
<i class="bx bxs-add-to-queue"></i> Add New
</button><form enctype="multipart/form-data" style="display: none;padding: 1rem 0"
action="{{route('mwe.operation.add-new-party')}}" method="post" id="new_party">
------------------------------------------------------------------------------------------------------------------------------------------------
<div class="col-md-3">
<label class="required">Shift</label>
<select class="custom-select select2 form-control" required id="rs_id"
name="rs_id">
<option value="">Select One</option>
@foreach($shiftList as $value)
<option value="{{$value->rs_id}}"
{{isset($mData->rs_id) && $mData->rs_id == $value->rs_id ? 'selected' : ''}}
>{{$value->rs_name.' ('.date('h:i A', strtotime($value->rs_start_time)).' ~ '.date('h:i A', strtotime($value->rs_end_time)).')'}}</option>
@endforeach
</select>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
<div class="col-md-12 mt-1">
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control"
aria-label="Description" id="description"
name="description"
placeholder="Enter Description"
><?php echo e(old('description', isset($mData->description) ? $mData->description : '')); ?></textarea>
<small class="text-muted form-text"></small>
</div>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
<fieldset class="border p-1 mt-1 mb-1 col-sm-12">
<div class="row ml-1">
<div class="col-sm-3">
<label for="review_by_id" class="required">Operator :</label>
<select class="custom-select select2 form-control operator_id"
id="operator_id">
</select>
<input type="hidden" id="operator_count"
value="{{isset($operatorCount) ? $operatorCount : ''}}">
<input type="hidden" id="all_operator"
value="{{isset($allOperator) ? $allOperator : ''}}">
<span class="text-danger"></span>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="required">Location</label>
<select class="select2 form-control pl-0 pr-0 location_id"
id="location_id">
<option value="">Select One</option>
@if(isset($locationList))
@foreach($locationList as $value)
<option value="{{$value->location_id}}">
{{$value->location}}
</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="col-sm-1" align="right">
<div id="start-no-field">
<label for="seat_to1"> </label><br/>
<button type="button" id="append"
class="btn btn-primary mb-1 add-row">
ADD
</button>
</div>
</div>
</div>
<div class="col-sm-12 mt-1">
<div class="table-responsive">
<table class="table table-sm table-striped table-bordered"
id="table-operator">
<thead>
<tr>
<th role="columnheader" scope="col"
aria-colindex="1" class="text-center" width="1%">Action
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center" width="10%">Operator
</th>
<th role="columnheader" scope="col"
aria-colindex="4" class="text-center" width="2%">Location
</th>
</tr>
</thead>
<tbody role="rowgroup" id="comp_body">
@if(!empty($dData))
@foreach($dData as $key=>$value)
<tr role="row">
<td aria-colindex="1" role="cell" class="text-center">
<input type='checkbox' name='record'
value="{{$value->operator_id.'+'.$value->r_d_id}}">
<input type="hidden" name="r_d_id[]"
value="{{$value->r_d_id}}"
class="r_d_id">
<input type="hidden" name="tab_operator_id[]"
value="{{$value->operator_id}}">
</td>
<td aria-colindex="7" role="cell">
<input type="text" class="form-control"
name="tab_operator_name[]" readonly
value="{{$value->operator_name}}">
</td>
<td aria-colindex="2" role="cell">
<select
class="custom-select form-control select2 tab_location_id"
id="tab_location_id_{{$key + 1}}"
name="tab_location_id[]">
<option value="">Select One</option>
@foreach($locationList as $values)
<option value="{{$values->location_id}}"
{{isset($value->location_id) && $value->location_id == $values->location_id ? 'selected' : ''}}
>{{$values->location}}</option>
@endforeach
</select>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
<div class="col-12 d-flex justify-content-start">
<button type="button"
class="btn btn-primary mb-1 delete-row">
Delete
</button>
</div>
</fieldset>
------------------------------------------------------------------------------------------------------------------------------------------------
Add + Delete row (My way):
var dataArray = new Array();
$(".add-row").click(function () {
let rs_id = $("#rs_id option:selected").val();
//let year = $("#r_year_id option:selected").val();
let r_name = $("#r_name").val();
let r_date = $("#r_date").val();
let location_id = $("#location_id option:selected").val();
let location = $("#location_id option:selected").text();
let emp_id = $("#operator_id option:selected").val();
let data = $("#operator_id option:selected").text();
let name = data.split('-');
let emp_name = name[1];
if (emp_id && rs_id && r_name && r_date && location_id) {
if ($.inArray(emp_id, dataArray) > -1) {
Swal.fire(
'Duplicate value not allowed.',
'',
'error'
)
} else {
let markup = "<tr role='row'>" +
"<td aria-colindex='1' role='cell' class='text-center'>" +
"<input type='checkbox' name='record' value='" + emp_id + "+" + "" + "'>" +
"<input type='hidden' name='tab_operator_id[]' value='" + emp_id + "'>" +
"<input type='hidden' name='tab_location_id[]' value='" + location_id + "'>" +
"</td><td aria-colindex='2' role='cell'>" + emp_name + "</td><td aria-colindex='2' role='cell'>" + location + "</td></tr>";
$("#operator_id").empty('');
$("#location_id").val('').trigger('change');
$("#table-operator tbody").append(markup);
dataArray.push(emp_id);
}
} else {
Swal.fire(
'Fill required value.',
'',
'error'
)
}
});
$(".delete-row").click(function () {
let arr_stuff = [];
let operator_id = [];
let r_d_id = [];
$(':checkbox:checked').each(function (i) {
arr_stuff[i] = $(this).val();
let sd = arr_stuff[i].split('+');
operator_id.push(sd[0]);
if (sd[1]) {
r_d_id.push(sd[1]);
}
});
if (r_d_id.length != 0) {
Swal.fire({
title: 'Are you sure?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
$.ajax({
type: 'GET',
url: '/roster-data-remove',
data: {r_d_id: r_d_id},
success: function (msg) {
if (msg == 0) {
Swal.fire({
title: 'Can not remove data. Attedeance process ongoing for this schedule.',
icon: 'error',
confirmButtonText: 'OK'
});
//return false;
} else {
Swal.fire({
title: 'Entry Successfully Deleted!',
icon: 'success',
confirmButtonText: 'OK'
}).then(function () {
for (var i = dataArray.length - 1; i >= 0; i--) {
for (var j = 0; j < operator_id.length; j++) {
if (dataArray[i] === operator_id[j]) {
dataArray.splice(i, 1);
}
}
}
$('td input:checked').closest('tr').remove();
});
}
}
});
}
});
} else {
for (var i = dataArray.length - 1; i >= 0; i--) {
for (var j = 0; j < operator_id.length; j++) {
if (dataArray[i] === operator_id[j]) {
dataArray.splice(i, 1);
}
}
}
$('td input:checked').closest('tr').remove();
/*Swal.fire({
title: 'Entry Successfully Deleted!',
icon: 'success',
confirmButtonText: 'OK'
}).then(function () {
$('td input:checked').closest('tr').remove();
});*/
}
});
Controller PART:
public function removeData(Request $request)
{
try {
foreach ($request->get('w_t_member_id') as $indx => $value) {
WorkshopTeamMember::where('w_t_member_id', $request->get("w_t_member_id")[$indx])->delete();
}
return '1';
} catch (\Exception $e) {
DB::rollBack();
return '0';
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
Add some data in ajax aray
Ajax Part:
var operator_count = $("#operator_count").val();
var all_operator = $("#all_operator").val();
var arr_allTrainee = []
try {
arr_allTrainee = JSON.parse(all_operator);
} catch (e) {
console.log("Invalid json")
}
if (operator_count) {
let i;
for (i = 0; i < operator_count; i++) {
dataArray.push(arr_allTrainee[i]);
}
}Controller Part:
public function edit(Request $request, $id)
{
$mData = RosterMaster::select('*')
->where('r_m_id', '=', $id)
->first();
$dData = RosterDetail::select('*')
->where('r_m_id', '=', $id)
->get();
$operatorCount = count($dData);
$allTrainee = RosterDetail::where('r_m_id', $id)->get(['operator_id'])->pluck('operator_id')->toArray();
return view('eqms.dutyroster.index', [
'mData' => $mData,
'dData' => $dData,
'yearList' => L_RosterYear::where('active_yn', 'Y')->get(),
'locationList' => Location::all(),
'shiftList' => L_RosterShift::all(),
'operatorCount' => $operatorCount,
'allOperator' => json_encode($allTrainee),
]);
}
------------------------------------------------------------------------------------------------------------------------------------------------
<form enctype="multipart/form-data"
@if(isset($mData->r_m_id)) action="{{route('duty-roster-update',[$mData->r_m_id])}}"
@else action="{{route('duty-roster-post')}}" @endif method="post" onsubmit="return chkTable()">
function chkTable() {
if ($('#comp_body tr').length == 0) {
Swal.fire({
title: 'Roster Setup Needed!',
icon: 'error',
confirmButtonText: 'OK'
});
return false;
}
}------------------------------------------------------------------------------------------------------------------------------------------------
Time Tag with Conversion:
<input type="time" autocomplete="off" class="form-control"
id="equip_return_time"
@if(isset($mData)) @if($mData->equip_meter_start==null) readonly
@else required
@endif @endif
name="equip_return_time"
value="{{isset($mData->equip_return_time) ? date('H:i A', strtotime($mData->equip_return_time)) : ''}}"
/>
function convertTime(timeString) {
let H = +timeString.substr(0, 2);
let h = (H % 12) || 12;
let ampm = H < 12 ? " AM" : " PM";
timeString = h + timeString.substr(2, 3) + ampm;
return timeString;
//console.log(timeString);
}------------------------------------------------------------------------------------------------------------------------------------------------
<div id="status-show" class="modal fade" role="dialog">
<div class="modal-dialog modal-full">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-uppercase text-left">
Assign Equipment
</h4>
<button class="close" type="button" data-dismiss="modal"
area-hidden="true">
×
</button>
</div>
<div class="modal-body">
<form id="workflow_form" method="post">
{!! csrf_field() !!}
<fieldset class="border p-1 mt-2 mb-1 col-sm-12"
id="detail_data">
<input type="hidden" id="dtl_eqr_id" name="dtl_eqr_id">
<input type="hidden" id="dtl_erm_id" name="dtl_erm_id">
<div class="row">
<div class="col-sm-3">
<div class="form-group">
<label>Location Type</label>
<input type="text" disabled
id="loc_typ"
class="form-control"
>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label>Location</label>
<input type="text"
id="loc" disabled
class="form-control"
>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label>Container 20</label>
<input type="number" disabled
id="cont_20"
class="form-control"
>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label>Container 40</label>
<input type="number" disabled
id="cont_40"
class="form-control"
>
</div>
</div>
<div class="col-sm-3">
<label>Request Date:</label>
<div class="input-group date" id="datetimepicker3"
data-target-input="nearest">
<input type="text" disabled
value="{{isset($mData->req_date) ? date('d-m-Y', strtotime($mData->req_date)) : ''}}"
class="form-control datetimepicker-input"
data-toggle="datetimepicker"
data-target="#datetimepicker3"
id="req_date"
name="req_date"
autocomplete="off"
/>
</div>
</div>
</div>
<div class="col-sm-12 mt-1">
<div class="table-responsive">
<table
class="table table-sm table-striped table-bordered"
id="table-dtl">
<thead>
<tr>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="7%">Equipment Type
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="7%">Load Capacity
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="7%">Requested Equipment
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="7%">Approved Equipment
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="7%">Supply Date
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="10%">Equipment Assigned
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="10%">Operator Assigned
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="20%">Equipment
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="20%">Operator
</th>
</tr>
</thead>
<tbody role="rowgroup">
</tbody>
</table>
</div>
</div>
<div class="form-group mt-1">
<div class="col-md-12 pr-0 d-flex justify-content-end">
<div class="form-group">
<button id="save-info" type="submit"
class="btn btn-primary mr-1 mb-1">Save
</button>
<button class="btn btn-primary mr-1 mb-1"
type="button" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<button type="button"
onclick="getData({{$value->s_d_id}},{{$value->s_m_id}})"
class="btn btn-success show-receive-modal workflowBtn">
Detail
</button>
function getData(s_d_id, s_m_id) {
let myModal = $('#status-show');
$("#dtl_sm_id").val(s_m_id);
$("#dtl_sd_id").val(s_d_id);
$.ajax({
url: APP_URL + '/get-service-dtl-emp-data/' + s_m_id + '/' + s_d_id,
success: function (msg) {
let markup = '';
$("#table-dtl > tbody").html("");
$.each(msg, function (i) {
let empI = msg[i].emp_name;
let desI = msg[i].designation;
markup += "<tr role='row'>" +
"<td aria-colindex='1' role='cell' class='text-center'>" +
"<input type='checkbox' name='record' value='" + msg[i].s_m_id + "+" + msg[i].s_d_id + "+" + msg[i].s_d_e_id + "'>" +
"<input type='hidden' name='tab_emp_id[]' value='" + msg[i].emp_id + "'>" +
"</td><td aria-colindex='2' role='cell'>" + empI + "</td><td aria-colindex='2' role='cell'><input type='text' class='form-control' name='tab_requested_equip[]' value='" + desI + "'></td></tr>";
});
$("#table-dtl tbody").html(markup);
}
});
myModal.modal({show: true});
return false;
}------------------------------------------------------------------------------------------------------------------------------------------------
HTML PART:
<div class="col-md-3 mt-1 empId" id="hide3"
@if(isset($mData->req_emp_id)) style="display: block"
@else style="display: none" @endif>
<label class="required">Requester :</label>
<select class="custom-select select2 form-control req_emp_id" disabled
id="req_emp_id" @if(isset($mData->req_emp_id)) name="req_emp_id"
@else name="" @endif>
@if(isset($mData))
<option
value="{{$mData->req_emp_id}}">{{$mData->req_emp_code.' '.$mData->req_emp_name.''}}</option>
@endif
</select>
</div>
AJAX PART:
$('.req_emp_id').select2({
placeholder: "Select one",
ajax: {
url: APP_URL + '/get-employee',
data: function (params) {
if (params.term) {
if (params.term.trim().length < 1) {
return false;
}
} else {
return false;
}
return params;
},
dataType: 'json',
processResults: function (data) {
var formattedResults = $.map(data, function (obj, idx) {
obj.id = obj.emp_id;
obj.text = obj.emp_code + '-' + obj.emp_name;
return obj;
});
return {
results: formattedResults,
};
}
}
});Controller PART:
public function getEmp(Request $request)
{
$searchTerm = $request->get('term');
$empId = Employee::where(function ($query) use ($searchTerm) {
$query->where(DB::raw('LOWER(emp_name)'), 'like', strtolower('%' . trim($searchTerm) . '%'))
->orWhere('emp_code', 'like', '' . trim($searchTerm) . '%');
//})->where('emp_status_id','13')->orWhere('emp_status_id','1')->orderBy('emp_id', 'ASC')->limit(10)->get(['emp_id', 'emp_code', 'emp_name', 'designation_id', 'dpt_department_id']);
})->orderBy('emp_id', 'ASC')->limit(10)->get(['emp_id', 'emp_code', 'emp_name', 'designation_id', 'dpt_department_id']);
return $empId;
}
WEB PART:
Route::get('/get-employee', 'Eqms\Setup\WSTeamSetupController@getEmp')->name('get-employee');
$("#load_capacity_id").val('').trigger('change');------------------------------------------------------------------------------------------------------------------------------------------------
Check Something on button click:
HTML PART:
<button id="eq-req-approval" type="submit"
class="btn btn-primary mr-1 mb-1" onclick="chkData()">
Approve
</button>
AJAX PART:
function chkData() {
let eqr_id = $("#eqr_id").val();//alert(eqr_id);
let data;
//return false;
$.ajax({
async: false,
url: APP_URL + '/submission-chk/' + eqr_id,
success: function (msg) {
data = msg;
}
});
if (data == 0) {
Swal.fire({
title: 'Please Fill the required value!',
icon: 'error',
confirmButtonText: 'OK'
});
return false;
} else {
return true;
}
}------------------------------------------------------------------------------------------------------------------------------------------------
Dropdown change check data empty:
$("#parts_name").on("change", function () {
let partsID = $("#parts_name").val();
let estimate_no = $("#estimate_no").val();
let url = APP_URL + '/get-request-stock-data/' + estimate_no + '/' + partsID;
if (((partsID !== undefined) || (partsID != null)) && partsID) {
$.ajax({
type: "GET",
url: url,
success: function (data) {
$('#stockQty').val(data[0].stock_qty);
$('#reqQty').val(data[0].req_qty);
},
error: function (data) {
alert('error asche');
}
});
} else {
$('#stockQty').val('');
$('#reqQty').val('');
}
});------------------------------------------------------------------------------------------------------------------------------------------------
DATE:
->addColumn('service_start_date', function ($query) {
if($query->service_start_date==null){
return '--';
}else{
return Carbon::parse($query->service_start_date)->format('d-m-Y');
}
})STATUS:
->addColumn('active_yn', function ($query) {
if($query->active_yn=="Y"){
$html = <<<HTML
<span class="badge badge-success"> Active</span>
HTML;
return $html;
}else{
$html = <<<HTML
<span class="badge badge-danger"> In-Active</span>
HTML;
return $html;
}
})DATE WITH TIME:
->addColumn('created_at', function ($data) {
return Carbon::parse($data->created_at)->format('d-m-Y h:i A');
})===>>>
->editColumn('inspector_assigned_by_emp_id', function ($data) {
return !empty($data['assignedBy'])?$data['assignedBy']['emp_name']:'N/A';
})===>>>
->editColumn('status', function ($data) {
return isset($data['status']) && $data['status'] == 'A' ? 'Active' : 'Inactive';
})===>>>
->editColumn('next_maintenance_at', function ($data) {
return (!$data['next_maintenance_at'])?'':HelperClass::defaultDateTimeFormat($data['next_maintenance_at'], 'date');
})
public static function defaultDateTimeFormat($datetime, $format='DATETIME')
{
switch (strtoupper($format)){
case 'DATETIME':
$data = date("d-m-Y h:i A", strtotime($datetime));
break;
case 'DATE':
$dateTime = new \DateTime($datetime);
$data = $dateTime->format('d/m/Y');
break;
case 'TIME':
$data = date("h:i A", strtotime($datetime));
break;
case 'LOCALDATE':
$dateTime = new \DateTime($datetime);
$data = $dateTime->format('d/m/Y');
break;
default:
$data = date("d-m-Y h:i A", strtotime($datetime));
break;
}
return $data;
}
public static function getStatus($status){
switch (strtoupper($status)){
case 'P':
$res = 'PENDING';
break;
case 'A':
$res = 'ACTIVE';
break;
case 'I':
$res = 'INACTIVE';
break;
case 'R':
$res = 'REJECTED';
break;
case 'C':
$res = 'APPROVED';
break;
default:
$res = '';
break;
}
return $res;
}===>>>
->editColumn('status', function ($data) {
return HelperClass::getStatusName($data['status']);
})public static function getStatusName($statusTag = '')
{
switch (strtoupper($statusTag)) {
case 'A':
$status ='Active';
$name ='<span class="badge badge-pill" style="background-color:dodgerblue">';
$name .= $status;
$name .='</span>';
break;
case 'I':
$status = 'Inactive';
$name = '<span class="badge badge-pill" style="background-color:#545b62">';
$name .= $status;
$name .='</span>';
break;
case 'P':
$status = 'Pending';
$name = '<span class="badge badge-pill" style="background-color:orange">';
$name .= $status;
$name .='</span>';
break;
case 'D':
$status = 'Delete';
$name ='<span class="badge badge-pill" style="background-color:orangered">';
$name .= $status;
$name .='</span>';
break;
case 'C':
$status = 'Complete';
$name ='<span class="badge badge-pill" style="background-color:darkgreen">';
$name .= $status;
$name .='</span>';
break;
case 'R':
$status = 'Reject';
$name ='<span class="badge badge-pill" style="background-color:orangered">';
$name .= $status;
$name .='</span>';
break;
case 'Y':
$status = 'Yes';
$name ='<span class="badge badge-pill" style="background-color:dodgerblue">';
$name .= $status;
$name .='</span>';
break;
case 'N':
$status = 'No';
$name ='<span class="badge badge-pill" style="background-color:orangered">';
$name .= $status;
$name .='</span>';
break;
default:
$status = 'Unknown';
$name ='<span class="badge badge-pill" style="background-color:orangered">';
$name .= $status;
$name .='</span>';
break;
}
return $name;
}
DELETE BTN:
->addColumn('action', function ($data) {
$actionBtn = '<a title="Delete" data-taskmonitorid="'.$data->task_monitor_id.'" class="dltBtn"><i class="bx bx-trash cursor-pointer" style="color: #CC0033;"></i></a>';
return $actionBtn;
})
->escapeColumns([])
->addIndexColumn()
->make(true);
FOR DELETE BTN:
Route::get('/data-remove', 'Mwe\ThirdPartyTaskMonitorController@removeData')->name('mwe.operation.task-data-remove');
public function removeData(Request $request)
{//dd($request);
try {
ThirdpartyTaskMonitor::where('task_monitor_id', $request->get("task_monitor_id"))->delete();
return '1';
} catch (\Exception $e) {
DB::rollBack();
return '0';
}
}
$('#searchResultTable tbody').on('click', '.dltBtn', function () {
let row_id = $(this).data("taskmonitorid");
let url = '{{route('mwe.operation.task-data-remove')}}';
Swal.fire({
title: 'Are you sure?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
$.ajax({
type: 'GET',
url: url,
data: {task_monitor_id: row_id},
success: function (msg) {
if (msg == 0) {
Swal.fire({
title: 'Something Went Wrong!!',
icon: 'error',
confirmButtonText: 'OK'
});
//return false;
} else {
Swal.fire({
title: 'Entry Successfully Deleted!',
icon: 'success',
confirmButtonText: 'OK'
}).then(function () {
let vessel_inspection_id = $('#vessel_inspection_id').val();
let workshopId = $('#workshopId').val();
let maintenance_req_id = $('#maintenance_req_id').val();
taskDtlList(maintenance_req_id, workshopId, vessel_inspection_id);
});
}
}
});
}
});
});------------------------------------------------------------------------------------------------------------------------------------------------
public function edit(Request $request, $id)
{
$data = BerthOperator::select('*')
->where('bo_id', '=', $id)
->first();
return view('eqms.berthoperator.index', [
'data' => $data,
]);
}
public function edit(Request $request, $id)
{
$sql = "select eq.equip_name, rd.* from roster_dtl rd
left join equipment eq on (eq.equip_id = rd.equip_id)
where rd.r_d_id = :r_d_id";
$mData = db::selectOne($sql,['r_d_id' => $id]);
return view('eqms.equipactivities.index', [
'mData' => $mData
]);
}
$workshops=Workshop::all()->sortBy('name');------------------------------------------------------------------------------------------------------------------------------------------------
Today Date PHP attach with time:
$today = date("Y-m-d");
$equip_return_time = isset($postData['equip_return_time']) ? $today . ' ' . (date('H:i:s', strtotime($postData['equip_return_time']))) : '';------------------------------------------------------------------------------------------------------------------------------------------------
Redirect in custom url with value:
return redirect('/equip-assign/' . $request->get('dtl_eqr_id'));
return redirect('/equipment-request/' . $response['p_EQR_ID']['value']);
------------------------------------------------------------------------------------------------------------------------------------------------
L_Load_Capacity::orderBy('load_capacity_id','asc')->get()------------------------------------------------------------------------------------------------------------------------------------------------
If data not available send blank on param in procedure:
'p_REQ_EMP_ID' => isset($postData['req_emp_id']) ? $postData['req_emp_id'] : '',
------------------------------------------------------------------------------------------------------------------------------------------------
Use Procedure Multiple Times:
foreach ($request->get('tab_location_type_id') as $indx => $value) {
//DB::beginTransaction();
//$r_d_id = null;
$status_code = sprintf("%4000s", "");
$status_message = sprintf("%4000s", "");
$params_dtl = [
'p_ERM_ID' => [
'value' => &$request->get('tab_erm_id')[$indx],
'type' => \PDO::PARAM_INPUT_OUTPUT,
'length' => 255
],
"p_EQR_ID" => $params['p_EQR_ID']['value'],
"p_LOCATION_TYPE_ID" => $request->get('tab_location_type_id')[$indx],
"p_LOCATION_ID" => $request->get('tab_location_id')[$indx],
"p_CONTAINER_20" => $request->get('tab_container_20')[$indx],
"p_CONTAINER_40" => $request->get('tab_container_40')[$indx],
"P_INSERT_BY" => auth()->id(),
"o_status_code" => &$status_code,
"o_status_message" => &$status_message
];//dd($params_dtl);
DB::executeProcedure("EQMS.EQUIP_REQUEST_MST_INS_UPD", $params_dtl);
if ($params_dtl['o_status_code'] != 1) {
DB::rollBack();
return $params_dtl;
}
//DB::commit();
}------------------------------------------------------------------------------------------------------------------------------------------------
Populate Datatable using Ajax (AGAIN):
function getData(erm_id, eqr_id) {
let myModal = $('#status-show');
$("#dtl_eqr_id").val(eqr_id);
$("#dtl_erm_id").val(erm_id);
$.ajax({
url: APP_URL + '/get-eqp-req-dtl-data/' + eqr_id + '/' + erm_id,
success: function (msg) {
let markup = '';
$("#table-dtl > tbody").html("");
$.each(msg, function (i) {
let loadC = msg[i].load_capacity;
let requested_equip = msg[i].requested_equip;
if (loadC === null) {
loadC = '';
}
if (requested_equip === null) {
requested_equip = '';
}
markup += "<tr role='row'>" +
"<td aria-colindex='1' role='cell' class='text-center'>" +
"<input type='checkbox' name='record' value='" + msg[i].eqr_id + "+" + msg[i].erm_id + "+" + msg[i].erd_id + "'>" +
"<input type='hidden' name='tab_equip_type_id[]' value='" + msg[i].equip_type_id + "'>" +
"<input type='hidden' name='tab_load_capacity_id[]' value='" + msg[i].load_capacity_id + "'>" +
"</td><td aria-colindex='2' role='cell'>" + msg[i].equip_type + "</td><td aria-colindex='2' role='cell'>" + loadC + "</td><td aria-colindex='2' role='cell'><input type='text' class='form-control' name='tab_requested_equip[]' value='" + requested_equip + "'></td></tr>";
});
$("#table-dtl tbody").html(markup);
}
});
myModal.modal({show: true});
return false;
}
Route::get('/get-eqp-req-dtl-data/{eqr_id}/{erm_id}','Eqms\EquipmentReqController@getDtlData')->name("get-detail-data");
public function getDtlData($eqr_id, $erm_id)
{
return response()->json(DB::table("equip_request_dtl")
->select("erd_id", "erm_id", "eqr_id", "equip_type", "load_capacity", "requested_equip", "equip_type_id", "load_capacity_id", "supplied_equip", "supplied_date")
->orderBy("insert_date", "DESC")
->where("eqr_id", "=", $eqr_id)
->where("erm_id", "=", $erm_id)
->get());
}
------------------------------------------------------------------------------------------------------------------------------------------------
$("#location_type_id").select2().on('change', function (e) {
let location_type_id = $(this).val();
$.ajax({
type: 'get',
url: '/get-location',
data: {location_type_id: location_type_id},
success: function (msg) {
$("#location_id").html(msg);
}
});
});
Route::get('/get-location', 'Eqms\EquipmentReqController@getLocation')->name('get-location');
function getLocation(Request $request)
{
$location_type_id = $request->input('location_type_id');
$list = DB::table('LOCATION')->where('location_type_id', '=', $location_type_id)->get();
$msg = '<option value="">Select One</option>';
foreach ($list as $data) {
$msg .= '<option value="' . $data->location_id . '">' . $data->location . '</option>';
}
return $msg;
}
ANOTHER ONE:
public function estimateParts(Request $request, $id)
{
$querys = "SELECT P.PART_ID ,P.PART_NO, P.PART_NAME
FROM SPARE_PART_REQ_MST m, SPARE_PART_REQ_DTL d, l_part p
WHERE D.PART_ID = p.part_id
AND D.ACTIVE_YN = 'Y'
AND M.S_P_REQ_MST_ID = D.S_P_REQ_MST_ID
AND D.S_P_REQ_MST_ID = :S_P_REQ_MST_ID" ;
$parts = db::select($querys,['S_P_REQ_MST_ID' => $id]);
$partdata = '';
if (!empty($parts)) {
$partdata .= '<option value="">--- Choose ---</option>';
foreach ($parts as $data) {
$partdata .= '<option value="' . $data->part_id . '">'.$data->part_no.'-' . $data->part_name . '</option>';
}
echo $partdata;
die;
} else {
echo '<option value="">--- Choose ---</option>';
}
}
Route::get('/ajax-estimate-parts-stock/{id}', 'Eqms\SparePartStockController@estimateParts')->name('ajax-estimate-parts-stock');
$('#estimate_no').on('change', function () {
var estimate_no = $('#estimate_no').val();
loadEstimateParts(estimate_no);
});
function loadEstimateParts(estimate_no) {
if (estimate_no !== undefined && estimate_no) {
$.ajax({
type: "GET",
url: APP_URL + '/ajax-estimate-parts-stock/' + estimate_no,
success: function (data) {
$('#parts_name').html(data);
},
error: function (data) {
alert('error');
}
});
} else {
$('#parts_name').val('');
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
On button submit search populate datatable:
public function dataTableList(Request $request)
{
$status = $request->get("status");
$load_capacity_id = $request->get("load_capacity_id");
$sql = "SELECT DISTINCT
e.equip_id,
e.equip_no,
e.equip_name,
e.manufacturer_name,
e.equip_model,
e.equip_sl_no,
e.manufacture_year,
lc.load_capacity,
r.location_id,
CASE
WHEN r.equip_id IS NOT NULL THEN 'WORKING'
WHEN d.equip_id IS NOT NULL THEN 'BREAKDOWN'
WHEN sm.equip_id IS NOT NULL THEN 'SCHEDULED SERVICE'
ELSE 'IDLE'
END AS status,
r.location,
d.assigned_ws_id,
d.assigned_ws_name
FROM equipment e
LEFT JOIN roster_dtl r ON (e.equip_id = r.equip_id)
LEFT JOIN repair_diagnosis_dtl d ON (e.equip_id = d.equip_id)
LEFT JOIN eqms.l_load_capacity lc
ON (lc.load_capacity_id = e.load_capacity_id)
LEFT JOIN EQMS.SERVICE_MST sm ON (e.EQUIP_ID = sm.EQUIP_ID)
WHERE e.load_capacity_id =
NVL ( :P_LOAD_CAPACITY_ID, e.load_capacity_id)
AND CASE
WHEN r.equip_id IS NOT NULL THEN 'WORKING'
WHEN d.equip_id IS NOT NULL THEN 'BREAKDOWN'
WHEN sm.equip_id IS NOT NULL THEN 'SCHEDULED SERVICE'
ELSE 'IDLE'
END =
NVL (
UPPER ( :P_STATUS),
CASE
WHEN r.equip_id IS NOT NULL THEN 'WORKING'
WHEN d.equip_id IS NOT NULL THEN 'BREAKDOWN'
WHEN sm.equip_id IS NOT NULL THEN 'SCHEDULED SERVICE'
ELSE 'IDLE'
END)";
$queryResult = db::select($sql,['P_STATUS' => $status, 'P_LOAD_CAPACITY_ID' => $load_capacity_id]);
return datatables()->of($queryResult)
->addColumn('equip_name', function ($query) {
return $query->equip_name.' -- '.$query->equip_no;
})
->addColumn('action', function ($query) {
if($query->status=="IDLE"){
$html = <<<HTML
<span class="badge badge-success"> IDLE</span>
HTML;
return $html;
}else if($query->status=="WORKING"){
$html = <<<HTML
<span class="badge badge-black"> $query->status ($query->location)</span>
HTML;
return $html;
}else if($query->status=="SCHEDULED SERVICE"){
$html = <<<HTML
<span class="badge badge-circle-info">$query->status</span>
HTML;
return $html;
}else{
$html = <<<HTML
<span class="badge badge-danger"> $query->status ($query->assigned_ws_name)</span>
HTML;
return $html;
}
})
->escapeColumns([])
->addIndexColumn()
->make(true);
}
Route::post('/equipment-status-datatable', 'Eqms\EquipStatusController@dataTableList')->name('equipment-status-datatable');
VIEW PAGE:
@extends('layouts.default')
@section('title')
:: Equipment Status
@endsection
@section('header-style')
<!--Load custom style link or css-->
@endsection
@section('content')
<div class="card">
<!-- Table Start -->
<div class="card-body">
<h4 class="card-title">Equipment Status</h4>
<hr>
<form method="POST" id="search-form" name="search-form">
{{ csrf_field() }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Status</label>
<select class="custom-select form-control select2" id="status"
name="status">
<option value="">Select One</option>
<option value="IDLE">IDLE</option>
<option value="WORKING">WORKING</option>
<option value="BREAKDOWN">BREAKDOWN</option>
<option value="SCHEDULED SERVICE">SCHEDULED SERVICE</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Load Capacity</label>
<select class="custom-select form-control select2" id="load_capacity_id"
name="load_capacity_id">
<option value="">Select One</option>
@foreach($loadCapacty as $value)
<option value="{{$value->load_capacity_id}}">{{$value->load_capacity}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-3 mt-2">
<div class="d-flex justify-content-start col">
<button type="submit" class="btn btn btn-dark shadow mb-1 btn-secondary">
<i class="bx bx-search"></i> Search
</button>
{{--<a class="btn btn-dark btn-secondary ml-1 mb-1" target="_blank"
href="{{url('/report/render/RPT_THIRD_PARTY_SERVICE_DETAILS?xdo=/~weblogic/CCMS/RPT_THIRD_PARTY_SERVICE_DETAILS.xdo&P_THIRD_PARTY_SERVICE_ID='.\Request::get('id').'&type=pdf&filename=RPT_THIRD_PARTY_SERVICE_DETAILS')}}">
<i class="bx bx-printer"></i> Print</a>--}}
</div>
</div>
</div>
</form>
</div>
</div>
@include('eqms.equipstatus.list')
@endsection
@section('footer-script')
<script type="text/javascript">
let url = '{{route('equipment-status-datatable')}}';
let oTable = $('#searchResultTable').DataTable({
processing: true,
serverSide: true,
order: [],
ajax: {
url: url,
'type': 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
data: function (d) {
d.status = $('#status').val();
d.load_capacity_id = $('#load_capacity_id').val();
}
},
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex'},
{data: 'load_capacity', name: 'load_capacity', searchable: true},
{data: 'equip_name', name: 'equip_name', searchable: true},
{data: 'manufacturer_name', name: 'manufacturer_name', searchable: true},
{data: 'equip_model', name: 'equip_model', searchable: true},
{data: 'action', name: 'action', searchable: true},
]
});
$(document).ready(function () {
$('#search-form').on('submit', function (e) {
e.preventDefault();
oTable.draw();
$('#hide_show').show();
let status = $('#status').val();
let load = $('#load_capacity_id').val();
let processUrl = '{{url('/report/render/RPT_EQUIPMENT_STATUS?xdo=/~weblogic/EQMS/RPT_EQUIPMENT_STATUS.xdo&p_status=:param1&p_load_capacity_id=:param2&type=pdf&filename=RPT_EQUIPMENT_STATUS')}}';
processUrl = processUrl.replace(':param1', status);
processUrl = processUrl.replace(':param2', load);
let urlString = processUrl.replace(/&/g, '&');
$("#go_there").attr("href", urlString);
//let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?status="+ status+ "&load="+ load;
//window.history.pushState({ path: newurl }, '', newurl);
});
});
</script>
@endsection
<div class="card">
<div class="card-body">
<section id="horizontal-vertical">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-md-3 mt-2">
<h3 class="card-title">Equipment Status List</h3>
</div>
<div class="col-md-9 mt-2" id="hide_show" style="display: none">
<div class="d-flex justify-content-end">
<a id="go_there" class="btn btn-dark btn-secondary ml-1" target="_blank">
<i class="bx bx-printer"></i> Print</a>
</div>
</div>
</div>
</div>
<div class="card-content">
<div class="card-body card-dashboard">
<div class="table-responsive">
<table id="searchResultTable" class="table table-sm mdl-data-table">
<thead>
<tr>
<th>#</th>
<th>Load Capacity</th>
<th>Equipment Name</th>
<th>MANUFACTURER</th>
<th>EQUIPMENT MODEL</th>
<th>Status</th>
</tr>
</thead>
<tbody id="resultDetailsBody">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
=>>>>> SELECT RRRM.R_P_REQ_TICKET_NO,
RRRM.R_P_REQ_MST_ID,
RRRM.REQ_DATE,
CASE WHEN RRRM.ACTIVE_YN IS NULL THEN 'N' ELSE RRRM.ACTIVE_YN END STATUS,
RRM.EQUIP_NAME,
RRM.EQUIP_ID,
RRM.R_R_NO,
RRM.R_R_MST_ID
FROM REPAIR_PART_REQUEST_MST RRRM, REPAIR_REQUEST_MST RRM
WHERE RRRM.R_R_MST_ID(+) = RRM.R_R_MST_ID
AND RRM.R_R_MST_ID = :R_R_MST_ID
=>>>>> SELECT * FROM EQUIPMENT WHERE EQUIP_ID NOT IN (SELECT EQUIP_ID FROM EQMS.SERVICE_MST)
=>>>>> SELECT DISTINCT er.*
FROM eqms.equip_request er, equip_request_mst rm
WHERE er.eqr_id = rm.eqr_id
AND EXISTS
(SELECT *
FROM equip_request_dtl d
WHERE d.EQR_ID = er.EQR_ID AND d.REQUESTED_EQUIP IS NOT NULL)
ORDER BY er.INSERT_DATE desc
====>>>>
$role_key = json_decode(Auth::user()->roles->pluck('role_key'));
$where = '';
if (in_array("MDA_SSAE_M", $role_key)){
$where = 'WHERE TR.FORWARD_TO_SSAE = '.auth()->user()->employee->emp_id;
}else if (in_array("MDA_ASW", $role_key)){
$where = 'WHERE TR.FORWARD_TO_ASW = '.auth()->user()->employee->emp_id;
}else if (in_array("MDA_XEN", $role_key)){
$where = 'WHERE TR.FORWARD_TO_XEN = '.auth()->user()->employee->emp_id;
}
//$querys = "SELECT TA.FORWARD_TO_SAE, TA.FORWARD_TO_SSAE, TA.FORWARD_TO_ASW, TA.FORWARD_TO_XEN, TA.APPROVE_YN, TR.THIRDPARTY_REQ_ID,TR.REQUEST_DATE,IJ.NAME TASK, DEP.DEPARTMENT_NAME, V.NAME VESSEL_NAME, MI.INSPECTOR_JOB_NUMBER, MR.REQUEST_NUMBER, TP.THIRDPARTY_NAME FROM MDA.THIRDPARTY_REQUEST TR LEFT JOIN MDA.MW_VESSEL_INSPECTIONS VI ON TR.MW_VESSEL_INSPECTIONS_ID = VI.ID LEFT JOIN MDA.MW_INSPECTION_JOBS IJ ON IJ.ID = VI.INSPECTION_JOB_ID LEFT JOIN MDA.MW_MAINTENANCE_REQS MR ON MR.ID = TR.MAINTENANCE_REQ_ID LEFT JOIN MDA.VESSELS V ON V.ID = MR.VESSEL_ID LEFT JOIN PMIS.L_DEPARTMENT DEP ON DEP.DEPARTMENT_ID = MR.DEPARTMENT_ID LEFT JOIN MDA.MW_MAINTENANCE_INSPECTOR MI ON MI.MAINTENANCE_REQ_ID = TR.MAINTENANCE_REQ_ID LEFT JOIN MDA.THIRDPARTY_ASSIGN TA ON TA.THIRDPARTY_REQ_ID = TR.THIRDPARTY_REQ_ID LEFT JOIN MDA.L_THIRDPARTY TP ON TP.THIRDPARTY_ID = TA.THIRDPARTY_ID $where ORDER BY TR.INSERT_DATE DESC" ;
$querys = "SELECT TR.*,IJ.NAME,MR.VESSEL_MASTER_ID,MR.REQUEST_NUMBER, V.NAME VESSEL_NAME,DEP.DEPARTMENT_NAME, VI.JOB_NUMBER INSPECTOR_JOB_NUMBER, TP.THIRDPARTY_NAME
FROM MDA.THIRDPARTY_REQUEST TR
LEFT JOIN MDA.MW_VESSEL_INSPECTIONS VI ON TR.MW_VESSEL_INSPECTIONS_ID = VI.ID
LEFT JOIN MDA.MW_INSPECTION_JOBS IJ ON IJ.ID = VI.INSPECTION_JOB_ID
LEFT JOIN MDA.MW_MAINTENANCE_REQS MR ON MR.ID = TR.MAINTENANCE_REQ_ID
LEFT JOIN MDA.CPA_VESSELS V ON V.ID = MR.VESSEL_ID
LEFT JOIN PMIS.L_DEPARTMENT DEP ON DEP.DEPARTMENT_ID = MR.DEPARTMENT_ID
LEFT JOIN MDA.THIRDPARTY_ASSIGN TA ON TA.THIRDPARTY_REQ_ID = TR.THIRDPARTY_REQ_ID
LEFT JOIN MDA.L_THIRDPARTY TP ON TP.THIRDPARTY_ID = TA.THIRDPARTY_ID
$where
ORDER BY TR.INSERT_DATE DESC" ;
$queryResult = DB::select($querys);------------------------------------------------------------------------------------------------------------------------------------------------
Ajax Data With Dropdown load:
WEB PART:
Route::get('/get-eqp-req-dtl/{eqr_id}/{erm_id}','Eqms\RequestApprovalController@getDtlData')->name("get-req-detail-data");
CONTROLLER PART:
public function getDtlData($eqr_id, $erm_id)
{
$process = [];
$b = DB::table("equip_request_mst")
->select("erm_id", "eqr_id", "location_type_id", "location_type", "location_id", "location", "location_bn", "container_20", "container_40")
->orderBy("insert_date","DESC")
->where("eqr_id", "=", $eqr_id)
->where("erm_id", "=", $erm_id)
->first();
$sql = "SELECT rd.erd_id,
rd.erm_id,
rd.eqr_id,
rd.equip_type,
eqp.EQUIP_NAME,
rd.load_capacity,
rd.requested_equip,
rd.equip_type_id,
rd.load_capacity_id,
rd.supplied_equip,
rd.supplied_date,
dd.operator_id roster_operator,
dd.OPERATOR_NAME,
dd.equip_id roster_eqp_id,
mst.location_id,
er.REQ_FOR_DATE
FROM equip_request_dtl rd, eqms.roster_dtl dd, eqms.equip_request_mst mst, EQMS.EQUIPMENT eqp, EQMS.EQUIP_REQUEST er
WHERE rd.erd_id = dd.erd_id(+)
AND mst.erm_id = rd.erm_id
AND er.EQR_ID = rd.EQR_ID
and dd.EQUIP_ID = eqp.EQUIP_ID(+)
AND rd.eqr_id = NVL ( :eqr_id, rd.eqr_id)
AND rd.erm_id = NVL ( :erm_id, rd.erm_id)";
$a = db::select($sql,['eqr_id' => $eqr_id, 'erm_id' => $erm_id]);
$msg1 = '<option value="">Please select One</option>';
$sql1 = "select rd.*,rd.OPERATOR_NAME || ' - ' || rd.R_NAME op_name from EQMS.ROSTER_DTL rd
where EQUIP_ID is null";
$datas1 = db::select($sql1);
foreach ($datas1 as $data){
$msg1 .= '<option value="'.$data->r_d_id.'">'.$data->op_name.'</option>';
}
//dd($msg1);
foreach ($a as $indx => $value) {
$a[$indx]->emp_dropdown = $msg1;
}
foreach ($a as $indx => $value) {
$sql = "SELECT e.*, e.EQUIP_NAME || ' - ' || e.EQUIP_TYPE equipment_name
FROM EQMS.EQUIPMENT e, EQMS.ROSTER_DTL d, EQMS.SERVICE_MST sm
WHERE e.EQUIP_ID = d.EQUIP_ID(+)
AND e.EQUIP_ID = sm.EQUIP_ID(+)
AND d.EQUIP_ID IS NULL
AND e.EQUIP_TYPE_ID = :EQUIP_TYPE_ID";
$datas = db::select($sql, ['EQUIP_TYPE_ID' => $a[$indx]->equip_type_id]);
if(count($datas)==0){
$msg = '<option value="">Please select One</option>';
$a[$indx]->eqip_dropdown = $msg;
}else{
$msg = '<option value="">Please select One</option>';
foreach ($datas as $data) {
$msg .= '<option value="' . $data->equip_id . '" >' . $data->equipment_name . '</option>';
}
$a[$indx]->eqip_dropdown = $msg;
}
}
return response(
[
'equip_request_dtl' => $a,
'equip_request_mst' => $b,
]
);
}
VIEW AJAX:
function getData(erm_id, eqr_id) {
let myModal = $('#status-show');
$("#dtl_eqr_id").val(eqr_id);
$("#dtl_erm_id").val(erm_id);
console.log(eqr_id + '+' + erm_id);
$.ajax({
url: APP_URL + '/get-eqp-req-dtl/' + eqr_id + '/' + erm_id,
success: function (msgs) {
let markup = '';
let mst = msgs.equip_request_mst;
$("#loc_typ").val(mst.location_type);
$("#loc").val(mst.location);
$("#cont_20").val(mst.container_20);
$("#cont_40").val(mst.container_40);
let msg = msgs.equip_request_dtl; //console.log(msg)
$("#table-dtl > tbody").html("");
$.each(msg, function (i) {
let loadC = msg[i].load_capacity;
if (loadC === null) {
loadC = '';
}
let supplied_equip = msg[i].supplied_equip;
if (supplied_equip === null || supplied_equip == '') {
supplied_equip = '';
}
let requested_equip = msg[i].requested_equip;
if (requested_equip == null || requested_equip == '') {
requested_equip = '';
}
let equip_name = msg[i].equip_name;
if (equip_name == null || equip_name == '') {
equip_name = '';
}
let operator_name = msg[i].operator_name;
if (operator_name == null || operator_name == '') {
operator_name = '';
}
let supplied_date;
if (msg[i].supplied_date) {
supplied_date = convertDate(msg[i].supplied_date);
} else {
supplied_date = '';
}
markup += "<tr role='row'>" +
"<td aria-colindex='2' role='cell'>" + msg[i].equip_type + "</td>" +
"<td aria-colindex='2' role='cell'>" + loadC + "</td>" +
"<td aria-colindex='2' role='cell'>" + requested_equip + "</td>" +
"<td aria-colindex='2' role='cell'>" + supplied_equip +
"<input type='hidden' name='tab_eqr_id[]' value='" + msg[i].eqr_id + "'>" +
"<input type='hidden' name='tab_erm_id[]' value='" + msg[i].erm_id + "'>" +
"<input type='hidden' name='tab_erd_id[]' value='" + msg[i].erd_id + "'>" +
"<input type='hidden' name='tab_equip_type_id[]' value='" + msg[i].equip_type_id + "'>" +
"<input type='hidden' name='tab_load_capacity_id[]' value='" + msg[i].load_capacity_id + "'>" +
"<input type='hidden' name='tab_supplied_equip[]' value='" + supplied_equip + "'>" +
"<td aria-colindex='2' role='cell'>" + supplied_date + "</td>" +
"<td aria-colindex='2' role='cell'>" + equip_name + "</td>" +
"<td aria-colindex='2' role='cell'>" + operator_name + "</td>" +
"<td aria-colindex='2' role='cell'><select class='custom-select form-control select2' required id='equip_type_id' name='dtl_equip_type_id[]'>" + msg[i].eqip_dropdown + "</select></td>" +
"<td aria-colindex='2' role='cell'><select class='custom-select form-control select2' required id='r_d_id' name='dtl_r_d_id[]'>" + msg[i].emp_dropdown + "</select></td>" +
"</tr>";
});
$("#table-dtl tbody").html(markup);
}
});
myModal.modal({show: true});
return false;
}------------------------------------------------------------------------------------------------------------------------------------------------
$getKey = json_encode(Auth::user()->roles->pluck('role_key'));//dd($getKey);
if (strpos($getKey, "MDA_SSAE_M") == TRUE){
$btn_shw_data = MaintenanceInspector::where('maintenance_req_id', $id)
->where('ASSIGNED_SSAE_EMP_ID', Auth::user()->emp_id)
->first('insp_conf_ssae');
$btn_shw_data =$btn_shw_data->insp_conf_ssae;
}else{
$btn_shw_data = '';
}------------------------------------------------------------------------------------------------------------------------------------------------
public function inspectionOrderDownload($id)
{
$docData = MaintenanceInspectionJob::find($id);
if ($docData) {
if ($docData->attachment && $docData->file_type) {
$attachment = substr($docData->attachment, strpos($docData->attachment, ",") + 1);
$content = base64_decode($attachment);//dd($attachment);
return response()->make($content, 200, [
'Content-Type' => $docData->file_type,
'Content-Disposition' => 'attachment; filename="' .'INSPECTION_ORDER_'. $id .'.'. $docData->file_type
]);
}
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
VIEW:
<div class="row">
<div class="col" id="final-selection-message"></div>
</div>
<form id="add-form" method="post" name="add-form">
{!! csrf_field() !!}
<div class="row">
<div class="col-12">
<div class="row mt-2 ml-2">
<div class="col-md-9">
<div id="start-no-field" class="form-group">
<label class="required">Task Detail</label>
<input type="text" id="description"
class="form-control"
oninput="this.value = this.value.toUpperCase()"
placeholder="Task Detail"
autocomplete="off">
</div>
</div>
<div class="col-md-3 mt-2">
<div id="start-no-field"
class="form-group">
<button class="btn btn-secondary hvr-underline-reveal" id="new-task"
type="button">
<i class="bx bxs-add-to-queue"></i> Add New
</button>
</div>
</div>
</div>
</div>
</div>
</form>
<div class="col-sm-12 mt-1">
<div class="table-responsive">
<table
class="table table-sm table-striped table-light"
id="table-dtl">
<thead>
<tr>
<th role="columnheader" scope="col"
aria-colindex="2"
width="10%">#
</th>
<th role="columnheader" scope="col"
aria-colindex="2" class="text-center"
width="50%">Task Detail
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
AJAX SECTION:
$('#new-task').on('click', function (e) {
e.preventDefault();
let answer = confirm('Are you sure?');
let desc = $('#description').val();
/*if (desc) {
alert('Please Add Description.');
}else{*/
if (answer == true) {
$.ajax({
type: 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
url: "{{route('mwe.operation.third-party-approval-new-task-dtl')}}",
data: {
thirdparty_req_id: $('#thirdparty_req_id').val(),
maintenance_req_id: $('#maintenance_req_id').val(),
workshopId: $('#mw_workshop_id').val(),
vessel_inspection_id: $('#mw_vessel_inspections_id').val(),
description: desc
},
success: function (data) {
$('#final-selection-message').html(data.html);
$('#description').val('');
onlyDtl($('#maintenance_req_id').val(), $('#mw_workshop_id').val(), $('#mw_vessel_inspections_id').val());
},
error: function (data) {
alert('error');
}
});
} else {
$('#final-selection-message').html('');
}
//}
});
function onlyDtl(maintenance_req_id, mw_workshop_id, mw_vessel_inspections_id) {
let url = '{{route('mwe.operation.only-dtl-datatable')}}';
let tblPreventivi = $('#table-dtl').DataTable({
processing: true,
serverSide: true,
bDestroy: true,
pageLength: 20,
bFilter: true,
async: false,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'All']],
/*serverSide: true,
bDestroy: true,*/
ajax: {
url: url,
data: {maintenance_req_id: maintenance_req_id, mw_workshop_id: mw_workshop_id, mw_vessel_inspections_id: mw_vessel_inspections_id},
'type': 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
},
"columns": [
{"data": 'DT_RowIndex', "name": 'DT_RowIndex'},
{"data": "description"},
],
});
}Route::post('/add-new-task-dtl', 'Mwe\ThirdPartyRequestsApprovalController@addNewDtl')->name('mwe.operation.third-party-approval-new-task-dtl');
Route::post('/only-dtl-datatable', 'Mwe\ThirdPartyRequestsApprovalController@onlyDtldataTable')->name('mwe.operation.only-dtl-datatable');
public function onlyDtldataTable(Request $request)
{
$maintenance_req_id = $request->get("maintenance_req_id");
$mw_workshop_id = $request->get("mw_workshop_id");
$mw_vessel_inspections_id = $request->get("mw_vessel_inspections_id");
$querys = "SELECT * FROM MDA.THIRDPARTY_TASK_MONITOR
WHERE MAINTENANCE_REQ_ID = :MAINTENANCE_REQ_ID
AND MW_VESSEL_INSPECTIONS_ID = :MW_VESSEL_INSPECTIONS_ID
AND MW_WORKSHOP_ID = :MW_WORKSHOP_ID
ORDER BY INSERT_DATE DESC" ;
$queryResult = db::select($querys,['MAINTENANCE_REQ_ID' => $maintenance_req_id, 'MW_VESSEL_INSPECTIONS_ID' => $mw_vessel_inspections_id, 'MW_WORKSHOP_ID' => $mw_workshop_id]);
return datatables()->of($queryResult)
->addIndexColumn()
->escapeColumns([])
->make(true);
}
<script>
$(".alert").fadeTo(2000, 2000).slideUp(500, function(){
$(".alert").slideUp(500);
});
</script>
<div class="alert @if($params['o_status_code'] == 1) alert-success @else alert-danger @endif" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
{{$params['o_status_message']}}
</div>
public function addNewDtl(Request $request)
{//dd($request->all());
DB::beginTransaction();
try {
$id = null;
$status_code = sprintf("%4000s", "");
$status_message = sprintf("%4000s", "");
$params = [
"P_TASK_MONITOR_ID" => $id,
"P_DESCRIPTION" => $request->get("description"),
"P_TASK_STATUS_ID" => '1',
"P_VESSEL_INSPECTION_ID" => $request->get("vessel_inspection_id"),
"P_MW_WORKSHOP_ID" => $request->get("workshopId"),
"P_MAINTENANCE_REQ_ID" => $request->get("maintenance_req_id"),
"P_THIRDPARTY_REQ_ID" => $request->get("thirdparty_req_id"),
"P_INSERT_BY" => auth()->id(),
"o_status_code" => &$status_code,
"o_status_message" => &$status_message
];
DB::executeProcedure("MDA.THIRDPARTY_SERVICE.APPROVAL_TASK_MONITORING_INS", $params);
$lastParams = $params;
if ($params['o_status_code'] != 1) {
DB::rollBack();
$params['html'] = view('mwe.thirdparty.message')->with('params', $params)->render();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return ["exception" => true, "o_status_code" => false, "o_status_message" => $exception->getMessage()];
}
$lastParams['html'] = view('mwe.thirdparty.message')->with('params', $lastParams)->render();
return $lastParams;
}
------------------------------------------------------------------------------------------------------------------------------------------------
$('#searchResultTable').DataTable().ajax.reload();
------------------------------------------------------------------------------------------------------------------------------------------------
Button click submit ajax with data:
<button class="btn btn-secondary hvr-underline-reveal" id="new-task"
type="button">
<i class="bx bxs-add-to-queue"></i> Add New
</button>
AJAX PORTION:
Route::post('/add-new-task-dtl', 'Mwe\ThirdPartyTaskMonitorController@addNewDtl')->name('mwe.operation.add-new-task-dtl');
$('#new-task').on('click', function (e) {
e.preventDefault();
var answer = confirm('Are you sure?');
let desc = $('#description').val();
/*if (desc) {
alert('Please Add Description.');
}else{*/
if (answer == true) {
$.ajax({
type: 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
url: "{{route('mwe.operation.add-new-task-dtl')}}",
data: {
thirdparty_req_id: $('#thirdparty_req_id').val(),
assign_id: $('#assign_id').val(),
description: desc
},
success: function (data) {
$('#final-selection-message').html(data.html);
$('#description').val('');
let thirdparty_req_id = $('#thirdparty_req_id').val();
taskDtlList(thirdparty_req_id);
},
error: function (data) {
alert('error');
}
});
} else {
$('#final-selection-message').html('');
}
//}
});
Controller Part:
public function addNewDtl(Request $request)
{//dd($request->all());
$lastParams = [];
DB::beginTransaction();
try {
$id = null;
$status_code = sprintf("%4000s", "");
$status_message = sprintf("%4000s", "");
$params = [
"P_TASK_MONITOR_ID" => $id,
"P_DESCRIPTION" => $request->get("description"),
"P_ASSIGN_ID" => $request->get("assign_id"),
"P_TASK_STATUS_ID" => '1',
"P_ESTIMATED_DATE" => null,
"P_COMPLETED_DATE" => null,
"P_THIRDPARTY_REQ_ID" => $request->get("thirdparty_req_id"),
"P_INSERT_BY" => auth()->id(),
"o_status_code" => &$status_code,
"o_status_message" => &$status_message
];
DB::executeProcedure("MDA.THIRDPARTY_SERVICE.THIRDPARTY_TASK_MONITORING_INS", $params);
$lastParams = $params;
if ($params['o_status_code'] != 1) {
DB::rollBack();
$params['html'] = view('mwe.thirdparty.message')->with('params', $params)->render();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return ["exception" => true, "o_status_code" => false, "o_status_message" => $exception->getMessage()];
}
$lastParams['html'] = view('mwe.thirdparty.message')->with('params', $lastParams)->render();
return $lastParams;
}
<script>
$(".alert").fadeTo(2000, 2000).slideUp(500, function(){
$(".alert").slideUp(500);
});
</script>
<div class="alert @if($params['o_status_code'] == 1) alert-success @else alert-danger @endif" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
{{$params['o_status_message']}}
</div>
------------------------------------------------------------------------------------------------------------------------------------------------
Route::post('/task-dtl-data-submit', 'Mwe\ThirdPartyTaskMonitorController@taskDtlPost')->name('mwe.operation.task-dtl-data-submit');
$('#final-results-form').on('submit', function (e) {
e.preventDefault();
var answer = confirm('Are you sure?');
if (answer == true) {
$.ajax({
type: 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
url: "{{route('mwe.operation.task-dtl-data-submit')}}",
data: $(this).serialize(),
success: function (data) {
$('#final-selection-message').html(data.html);
let thirdparty_req_id = $('#thirdparty_req_id').val();
taskDtlList(thirdparty_req_id);
},
error: function (data) {
alert('error');
}
});
} else {
$('#final-selection-message').html('');
}
});
public function taskDtlPost(Request $request)
{
$lastParams = [];
DB::beginTransaction();
try {
foreach ($request->get('task_monitor_id') as $indx => $value) {
if($request->get('estimated_date')[$indx]!=null){
$estimated_date = isset($request->get('estimated_date')[$indx]) ? date('Y-m-d', strtotime($request->get('estimated_date')[$indx])) : '';
}else{
$estimated_date = '';
}
if($request->get('completed_date')[$indx]!=null){
$completed_date = isset($request->get('completed_date')[$indx]) ? date('Y-m-d', strtotime($request->get('completed_date')[$indx])) : '';
}else{
$completed_date = '';
}
$status_code = sprintf("%4000s", "");
$status_message = sprintf("%4000s", "");
$params = [
"P_TASK_MONITOR_ID" => $request->get('task_monitor_id')[$indx],
"P_TASK_STATUS_ID" => $request->get('task_status_id')[$indx],
"P_ESTIMATED_DATE" => $estimated_date,
"P_COMPLETED_DATE" => $completed_date,
"P_INSERT_BY" => auth()->id(),
"o_status_code" => &$status_code,
"o_status_message" => &$status_message
];//dd($params);
DB::executeProcedure("MDA.THIRDPARTY_SERVICE.THIRDPARTY_TASK_MONITORING_UPD", $params);
$lastParams = $params;
if ($params['o_status_code'] != 1) {
DB::rollBack();
$params['html'] = view('mwe.thirdparty.message')->with('params', $params)->render();
}
DB::commit();
}
} catch (\Exception $exception) {
DB::rollBack();
return ["exception" => true, "o_status_code" => false, "o_status_message" => $exception->getMessage()];
}
$lastParams['html'] = view('mwe.thirdparty.message')->with('params', $lastParams)->render();
return $lastParams;
}
------------------------------------------------------------------------------------------------------------------------------------------------
Ajax File Content base64:
function encodeFileAsURL() {
var file = document.querySelector('input[type=file]')['files'][0];
var reader = new FileReader();
var baseString;
reader.onloadend = function () {
baseString = reader.result;
$("#converted_file").val(baseString);
//console.log(baseString);
};
reader.readAsDataURL(file);
}let converted_file = $("#converted_file").val();
let filePath = $("#attachedFile").val();
let file_ext = '';
let fileName = '';
if (filePath) {
file_ext = filePath.substr(filePath.lastIndexOf('.') + 1, filePath.length);
fileName = document.getElementById('attachedFile').files[0].name;
}<div class="col-md-5">
<div class="form-group">
<label class="required">Attachment</label>
<input type="file" class="form-control" id="attachedFile"
onchange="encodeFileAsURL();"/>
</div>
<input type="hidden" id="converted_file" name="converted_file">
</div>