FIX_remove_conflict_in_route:ss

This commit is contained in:
sriramv 2024-05-07 09:02:07 +05:30
commit bde891cb9f
20 changed files with 372 additions and 204 deletions

View File

@ -141,6 +141,8 @@ $routes->get('dashboard', 'Users::dashboard');
// Model //
$routes->get('bike_model_index/(:any)', 'Model::index/$1');
$routes->post('create_model', 'Model::create_model');
$routes->get('delete_model/(:any)', 'Model::delete_model/$1');
// $routes->post('create_model/(:any)', 'Model::create_model/$1');
$routes->post('status_model', 'Model::status_model');
// Model End's//

View File

@ -118,12 +118,13 @@ class Branch extends BaseController
{
if ($branch_id) {
$data = $this->request->getPost();
// echo "<pre>";
// print_r($data);die;
$BranchModel = new BranchModel();
// print_r($data);die;
$BranchModel->update($branch_id,$data);
return view('dashboard');
return redirect()->to('get_branch_edit_form/'.session()->get("logged_user_branch_id"));
}
}

View File

@ -31,9 +31,9 @@ class Business extends BaseController
} else if ($business_id !== '0') {
$BusinessModel = new BusinessModel();
$business=$BusinessModel->getBusinessById($business_id);
$data['business']=$business;
$data['page_name']="Edit Business" ;
$business=$BusinessModel->getBusinessById($business_id);
$data['business']=$business;
$data['page_name']="Edit Business" ;
}
$data['business_id'] = $business_id;
@ -68,18 +68,8 @@ class Business extends BaseController
$data = [
'business_name' => $this->request->getPost('businessname'),
'email' => $this->request->getPost('email'),
'address' => $this->request->getPost('address'),
'gstno' => $this->request->getPost('gstno'),
'mobile' => $this->request->getPost('mobile'),
'city' => $this->request->getPost('city'),
'state' => $this->request->getPost('state'),
'code' => $this->request->getPost('code'),
'postal_code' => $this->request->getPost('postalcode'),
'country' => $this->request->getPost('country'),
'isactive' => 1 // Assuming this is a default value or handled separately
];
// print_r($data);die;
$business_id = $this->request->getPost('business_id');
@ -92,8 +82,15 @@ class Business extends BaseController
$BusinessModel->insert($data);
}
// echo"<pre>";
// print_r(session()->get("logged_user_business_id"));die;
if (session()->get('logged_user_role') == "Administrator") {
return redirect()->to('new_business/'.session()->get("logged_user_business_id"));
}else{
return redirect()->to('business_index');
}
return redirect()->to('business_index');
}
public function delete_business($business_id)
{

View File

@ -24,7 +24,7 @@ class Make extends BaseController
{
$BikemakeModel = new BikemakeModel();
$make = $BikemakeModel->findAll();
$make = $BikemakeModel->orderBy('make')->findAll();
$data['make']=$make;
return view('make_list',$data);

View File

@ -33,7 +33,7 @@ class Model extends BaseController
$make_name= $make_value[0]['make'];
$make_id= $make_value[0]['make_id'];
$model = $BikemodelsModel->where('make_id',$make_id)->findAll();
$model = $BikemodelsModel->orderBy('model_name')->where('make_id',$make_id)->findAll();
$data['model']=$model;
$data['make_name'] =$make_name;
$data['make_id'] =$make_id;
@ -41,6 +41,23 @@ class Model extends BaseController
return view('bike_model_list',$data);
}
public function delete_model($model_id){
$BikemodelsModel = new BikemodelsModel();
$model = $BikemodelsModel->where('model_id',$model_id)->first();
if ($model) {
$delete_done = $BikemodelsModel->where('model_id',$model_id)->delete();
if($delete_done){
return json_encode("delete_done");
}
}else{
}
}
public function create_model()
{

View File

@ -29,6 +29,7 @@ class Reorderlevel extends BaseController
->join('vendor', 'vendor.vendor_id = products.prefered_vendor')
->where('products.qty_stock <= purchase_order_level')
->groupBy('products.prefered_vendor')
->orderBy('prefered_vendor_name', 'ASC')
->findAll();
// echo json_encode($reorder);die;
$data['reorder']=$reorder;

View File

@ -302,6 +302,7 @@ public function delete_sales_product()
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// Fetch the invoice data based on $invoice_id
$model = new SalesOrderModel();
$saleOrderCount = count($model->where('status','Paid')->findAll());
$VehicleModel = new VehicleModel();
$BranchModel = new BranchModel();
$BusinessModel = new BusinessModel();
@ -309,7 +310,6 @@ public function delete_sales_product()
$BikemakeModel = new BikemakeModel();
$data = $model->getSalesPdf($sales_order_id);
$bus_id = $this->session->get('logged_user_business_id');
$company_address = $BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll();
$branch = $BranchModel->where('branch_id', $data[0]->branch_id)->first();
$business = $BusinessModel->where('business_id', $branch['business_id'])->first();
$vehicle = $VehicleModel->where('vehicle_id',$data[0]->vehicle_id)->first();
@ -355,7 +355,7 @@ public function delete_sales_product()
// return view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', ['sales' => $data,'company_address'=>$company_address,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
$html = view('invoice_pdf_template', ['sales' => $data,'saleOrderCount' => $saleOrderCount,'items'=>$items,'branch'=>$branch, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);

View File

@ -26,7 +26,7 @@ class Vendor extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$VendorModel = new VendorModel();
$vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->orderBy('vendor_name')->findAll();
$data['vendor']=$vendor;
return view('vendor_list',$data);

View File

@ -5,7 +5,7 @@ class BranchModel extends Model
{
protected $table = 'branches';
protected $primaryKey = 'branch_id';
protected $allowedFields = ['business_id','branch_id','','branch_name','email','mobile_no','address','city','state','postal_code','country','isactive'];
protected $allowedFields = ['business_id','branch_id','branch_name','gstno','email','contact_1','contact_2','address','city','state','country','postal_code','state_code','isactive'];
public function getBranchesByBusinessId($business_id)
{

View File

@ -5,7 +5,7 @@ class BusinessModel extends Model
{
protected $table = 'business';
protected $primaryKey = 'business_id';
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address', 'gstno','city','state', 'code','postal_code','country','isactive'];
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','isactive'];
public function getBusinessById($business_id) {
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();

View File

@ -13,7 +13,7 @@ class SalesOrderModel extends Model
->join('branches as B','B.branch_id = sales_order.branch_id','left')
->select('sales_order.*')
->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.mobile_no as company_mobile_no')
->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no_1,B.contact_2 as company_mobile_no_2')
->get()
->getResult();

View File

@ -42,7 +42,7 @@
</td>
<td>
<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="<?php echo $item['model_id']; ?>" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>
<a data-value="<?php echo $item['model_id']; ?>" onclick="deleteModel(this)"><i style="color: #526dee;margin-left: 10px;" class="ri-delete-bin-line"></i></a>
<?php if($item['isactive'] == 1): ?>
<a style="color:red; margin-left:12px;" data-id="<?php echo $item['model_id']; ?>" data-isactive="<?php echo $item['isactive']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>
<?php else: ?>
@ -68,7 +68,6 @@
<div class="text-center mt-2 mb-4">
<h4 id="form_add_edit">Add Models</h4>
</div>
<form id="model_form_data" class="px-3">
<div class="form-group">
<input type="text" id="edit_model_id" hidden>
@ -83,8 +82,6 @@
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModels(this)">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
@ -95,7 +92,7 @@
<script>
function submitModels(params) {
console.log( $('#modelname').val());
// console.log( $('#modelname').val());
var formData = {
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
@ -110,43 +107,44 @@
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_model_login-modal_1').modal('hide');
$('#makename').val('');
$('#modelname').val('');
toastr.success(response.data, 'Success');
}else{
$('#bike_model_login-modal_1').modal('hide');
$('#makename').val('');
$('#modelname').val('');
toastr.success(response.data, 'Success');
$('tbody').html('');
$('tbody').html('');
$.each(response.model_list, function(index, item) {
var row = '<tr>' +
'<td class="model_name">' + item.model_name + '</td>' +
'<td>';
$.each(response.model_list, function(index, item) {
var row = '<tr>' +
'<td class="model_name">' + item.model_name + '</td>' +
'<td>';
if (item.isactive == 1) {
row += '<span style="color:green">Active</span>';
} else if (item.isactive == 0) {
row += '<span style="color:red">Inactive</span>';
}
row += '</td><td>';
row += '<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="' + item.model_id + '" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>';
// Check the isactive status and set the icon color accordingly
if (item.isactive == 1) {
row += '<span style="color:green">Active</span>';
row += '<a style="color:red; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
} else if (item.isactive == 0) {
row += '<span style="color:red">Inactive</span>';
row += '<a style="color:green; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i></a>';
}
row += '</td><td>';
row += '</td><td></td></tr>';
row += '<a data-toggle="modal" data-target="#bike_model_login-modal_1" data-value="' + item.model_id + '" class="edit-button" onclick="editModel(this)"><i class="ri-pencil-line"></i></a>';
// Check the isactive status and set the icon color accordingly
if (item.isactive == 1) {
row += '<a style="color:red; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i><i class="fa fa-times" style="font-size: x-small;"></i></a>';
} else if (item.isactive == 0) {
row += '<a style="color:green; margin-left:12px;" data-id="' + item.model_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)" ><i class="fa fa-bicycle"></i></a>';
}
row += '</td><td></td></tr>';
// Append the row to the tbody
$('tbody').append(row);
});
}
// Append the row to the tbody
$('tbody').append(row);
});
}
},
error: function(xhr, status, error) {
// Handle error response here
@ -234,6 +232,26 @@
$('#modelname').val('');
}
function deleteModel(params) {
var model_id = $(params).data('value');
$.ajax({
type: 'GET',
url: '<?php echo base_url()."delete_model/"?>'+model_id,
dataType: 'json',
success: function(response) {
console.log(response);
if (response == "delete_done") {
window.location.reload();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -21,16 +21,41 @@
<input type="text" class="form-control" name="branch_name" placeholder="Name" value="<?= isset($branch['branch_name']) ? $branch['branch_name'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($branch['mobile_no']) ? $branch['mobile_no'] : '' ?>" required maxlength="10" minlength="10">
<label for="inputPassword4" class="col-form-label">GST No</label>
<input type="text" class="form-control" name="gstno" placeholder="GSTNO"value="<?= isset($branch['gstno']) ? $branch['gstno'] : '' ?>" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12" style="margin-bottom: -7px;">
<h5>Contact Details</h5>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Email</label>
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($branch['email']) ? $branch['email'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Contact 1</label>
<input type="text" class="form-control" name="contact_1" placeholder="Contact 1" value="<?= isset($branch['contact_1']) ? $branch['contact_1'] : '' ?>" required maxlength="10" minlength="10">
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Contact 2</label>
<input type="text" class="form-control" name="contact_2" placeholder="Contact 2" value="<?= isset($branch['contact_2']) ? $branch['contact_2'] : '' ?>" required maxlength="10" minlength="10">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12" style="margin-bottom: -7px;">
<h5>Address Details</h5>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Address</label>
<!-- <textarea name="" id="" class="form-control"></textarea> -->
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($branch['address']) ? $branch['address'] : '' ?>" required>
</div>
<!-- <div class="form-group col-md-8"> -->
<!-- </div> -->
<input type="hidden" id="business_id" name="business_id" value="<?= isset($branch['business_id']) ? $branch['business_id'] : '' ?>">
<div class="form-group col-md-6">
<input type="hidden" id="business_id" name="business_id" value="<?= isset($branch['business_id']) ? $branch['business_id'] : '' ?>">
<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($branch['city']) ? $branch['city'] : '' ?>" required>
</div>
@ -38,10 +63,29 @@
<label for="inputPassword4" class="col-form-label">State</label>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($branch['state']) ? $branch['state'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Country</label>
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($branch['country']) ? $branch['country'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Postal Code</label>
<input type="text" class="form-control" name="postal_code" placeholder="Postal Code"value="<?= isset($branch['postal_code']) ? $branch['postal_code'] : '' ?>" required maxlength="6" minlength="6">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">State Code</label>
<input type="text" class="form-control" name="state_code" placeholder="Code"value="<?= isset($branch['state_code']) ? $branch['state_code'] : '' ?>" required>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>

View File

@ -24,11 +24,12 @@
<thead>
<tr>
<th>Branch Name</th>
<th>GST</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Postal Code</th>
<th>Mobile No</th>
<th>Contact</th>
<th>Active</th>
<th>User List</th>
<th>Action</th>
@ -39,11 +40,12 @@
?>
<tr>
<td><?= $value['branch_name']; ?></td>
<td><?= $value['gstno']; ?></td>
<td><?= $value['address']; ?></td>
<td><?= $value['city']; ?></td>
<td><?= $value['state']; ?></td>
<td><?= $value['postal_code']; ?></td>
<td><?= $value['mobile_no']; ?></td>
<td><?= $value['contact_1']; ?></td>
<td>
<?php if ($value['isactive'] == 0): ?>
<span style="color: red;">Inactive</span>
@ -74,7 +76,6 @@
</div> <!-- end col -->
<!-- Start Bike Make Create Pop-UP -->
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@ -82,33 +83,80 @@
<div class="text-center mt-2 mb-4">
<h4>Add Branch - <?php echo $business_name;?></h4>
</div>
<form id="model_form_data" class="px-3">
<form id="model_form_data" class="px-4">
<input type="text" id="business_id" value="<?php echo $business_id; ?>" hidden>
<input type="text" id="branch_id" hidden>
<div class="form-group">
<label for="branchname">Branch Name </label>
<input class="form-control" name="branch_name" type="text" id="branch_name" required="" placeholder="Branch Name....">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="branchname">Branch Name</label>
<input class="form-control" name="branch_name" type="text" id="branch_name" required="" placeholder="Branch Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="gstno">GST No</label>
<input class="form-control" name="gst_no" type="text" id="gst_no" required="" placeholder="GST No">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" name="email" type="email" id="email" required="" placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact1">Contact 1</label>
<input class="form-control" name="contact_1" type="text" id="contact_1" required="" placeholder="Contact 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact2">Contact 2</label>
<input class="form-control" name="contact_2" type="text" id="contact_2" required="" placeholder="Contact 2">
</div>
</div>
</div>
<div class="form-group">
<label for="address">Address </label>
<input class="form-control" name="address" type="text" id="address" required="" placeholder="Address....">
</div>
<div class="form-group">
<label for="city">City </label>
<input class="form-control" name="city" type="text" id="city" required="" placeholder="City....">
</div>
<div class="form-group">
<label for="state">State </label>
<input class="form-control" name="state" type="text" id="state" required="" placeholder="State....">
</div>
<div class="form-group">
<label for="pincode">Pin Code </label>
<input class="form-control" name="postal_code" type="text" id="postal_code" required="" placeholder="Pin Code....">
</div>
<div class="form-group">
<label for="mobilenumber">Mobile Number </label>
<input class="form-control" name="mobile_no" type="text" id="mobile_no" required="" placeholder="Mobile Number....">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="address">Address</label>
<input class="form-control" name="address" type="text" id="address" required="" placeholder="Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="city">City</label>
<input class="form-control" name="city" type="text" id="city" required="" placeholder="City">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="state">State</label>
<input class="form-control" name="state" type="text" id="state" required="" placeholder="State">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="pincode">Country</label>
<input class="form-control" name="country" type="text" id="country" required="" placeholder="Country">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="pincode">Pin Code</label>
<input class="form-control" name="postal_code" type="text" id="postal_code" required="" placeholder="Postal Code">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="statecode">State Code</label>
<input class="form-control" name="state_code" type="text" id="state_code" required="" placeholder="State Code">
</div>
</div>
</div>
<div class="form-group text-center">
@ -120,6 +168,7 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- End Bike Make Create Pop-UP -->
</div>
@ -180,14 +229,18 @@
dataType: 'json',
success: function(response) {
// console.log(response);
$('#branch_name').val(response.branch_name);
$('#gst_no').val(response.gstno);
$('#email').val(response.email);
$('#contact_1').val(response.contact_1);
$('#contact_2').val(response.contact_2);
$('#address').val(response.address);
$('#branch_id').val(response.branch_id);
$('#city').val(response.city);
$('#mobile_no').val(response.mobile_no);
$('#postal_code').val(response.postal_code);
$('#state').val(response.state);
$('#country').val(response.country);
$('#state_code').val(response.state_code);
},
error: function(xhr, status, error) {

View File

@ -20,47 +20,8 @@
<label for="inputEmail4" class="col-form-label">Business Name</label>
<input type="text" class="form-control" name="businessname" placeholder="Name" value="<?= isset($business['business_name']) ? $business['business_name'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputEmail4" class="col-form-label">Email</label>
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($business['email']) ? $business['email'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputAddress" class="col-form-label">Mobile</label>
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($business['mobile']) ? $business['mobile'] : '' ?>" required maxlength="10" minlength="10">
</div>
<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($business['address']) ? $business['address'] : '' ?>" required>
</div>
</div>
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">GST No</label>
<input type="text" class="form-control" name="gstno" placeholder="GSTNO"value="<?= isset($business['gstno']) ? $business['gstno'] : '' ?>" required>
</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($business['city']) ? $business['city'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">State</label>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($business['state']) ? $business['state'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">State Code</label>
<input type="text" class="form-control" name="code" placeholder="Code"value="<?= isset($business['code']) ? $business['code'] : '' ?>" required>
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Postal Code</label>
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($business['postal_code']) ? $business['postal_code'] : '' ?>" required maxlength="6" minlength="6">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Country</label>
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($business['country']) ? $business['country'] : '' ?>" required>
</div>
</div>
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>

View File

@ -12,8 +12,8 @@
.business-logo-container {text-align: center;}
img.business-logo {max-width: 200px;}
.business-name {font-size: 16px;font-weight: bold;margin-top: 10px;}
table.invoice-info-table {width: 100%;}
table.invoice-info-table th,table.invoice-info-table td {text-align: right;}
table.invoice-info-table {width: 110%;}
/* table.invoice-info-table th,table.invoice-info-table td {text-align: right;} */
table.addresses-table {width: 100%;}
table.addresses-table th {text-align: left;padding-left: 8px;}
.billing-address {width: 50%;padding-left: 8px;}
@ -31,8 +31,11 @@
td.invoice-number {font-size: 18px;font-weight: bold; /* Make the text bold */}
p {margin-top: 0;margin-bottom: 0rem;}
.invoice-info-table {border-collapse: collapse;}
.invoice-info-table td {border: 1px solid black;width: 100px;}
.invoice-info-table td {border: 1px solid black;}
.invoice-info-table tr:first-child td {border-top: none;}
.invoice-info-table tr:first-child td {border-right: none;}
.invoice-info-table tr td:nth-child(2) {border-left: none;}
.invoice-info-table tr:first-child td {border-bottom: none;}
.invoice-info-table tr:last-child td {border-bottom: none;}
.invoice-info-table tr td:first-child {border-left: none;}
.invoice-info-table tr td:last-child {border-right: none;}
@ -50,28 +53,29 @@
<?php foreach ($sales as $value) : ?>
<tr>
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
THE MECHANIC
<?= $business['business_name'] ?>
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
</td>
</tr>
<tr>
<td>
<p><?= $value->company_address ?>,<br>
<p style="margin-top: -15px;"><?= $value->company_address ?>,<br>
<?= $value->company_city ?>,
<?= $value->company_state ?>
<?= $value->company_postal_code ?>.</p>
<?= $value->company_postal_code ?>.<br>
<p><?= $value->company_mobile_no ?></p>
<!-- <?= $value->company_mobile_no_1 ?>, <?= $value->company_mobile_no_2 ?> -->
</p>
</td>
</tr>
<tr>
<td>
<div ><span>GSTIN: <?php echo $business['gstno']?> </span><br>
<span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<span>Contact : <?php echo $business['mobile']?></span><br>
<span>Email : <?php echo $business['email']?></span><br><br>
<span>Buyer (Bill To) </span>
<div style="margin-top: -20px;"><span>GSTIN: <?php echo $branch['gstno']?> </span><br>
<span>State Name: <?php echo $branch['state']?> , Code: <?php echo $branch['state_code']?> </span><br>
<span>Contact : <?php echo $branch['contact_1']?>, <?php echo $branch['contact_2']?></span><br>
<span>Email : <?php echo $branch['email']?></span><br><br>
<span ><b>Buyer (Bill To) </b> </span>
</div>
</td>
</tr>
@ -85,39 +89,50 @@
<td>
<table class="invoice-info-table" >
<tbody >
<tr>
<td>Invoice No.</td><td><?= $sales[0]->order_number ?></td>
<tr><?php $currentYear = date('y');
$nextYear = date('y', strtotime('+1 year'));
$yearRange = $currentYear . '-' . $nextYear;
$businessName = trim($business['business_name']);
$words = explode(' ', $businessName);
$initials = '';
foreach ($words as $word) {
$word = preg_replace("/[^A-Za-z]/", '', $word);
$initials .= strtoupper(substr($word, 0, 1));
}
?>
<td>Invoice No.</td><td><?= $initials ."/".$yearRange."/" . $saleOrderCount+1 ?></td>
</tr>
<tr>
<td>Dated</td><td><?= date('Y-m-d', strtotime($sales[0]->created_at)) ?></td>
<td>Date</td><td><?= date('Y-m-d', strtotime($sales[0]->created_at)) ?></td>
</tr>
<tr>
<td>Bike Name</td><td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
<td>Bike Make & Model</td><td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
</tr>
<tr>
<td>Colour</td><td><?php echo $vehicle['colour']?></td>
</tr>
<tr>
<td>Bike Number</td><td><?php echo $vehicle['reg_no']?></td>
<td>Register Number</td><td><?php echo $vehicle['reg_no']?></td>
</tr>
<tr>
<td>Contact Number</td><td><?php echo $vehicle['mobile_no']?></td>
</tr>
<tr>
<td>Sale Order No. </td><td><?= $sales[0]->sales_order_id ?></td>
<td>Sale Order No </td><td><?= $sales[0]->order_number ?></td>
</tr>
<tr>
<td>Delivery Date</td><td>5</td>
</tr>
<tr>
<td>Mode Of Payment</td><td><?= $sales[0]->mode_of_payment ?></td>
<td>Payment Mode</td><td><?= (isset($sales[0]->mode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<table class="addresses-table">
<table class="addresses-table" style="margin-top: -10px;">
<tr >
<td class="billing-address">
@ -167,21 +182,21 @@
<td style="border: 1px solid black;">
<?= $serialNumber++; ?>
</td>
<td style="border-right: 0.5px solid black;"><?= $item->product_name ?></td>
<td style="border-right: 0.5px solid black;"> <?php echo number_format($amountWithoutTax, 2, '.', ','); ?></td>
<td style="border-right: 0.5px solid black;"><?= $item->qty ?></td>
<td style="border-right: 0.5px solid black;">nos</td>
<td style="border-right: 0.5px solid black;"><?= $item->tax ?>%</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border: 0.5px solid black;"><?php echo $taxable_amount * $item->tax / 100 ?></td>
<td style="border: 0.5px solid black;"><?= $item->product_name ?></td>
<td style="border: 0.5px solid black;"><?= $item->net_price; ?></td>
<td style="border: 0.5px solid black;"><?= $item->qty ?></td>
<td style="border: 0.5px solid black;">nos</td>
<td style="border: 0.5px solid black;"><?= $taxable_amount ?></td>
<td style="border: 0.5px solid black;"><?= $item->tax ?>%</td>
<td style="border: 0.5px solid black;"><?= $cgst ?></td>
<td style="border: 0.5px solid black;"><?= $sgst ?></td>
<td style="border: 0.5px solid black;"><?= $cgst + $sgst ?></td>
<td style="border: 0.5px solid black;"><?= $item->amount ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="6" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
<td colspan="7" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Total Taxable Value</td>
<td style="border: 0.5px solid black;"><?= $sales[0]->tax ?></td>
</tr>
@ -208,7 +223,7 @@
<tr><td></td></tr>
<tr>
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesnt require signature</p></td>
<td colspan="3" style="border: 0.5px solid black;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
<td colspan="4" style="border: 0.5px solid black;text-align: center;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
</tr>
</tbody>
</table>

View File

@ -201,37 +201,39 @@
$('#bike_make_name').val('');
toastr.success(response.data, 'Success');
$('tbody').html('');
// $('tbody').html('');
$.each(response.make_list, function(index, item) {
var row = '<tr>' +
'<td class="make">' + item.make + '</td>' +
'<td>';
window.location.reload();
if (item.isactive == 1) {
row += '<span style="color:green">Active</span>';
} else if (item.isactive == 0) {
row += '<span style="color:red">Inactive</span>';
}
// $.each(response.make_list, function(index, item) {
// var row = '<tr>' +
// '<td class="make">' + item.make + '</td>' +
// '<td>';
row += '</td><td>';
// if (item.isactive == 1) {
// row += '<span style="color:green">Active</span>';
// } else if (item.isactive == 0) {
// row += '<span style="color:red">Inactive</span>';
// }
// Check the isactive status and set the icon color accordingly
row += '<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="'+ item.make_id +'" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line" style="font-size:20px;"></i></a>';
// row += '</td><td>';
row +='<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="'+ item.make_id+'" data-value="' +item.make+'" onclick="setMakeName(this)"><i class="ri-add-line icon-large" style="font-size:20px;"></i></a>';
row +='<a href="bike_model_index/' +item.make_id+'" class="view-list-button" title="Model List" style="margin-left: 12px;"><i class="ri-list-check-2 icon-large" style="font-size:20px;"></i></a>';
if (item.isactive == 1) {
row += '<a style="color:red; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i><i class="fa fa-times" style="font-size: x-small;" style="font-size:20px;"></i></a>';
} else if (item.isactive == 0) {
row += '<a style="color:green; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i></a>';
}
// // Check the isactive status and set the icon color accordingly
// row += '<a data-toggle="modal" data-target="#bike_make_login-modal" data-value="'+ item.make_id +'" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line" style="font-size:20px;"></i></a>';
row += '</td><td></td></tr>';
// row +='<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="'+ item.make_id+'" data-value="' +item.make+'" onclick="setMakeName(this)"><i class="ri-add-line icon-large" style="font-size:20px;"></i></a>';
// row +='<a href="bike_model_index/' +item.make_id+'" class="view-list-button" title="Model List" style="margin-left: 12px;"><i class="ri-list-check-2 icon-large" style="font-size:20px;"></i></a>';
// if (item.isactive == 1) {
// row += '<a style="color:red; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Deactivate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i><i class="fa fa-times" style="font-size: x-small;" style="font-size:20px;"></i></a>';
// } else if (item.isactive == 0) {
// row += '<a style="color:green; margin-left:12px;" data-id="' + item.make_id + '" data-isactive="' + item.isactive + '" title="Activate" onclick="statusChange(this)"><i class="fa fa-bicycle" style="font-size:20px;"></i></a>';
// }
// Append the row to the tbody
$('tbody').append(row);
});
// row += '</td><td></td></tr>';
// // Append the row to the tbody
// $('tbody').append(row);
// });
}
},

View File

@ -105,6 +105,7 @@
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger"></span></label>
<select class="form-control status-select SelExample" name="productcategory" required data-toggle="select2">
<option value="" >Select Category</option>
<option value="Bearings" <?= (isset($products['product_category']) && $products['product_category'] == 'Tanks') ? 'selected' : '' ?>>Tanks</option>
<option value="Bearings" <?= (isset($products['product_category']) && $products['product_category'] == 'Bearings') ? 'selected' : '' ?>>Bearings</option>
<option value="Paste" <?= (isset($products['product_category']) && $products['product_category'] == 'Paste') ? 'selected' : '' ?>>Paste</option>
<option value="Clutch Plates" <?= (isset($products['product_category']) && $products['product_category'] == 'Clutch Plates') ? 'selected' : '' ?>>Clutch Plates</option>

View File

@ -150,11 +150,13 @@
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<th>Rate</th>
<th>Qty</th>
<th>Taxable Amount</th>
<th>Tax</th>
<th>Tax Amount</th>
<!-- <th style="text-align: center !important" colspan="2">Discount</th> -->
<th>Amount</th>
<th>Total Amount</th>
<th hidden></th>
<th></th>
</tr>
@ -166,7 +168,7 @@
<?php foreach ($sales_product as $salechild) :
if ($salechild['isactive'] == 1) : ?>
<tr>
<td>
<td style="width:5%;">
<select class="form-control book-select SelExample" name="item_details[]"
required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
@ -186,19 +188,34 @@
<?php endforeach; ?>
</select>
</td>
<td style="width:10%;">
<input type="number" class="form-control item-quantity" name="quantity[]"
min="0"
value="<?= isset($salechild['qty']) ? $salechild['qty'] : '1' ?>">
</td>
<td style="width:10%;">
<input type="text" class="form-control item-rate" name="unit-price[]"
readonly
value="<?= isset($salechild['net_price']) ? $salechild['net_price'] : '' ?>">
</td>
<td style="width:10%;">
<input type="number" class="form-control item-quantity" name="quantity[]"
min="0"
value="<?= isset($salechild['qty']) ? $salechild['qty'] : '1' ?>" onchange="updateThirdColumnValue(this); updateTaxAmount(this)">
</td>
<td style="width:12%;">
<?php if (isset($salechild['net_price']) && isset($salechild['qty'])) {
$result = $salechild['net_price'] * $salechild['qty'];
echo '<input type="text" class="form-control item-result" value="' . $result . '" readonly>';
} ?>
</td>
<td style="width:10%;">
<input type="text" class="form-control item-tax" name="item-tax[]"
value="<?= isset($salechild['tax']) ? $salechild['tax'] : '' ?>">
value="<?= isset($salechild['tax']) ? $salechild['tax'] : '' ?>" onchange="updateTaxAmount(this)">
</td>
<td>
<?php if (isset($salechild['tax']) && isset($result) ) {
$tax_amount= $result * $salechild['tax'] / 100;
} else {
$tax_amount=0 ;
}
?>
<input type="text" class="form-control" name="tax-amount[]" value="<?= $tax_amount; ?>" readonly>
</td>
<!-- <td style="width:12%;">
<input type="number" class="form-control item-discount-amount" min="0" name="discount_amount[]" value="<?= isset($salechild['discount']) ? $salechild['discount'] : '' ?>">
@ -216,7 +233,7 @@
<td hidden><input type="hidden"
value="<?= isset($salechild['sales_order_product_id']) ? $salechild['sales_order_product_id'] : '' ?>"
name="sales_order_product_id[]"></td>
<td style="width:12%;">
<td style="width:7%;">
<center><i class="fa fa-trash remove-item"></i></center>
</td>
</tr>
@ -517,15 +534,17 @@ $(document).ready(function() {
// Calculate total tax by adding CGST and SGST
var tax = cgst + sgst;
$(row).find('.item-tax').val(tax.toFixed(2));
// console.log("tax");
// console.log(tax);
$(row).find('.item-tax').val(tax);
var rate = $(row).find('.item-rate').val();
var quantity = $(row).find('.item-quantity').val();
var amount = rate * quantity;
console.log(amount);
// console.log(amount);
var taxamount = amount * tax / 100;
var finalamt = amount + taxamount;
console.log("samount".samount);
// console.log("samount".samount);
$(row).find('.item-amount').val(finalamt);
}
@ -536,17 +555,27 @@ $(document).ready(function() {
var quantity = $(this).closest('tr').find('.item-quantity').val(1);
// Find product details from JSON
var product = products.find(function(item) {
return item.product_id == productId;
});
var cgst = parseInt(product.cgst);
var sgst = parseInt(product.sgst);
var totalTax = cgst + sgst;
var total_tax_amount = parseInt(product.unit_price) * totalTax / 100;
$(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
// Access unit price from product and set it as rate
var unitPrice = parseFloat(product.unit_price); // Convert to float if necessary
$(this).closest('tr').find('.item-rate').val(unitPrice);
$(this).closest('tr').find('.item-result').val(unitPrice);
$(this).closest('tr').find('.tax-amount').val(total_tax_amount);
// Calculate amount and update amount input field
calculateAmount($(this).closest('tr'));
@ -651,9 +680,11 @@ $(document).ready(function() {
}
newRow += '</select></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]"/></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" /></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-result" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
@ -978,4 +1009,29 @@ $(document).on('click', '#selectClient', function() {
$('#mode_of_payment').removeAttr('required');
}
})
</script>
<script>
function updateThirdColumnValue(input) {
const itemRate = parseFloat(input.parentNode.previousElementSibling.querySelector('.item-rate').value);
const quantity = parseFloat(input.value);
const result = itemRate * quantity;
input.parentNode.nextElementSibling.querySelector('.item-result').value = result;
}
function updateThirdColumnValue(input) {
const itemRate = parseFloat(input.parentNode.previousElementSibling.querySelector('.item-rate').value);
const quantity = parseFloat(input.value);
const result = itemRate * quantity;
input.parentNode.nextElementSibling.querySelector('.item-result').value = result;
// After updating the third column, also update tax amount
updateTaxAmount(input);
}
function updateTaxAmount(input) {
const row = input.closest('tr');
const itemResult = parseFloat(row.querySelector('.item-result').value);
const taxValue = parseFloat(row.querySelector('.item-tax').value);
const taxAmount = itemResult * taxValue / 100;
row.querySelector('[name="tax-amount[]"]').value = taxAmount; // Ensure two decimal places
}
</script>

View File

@ -82,7 +82,7 @@
</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'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" required/>
<input type="text" class="form-control" name="contact_person_mobile1" placeholder="Mobile" value="<?= isset($vendor['contact_person_mobile1']) ? $vendor['contact_person_mobile1'] : '' ?>" minlength="8" 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>
@ -96,7 +96,7 @@
</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'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" />
<input type="text" class="form-control" name="contact_person_mobile2" placeholder="Mobile" value="<?= isset($vendor['contact_person_mobile2']) ? $vendor['contact_person_mobile2'] : '' ?>" minlength="8" onkeypress = "return onlyNumbers(event)" />
</div>
<div class="form-group col-md-4">
<label for="inputAddress" class="col-form-label">Designation</label>