File: /var/www/html/owlcrm/resources/views/users/posts/edit.blade.php
@extends('adminlte::page')
@section('title', 'Dashboard')
@section('content_header')
<h1>Leads</h1>
<small>Manage Leads</small>
@stop
@section('content')
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Edit Leads</h3>
</div>
@if (session('error'))
<h6 class="alert alert-danger">
{{ session('error') }}
</h6>
@endif
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" id="edit_leads" role="form" action="{{ route('leads.update', $lead->id) }}"
class="jqueryValidation">
@csrf
@method('PATCH')
<div class="card-body">
<div class="form-group">
<label for="title">Title</label>
<x-adminlte-input class="form-control" id="title" name="title" placeholder="Enter Title"
value="{{ $lead->title }}" required />
</div>
<div class="form-group">
<label for="lead_source">Lead Source</label>
<select class="form-control" name="lead_source" id="" required>
@foreach ($lead_sources as $lead_source)
<option value="{{ $lead_source->id }}"
{{ $lead->source == $lead_source->id ? 'selected' : '' }}>{{ $lead_source->name }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="assign_to">Assign to</label>
<select class="form-control" name="assign_to" id="" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $lead->assigned_to == $user->id ? 'selected' : '' }}>
{{ $user->first_name . $user->last_name }}
</option>
@endforeach
</select>
</div>
{{-- <div class=" form-group">
<label for="customer">Customer</label>
<x-adminlte-input class="form-control" id="customer_id" name="customer_id" placeholder="Enter Customer"
value="{{ old('customer_id') }}" />
</div> --}}
<div class="form-group">
<label for="salutation">Salutation</label>
<select class="form-control" name="salutation" id="" required>
@foreach (App\Models\Lead::Lead_salutation as $key => $Lead_salutation)
<option value="{{ $key }}"{{ $lead->salutation == $key ? 'selected' : '' }}>
{{ $Lead_salutation }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="first_name">First Name</label>
<x-adminlte-input class="form-control" id="first_name" name="first_name" placeholder="Enter First Name"
value="{{ $lead->first_name }}" required />
</div>
<div class="form-group">
<label for="last_name">Last Name</label>
<x-adminlte-input class="form-control" id="last_name" name="last_name" placeholder="Enter Last Name"
value="{{ $lead->first_name }}" required />
</div>
<div class=" form-group">
<label for="gender"> Gender</label>
<select class="form-control" id="" name="gender" required>
@foreach (App\Models\Lead::Lead_gender as $key => $Lead_gender)
<option value="{{ $key }}"{{ $lead->gender == $key ? 'selected' : '' }}>
{{ $Lead_gender }}</option>
@endforeach
<select>
</div>
<div class=" form-group">
<label for="property_interest_type"> Property Interest Type</label>
<select class="form-control" id="" name="property_interest_type" required>
@foreach (App\Models\Lead::property_interest_type as $key => $property_interest_type)
<option
value="{{ $key }}"{{ $lead->property_interest_type == $key ? 'selected' : '' }}>
{{ $property_interest_type }}</option>
@endforeach
<select>
</div>
<div class="form-group">
<input type="checkbox" id="is_organization" name="is_organization" value="1"
{{ $lead->is_organization == '1' ? 'checked' : '' }}>
<label for="is_organization">Is Organisation</label>
</div>
<div class=" form-group">
<label for="organization_name">Organisation Name</label>
<x-adminlte-input class="form-control" id="organization_name" name="organization_name"
placeholder="Enter Organization Name" value="{{ $lead->organization_name }}" />
</div>
<div class="form-group">
<label for="tags">Tags </label>
{{-- <x-adminlte-input type="form-control " class="form-control" id="tags" name="tags"
placeholder="Enter Tags" value="{{ old('tags') }}" /> --}}
<input type="text" name="input" class="form-control" placeholder="Add tags"
value="{{ $lead->tags }}" required>
</div>
<div class="form-group">
<label for="designation"> Designation </label>
<x-adminlte-input type=" form-control " class="form-control" id="designation" name="designation"
placeholder="Enter Designation" value="{{ $lead->designation }}" required />
</div>
{{-- <div class="form-group">
<label for="budget">Budget</label>
<x-adminlte-input type="form-control" class="form-control" id="Budget" name="Budget"
placeholder="Enter Budget" />
</div> --}}
<div class="form-group">
<label for="budget-range">Budget Range</label>
<div class="d-flex">
<x-adminlte-input type="number" class="form-control" id="minBudget" name="minBudget"
placeholder="Min Budget" value="{{ explode('-', $lead->budget)[0] ?? '' }}" />
<span class="mx-2">to</span>
<x-adminlte-input type="number" class="form-control" id="maxBudget" name="maxBudget"
placeholder="Max Budget" value="{{ explode('-', $lead->budget)[1] ?? '' }}" />
</div>
<input type="hidden" id="budget" name="budget" value="">
</div>
<div class="form-group">
<label for="email">Email</label>
<x-adminlte-input type="email" class="form-control" id="email" name="email"
placeholder="Enter Email" value="{{ $lead->email_address }}" required />
</div>
<div class="form-group">
<label for="website">Website</label>
<x-adminlte-input type="form-control" class="form-control" id="website" name="website"
placeholder="Enter website" value="{{ $lead->website }}" required />
</div>
<div class="form-group">
<label for=" phone_number"> Phone number</label>
<x-adminlte-input type="number" class="form-control" id="phone_number" name="phone_number"
placeholder="Enter Phone number" value="{{ $lead->phone }}" required />
</div>
<div class="form-group">
<label for=" mobile_number"> Mobile Number</label>
<x-adminlte-input type="number" class="form-control" id="mobile_number" name="mobile_number"
placeholder="Enter Mobile Number" value="{{ $lead->mobile_number }}" required />
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description" rows="4" placeholder="Enter Description"
required>{{ old('description', $lead->description) }}</textarea>
</div>
<div class="form-group">
<label for="last_contacted">Last Contacted</label>
<x-adminlte-input type="date" class="form-control" id="last_contacted" name="last_contacted"
placeholder="Enter Last Contacted"
value="{{ old('last_contacted', $lead->last_contacted ? \Carbon\Carbon::parse($lead->last_contacted)->format('Y-m-d') : '') }}"
required />
</div>
<div class="form-group">
<label for="next_follow_up">Next Follow Up</label>
<x-adminlte-input type="date" class="form-control" id="next_follow_up" name="next_follow_up"
placeholder="Enter Next Follow Up"
value="{{ old('next_follow_up', $lead->next_followup ? \Carbon\Carbon::parse($lead->next_followup)->format('Y-m-d') : '') }}"
required />
</div>
<div class="form-group">
<label for="address_line_1"> Adress Line 1 </label>
<x-adminlte-input type=" form-control " class="form-control" id="address_line_1"
name="address_line_1" placeholder="Enter Adress Line 1" value="{{ $lead->address_line_1 }}" />
</div>
<div class="form-group">
<label for="address_line_2"> Adress Line 2 </label>
<x-adminlte-input type=" form-control " class="form-control" id="address_line_2"
name="address_line_2" placeholder="Enter Adress Line 2" value="{{ $lead->address_line_2 }}" />
</div>
<div class="form-group">
<label for="country">Select your Country</label>
<select name="country" id="country" class="form-control select2" required>
@foreach ($countries as $key => $value)
<option value="{{ $value->id }}" {{ $lead->country == $value->id ? 'selected' : '' }}>
{{ $value->name }}
</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="state">Select your State</label>
<select name="state" id="state" class="form-control select2" required>
@foreach ($states as $state)
<option value="{{ $state->id }}" {{ $lead->state == $state->id ? 'selected' : '' }}>
{{ $state->name }}
</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="city">Select your City</label>
<select name="city" id="city" class="form-control select2" required>
@foreach ($cities as $city)
<option value="{{ $city->id }}" {{ $lead->city == $city->id ? 'selected' : '' }}>
{{ $city->name }}
</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="postal_code"> Postal Code </label>
<x-adminlte-input type=" form-control " class="form-control" id="postal_code" name="postal_code"
placeholder="Enter Postal Code" value="{{ $lead->postal_code }}" required />
</div>
<div class=" form-group">
<label for="lead_status">Lead Status</label>
<select name="lead_status" id="lead_status" class="form-control" required>
@foreach (App\Models\Lead::post_status as $key => $post_status)
<option value="{{ $key }}" {{ $key == 'converted' ? 'disabled' : '' }}
{{ $lead->status == $key ? 'selected' : '' }}>
{{ $lead_status }}</option>
@endforeach
</select>
</div>
</div>
<div class="card-footer d-flex justify-content-end">
<a href="{{ route('leads.index') }}" class="btn btn-danger mx-1">Cancel</a>
<button type="submit" class="btn btn-dark mx-1">Update</button>
</div>
</form>
</div>
@push('js')
{{-- country-state-city --}}
<script type="text/javascript">
$(document).ready(function() {
//Initialize Select2 Elements
$('.select2').select2();
$('select[name="country"]').on('change', function() {
// alert(" {{ url('/getStates') }} / + country_id ");
var country_id = $(this).val();
// alert("{{ '/getStates' }}/" + country_id);
if (country_id) {
$.ajax({
url: "{{ '/getStates' }}/" + country_id,
type: "GET",
dataType: "json",
success: function(data) {
console.log(data);
$('select[name="state"]').empty();
$.each(data, function(key, value) {
$('select[name="state"]').append(
'<option value="' +
key + '">' + value + '</option>');
});
}
});
} else {
$('select[name="state"]').empty();
}
});
$('select[name="state"]').on('change', function() {
var state_id = $(this).val();
if (state_id) {
$.ajax({
url: "{{ '/getCities' }}/" + state_id,
type: "GET",
dataType: "json",
success: function(data) {
console.log(data);
$('select[name="city"]').empty();
$.each(data, function(key, value) {
$('select[name="city"]').append('<option value="' +
key + '">' + value + '</option>');
});
}
});
} else {
$('select[name="city"]').empty();
}
});
});
// {{-- End country-state-city --}}
// tags
$(document).ready(function() {
$('input[name="input"]').tagsinput({
trimValue: true,
confirmKeys: [13, 44, 32]
});
$('.bootstrap-tagsinput input').on('focus', function() {
$(this).closest('.bootstrap-tagsinput').addClass('has-focus');
}).on('blur', function() {
$(this).closest('.bootstrap-tagsinput').removeClass('has-focus');
});
});
// End-tags
// {{-- budget-range --}}
document.addEventListener('DOMContentLoaded', function() {
const minBudgetInput = document.getElementById('minBudget');
const maxBudgetInput = document.getElementById('maxBudget');
const budgetInput = document.getElementById('budget');
function updateBudgetField() {
const minBudget = minBudgetInput.value || 0; // Ensure default value is 0 if empty
const maxBudget = maxBudgetInput.value || 0; // Ensure default value is 0 if empty
budgetInput.value = `${minBudget}-${maxBudget}`;
}
minBudgetInput.addEventListener('input', updateBudgetField);
maxBudgetInput.addEventListener('input', updateBudgetField);
// Initialize budget field on load
updateBudgetField();
});
// end budget-range
// OrganizationName field
$(document).ready(function() {
function toggleOrganizationName() {
if ($('#is_organization').is(':checked')) {
$('#organization_name').prop('disabled', false);
} else {
$('#organization_name').prop('disabled', true);
}
}
// Initial check
toggleOrganizationName();
// Listen for changes
$('#is_organization').change(function() {
toggleOrganizationName();
});
});
// End OrganizationName field
</script>
@endpush
@stop