Merge branch 'uat' of bitbucket.org:venbainformationtechnology/vb_book into uat
This commit is contained in:
commit
55ea30325c
@ -38,19 +38,28 @@ class Books extends BaseController
|
||||
{
|
||||
helper('session');
|
||||
$data['session_bid'] = get_business_id();
|
||||
|
||||
// Fetch categories from the model
|
||||
$model = new BooksModel();
|
||||
$categories = $model->getCategories();
|
||||
|
||||
if ($id === '0') {
|
||||
$data['page_name'] = 'Add Book';
|
||||
$data['page_name'] = 'Add Book';
|
||||
$data['details'] = [];
|
||||
} else if ($id !== '0') {
|
||||
$data['page_name'] = 'Edit Book';
|
||||
$model = new BooksModel();
|
||||
$model->setTable('books');
|
||||
$details = $model->where(['book_id' => $id, 'isactive' => 1])->first();
|
||||
$data['details'] = $details;
|
||||
} elseif ($id !== '0') {
|
||||
$data['page_name'] = 'Edit Book';
|
||||
|
||||
$imageData = $model->getBooksAndImagesByBookId($id);
|
||||
|
||||
$data['details'] = $imageData[0];
|
||||
|
||||
}
|
||||
|
||||
$data['categories'] = $categories; // Pass the categories to the view
|
||||
|
||||
$this->render_page('book_form', $data);
|
||||
}
|
||||
|
||||
|
||||
## For inserting/updating details of book
|
||||
public function insert_books()
|
||||
{
|
||||
@ -59,51 +68,11 @@ class Books extends BaseController
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_bid = get_business_id();
|
||||
|
||||
// $validationRule = [
|
||||
// 'userfile' => [
|
||||
// 'label' => 'Image File',
|
||||
// 'rules' => [
|
||||
// 'uploaded[coverpicture]',
|
||||
// 'is_image[coverpicture]',
|
||||
// 'mime_in[coverpicture,image/jpg,image/jpeg,image/gif,image/png,image/webp]',
|
||||
|
||||
// ],
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// if (!$this->validate($validationRule) && $this->request->getPost('coverpicture') === '') {
|
||||
// $data = ['errors' => $this->validator->getErrors()];
|
||||
// print_r($data);
|
||||
// return 'hello';
|
||||
// }
|
||||
// $img = $this->request->getFile('coverpicture');
|
||||
// $book_id = $this->request->getPost('book_id');
|
||||
$business_id = $this->request->getPost('business_id');
|
||||
// $filePath = 'public/uploads/' . $this->request->getPost('coverpicture');
|
||||
|
||||
// ## File Already Existing or not
|
||||
// if ($img->isValid() && !$img->hasMoved()) {
|
||||
// $fileName = $img->getName();
|
||||
// $img->move('public/uploads/', $fileName);
|
||||
|
||||
|
||||
// // Delete the previous image file if it exists
|
||||
// if ($book_id) {
|
||||
// $previousFileName = $this->request->getPost('previous_file');
|
||||
// if ($previousFileName && is_file('public/uploads/' . $previousFileName)) {
|
||||
// link('public/uploads/' . $previousFileName);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// $fileName = $this->request->getPost('previous_file', ''); // Use the previous filename if no new image is provided
|
||||
// }
|
||||
|
||||
|
||||
$BooksModel = new BooksModel();
|
||||
$BooksModel = new BooksModel();
|
||||
$data = [
|
||||
|
||||
'title' => $this->request->getPost('title'),
|
||||
// 'cover_picture' => $fileName,
|
||||
|
||||
'publication_date' => $this->request->getPost('publication_date'),
|
||||
'publisher' => $this->request->getPost('publisher'),
|
||||
'genre' => $this->request->getPost('genre'),
|
||||
@ -113,7 +82,8 @@ class Books extends BaseController
|
||||
'price' => $this->request->getPost('price'),
|
||||
'isbn_code' => $this->request->getPost('isbn_code'),
|
||||
'tax'=>$this->request->getPost('tax'),
|
||||
'business_id' => $business_id
|
||||
'business_id'=>$session_bid
|
||||
|
||||
];
|
||||
$book_id = $this->request->getPost('book_id'); // Get the book ID for update purpose
|
||||
|
||||
@ -121,6 +91,41 @@ class Books extends BaseController
|
||||
// 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]);
|
||||
}
|
||||
if (!empty($_FILES['img_name']['name'])) {
|
||||
// A new image has been uploaded
|
||||
|
||||
// First, delete the previous image file if it exists
|
||||
if (!empty($imageData) && file_exists(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name)) {
|
||||
unlink(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name);
|
||||
}
|
||||
|
||||
|
||||
$imageData = [
|
||||
'book_id' => $bookId, // 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']
|
||||
];
|
||||
|
||||
// Move the uploaded image to a desired location
|
||||
$imagePath = 'public/uploads/' . $_FILES['img_name']['name'];
|
||||
move_uploaded_file($_FILES['img_name']['tmp_name'], $imagePath);
|
||||
|
||||
// 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', 'Book has been added successfully.');
|
||||
$this->logger->info("Books: has been added successfully. Inserted ID = " . $BooksModel->insertID());
|
||||
@ -133,6 +138,18 @@ class Books extends BaseController
|
||||
$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', 'Book has been updated successfully.');
|
||||
$this->logger->info("Books: has been updated successfully. Updated Book ID = " . $book_id);
|
||||
@ -145,6 +162,7 @@ class Books extends BaseController
|
||||
$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');
|
||||
}
|
||||
|
||||
|
||||
@ -44,10 +44,13 @@ class Scheme extends BaseController
|
||||
} else if ($id !== '0') {
|
||||
$data['page_name'] = 'Edit Scheme';
|
||||
$model = new SchemeModel();
|
||||
$model->setTable('books');
|
||||
$edit_user_details = $model->where(['book_id' => $id])->first();
|
||||
|
||||
|
||||
$data['scheme'] = $edit_user_details;
|
||||
$imageData = $model->getBooksAndImagesByBookId($id);
|
||||
|
||||
$data['scheme'] = $imageData[0];
|
||||
|
||||
// print_r($data);die();
|
||||
}
|
||||
|
||||
$data['session_bid'] = $session_bid;
|
||||
@ -104,12 +107,36 @@ class Scheme extends BaseController
|
||||
session()->setFlashdata('error', 'Scheme could not be added. Please try again..');
|
||||
$this->logger->error("Scheme: Err could not be added. Please try again.");
|
||||
}
|
||||
}
|
||||
if (!empty($_FILES['img_name']['name'])) {
|
||||
// A new image has been uploaded
|
||||
|
||||
// First, delete the previous image file if it exists
|
||||
if (!empty($imageData) && file_exists(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name)) {
|
||||
unlink(WRITEPATH . 'public/uploads/' . $imageData[0]->img_name);
|
||||
}
|
||||
|
||||
$imageData = [
|
||||
'book_id' => $last_inserted_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']
|
||||
];
|
||||
|
||||
// Move the uploaded image to a desired location
|
||||
$imagePath = 'public/uploads/' . $_FILES['img_name']['name'];
|
||||
move_uploaded_file($_FILES['img_name']['tmp_name'], $imagePath);
|
||||
|
||||
// Update image data in the 'book_images' table
|
||||
$SchemeModel->insertImage($imageData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's an update operation
|
||||
$isactive = $this->request->getPost('isactive');
|
||||
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
|
||||
$data['updated_by'] = $session_uid;
|
||||
|
||||
$SchemeModel->update($scheme_id, $data);
|
||||
if ($SchemeModel->update($scheme_id, $data)) {
|
||||
session()->setFlashdata('success', 'Scheme has been updated successfully.');
|
||||
$this->logger->info("Scheme: has been updated successfully. Updated Scheme ID = " . $scheme_id);
|
||||
|
||||
@ -57,6 +57,40 @@ class BooksModel extends Model
|
||||
|
||||
return $books;
|
||||
}
|
||||
public function insertBooksCategory($book_id, $category_id)
|
||||
{
|
||||
$data = [
|
||||
'book_id' => $book_id,
|
||||
'category_id' => $category_id,
|
||||
];
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('book_categories');
|
||||
$builder->insert($data);
|
||||
}
|
||||
public function getCategories()
|
||||
{
|
||||
// Use the Query Builder to retrieve categories from the 'categories' table
|
||||
$categories = $this->db->table('category')->get()->getResultArray();
|
||||
|
||||
return $categories;
|
||||
}
|
||||
public function getBooksAndImagesByBookId($id)
|
||||
{
|
||||
$builder = $this->db->table('books');
|
||||
$builder->select('books.*, book_images.img_name, book_images.is_cover, book_images.type');
|
||||
$builder->join('book_images', 'book_images.book_id = books.book_id', 'left');
|
||||
$builder->where('books.book_id', $id);
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
public function insertImage($imageData)
|
||||
{
|
||||
return $this->db->table('book_images')->insert($imageData);
|
||||
}
|
||||
|
||||
|
||||
public function getData($table, $where = null,$whereIn = null)
|
||||
{
|
||||
|
||||
@ -43,8 +43,26 @@ class SchemeModel extends Model
|
||||
|
||||
return $schemes;
|
||||
}
|
||||
public function getBooksAndImagesByBookId($id)
|
||||
{
|
||||
$builder = $this->db->table('books');
|
||||
$builder->select('books.*, book_images.img_name, book_images.is_cover, book_images.type');
|
||||
$builder->join('book_images', 'book_images.book_id = books.book_id', 'left');
|
||||
$builder->where('books.book_id', $id);
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function insertImage($imageData)
|
||||
{
|
||||
return $this->db->table('book_images')->insert($imageData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public function getSchemeDuration($schemeId)
|
||||
// {
|
||||
// $query = $this->select('duration')
|
||||
@ -110,6 +128,15 @@ public function getAllSchemes()
|
||||
{
|
||||
return $this->findAll();
|
||||
}
|
||||
public function updateImage($schemeId, $imageData)
|
||||
{
|
||||
$builder = $this->db->table('book_images');
|
||||
$builder->set($imageData);
|
||||
$builder->where('book_id', $schemeId);
|
||||
$builder->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getData($table, $where = null, $whereIn = null)
|
||||
{
|
||||
|
||||
@ -3,19 +3,19 @@
|
||||
<head>
|
||||
</head>
|
||||
<style>
|
||||
/* CSS for the preview image */
|
||||
.preview-image {
|
||||
display: block;
|
||||
/* Ensure the image is displayed as a block element */
|
||||
width: 120px;
|
||||
/* Set the desired width for passport size */
|
||||
height: 160px;
|
||||
/* Set the desired height for passport size */
|
||||
object-fit: cover;
|
||||
/* Maintain the aspect ratio and fill the container */
|
||||
margin-top: 10px;
|
||||
/* Add a top margin for spacing */
|
||||
}
|
||||
/* CSS for the preview image */
|
||||
.preview-image {
|
||||
display: block;
|
||||
/* Ensure the image is displayed as a block element */
|
||||
width: 120px;
|
||||
/* Set the desired width for passport size */
|
||||
height: 160px;
|
||||
/* Set the desired height for passport size */
|
||||
object-fit: cover;
|
||||
/* Maintain the aspect ratio and fill the container */
|
||||
margin-top: 10px;
|
||||
/* Add a top margin for spacing */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@ -27,111 +27,143 @@
|
||||
<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="Title"
|
||||
required />
|
||||
<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="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 />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
</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="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 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 />
|
||||
<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>
|
||||
</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>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="genre" class="col-form-label">Genre</label>
|
||||
<input type="text" class="form-control" id="genre" name="genre" placeholder="Genre" rows="5"><?= isset($details['genre']) ? $details['genre'] : '' ?></textarea>
|
||||
<!-- <input type="text" class="form-control" id="genre" name="genre" placeholder="Genre" value="<?= isset($details['genre']) ? $details['genre'] : '' ?>" /> -->
|
||||
<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="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'] : '' ?>" />
|
||||
|
||||
|
||||
<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): ?>
|
||||
|
||||
<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)" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>">
|
||||
<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'] : '' ?>" />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="image-previews mt-4"></div>
|
||||
<label for="coverpicture" class="col-form-label">Book Cover Picture<span class="text-danger"></span></label>
|
||||
<br />
|
||||
<input type="file" id="cover_picture" name="coverpicture[]" />
|
||||
<!-- <input type="text" class="form-control" id="cover_picture" name="cover_picture" placeholder="Book Cover picture Name" required value="<?= isset($details['cover_picture']) ? $details['cover_picture'] : '' ?>" /> -->
|
||||
<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>
|
||||
</div>
|
||||
</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 ?>" />
|
||||
<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)) { ?>
|
||||
<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' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
</div>
|
||||
<br>
|
||||
<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' : '' ?>>
|
||||
<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" type="submit">
|
||||
@ -149,38 +181,36 @@
|
||||
</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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
</html>
|
||||
@ -62,17 +62,16 @@
|
||||
<th>Invoice Number</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Customer Name</th>
|
||||
|
||||
<!-- <th>Book Name</th>
|
||||
<th>Quantity</th>
|
||||
<th>Price</th>
|
||||
<th>Discount</th>
|
||||
<th>Tax</th> -->
|
||||
<th>Status</th>
|
||||
<th>Approve INV</th>
|
||||
<th>Action</th>
|
||||
<th>view</th>
|
||||
<th>Print</th>
|
||||
</tr>
|
||||
<th>Total</th>
|
||||
<th align="center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($invoice as $row): ?>
|
||||
@ -82,16 +81,17 @@
|
||||
<td><?= $row['invoice_date']; ?></td>
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['status']; ?></td>
|
||||
<td style align="center"><a href="<?= "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button"><i class="ri-checkbox-circle-fill"></i></a></td>
|
||||
<td>
|
||||
<td>₹ <span data-plugin="counterup"><?= $row['total_amount']; ?></span></td>
|
||||
<td><a href="<?= "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>
|
||||
|
||||
<?php if ($row['invoice_type'] == 1): ?>
|
||||
<a href="<?= "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>
|
||||
<?php elseif ($row['invoice_type'] == 2): ?>
|
||||
<a href="<?= "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button"><i class="ri-file-download-line"></i></a></td>
|
||||
<td><a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button"><i class="ri-printer-line"></i></a></td>
|
||||
|
||||
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>
|
||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a></td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sduration" class="col-form-label">Duration<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="sduration" value="<?= isset($scheme['duration']) ? $scheme['duration'] : '' ?>" placeholder="Duration In Months" required />
|
||||
<input type="text" class="form-control" name="sduration" value="<?= isset($scheme['duration']) ? $scheme['duration'] : '' ?>" placeholder="Duration In Months(ex 1)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
@ -32,15 +32,32 @@
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sdescription" class="col-form-label">Description<span class="text-danger"></span></label>
|
||||
<textarea class="form-control" name="sdescription" placeholder="Description" ><?= isset($scheme['description']) ? $scheme['description'] : '' ?></textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="img_name" class="col-form-label">Scheme Picture</label>
|
||||
<input type="file" name="img_name" accept="image/*" />
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<?php if (isset($scheme) && !empty($scheme)): ?>
|
||||
<img id="imagePreview" src="<?= base_url('public/uploads/' . $scheme['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 scheme id" value="<?= isset($scheme['book_id']) ? $scheme['book_id'] : '' ?>" />
|
||||
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
|
||||
<?php if (!empty($scheme)) { ?>
|
||||
<?php if (!empty($scheme)) { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($scheme) && $scheme['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
@ -65,4 +82,5 @@
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- end row -->
|
||||
Loading…
Reference in New Issue
Block a user