diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 3eac684a..35b5f80d 100755 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -48,15 +48,11 @@ class Books extends BaseController $data['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); } @@ -108,36 +104,94 @@ class Books extends BaseController $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]); + $BooksModel->db->table('book_categories')->where('id', $existingRecordId)->update(['isactive' => 0,'updated_by'=>(int)$session_uid]); $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 - - // 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' => $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'] + ## CI validation rule for img_name + $validationRule = [ + 'img_name' => [ + 'label' => 'Image File', + 'rules' => 'uploaded[img_name]|is_image[img_name]|mime_in[img_name,image/jpg,image/jpeg,image/gif,image/png,image/webp]' + ] ]; - - // 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); - } + + $img_details = $this->request->getFile('img_name'); // Here I Have Image details ; + $final_img_name = NULL;//Just flag + $existing_img_name = $this->request->getPost('existing_img_name'); // HiddenField for if have any pic name means; + $img_path = 'public/uploads/'; + + ##Step 1 : image details available + if($img_details){ + $this->logger->info("Books: image details avaiable"); + ##Step 2 : i have image details .
+ if ($img_details->isValid()) { + ##Step 3 : image Name.$new_img_name."
"; + $new_img_name = $img_details->getName(); // before movement name + $this->logger->info("Books: Image Name B4 Upload".$new_img_name); + ##Step 4 : Validation Rule Apply here.if not throw the error"
"; + if (!$this->validate($validationRule)) { + if($new_img_name !== ''){ + + $error = $this->validator->getErrors(); + // echo "Error : ".(string)$error."
"; + $this->logger->error("Books: Err on image upload".$error['img_name']); + throw new \Exception((string)$error['img_name']); + } + } + ##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder + if($new_img_name !== $existing_img_name){ + $existing_images_record = $BooksModel->db->table('book_images') + ->where(['book_id'=>$book_id,'isactive'=>1,'type'=>1]) + ->get()->getRow(); + $existing_image_id = $existing_images_record->book_img_id; + $this->logger->info("Books: Image Name are Differ".$new_img_name." & ".$existing_img_name); + ## Step 6 : Different Image Name means removed on target folder using Unlink; + if ($existing_image_id && $existing_img_name && is_file($img_path.$existing_img_name)) { + $BooksModel->db->table('book_images')->where(['book_img_id'=>$existing_image_id,"book_id"=>$book_id])->update(['isactive' => 0,"updated_by"=>(int)$session_uid]); + $book_images_affectedRows = $BooksModel->db->affectedRows(); + $this->logger->info("Books: Image has been updated successfully. Updated Book Image ID = " . $existing_image_id." Aff ".$book_images_affectedRows); + $this->logger->info("Books: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted."); + unlink($img_path.$existing_img_name); + }else{ + if(!$existing_image_id) $this->logger->info("Books: already Image Available but existing image id not availble in our DB So Unable to deactive"); + if(!$existing_img_name) $this->logger->info("Books: already Image Available but existing image name not founded So Unable to deactive"); + if(!is_file($img_path.$existing_img_name)) $this->logger->info("Books: Image on target Folder Path : ".$img_path.$existing_img_name." So Unable to deactive"); + } + ## Step 7 : Moved to target; + $img_details->move($img_path, $new_img_name); + $final_img_name = $img_details->getName(); // after movement name + $image_data = [ + 'book_id' => $book_id, + 'img_name' => $new_img_name, + 'is_cover' => 1, // cover images means 1 + 'type' => 1, // manual uploaded means 1 + ]; + + // Update image data in the 'book_images' table + $BooksModel->insertImage($image_data); + + $this->logger->info("Books: Image Name After Upload".$final_img_name); + }else{ + $final_img_name = $existing_img_name; + $this->logger->info("Books: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload"); + } + } + else{ + ## Step 8 : Not a Vaild Image File so replace Existing file name; + $final_img_name = $existing_img_name; + $this->logger->info("Books: Not a Vaild Image File Nothing To Update/Upload"); + // throw new \Exception("Not a Vaild Image File"); + } + } + else{ + ## Step 9 : Testing Purpose File Details Not Available. so i can't move it.; + $this->logger->info("Books: Testing Purpose Image Details Not Available. so i can't move it."); + $final_img_name = $existing_img_name; + //throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice"); + } } catch (\Exception $e) { $this->logger->error("Book: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); diff --git a/app/Controllers/Event.php b/app/Controllers/Event.php index 05eee303..5fc2b643 100644 --- a/app/Controllers/Event.php +++ b/app/Controllers/Event.php @@ -107,7 +107,7 @@ class Event extends BaseController helper('session'); helper('financial_year_helper'); $session_bid = get_business_id(); - $data['page_name'] = 'Edit invoice number formatting'; + $data['page_name'] = 'Edit Invoice number formatting'; $model = new EventModel(); $edit_event_details = $model->setTable('invoice_number_formatting')->where(['id' => (int)$id,'business_id'=>$session_bid])->first(); $data['event'] = $edit_event_details; diff --git a/app/Models/BooksModel.php b/app/Models/BooksModel.php index 6a5a44c7..945f3f2a 100644 --- a/app/Models/BooksModel.php +++ b/app/Models/BooksModel.php @@ -30,7 +30,7 @@ class BooksModel extends Model public function getnonMembershiplist($business_id) { $builder = $this->builder(); - $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->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,category.id as category_id'); $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); @@ -52,6 +52,7 @@ class BooksModel extends Model 'language'=>$row->language, 'publication_date'=>$row->publication_date, 'name'=>$row->name, + 'category_id' => $row->category_id, 'wp_api_product_id'=>$row->wp_api_product_id ]; } @@ -72,8 +73,7 @@ public function insertBooksCategory($book_id, $category_id) public function getCategories() { // Use the Query Builder to retrieve categories from the 'categories' table - $categories = $this->db->table('category')->get()->getResultArray(); - + $categories = $this->db->table('category')->groupBy('category.name')->get()->getResultArray(); return $categories; } public function getBooksAndImagesByBookId($id) diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php index f629b500..7be48e91 100644 --- a/app/Models/CustomerModel.php +++ b/app/Models/CustomerModel.php @@ -115,7 +115,7 @@ public function getSubscriberDataByCustomerId($customerId) $builder->groupBy('subscription.sub_id'); // Execute the query and return the result as an array of objects. return $builder->get()->getResult(); - print_r($this->db->getLastQuery());die; + // print_r($this->db->getLastQuery());die; } public function saveGroupDetails($data){ diff --git a/app/Models/SchemeModel.php b/app/Models/SchemeModel.php index 64788edd..eef0182c 100644 --- a/app/Models/SchemeModel.php +++ b/app/Models/SchemeModel.php @@ -102,7 +102,7 @@ public function getSchemeNames() } return $schemes; - print_r($schemes);die(); + // print_r($schemes);die(); } public function getSchemeNameById($schemeId) diff --git a/app/Views/book_form.php b/app/Views/book_form.php index 006cc2a7..c8226fe2 100644 --- a/app/Views/book_form.php +++ b/app/Views/book_form.php @@ -97,28 +97,34 @@ - -
- - -
-
- - Image Preview - - - +
+ +
+
+ Image Cover +
+
Existing Image
+

+ +
+
+
+ +
+ + +
+
@@ -139,7 +145,7 @@ " class="btn btn-secondary waves-effect">Cancel - + @@ -203,4 +209,21 @@ // Set the min and max date attributes DateInput.setAttribute("max", maxDate); + + \ No newline at end of file diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 1580177d..680c2c0f 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -23,7 +23,7 @@ } } ?> - + @@ -348,7 +348,7 @@
+91
- +
Please provide.
@@ -596,8 +596,9 @@ var iid_arr = ; var custid = ""; var inv_number = ""; + var ship_addrid = ""; if (custid != '') { - var ship_addrid = ""; + ship_addrid = ""; var bill_addrid = ""; var cust_ship_arr = ; if (cust_ship_arr.length > 0) { @@ -666,6 +667,13 @@ return serial_number; } + + if (custid != '' && (ship_addrid == undefined || ship_addrid == null || ship_addrid == '0' || ship_addrid == '')) { + + $("#storeShippingAddress").prop("readonly", false); + console.log('ship addrid is undefined, null, 0, or empty'); + } + }); // Billing ajax call diff --git a/app/Views/report_general_invoice.php b/app/Views/report_general_invoice.php index de0616ab..259267ff 100644 --- a/app/Views/report_general_invoice.php +++ b/app/Views/report_general_invoice.php @@ -1,175 +1,165 @@ -
-

