274 lines
16 KiB
PHP
Executable File
274 lines
16 KiB
PHP
Executable File
<?php include('layout/header.php'); ?>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<h4 class="page-title"><?php echo $page_name?></h4>
|
|
<div class="page-title-right">
|
|
<a href="<?= base_url() . "vendor_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
|
<ol class="breadcrumb m-0">
|
|
|
|
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<form id="vendor_form" action="<?= base_url() . "add_vendor"; ?>" method="post">
|
|
<h4 class="header-title">Vendor Details :</h4>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Vendor Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="vendor_name" placeholder="Vendor Name" value="<?= isset($vendor['vendor_name']) ? $vendor['vendor_name'] : '' ?>" required>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Email<span class="text-danger">*</span></label>
|
|
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vendor['vendor_email']) ? $vendor['vendor_email'] : '' ?>" required>
|
|
</div>
|
|
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Category<span class="text-danger"></span></label>
|
|
|
|
<select class="form-control status-select SelExample" name="category" required data-toggle="select2">
|
|
<option value="">Select Category</option>
|
|
<?php
|
|
if (isset($vendor['vendor_id']) && $vendor['vendor_id']) {
|
|
foreach ($productcategory as $category) :
|
|
$isDisabled = ((int)$category['isactive'] == 0);
|
|
$isSelected = (isset($vendor['category']) && $vendor['category'] === $category['product_category_name']); ?>
|
|
|
|
<option value="<?= $category['product_category_name'] ?>"
|
|
<?php if ($isSelected) echo "selected"; ?>
|
|
<?= $isDisabled ? 'disabled' : ''; ?>>
|
|
<?= $category['product_category_name'] . ($isDisabled ? " (Disabled)" : ""); ?>
|
|
</option>
|
|
|
|
<?php endforeach;
|
|
} else {
|
|
foreach ($productcategory as $category) :
|
|
if ((int)$category['isactive'] == 1) { ?>
|
|
<option value="<?= $category['product_category_name'] ?>">
|
|
<?= $category['product_category_name']; ?>
|
|
</option>
|
|
<?php }
|
|
endforeach;
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="inputEmail4" class="col-form-label">GST Number<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="gstnumber" placeholder="GST Number" value="<?= isset($vendor['gstnumber']) ? $vendor['gstnumber'] : '' ?>" pattern="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}[Z]{1}[0-9A-Z]{1}" title="Enter a valid GST Number">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="inputPassword4" class="col-form-label">Vendor Type<span class="text-danger">*</span></label>
|
|
<select class="form-control " name="vendortype" required data-toggle="select2" >
|
|
<option value="">Select a Type</option>
|
|
<option value="Retailer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Retailer' ? 'selected' : '' ?>>Retailer</option>
|
|
<option value="Authorised Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Authorised Dealer' ? 'selected' : '' ?>>Authorised Dealer</option>
|
|
<option value="Wholesale Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Wholesale Dealer' ? 'selected' : '' ?>>Wholesale Dealer</option>
|
|
<option value="Wholesale OEM Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Wholesale OEM Dealer' ? 'selected' : '' ?>>Wholesale OEM Dealer</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
|
|
<select class="form-control SelExample" id="manufacturer" name="manufacturer[]" required multiple>
|
|
<option value="">Select a Manufacturer</option>
|
|
<?php if(isset($manufacturers) && !empty($manufacturers)): ?>
|
|
<?php foreach($manufacturers as $value): ?>
|
|
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($vendor['manufacturer_id']) && in_array($value['manufacturer_id'], json_decode($vendor['manufacturer_id'], true)) ? 'selected' : '' ?>>
|
|
<?= $value['manufacturer_name'] ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
</select>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<br>
|
|
<h4 class="header-title">Contact Person Details :</h4>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="contact_person_name1" placeholder="Name" value="<?= isset($vendor['contact_person_name1']) ? $vendor['contact_person_name1'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="contact_person_mobile1" placeholder="Mobile" value="<?= isset($vendor['contact_person_mobile1']) ? $vendor['contact_person_mobile1'] : '' ?>" minlength="6" maxlength="16" onkeypress = "return onlyNumbers(event)" required/>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Designation<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="contact_person_designation1" placeholder="Designation" value="<?= isset($vendor['contact_person_designation1']) ? $vendor['contact_person_designation1'] : '' ?>" required/>
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Name</label>
|
|
<input type="text" class="form-control" name="contact_person_name2" placeholder="Name" value="<?= isset($vendor['contact_person_name2']) ? $vendor['contact_person_name2'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Mobile</label>
|
|
<input type="text" class="form-control" name="contact_person_mobile2" placeholder="Mobile" value="<?= isset($vendor['contact_person_mobile2']) ? $vendor['contact_person_mobile2'] : '' ?>" minlength="8" maxlength="16" onkeypress = "return onlyNumbers(event)" />
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Designation</label>
|
|
<input type="text" class="form-control" name="contact_person_designation2" placeholder="Designation" value="<?= isset($vendor['contact_person_designation2']) ? $vendor['contact_person_designation2'] : '' ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Name</label>
|
|
<input type="text" class="form-control" name="contact_person_name3" placeholder="Name" value="<?= isset($vendor['contact_person_name3']) ? $vendor['contact_person_name3'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Mobile</label>
|
|
<input type="text" class="form-control" name="contact_person_mobile3" placeholder="Mobile" value="<?= isset($vendor['contact_person_mobile3']) ? $vendor['contact_person_mobile3'] : '' ?>" maxlength="16" minlength="6" onkeypress = "return onlyNumbers(event)" />
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputAddress" class="col-form-label">Designation</label>
|
|
<input type="text" class="form-control" name="contact_person_designation3" placeholder="Designation" value="<?= isset($vendor['contact_person_designation3']) ? $vendor['contact_person_designation3'] : '' ?>" />
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" id="vendor_id" name="vendor_id" value="<?= isset($vendor['vendor_id']) ? $vendor['vendor_id'] : '' ?>">
|
|
<h4 class="header-title">Vendor Address Information :</h4>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="inputPassword4" class="col-form-label">Address</label>
|
|
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($vendor['address']) ? $vendor['address'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="inputPassword4" class="col-form-label">City</label>
|
|
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($vendor['city']) ? $vendor['city'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputPassword4" class="col-form-label">State</label>
|
|
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($vendor['state']) ? $vendor['state'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputPassword4" class="col-form-label">Country</label>
|
|
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($vendor['country']) ? $vendor['country'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputPassword4" class="col-form-label">Pin Code</label>
|
|
<input type="text" class="form-control" name="postalcode" placeholder="Pin Code"value="<?= isset($vendor['postal_code']) ? $vendor['postal_code'] : '' ?>" maxlength="6" minlength="6">
|
|
</div>
|
|
|
|
</div>
|
|
<button type="submit" id="vendor_add_submit" class="btn btn-primary" style="float:right;">Submit</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include('layout/footer.php'); ?>
|
|
</div>
|
|
<script>
|
|
function onlyNumbers(event) {
|
|
var charcode;
|
|
charcode = event.which || event.keyCode;
|
|
var input = event.target.value;
|
|
|
|
// Allow only the '+' sign as the first character and digits (0-9)
|
|
if ((charcode >= 48 && charcode <= 57) || (charcode === 43 && (input.length === 0 || (input.length === 1 && input[0] !== '+')))) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
</script>
|
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
|
<script>
|
|
$(document).ready(function(){
|
|
// Initialize select2
|
|
$(".SelExample").select2();
|
|
});
|
|
</script>
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
$('.status-select').select2({
|
|
placeholder: "Select vendor types",
|
|
allowClear: true
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Initialize select2 for the make select dropdown
|
|
$(".SelExample").select2();
|
|
|
|
// Event listener for change in make select dropdown
|
|
$("#make").on('change', function() {
|
|
var selected_makes = $(this).val(); // Get an array of selected make IDs
|
|
|
|
// AJAX request to fetch models based on selected make IDs
|
|
$.ajax({
|
|
url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: { selected_makes: selected_makes },
|
|
success: function(response) {
|
|
// Clear existing options in model select dropdown
|
|
$("#model").empty();
|
|
|
|
// Populate model select dropdown with fetched models
|
|
$.each(response, function(index, model) {
|
|
$("#model").append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
|
});
|
|
|
|
// Refresh select2 to reflect changes
|
|
$("#model").trigger('change');
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(error); // Log any errors to the console
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#vendor_add_submit').click(function (event) {
|
|
var form = document.getElementById('vendor_form');
|
|
if (form.checkValidity()) {
|
|
$(this).attr('disabled', true).text('Processing...');
|
|
$('#vendor_form').submit();
|
|
}else{
|
|
$(this).attr('disabled', false).text('Submit');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<style>
|
|
|
|
|
|
.select2-container .select2-selection--multiple .select2-selection__choice{
|
|
padding: 5px 7px 5px 0 !important;
|
|
color: #000000;
|
|
|
|
}
|
|
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
|
color:#ffffff;
|
|
background-color: #526dee;
|
|
}
|
|
.select2-container--default .select2-results__option{
|
|
border-bottom: 1px solid #dddddd;
|
|
}
|
|
.select2-container--default .select2-results__option[aria-selected=true]{
|
|
color: #000000;
|
|
background-color: #3efba4;
|
|
font-weight: 500;
|
|
border-bottom: 1px solid #747474;
|
|
}
|
|
</style>
|