Book Module 1 : ps

This commit is contained in:
VE10-Sanjeev 2023-12-26 19:08:02 +05:30
parent 47428911e7
commit 482bbf1576
6 changed files with 194 additions and 232 deletions

View File

@ -63,44 +63,58 @@ class Books extends BaseController
## For inserting/updating details of book
public function insert_books()
{
try{
helper('session');
$session_uid = get_logged_user_id();
$session_bid = get_business_id();
$BooksModel = new BooksModel();
$data = [
'title' => $this->request->getPost('title'),
'publication_date' => $this->request->getPost('publication_date'),
'publisher' => $this->request->getPost('publisher'),
'genre' => $this->request->getPost('genre'),
'language' => $this->request->getPost('language'),
'description' => $this->request->getPost('description'),
'page_count' => $this->request->getPost('page_count'),
'price' => $this->request->getPost('price'),
'isbn_code' => $this->request->getPost('isbn_code'),
'tax'=>$this->request->getPost('tax'),
'business_id'=>$session_bid
];
$book_id = $this->request->getPost('book_id'); // Get the book ID for update purpose
if (empty($book_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$bookId = $BooksModel->insert($data);
// Retrieve the selected category ID from the form
$category_id = $this->request->getPost('category_id');
if ($category_id) {
// Insert the book-category association into the book_categories table
$BooksModel->db->table('book_categories')->insert(['book_id' => $bookId, 'category_id' => $category_id]);
$requested_details = $this->request->getPost();
try{
$session_uid = get_logged_user_id();
$session_bid = get_business_id();
$BooksModel = new BooksModel();
$book_id = $requested_details['book_id'];
if (empty($book_id )) {
$requested_details['created_by'] = (int)$session_uid;
if ($BooksModel->insert($requested_details)) {
$book_id = $BooksModel->insertID();
session()->setFlashdata('success', 'product successfully created.');
$this->logger->info("Books: has been added successfully. Inserted ID = " . $book_id);
} else {
session()->setFlashdata('error', 'product could not be created. Please try again..');
$this->logger->error("Books: Err could not be added. Please try again.");
}
} else {
$isactive = $this->request->getPost('isactive');
$requested_details['isactive'] = ($isactive == 'on') ? 1 : 0;
$requested_details['updated_by'] = (int)$session_uid;
if ($BooksModel->update($book_id, $requested_details)) {
$book_affectedRows = $BooksModel->db->affectedRows();
session()->setFlashdata('success', 'product successfully updated.');
$this->logger->info("Books: has been updated successfully. Updated Book ID = " . $book_id . " Aff ".$book_affectedRows);
} else {
session()->setFlashdata('error', 'product updation failed. Please try again.');
$this->logger->error("Books: Err Failed to update ID =" . $book_id);
}
}
## book category section.
$category_id = $requested_details['category_id'];
if ($category_id) {
$existingRecord = $BooksModel->db->table('book_categories')
->where(['book_id'=> $book_id,'category_id'=> $category_id])
->get()
->getRow();
if (!$existingRecord) {
$BooksModel->db->table('book_categories')->insert(['book_id' => $book_id, 'category_id' => $category_id]);
$book_categories_id = $BooksModel->db->insertID();
$this->logger->info("Books Category : has been added successfully. Inserted ID = " . $book_categories_id);
}else{
$existingRecordId = $existingRecord->id;
$BooksModel->db->table('book_categories')->where('id', $existingRecordId)->update(['isactive' => 1]);
$book_categories_affectedRows = $BooksModel->db->affectedRows();
$this->logger->info("Books Category : has been updated successfully. Updated Book Category ID = " . $existingRecordId." Aff ".$book_categories_affectedRows);
}
}
##book image section.
if (!empty($_FILES['img_name']['name'])) {
// A new image has been uploaded
@ -111,7 +125,7 @@ class Books extends BaseController
$imageData = [
'book_id' => $bookId, // Assuming $last_inserted_id contains the ID of the inserted scheme
'book_id' => $book_id, // Assuming $last_inserted_id contains the ID of the inserted scheme
'img_name' => $_FILES['img_name']['name'],
'is_cover' => 1, // Set this based on your requirements
'type' => $_FILES['img_name']['type']
@ -124,45 +138,11 @@ class Books extends BaseController
// Update image data in the 'book_images' table
$BooksModel->insertImage($imageData);
}
// print_r($bookId); print_r($imageData); print_r($category_id);die;
if ($BooksModel->insert($data)) {
session()->setFlashdata('success', 'product successfully created.');
$this->logger->info("Books: has been added successfully. Inserted ID = " . $BooksModel->insertID());
} else {
session()->setFlashdata('error', 'product could not be created. Please try again..');
$this->logger->error("Books: Err could not be added. Please try again.");
}
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
$BooksModel->update($book_id, $data);
// Retrieve the selected category ID from the form
$category_id = $this->request->getPost('category_id');
// Remove existing category associations
$BooksModel->db->table('book_categories')->where('book_id', $book_id)->delete();
if ($category_id) {
// Insert the book-category association into the book_categories table
$BooksModel->db->table('book_categories')->insert(['book_id' => $book_id, 'category_id' => $category_id]);
}
if ($BooksModel->update($book_id, $data)) {
session()->setFlashdata('success', 'product successfully updated.');
$this->logger->info("Books: has been updated successfully. Updated Book ID = " . $book_id);
} else {
session()->setFlashdata('error', 'product updation failed. Please try again.');
$this->logger->error("Books: Err Failed to update ID =" . $book_id);
}
}
} catch (\Exception $e) {
$this->logger->error("Book: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('book_list');
}

View File

@ -5,7 +5,7 @@ class BooksModel extends Model
{
protected $table = 'books';
protected $primaryKey = 'book_id';
protected $allowedFields = ['book_id','title','cover_picture','publication_date','isbn_code','publisher','category','genre','language','description','page_count','tax','price','created_on','created_by','updated_on','updated_by','isactive','business_id'];
protected $allowedFields = ['book_id','author','publishers_code','title','cover_picture','publication_date','isbn_code','publisher','category','genre','language','description','page_count','tax','price','created_on','created_by','updated_on','updated_by','isactive','business_id'];
public function saveData($data, $id = null)
{
@ -30,7 +30,7 @@ class BooksModel extends Model
public function getnonMembershiplist($business_id)
{
$builder = $this->builder();
$builder->select('books.book_id, books.title, books.price, books.duration, books.isactive, books.publisher, books.genre, books.language, books.publication_date, GROUP_CONCAT(category.name SEPARATOR \',\') as name');
$builder->select('books.book_id, books.wp_api_product_id, books.title, books.price, books.duration, books.isactive, books.publisher, books.genre, books.language, books.publication_date, GROUP_CONCAT(category.name SEPARATOR \',\') as name');
$builder->join('book_categories', 'book_categories.book_id = books.book_id and book_categories.isactive = 1', 'left');
$builder->join('category', 'category.id = book_categories.category_id', 'left');
$builder->where('books.business_id', $business_id);
@ -51,7 +51,8 @@ class BooksModel extends Model
'genre'=>$row->genre,
'language'=>$row->language,
'publication_date'=>$row->publication_date,
'name'=>$row->name
'name'=>$row->name,
'wp_api_product_id'=>$row->wp_api_product_id
];
}
@ -78,8 +79,9 @@ public function getCategories()
public function getBooksAndImagesByBookId($id)
{
$builder = $this->db->table('books');
$builder->select('books.*, book_images.img_name, book_images.is_cover, book_images.type');
$builder->select('books.*, book_images.img_name, book_images.is_cover, book_images.type,book_categories.category_id');
$builder->join('book_images', 'book_images.book_id = books.book_id', 'left');
$builder->join('book_categories', 'book_categories.book_id = books.book_id', 'left');
$builder->where('books.book_id', $id);
$query = $builder->get();

View File

@ -1,7 +1,3 @@
<html>
<head>
</head>
<style>
/* CSS for the preview image */
.preview-image {
@ -27,205 +23,188 @@
<h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<?php endif; ?>
<form class="needs-validation" novalidate method="post" enctype="multipart/form-data"
action="<?= base_url() . "insert_books"; ?>">
<form class="needs-validation" novalidate method="post" enctype="multipart/form-data" action="<?= base_url() . "insert_books"; ?>">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="title" class="col-form-label">Book Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="title" name="title"
value="<?= isset($details['title']) ? $details['title'] : '' ?>" placeholder="Title"
required />
<label for="title" class="col-form-label">Book Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="title" name="title" value="<?= isset($details['title']) ? $details['title'] : '' ?>" placeholder="Name of the book" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="author" class="col-form-label">Book Author<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="author" name="author" value="<?= isset($details['author']) ? $details['author'] : '' ?>" placeholder="Name of the book author" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Book Publisher Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Book Publisher" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="publishers_code" class="col-form-label">Book Publishers Code</label>
<input type="text" class="form-control" id="publishers_code" name="publishers_code" placeholder="Book Publishers code" value="<?= isset($details['publishers_code']) ? $details['publishers_code'] : '' ?>" />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger">*</span></label>
<input type="date" class="form-control" id="publication_date" name="publication_date" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required placeholder="Publication Date">
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Book Publisher Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="publisher" name="publisher"
placeholder="Book Publisher (Authors)"
value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" required />
<label for="price" class="col-form-label">Book Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="price" name="price" placeholder="Book Price" required value="<?= isset($details['price']) ? $details['price'] : '' ?>" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="price" class="col-form-label">Book Price<span
class="text-danger">*</span></label>
<input type="number" class="form-control" id="price" name="price"
placeholder="Book Price" required
value="<?= isset($details['price']) ? $details['price'] : '' ?>" />
<label for="isbn_code" class="col-form-label">ISBN Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="isbn_code" name="isbn_code" value="<?= isset($details['isbn_code']) ? $details['isbn_code'] : '' ?>" placeholder="ISBN Code" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="isbn_code" class="col-form-label">ISBN CODE<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="isbn_code" name="isbn_code"
value="<?= isset($details['isbn_code']) ? $details['isbn_code'] : '' ?>"
required />
<div class="invalid-feedback"> Please provide. </div>
<label for="page_count" class="col-form-label">Page Count<span class="text-danger"></span></label>
<input type="number" class="form-control" id="page_count" name="page_count" placeholder="Page Count" value="<?= isset($details['page_count']) ? $details['page_count'] : '' ?>" />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="page_count" class="col-form-label">Page Count<span
class="text-danger"></span></label>
<input type="number" class="form-control" id="page_count" name="page_count"
placeholder="Page Count"
value="<?= isset($details['page_count']) ? $details['page_count'] : '' ?>" />
</div>
<div class="form-group col-md-6">
<label for="category_id" class="col-form-label">Category</label>
<select class="form-control" id="category_id" name="category_id">
<option>Select the Category of the Book</option>
<?php foreach ($categories as $category): ?>
<?php foreach ($categories as $category) : ?>
<option value="<?= $category['id'] ?>">
<?= $category['name'] ?>
</option>
<option value="<?= $category['id'] ?>">
<?= $category['name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="language" class="col-form-label">Language<span
class="text-danger"></span></label>
<input type="text" class="form-control" id="language" name="language"
placeholder="Language"
value="<?= isset($details['language']) ? $details['language'] : '' ?>" />
</div>
<div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"></span></label>
<input type="date" class="form-control" id="publication_date" name="publication_date" placeholder="Publication Date (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" />
<label for="language" class="col-form-label">Language<span class="text-danger"></span></label>
<input type="text" class="form-control" id="language" name="language" placeholder="Language" value="<?= isset($details['language']) ? $details['language'] : '' ?>" />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="tax" class="col-form-label">TAX<span class="text-danger"></span></label>
<input type="text" class="form-control" id="tax" name="tax" placeholder="tax"
value="<?= isset($details['tax']) ? $details['tax'] : '' ?>" />
<input type="text" class="form-control" id="tax" name="tax" placeholder="Tax" value="<?= isset($details['tax']) ? $details['tax'] : '' ?>" />
</div>
<div class="form-group col-md-6">
<label for="description" class="col-form-label">Description<span
class="text-danger"></span></label>
<textarea class="form-control" id="description" name="description"
placeholder="Description"
rows="5"><?= isset($details['description']) ? $details['description'] : '' ?></textarea>
<label for="description" class="col-form-label">Description<span class="text-danger"></span></label>
<textarea class="form-control" id="description" name="description" placeholder="Description" rows="5"><?= isset($details['description']) ? $details['description'] : '' ?></textarea>
</div>
</div>
<div class="form-group col-md-4">
<label for="img_name" class="col-form-label">Picture</label>
<input type="file" name="img_name" accept="image/*" />
</div>
<div class="form-group col-md-4">
<?php if (isset($details) && !empty($details)): ?>
<img id="imagePreview" src="<?= base_url('public/uploads/' . $details['img_name']) ?>" alt="Image Preview" style="max-width: 200px; display: block" />
<?php else: ?>
<img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" />
<?php endif; ?>
</div>
</div>
<input type="hidden" id="book_id" name="book_id" placeholder="hidden for book id"
value="<?= isset($details['book_id']) ? $details['book_id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id"
value="<?= $session_bid ?>" />
<?php if (!empty($details)) { ?>
<label for="img_name" class="col-form-label">Picture</label>
<input type="file" name="img_name" accept="image/*" />
</div>
<div class="form-group col-md-4">
<?php if (isset($details) && !empty($details)) : ?>
<img id="imagePreview" src="<?= base_url('public/uploads/' . $details['img_name']) ?>" alt="Image Preview" style="max-width: 200px; display: block" />
<?php else : ?>
<img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" />
<?php endif; ?>
</div>
</div>
<input type="hidden" id="book_id" name="book_id" placeholder="hidden for book id" value="<?= isset($details['book_id']) ? $details['book_id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
<?php if (!empty($details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="isactive" name="isactive" class="form-control"
<?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>>
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit">
Submit
</button>
<button type="reset" class="btn btn-primary waves-effect mr-1">
Reset
</button>
<a href="<?= base_url() . "book_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
<?php } ?>
<div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit">
Submit
</button>
<button type="reset" class="btn btn-primary waves-effect mr-1">
Reset
</button>
<a href="<?= base_url() . "book_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div><!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function() {
const coverPictureInput = documenxt.getElementById("cover_picture");
const imagePreviewContainer = document.querySelector(".image-previews");
document.addEventListener("DOMContentLoaded", function() {
const coverPictureInput = documenxt.getElementById("cover_picture");
const imagePreviewContainer = document.querySelector(".image-previews");
coverPictureInput.addEventListener("change", function(event) {
// imagePreviewContainer.innerHTML = ""; // Clear previous previews
coverPictureInput.addEventListener("change", function(event) {
// imagePreviewContainer.innerHTML = ""; // Clear previous previews
const selectedImages = Array.from(event.target.files);
const selectedImages = Array.from(event.target.files);
selectedImages.forEach(function(image, index) {
const imageWrapper = document.createElement("div");
imageWrapper.classList.add("mr-3");
selectedImages.forEach(function(image, index) {
const imageWrapper = document.createElement("div");
imageWrapper.classList.add("mr-3");
const imagePreview = document.createElement("img");
imagePreview.src = URL.createObjectURL(image);
imagePreview.classList.add("preview-image");
imagePreview.style.width = "120px"; // Set width as needed
const imagePreview = document.createElement("img");
imagePreview.src = URL.createObjectURL(image);
imagePreview.classList.add("preview-image");
imagePreview.style.width = "120px"; // Set width as needed
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.classList.add("image-checkbox");
checkbox.checked = false; // Set default as unchecked
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.classList.add("image-checkbox");
checkbox.checked = false; // Set default as unchecked
imageWrapper.appendChild(checkbox);
imageWrapper.appendChild(imagePreview);
imagePreviewContainer.appendChild(imageWrapper);
imageWrapper.appendChild(checkbox);
imageWrapper.appendChild(imagePreview);
imagePreviewContainer.appendChild(imageWrapper);
});
});
});
});
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
});
</script>
</body>
<script>
const DateInput = document.getElementById("publication_date");
</html>
// Get the current date
const currentDate = new Date();
// Calculate the min and max date strings
const minDate = "YYYY-MM-DD"; // Replace with your desired minimum date
const maxDate = currentDate.toISOString().split("T")[0]; // Today's date in YYYY-MM-DD format
// Set the min and max date attributes
DateInput.setAttribute("max", maxDate);
</script>

View File

@ -2,9 +2,9 @@
<div class="col-12">
<div class="card">
<div class="card-body">
<!-- <div class="float-right">
<div class="float-right">
<a href="<?= base_url() . "book_page/0"; ?>" class="btn btn-primary waves-effect"> <span> <i class="mdi mdi-book-plus"></i></span> Add Book </a>
</div> -->
</div>
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
@ -38,7 +38,7 @@
<th>Year Of Release</th>
<th>Price of the Book</th>
<th>Status</th>
<!-- <th>Action</th> -->
<th>Action</th>
</tr>
</thead>
<tbody>
@ -64,12 +64,14 @@
<td>
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
</td>
<!-- <td>
<td>
<?php if($row['wp_api_product_id']){
echo "Online Product";
}else{ ?>
<a href="<?php echo $edit_page_route; ?>" class="edit-button"> <i class="ri-pencil-line"></i></a>
<a href="<?= base_url() . "delete_books/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td> -->
<?php } ?>
</td>
</tr>
<?php endforeach; ?>

View File

@ -57,14 +57,13 @@ File: Form pickers init js
//Date range picker
$('.input-daterange-datepicker').daterangepicker({
format: 'DD/MM/YYYY',
buttonClasses: ['btn', 'btn-sm'],
applyClass: 'btn-secondary',
cancelClass: 'btn-primary'
});
$('.input-daterange-timepicker').daterangepicker({
timePicker: true,
format: 'DD/MM/YYYY h:mm A',
format: 'MM/DD/YYYY h:mm A',
timePickerIncrement: 30,
timePicker12Hour: true,
timePickerSeconds: false,
@ -73,9 +72,9 @@ File: Form pickers init js
cancelClass: 'btn-primary'
});
$('.input-limit-datepicker').daterangepicker({
format: 'DD/MM/YYYY',
minDate: '01/06/2020',
maxDate: '30/06/2020',
format: 'MM/DD/YYYY',
minDate: '06/01/2020',
maxDate: '06/30/2020',
buttonClasses: ['btn', 'btn-sm'],
applyClass: 'btn-secondary',
cancelClass: 'btn-primary',
@ -87,11 +86,11 @@ File: Form pickers init js
$('#reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
$('#reportrange').daterangepicker({
format: 'DD/MM/YYYY',
format: 'MM/DD/YYYY',
startDate: moment().subtract(29, 'days'),
endDate: moment(),
minDate: '01/01/2020',
maxDate: '31/12/2020',
maxDate: '12/31/2020',
dateLimit: {
days: 60
},

View File

@ -664,11 +664,11 @@
calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
curDate.hour(12);
if (this.minDate && calendar[row][col].format('DD/MM/YYYY') == this.minDate.format('DD/MM/YYYY') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
calendar[row][col] = this.minDate.clone();
}
if (this.maxDate && calendar[row][col].format('DD/MM/YYYY') == this.maxDate.format('DD/MM/YYYY') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
calendar[row][col] = this.maxDate.clone();
}
@ -808,11 +808,11 @@
classes.push('off', 'disabled');
//highlight the currently selected start date
if (calendar[row][col].format('DD/MM/YYYY') == this.startDate.format('DD/MM/YYYY'))
if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
classes.push('active', 'start-date');
//highlight the currently selected end date
if (this.endDate != null && calendar[row][col].format('DD/MM/YYYY') == this.endDate.format('DD/MM/YYYY'))
if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
classes.push('active', 'end-date');
//highlight dates in-between the selected dates
@ -1370,7 +1370,7 @@
var i = 0;
for (var range in this.ranges) {
if (this.timePicker) {
var format = this.timePickerSeconds ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY HH:mm";
var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm";
//ignore times when comparing dates if time picker seconds is not enabled
if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
customRange = false;
@ -1379,7 +1379,7 @@
}
} else {
//ignore times when comparing dates if time picker is not enabled
if (this.startDate.format('DD/MM/YYYY') == this.ranges[range][0].format('DD/MM/YYYY') && this.endDate.format('DD/MM/YYYY') == this.ranges[range][1].format('DD/MM/YYYY')) {
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
customRange = false;
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
break;
@ -1479,7 +1479,7 @@
this.setStartDate(start);
if (this.singleDatePicker) {
this.endDate = this.startDate.clone();
} else if (this.endDate && this.endDate.format('DD/MM/YYYY') == start.format('DD/MM/YYYY') && this.endDate.isBefore(start)) {
} else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
this.setEndDate(start.clone());
}
} else if (this.endDate) {