+

-
+
-
-
- -
-
- +
+
+ +
+
+ +
-
-
- - - - +
+
-
-
-
- -
- - - - - - - - - - - - - - - - +
+
+
+
+
Invoice NoInvoice DateCustomer NameGSTDiscountCountOT ChargesTotalStatusPayment
+ + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + -
Invoice NoInvoice DateCustomer NameGSTDiscountCountOT ChargesTotalStatusPayment
invoice_number;?>formatted_invoice_date;?>first_name." ".$row->last_name;?>tax . '%'; ?>discount, 2, '.', ','); ?>item_count;?>shipping_charge, 2, '.', ','); ?>total_amount, 2, '.', ','); ?>status;?>payment_method;?>
invoice_number; ?>formatted_invoice_date; ?>first_name . " " . $row->last_name; ?>tax . '%'; ?>discount, 2, '.', ','); ?>item_count; ?>shipping_charge, 2, '.', ','); ?>total_amount, 2, '.', ','); ?>status; ?>payment_method; ?>
-
-
-
-
+ +
+
+ + - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/Views/report_itemwise.php b/app/Views/report_itemwise.php index 39597b31..55eed51d 100644 --- a/app/Views/report_itemwise.php +++ b/app/Views/report_itemwise.php @@ -35,7 +35,7 @@
- +
diff --git a/app/Views/report_mem_invoice.php b/app/Views/report_mem_invoice.php index c68d9bd3..890b18f4 100644 --- a/app/Views/report_mem_invoice.php +++ b/app/Views/report_mem_invoice.php @@ -27,7 +27,7 @@
-
Product Name
+