242 lines
13 KiB
PHP
242 lines
13 KiB
PHP
<?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() . "product_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
|
<ol class="breadcrumb m-0">
|
|
|
|
</li>
|
|
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
|
|
<li class="breadcrumb-item active">Datatables</li> -->
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="header-title"></h4>
|
|
<form action="<?= base_url() . "add_purchase"; ?>" method="post">
|
|
<h4 class="header-title">Purchase Details :</h4><br>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="make" class="col-form-label">Product<span class="text-danger">*</span></label>
|
|
<select class="form-control" name="product_id" id="product_id">
|
|
<option value="0">Select Product</option>
|
|
<?php foreach ($product as $item): ?>
|
|
<option value="<?= $item['product_id'] ?>"><?= $item['product_name'] ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="model" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="vendor_id" id="vendor_id">
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="inputEmail4" class="col-form-label">Product Quantity<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="product_quantity" id="product_quantity" placeholder="Product Quantity" value="<?= isset($products['product_quantity']) ? $products['product_quantity'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="vendor" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="unit_price" id="unit_price">
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="vendor" class="col-form-label">Total Price<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="total_price" id="total_price">
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="order_date" class="col-form-label">Order Date</label>
|
|
<input type="date" class="form-control" name="order_date" id="order_date" value="<?= isset($purchase['order_date']) ? $purchase['order_date'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="contact_person_name" class="col-form-label">Contact Person Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="contact_person_name" id="contact_person_name" placeholder="Contact Person Name.."value="<?= isset($purchase['contact_person_name']) ? $purchase['contact_person_name'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="contact_person_mobile" class="col-form-label">Contact Person Mobile<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="contact_person_mobile" id="contact_person_mobile" placeholder="Contact Person Mobile" value="<?= isset($purchase['contact_person_mobile']) ? $purchase['contact_person_mobile'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="purchase_status" class="col-form-label">Purchase Status<span class="text-danger">*</span></label>
|
|
<select name="purchase_status" id="purchase_status" class="form-control">
|
|
<option value="draft">Draft</option>
|
|
<option value="released">Released</option>
|
|
<option value="cancel">Cancel</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<h4 class="header-title">Billing Addresss :</h4><br>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-3">
|
|
<label for="billing_addresss" class="col-form-label">Billing Addresss<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="billing_addresss" id="billing_addresss" placeholder="Billing Addresss"value="<?= isset($purchase['billing_addresss']) ? $purchase['billing_addresss'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-3" >
|
|
<label for="billing_state" class="col-form-label">Billing State</label>
|
|
<input type="text" class="form-control" name="billing_state" id="billing_state" placeholder="Billing State"value="<?= isset($purchase['billing_state']) ? $purchase['billing_state'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="Billing City" class="col-form-label">Billing City<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="billing_city" id="billing_city" placeholder="Billing City"value="<?= isset($purchase['billing_city']) ? $purchase['billing_city'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="Billing Postal Code" class="col-form-label">Billing Pin Code<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="billing_postal_code" id="billing_postal_code" placeholder="Billing Pin Code"value="<?= isset($purchase['billing_postal_code']) ? $purchase['billing_postal_code'] : '' ?>" required>
|
|
</div>
|
|
|
|
</div><br>
|
|
<h4 class="header-title">Shipping Addresss :</h4><br>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-3">
|
|
<label for="shipping_addresss" class="col-form-label">Shipping Addresss<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="shipping_addresss" id="shipping_addresss" placeholder="Shipping Addresss"value="<?= isset($purchase['shipping_addresss']) ? $purchase['shipping_addresss'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-3" >
|
|
<label for="shipping_state" class="col-form-label">Shipping State</label>
|
|
<input type="text" class="form-control" name="shipping_state" id="shipping_state" placeholder="Shipping State"value="<?= isset($purchase['shipping_state']) ? $purchase['shipping_state'] : '' ?>" >
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="Shipping City" class="col-form-label">Shipping City<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="shipping_city" id="shipping_city" placeholder="Shipping City"value="<?= isset($purchase['shipping_city']) ? $purchase['shipping_city'] : '' ?>" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="Shipping Postal Code" class="col-form-label">Shipping Pin Code<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="shipping_postal_code" id="shipping_postal_code" placeholder="Shipping Pin Code"value="<?= isset($purchase['shipping_postal_code']) ? $purchase['shipping_postal_code'] : '' ?>" required>
|
|
</div>
|
|
</div><br>
|
|
<h4 class="header-title">Description Details :</h4><br>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-12">
|
|
<label for="inputPassword4" class="col-form-label">Description</label>
|
|
<textarea class="form-control" name="description" placeholder="Description"value="<?= isset($products['description']) ? $products['description'] : '' ?>" required>
|
|
</textarea>
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php include('layout/footer.php'); ?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Check SGST checkbox by default
|
|
$('#sgstCheckbox').prop('checked', true);
|
|
$('#sgstValue').removeClass('d-none');
|
|
|
|
// Check CGST checkbox by default
|
|
$('#cgstCheckbox').prop('checked', true);
|
|
$('#cgstValue').removeClass('d-none');
|
|
|
|
// Handle change event for SGST checkbox
|
|
$('#sgstCheckbox').change(function() {
|
|
if ($(this).is(":checked")) {
|
|
$('#sgstValue').removeClass('d-none');
|
|
} else {
|
|
$('#sgstValue').addClass('d-none');
|
|
}
|
|
});
|
|
|
|
// Handle change event for CGST checkbox
|
|
$('#cgstCheckbox').change(function() {
|
|
if ($(this).is(":checked")) {
|
|
$('#cgstValue').removeClass('d-none');
|
|
} else {
|
|
$('#cgstValue').addClass('d-none');
|
|
}
|
|
});
|
|
});
|
|
|
|
</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() {
|
|
$('#product_id').change(function() {
|
|
var product_id = $(this).val();
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url('get_product/') ?>' + product_id,
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
console.log(response);
|
|
|
|
if (response) {
|
|
$('#unit_price').val(response.unit_price);
|
|
$('#vendor_id').val(response.vendor_name);
|
|
$('#vendor_id').attr('data-id', response.prefered_vendor);
|
|
|
|
$('#product_quantity').val(response.reorder_level);
|
|
$('#contact_person_name').val(response.contact_person_name1);
|
|
$('#contact_person_mobile').val(response.contact_person_mobile1);
|
|
$('#total_price').val(response.unit_price * response.reorder_level);
|
|
|
|
|
|
var currentDate = new Date().toISOString().split('T')[0]; // Get current date in yyyy-mm-dd format
|
|
$('#order_date').val(currentDate);
|
|
|
|
|
|
$('#shipping_addresss').val(response.branch.address);
|
|
$('#shipping_state').val(response.branch.state);
|
|
$('#shipping_city').val(response.branch.city);
|
|
$('#shipping_postal_code').val(response.branch.postal_code);
|
|
|
|
|
|
$('#billing_addresss').val(response.business.address);
|
|
$('#billing_state').val(response.business.state);
|
|
$('#billing_city').val(response.business.city);
|
|
$('#billing_postal_code').val(response.business.postal_code);
|
|
console.log(response.branch);
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Handle error
|
|
console.error(xhr.responseText);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</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>
|