Internal Discussion 31st : ps

This commit is contained in:
VE10-Sanjeev 2023-11-01 19:10:08 +05:30
parent e2449f18d6
commit b2c2793df2
20 changed files with 668 additions and 811 deletions

View File

@ -19,7 +19,7 @@ class ApiIntegration extends ResourceController
public function __construct() public function __construct()
{ {
$this->global_variable_business_id = 1; $this->global_variable_business_id = 1;
$this->global_variable_role = "online"; $this->global_variable_role = "Online";
$api_model = new ApiIntegrationModel(); $api_model = new ApiIntegrationModel();
$table = 'users'; $table = 'users';
$where = ['role'=>$this->global_variable_role,'business_id'=>(int)$this->global_variable_business_id]; $where = ['role'=>$this->global_variable_role,'business_id'=>(int)$this->global_variable_business_id];

View File

@ -91,20 +91,15 @@ class Customer extends BaseController
$session_uid = get_logged_user_id(); $session_uid = get_logged_user_id();
$session_role = get_user_role(); $session_role = get_user_role();
$model = new CustomerModel(); $model = new CustomerModel();
$dob = $this->request->getPost('dob');
$dob = (isset($dob) && $dob != "") ? $dob : NULL ;
$data = [ $data = [
'first_name' => $this->request->getPost('cfname'), 'first_name' => $this->request->getPost('cfname'),
'last_name' => $this->request->getPost('csname'), 'last_name' => $this->request->getPost('csname'),
'mobile_no' => $this->request->getPost('cmobile'), 'mobile_no' => $this->request->getPost('cmobile'),
'address' => $this->request->getPost('address'),
'city' => $this->request->getPost('ccity'),
'email' => $this->request->getPost('cmail'), 'email' => $this->request->getPost('cmail'),
'state' => $this->request->getPost('cstate'), 'date_of_birth' => $dob,
'postal_code' => $this->request->getPost('czip'), 'mode' => "Offline",
'country' => $this->request->getPost('ccountry'),
'date_of_birth' => $this->request->getPost('dob'),
'gender' => $this->request->getPost('gen'),
'profile_picture' => $this->request->getPost('cfile'),
'mode' => $this->request->getPost('cmode'),
'business_id' => $this->request->getPost('business_id') 'business_id' => $this->request->getPost('business_id')
]; ];
@ -308,7 +303,7 @@ class Customer extends BaseController
['value'=>'CA.state','fieldflag'=>1,'text'=> 'State','disable' => false], ['value'=>'CA.state','fieldflag'=>1,'text'=> 'State','disable' => false],
['value'=>'CM.name','fieldflag'=>1,'text'=> 'Category','disable' => false], ['value'=>'CM.name','fieldflag'=>1,'text'=> 'Category','disable' => false],
['value'=>'I.invoice_date','fieldflag'=>2,'text'=> 'Invoice Date','disable' => false], ['value'=>'I.invoice_date','fieldflag'=>2,'text'=> 'Invoice Date','disable' => false],
['value'=>'S.to_subscription','fieldflag'=>2,'text'=> 'Due Date','disable' => false]]; ['value'=>'S.to_subscription','fieldflag'=>2,'text'=> 'Expiry Date','disable' => false]];
$data['operator'] = [ $data['operator'] = [
'' => 'Choose the operator', '' => 'Choose the operator',

View File

@ -48,7 +48,7 @@ public function new_event($id)
$data['page_name'] = 'Add Event'; $data['page_name'] = 'Add Event';
$data['event'] = []; $data['event'] = [];
} else if ($id !== '0') { } else if ($id !== '0') {
$data['page_name'] = 'Edit Scheme'; $data['page_name'] = 'Edit Event';
$model = new EventModel(); $model = new EventModel();
$model->setTable('events'); $model->setTable('events');
$edit_event_details = $model->where(['id' => $id])->first(); $edit_event_details = $model->where(['id' => $id])->first();

View File

@ -50,19 +50,19 @@ class Invoice extends BaseController
$data['books'] = $model->getNonMembershipCategoryBooks('books', $where); $data['books'] = $model->getNonMembershipCategoryBooks('books', $where);
if ($id === '0') { if ($id === '0') {
$this->logger->info("Book Invoice: In Add Page"); $this->logger->info("Book Invoice: In Add Details");
$data['page_name'] = 'Add Book Invoice Details'; $data['page_name'] = 'Add Book Invoice Details';
$data['invoice_type'] = '2'; $data['invoice_type'] = '2';
$data['invoice_details'] = []; $data['invoice_details'] = [];
$data['invoice_item_details'] = []; $data['invoice_item_details'] = [];
} elseif ($id !== '0') { } elseif ($id !== '0') {
$this->logger->info("Book Invoice: In Edit Page ID =" . $id); $this->logger->info("Book Invoice: In Edit Details ID =" . $id);
$data['page_name'] = 'Edit Book Invoice Details'; $data['page_name'] = 'Edit Book Invoice Details';
$data['invoice_type'] ='2'; $data['invoice_type'] ='2';
$data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first(); $data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first();
$data['invoice_item_details'] = $this->get_invoice_item($id); $data['invoice_item_details'] = $this->get_invoice_item($id);
} }
// print_r($data['invoice_details']);die;
$this->render_page('invoice_form', $data); $this->render_page('invoice_form', $data);
} }

View File

@ -27,7 +27,7 @@ class Subscription extends BaseController
$model = new InvoiceModel(); $model = new InvoiceModel();
$data['page_name'] = 'Subscription Invoice Details'; $data['page_name'] = 'Subscription Invoice Details';
$data['invoice'] = $model->getJoinedData($where); $data['invoice'] = $model->getSubscriptionInvoiceDetail($where);
$this->logger->info("Invoice: Listing Count ." . count($data['invoice'])); $this->logger->info("Invoice: Listing Count ." . count($data['invoice']));

View File

@ -151,7 +151,7 @@ public function getGroupDetails()
return $this->db->table('customer_groups as CG' ) return $this->db->table('customer_groups as CG' )
->join('users as U1', 'U1.user_id = CG.created_by', 'left') ->join('users as U1', 'U1.user_id = CG.created_by', 'left')
->join('users as U2', 'U2.user_id = CG.updated_by', 'left') ->join('users as U2', 'U2.user_id = CG.updated_by', 'left')
->select('CG.group_id,CG.group_name,CG.created_on,CG.created_by,CG.updated_on,CG.updated_by,DATE_FORMAT(CG.created_on, "%d-%m-%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,CG.isactive') ->select('CG.group_id,CG.group_name,CG.created_on,CG.created_by,CG.updated_on,CG.updated_by,DATE_FORMAT(CG.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,CG.isactive')
// ->where(['CG.isactive' => 1]) // ->where(['CG.isactive' => 1])
->get() ->get()
->getResultArray(); ->getResultArray();

View File

@ -44,6 +44,33 @@ public function updateData($table, $data, $where)
return $affected_rows; return $affected_rows;
} }
public function getSubscriptionInvoiceDetail($where)
{
$result = $this->getJoinedData($where);
// print_r($result);die;
if(!empty($result)){
foreach ($result as $i => $item) {
$invoiceId = $item['invoice_id'];
$scheme_name = [];
$from_subscription = [];
$to_subscription = [];
$invoiceItems = $this->getInvoiceItems($invoiceId);
foreach ($invoiceItems as $j => $child) {
if ($child->category_name == 'Membership') {
$scheme_name[] = $child->title;
$from_subscription[] = $child->from_subscription ? date('d/m/Y', strtotime($child->from_subscription)) : "";
$to_subscription[] = $child->to_subscription ? date('d/m/Y', strtotime($child->to_subscription)) : "";
}
}
$result[$i]['scheme_name'] = !empty($scheme_name) ? implode(", ", $scheme_name) : '';
$result[$i]['from_subscription'] = !empty($from_subscription) ? implode(", ", $from_subscription) : '';
$result[$i]['to_subscription'] = !empty($to_subscription) ? implode(", ", $to_subscription) : '';
$result[$i]['invoice_items_details'] = $invoiceItems;
}
}
return $result;
}
public function getJoinedData($where) public function getJoinedData($where)
{ {
@ -127,14 +154,14 @@ public function updateData($table, $data, $where)
} }
// this function Also Used For Approve Notification. // this function Also Used For Approve Notification.
public function getInvoiceItems($id) public function getInvoiceItems($id)
{ {
$data = $this->db->table('invoiceitems') $data = $this->db->table('invoiceitems')
->where(['invoice_id' => $id, 'invoiceitems.isactive' => 1]) ->where(['invoice_id' => $id, 'invoiceitems.isactive' => 1])
->join('books as B', 'B.book_id = invoiceitems.product', 'left') ->join('books as B', 'B.book_id = invoiceitems.product', 'left')
// ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left') ->join('book_categories as BC', 'BC.book_id = invoiceitems.product', 'left')
->select('invoiceitems.*,B.*') ->join('category as C', 'C.id = BC.category_id', 'left')
->select('invoiceitems.*,B.*,C.name as category_name')
//->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order //->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order
//->limit(1,0) //->limit(1,0)
->get() ->get()

View File

@ -41,7 +41,7 @@ class NotificationModel extends Model
return $this->db->table('templates as T' ) return $this->db->table('templates as T' )
->join('users as U1', 'U1.user_id = T.created_by', 'left') ->join('users as U1', 'U1.user_id = T.created_by', 'left')
->join('users as U2', 'U2.user_id = T.updated_by', 'left') ->join('users as U2', 'U2.user_id = T.updated_by', 'left')
->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d-%m-%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,T.isactive') ->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,T.isactive')
->get()->getResultArray(); ->get()->getResultArray();
} }
@ -81,7 +81,7 @@ public function getCampaignDetails(){
->join('users as U1', 'U1.user_id = NC.created_by', 'left') ->join('users as U1', 'U1.user_id = NC.created_by', 'left')
->join('users as U2', 'U2.user_id = NC.updated_by', 'left') ->join('users as U2', 'U2.user_id = NC.updated_by', 'left')
->join('templates as T', 'T.template_id = NC.template_id', 'left') ->join('templates as T', 'T.template_id = NC.template_id', 'left')
->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d-%m-%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,NC.scheduled_time') ->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,NC.scheduled_time')
->get()->getResultArray(); ->get()->getResultArray();
if (!empty($result)) { if (!empty($result)) {

View File

@ -2,9 +2,9 @@
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <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> <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> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
@ -38,7 +38,7 @@
<th>Year Of Release</th> <th>Year Of Release</th>
<th>Price of the Book</th> <th>Price of the Book</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <!-- <th>Action</th> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -58,17 +58,18 @@
<td><?php echo $row['publisher']; ?></td> <td><?php echo $row['publisher']; ?></td>
<td><?php echo $row['name']; ?></td> <td><?php echo $row['name']; ?></td>
<td><?php echo $row['language']; ?></td> <td><?php echo $row['language']; ?></td>
<td><?php echo date('Y', strtotime($row['publication_date'])); ?></td> <td><?php echo $row['publication_date'] ? date('Y', strtotime($row['publication_date'])) : "" ; ?></td>
<td> <span data-plugin="counterup"><?php echo $row['price']; ?></span></td> <!-- <td> <span data-plugin="counterup"><?php echo $row['price']; ?></span></td> -->
<td> <?php echo $row['price']; ?></td>
<td> <td>
<span class="<?php echo $class; ?>"><?php echo $message; ?></span> <span class="<?php echo $class; ?>"><?php echo $message; ?></span>
</td> </td>
<td> <!-- <td>
<a href="<?php echo $edit_page_route; ?>" class="edit-button"> <i class="ri-pencil-line"></i></a> <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> <a href="<?= base_url() . "delete_books/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td> </td> -->
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -9,7 +9,7 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a> <a class="nav-link" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
</li> </li>
<?php if ($page_name === 'Edit Customer') : ?> <?php if ($page_name === 'Edit Customer Details') : ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a> <a class="nav-link active" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
</li> </li>
@ -59,30 +59,9 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="dob" class="col-form-label">Date Of Birth</label> <label for="dob" class="col-form-label">Date Of Birth</label>
<input type="date" class="form-control" name="dob" value="<?= isset($customer['date_of_birth']) ? $customer['date_of_birth'] : '' ?>" placeholder="Date Of Birth" /> <input type="date" class="form-control" name="dob" value="<?= isset($customer['date_of_birth']) ? $customer['date_of_birth'] : '' ?>" placeholder="Date Of Birth" />
</div>
<div class="form-group col-md-4">
<label for="gen" class="col-form-label">Gender<span class="text-danger"> *</span></label>
<select class="form-control" name="gen" required>
<option value="" > Select the Gender</option>
<option value="male" <?= isset($customer['gender']) && $customer['gender'] == 'male' ? 'selected' : '' ?>>Male</option>
<option value="female" <?= isset($customer['gender']) && $customer['gender'] == 'female' ? 'selected' : '' ?>>Female</option>
</select>
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="cmode" class="col-form-label">Mode<span class="text-danger"> *</span></label>
<select class="form-control" name="cmode" required>
<option value="offline" <?= isset($customer['mode']) && $customer['mode'] == 'offline' ? 'selected' : '' ?>>Offline</option>
<option value="online" <?= isset($customer['mode']) && $customer['mode'] == 'online' ? 'selected' : '' ?>>Online</option>
</select>
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<input type="hidden" id="customer_id" name="customer_id" placeholder="hidden for customer id" value="<?= isset($customer['customer_id']) ? $customer['customer_id'] : '' ?>" /> <input type="hidden" id="customer_id" name="customer_id" placeholder="hidden for customer id" value="<?= isset($customer['customer_id']) ? $customer['customer_id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" /> <input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
@ -153,11 +132,6 @@
</select> </select>
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="bcity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<div id="billinput" style="display: block"> <div id="billinput" style="display: block">
<label for="bistate" class="col-form-label">State</label> <label for="bistate" class="col-form-label">State</label>
@ -178,6 +152,11 @@
</div> </div>
</div> </div>
<div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="bcity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label> <label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bzip" name="bzip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" /> <input type="text" class="form-control" id="bzip" name="bzip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
@ -197,7 +176,7 @@
<label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label> <label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label>
</div> </div>
</div> </div>
<div class="after-add-smore"> <div class="after-shipping-addr-add-more">
<hr /> <hr />
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
@ -226,12 +205,6 @@
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="scity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scity" name="scity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="" class="col-form-label">State</label> <label for="" class="col-form-label">State</label>
<input type="text" class="form-control" id="sistate0" name="sistate[]" placeholder="State" style="display: block" /> <input type="text" class="form-control" id="sistate0" name="sistate[]" placeholder="State" style="display: block" />
<select class="form-control" id="sdstate0" name="sdstate[]" style="display: none"> <select class="form-control" id="sdstate0" name="sdstate[]" style="display: none">
@ -242,12 +215,13 @@
</option> </option>
<?php } ?> <?php } ?>
</select> </select>
</select>
</select>
<!-- <div class="invalid-feedback"> Please provide. </div> --> <!-- <div class="invalid-feedback"> Please provide. </div> -->
</div> </div>
<div class="form-group col-md-3">
<label for="scity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scity" name="scity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="szip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label> <label for="szip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="szip" name="szip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" /> <input type="text" class="form-control" id="szip" name="szip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
@ -260,16 +234,13 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<input type="hidden" id="scustomer_address_id" name="scustomer_address_id[]" placeholder="hidden for shipping customer address id" /> <input type="hidden" id="scustomer_address_id" name="scustomer_address_id[]" placeholder="hidden for shipping customer address id" />
</div> </div>
<div class="form-group col-md-9 schange text-right m-b-0"> <div class="form-group col-md-9 shipping-addr-div-change text-right m-b-0">
<!-- <a class="btn btn-success waves-effect waves-light mr-1 add-smore">+ Add More Shipping Address </a> --> <a class="btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more">+ Add More Shipping Address </a>
<a class="btn btn-danger waves-effect waves-light mr-1 sremove">- Remove </a> <a class="btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove">- Remove </a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group text-right m-b-0">
<a class="btn btn-success add-smore">+ Add More Shipping Address </a>
</div>
<?php if (!empty($customer)) { ?> <?php if (!empty($customer)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer) && $customer['isactive'] == 1 ? 'checked' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer) && $customer['isactive'] == 1 ? 'checked' : '' ?>>
@ -278,9 +249,7 @@
<br> <br>
<?php } ?> <?php } ?>
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitButton"> <button class="btn btn-success waves-effect waves-light mr-1" type="submit">Submit</button>
Submit
</button>
<!-- <button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button> --> <!-- <button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button> -->
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button> <button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a> <a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
@ -431,9 +400,9 @@
j=0; j=0;
for (var i = 0; i < sarray.length; i++) { for (var i = 0; i < sarray.length; i++) {
if (i == 0) { if (i == 0) {
var html = $(".after-add-smore").first(); var html = $(".after-shipping-addr-add-more").first();
} else { } else {
var html = $(".after-add-smore").first().clone(); var html = $(".after-shipping-addr-add-more").first().clone();
} }
if((barray[0]['address_1'] == sarray[i]['address_1']) && if((barray[0]['address_1'] == sarray[i]['address_1']) &&
(barray[0]['city'] == sarray[i]['city']) && (barray[0]['city'] == sarray[i]['city']) &&
@ -459,35 +428,32 @@
html.find('input#szip').val(sarray[i]['postal_code']); html.find('input#szip').val(sarray[i]['postal_code']);
if (i !== 0) { if (i !== 0) {
// html.find(".schange").html("<a class='btn btn-success waves-effect waves-light mr-1 add-smore'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>"); html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
html.find(".schange").html("<a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>"); html.insertAfter(".after-shipping-addr-add-more:last");
html.insertAfter(".after-add-smore:last");
} }
if (sarray.length == 1) { $(".schange").hide(); }
j++; j++;
toggleButtons();
} }
} else { } else {
$(".sremove").hide(); toggleButtons();
$(".add-smore").show();
} }
$("body").on("click", ".add-smore", function() { $("body").on("click", ".shipping-addr-add-more", function() {
var html = $(".after-add-smore").first().clone(); var html = $(".after-shipping-addr-add-more").first().clone();
var count = $(".after-add-smore").length; var count = $(".after-shipping-addr-add-more").length;
html.find('select#scountry0').attr('id','scountry'+count).val('') html.find('select#scountry0').attr('id','scountry'+count).val('')
html.find('select#sdstate0').attr('id','sdstate'+count).css("display", "none").val(''); html.find('select#sdstate0').attr('id','sdstate'+count).css("display", "none").val('');
html.find('input#sistate0').attr('id','sistate'+count).css("display", "block").val(''); html.find('input#sistate0').attr('id','sistate'+count).css("display", "block").val('');
html.find('input').val(''); // Clear input values in the cloned element html.find('input').val(''); // Clear input values in the cloned element
// html.find(".schange").html("<a class='btn btn-success waves-effect waves-light mr-1 add-smore'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>"); html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
html.find(".schange").html("<a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>"); html.insertAfter(".after-shipping-addr-add-more:last");
html.insertAfter(".after-add-smore:last");
toggleButtons(); toggleButtons();
}); });
$("body").on("click", ".sremove", function() { $("body").on("click", ".shipping-addr-remove", function() {
var rows = $(".after-add-smore"); var rows = $(".after-shipping-addr-add-more");
if (rows.length > 1) { if (rows.length > 1) {
$(this).parents(".after-add-smore").remove(); $(this).parents(".after-shipping-addr-add-more").remove();
} else { } else {
alert("At least one Shipping Address must be displayed."); alert("At least one Shipping Address must be displayed.");
} }
@ -495,14 +461,32 @@
}); });
function toggleButtons() { function toggleButtons() {
var elementCount = $(".after-add-smore").length; var elementCount = $(".after-shipping-addr-add-more").length;
console.log('elementCount == '+elementCount);
if (elementCount > 1) { if (elementCount > 1) {
$(".schange").show(); $(".shipping-addr-remove").show(); // Show the "shipping-addr-remove" buttons
} else { } else {
$(".schange").hide(); $(".shipping-addr-remove").hide(); // Hide the "shipping-addr-remove" buttons
} }
$(".after-shipping-addr-add-more .shipping-addr-add-more").hide();
$(".after-shipping-addr-add-more:last .shipping-addr-add-more").show();
} }
$('#submit-button').click(function() {
// Disable the button
$(this).prop('disabled', true);
// Change the button content to a spinner
$(this).html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...');
// Simulate a delay to demonstrate loading (you can replace this with your actual loading logic)
setTimeout(function() {
// Re-enable the button and restore the original text
$('#submit-button').prop('disabled', false);
$('#submit-button').html('Submit');
}, 3000); // Replace 3000 with the actual loading time in milliseconds
});
}); });
function changeFields(element) { function changeFields(element) {
@ -553,19 +537,4 @@ function validateEmail(email) {
validationMessage.style.color = "red"; validationMessage.style.color = "red";
} }
} }
// let clicked = false;
// function handleButtonClick() {
// if (!clicked) { // Check if the button hasn't been clicked before
// clicked = true;
// const requiredInputs = document.querySelectorAll('#myForm [required]');
// for (let input of requiredInputs) {
// if (input.value.trim() === '') {
// alert('Please fill in all required fields.');
// return false; // Prevent form submission
// }
// }
// document.getElementById("submitButton").disabled = true;
// // Add your code here to handle the first click action
// }
// }
</script> </script>

View File

@ -53,7 +53,7 @@
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td> <td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
<td> <td>
<a href="<?= base_url() . "view_customer_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a> <a href="<?= base_url() . "view_customer_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a>
<a class="preview-button" title="Preview" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a> <a class="preview-button" title="Customer list" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a>
<?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_customer_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?> <?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_customer_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
</td> </td>
</tr> </tr>
@ -69,7 +69,7 @@
<div class="modal-dialog modal-dialog-scrollable" role="document"> <div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="scrollableModalTitle">Data Preview</h5> <h5 class="modal-title" id="scrollableModalTitle">Customer list</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
@ -112,7 +112,7 @@ $(document).ready(function() {
// Get the data-primary-key attribute from the modal trigger // Get the data-primary-key attribute from the modal trigger
var primaryKey = $(event.relatedTarget).data('primary-key'); var primaryKey = $(event.relatedTarget).data('primary-key');
var groupName = $(event.relatedTarget).data('group-name'); var groupName = $(event.relatedTarget).data('group-name');
$('#scrollableModalTitle').text(groupName + ' - Data Preview'); $('#scrollableModalTitle').text(groupName + ' - Customer list');
// Get the table reference // Get the table reference
var table = $("#data-table tbody"); var table = $("#data-table tbody");

View File

@ -127,7 +127,7 @@
<div class="modal-dialog modal-dialog-scrollable" role="document"> <div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="scrollableModalTitle">Data Preview</h5> <h5 class="modal-title" id="scrollableModalTitle">Customer list</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
@ -434,7 +434,7 @@ document.getElementById("addItem").addEventListener("click", function() {
dataType: "json", // Expect JSON response dataType: "json", // Expect JSON response
success: function(response) { success: function(response) {
if (response.length > 0) { if (response.length > 0) {
$('#scrollableModalTitle').text(groupName + ' - Data Preview'); $('#scrollableModalTitle').text(groupName + ' - Customer list');
// Clear existing rows // Clear existing rows
table.empty(); table.empty();
$x=0; $x=0;

View File

@ -30,11 +30,9 @@
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th hidden></th> <th hidden></th>
<th>First Name</th> <th>Name</th>
<th>Last Name</th>
<th>Mobile Number</th> <th>Mobile Number</th>
<th>Email</th> <th>Email</th>
<th>Mode</th> <th>Mode</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
@ -42,8 +40,7 @@
<?php foreach ($customer as $value) :?> <?php foreach ($customer as $value) :?>
<tr> <tr>
<td hidden><?$value['customer_id'];?></td> <td hidden><?$value['customer_id'];?></td>
<td><?= $value['first_name']; ?></td> <td><?= $value['first_name'].' '.$value['last_name'] ; ?></td>
<td><?= $value['last_name']; ?></td>
<td><?= $value['mobile_no']; ?></td> <td><?= $value['mobile_no']; ?></td>
<td><?= $value['email']; ?></td> <td><?= $value['email']; ?></td>
<td><?= $value['mode']; ?></td> <td><?= $value['mode']; ?></td>

View File

@ -1,38 +1,24 @@
<html> <div class="row">
<head>
<style>
.discount-header {
text-align: center;
/* Add this to center-align the content */
}
</style>
</head>
<body>
<div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4> <h4 class="header-title"><?= $page_name; ?></h4>
<!-- <p class="sub-header"><?php print_r($invoice_details); ?> </p> --> <br>
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice";?>" > <form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>">
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="customerName">Customer Name</label> <label for="customerName">Customer Name<span class="text-danger"> *</span></label>
<select class="form-control" id="customerName" name="customer_name" required> <select class="form-control" id="customerName" name="customer_name" required>
<option value="">Select a customer</option> <option value="">Select a customer</option>
<?php foreach ($customers as $customer) : ?> <?php foreach ($customers as $customer) : ?>
<option value="<?= $customer->customer_id ?>" <option value="<?= $customer->customer_id ?>" <?php if (isset($invoice_details['customer_id']) && ($invoice_details['customer_id'] === $customer->customer_id)) echo "selected"; ?>>
<?php if (isset($invoice_details['customer_id']) && ($invoice_details['customer_id'] === $customer->customer_id)) echo "selected"; ?>> <?= $customer->first_name . ' ' . $customer->last_name; ?></option>
<?= $customer->first_name.' '.$customer->last_name; ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div>
<div class="invalid-feedback"> Please select customer. </div> <div class="invalid-feedback"> Please select customer. </div>
</div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="loadShippingDropdown">Shipping Address</label> <label for="loadShippingDropdown">Shipping Address</label>
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id"> <select class="form-control" id="loadShippingDropdown" name="shipping_address_id">
@ -43,83 +29,57 @@
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="storeBillingAddress"> Billing Address &ensp;( <input type="checkbox" <label for="storeBillingAddress"> Billing Address &ensp;( <input type="checkbox" id="editAddressesCheckbox" /> Do you want to edit/change addresses?)</label>
id="editAddressesCheckbox" /> Do you want to edit/change addresses?)</label> <input type="hidden" id="hiddenBillingAddressId" name="billing_address_id" placeholder="hidden for billing address id" value="<?= isset($invoice_details['billing_address_id']) ? $invoice_details['billing_address_id'] : '' ?>" />
<input type="hidden" id="hiddenBillingAddressId" name="billing_address_id" <textarea class="form-control" id="storeBillingAddress" name="billing_address" rows="4" readonly><?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : '' ?></textarea>
placeholder="hidden for billing address id"
value="<?= isset($invoice_details['billing_address_id']) ? $invoice_details['billing_address_id'] : '' ?>" />
<textarea class="form-control" id="storeBillingAddress" name="billing_address"
rows="4"
readonly><?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : '' ?></textarea>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="storeShippingAddress">Shipping Address</label> <label for="storeShippingAddress">Shipping Address</label>
<textarea class="form-control" id="storeShippingAddress" name="shipping_address" <textarea class="form-control" id="storeShippingAddress" name="shipping_address" rows="4" readonly><?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : '' ?></textarea>
rows="4"
readonly><?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : '' ?></textarea>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="event" class="col-form-label">Events<span <label for="event" class="col-form-label">Events</label>
class="text-danger">*</span></label> <input type="hidden" id="hiddenEventNextId" name="event_next_id" placeholder="hidden for event next id" />
<input type="hidden" id="hiddenEventNextId" name="event_next_id" <select class="form-control" id="event" name="event_id">
placeholder="hidden for event next id" />
<select class="form-control" id="event" name="event_id" required>
<option value="">Select an Events</option> <option value="">Select an Events</option>
<?php foreach ($events as $event) : ?> <?php foreach ($events as $event) : ?>
<!-- <option value="<?= $event->id ?>"><?= $event->event_name ?></option> --> <!-- <option value="<?= $event->id ?>"><?= $event->event_name ?></option> -->
<option value="<?= $event->id ?>" <option value="<?= $event->id ?>" <?php if (isset($invoice_details['event_id']) && ($invoice_details['event_id'] === $event->id)) echo "selected"; ?>>
<?php if (isset($invoice_details['event_id']) && ($invoice_details['event_id'] === $event->id)) echo "selected"; ?>>
<?= $event->event_name ?></option> <?= $event->event_name ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<div class="invalid-feedback"> Please select an events. </div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="invoiceNumber">Invoice Number</label> <label for="invoiceNumber">Invoice Number</label>
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number" <input type="text" class="form-control" id="invoiceNumber" name="invoice_number" value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="orderNumber">Order Number</label> <label for="orderNumber">Order Number</label>
<input type="text" class="form-control" id="orderNumber" name="order_number" <input type="text" class="form-control" id="orderNumber" name="order_number" value="<?= isset($invoice_details['order_number']) ? $invoice_details['order_number'] : '' ?>">
value="<?= isset($invoice_details['order_number']) ? $invoice_details['order_number'] : '' ?>">
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="invoiceDate">Invoice Date</label> <label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" <input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" required>
value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>">
</div>
<div class="form-group col-md-6">
<label for="dueDate">Due Date</label>
<input type="date" class="form-control" id="dueDate" name="due_date"
value="<?= isset($invoice_details['due_date']) ? $invoice_details['due_date'] : '' ?>">
</div> </div>
</div> </div>
<?php if ($invoice_type === '1') : ?>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<?php if ($invoice_type === '1'): ?>
<label for="fromsubcription">From Subcription</label> <label for="fromsubcription">From Subcription</label>
<input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>">
<input type="date" class="form-control" id="fromsubcription"
name="from_subscription"
value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="tosubcription">To Subcription</label> <label for="tosubcription">To Subcription</label>
<input type="date" class="form-control" id="to_subcription" name="to_subscription" <input type="date" class="form-control" id="to_subcription" name="to_subscription" value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>">
value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>"> </div>
</div>
<?php endif; ?> <?php endif; ?>
</div>
</div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<h4>Item Details</h4> <h4>Item Details</h4>
@ -132,102 +92,74 @@
<th>Rate</th> <th>Rate</th>
<th>Tax</th> <th>Tax</th>
<th>Amount </th> <th>Amount </th>
<th class="discount-header" colspan="2">Discount</th> <th style="text-align: center !important" colspan="2">Discount</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- Dynamically add rows for item details --> <!-- Dynamically add rows for item details -->
<?php if(!empty($invoice_item_details)){ foreach ($invoice_item_details as $ii_details): ?> <?php if (!empty($invoice_item_details)) {
foreach ($invoice_item_details as $inx => $ii_details) : ?>
<tr> <tr>
<td><select class="form-control" id="book" name="item_details[]" <td><select class="form-control" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required>
onchange="displayBookTag(this)" required>
<option value="">Select a book</option> <option value="">Select a book</option>
<?php foreach ($books as $book) : ?> <?php foreach ($books as $book) : ?>
<option value="<?= $book->book_id ?>" <option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
<?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
<?= $book->title ?></option> <?= $book->title ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select></td> </select></td>
<td style="width:10%;"><input type="number" class="form-control" <td style="width:10%;"><input type="number" class="form-control" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" />
id="quantity" name="quantity[]" oninput="calculateInvoice(this)"
value="<?= isset($ii_details['product']) ? $ii_details['quantity'] : '' ?>" />
</td> </td>
<td style="width:10%;"><input type="text" class="form-control" id="rate" <td style="width:10%;"><input type="text" class="form-control" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" readonly />
name="rate[]" oninput="calculateInvoice(this)"
value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" />
</td> </td>
<td style="width:5%;"><input type="text" class="form-control item-tax" <td style="width:8%;"><input type="text" class="form-control item-tax" id="<?= "tax" . $inx; ?>" name="tax[]" value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" readonly />
id="tax" name="tax[]"
value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" />
</td> </td>
<td style="width:12%;"><input type="text" <td style="width:12%;"><input type="text" class="form-control item-amount" id="<?= "amount" . $inx; ?>" name="amount[]" value="<?= isset($ii_details['subtotal']) ? $ii_details['subtotal'] : '' ?>" />
class="form-control item-amount" id="amount" name="amount[]"
value="<?= isset($ii_details['subtotal']) ? $ii_details['subtotal'] : '' ?>" />
</td> </td>
<td style="width:12%;"><input type="text" <td style="width:12%;"><input type="text" class="form-control item-discount-amount" id="<?= "item_discount_amount" . $inx; ?>" name="discount_amount[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['discount_amount']) ? $ii_details['discount_amount'] : '' ?>" />
class="form-control item-discount-amount"
name="discount_amount[]" oninput="calculateInvoice(this)"
value="<?= isset($ii_details['discount_amount']) ? $ii_details['discount_amount'] : '' ?>" />
</td> </td>
<td style="width:10%;"> <td style="width:10%;">
<select class="form-control item-discount-type" <select class="form-control item-discount-type" id="<?= "discount_type" . $inx; ?>" name="discount_type[]" oninput="calculateInvoice(this,<?= $inx; ?>)">
name="discount_type[]" oninput="calculateInvoice(this)"> <option value="" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '₹') echo "selected"; ?>>
<option value=""
<?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '₹') echo "selected"; ?>>
</option> </option>
<option value="%" <option value="%" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
<?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
%</option> %</option>
</select> </select>
</td> </td>
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId" <td><input type="hidden" class="form-control" id="<?= "hiddenInvoiceChildId" . $inx; ?>" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" value="<?= isset($ii_details['invoice_child_id']) ? $ii_details['invoice_child_id'] : '' ?>" />
name="invoice_child_id[]" value=""
placeholder="hidden for invoice child/item id"
value="<?= isset($ii_details['invoice_child_id']) ? $ii_details['invoice_child_id'] : '' ?>" />
<center><i class="fa fa-trash remove-item "></i></center> <center><i class="fa fa-trash remove-item "></i></center>
</td> </td>
</tr> </tr>
<?php endforeach; }else{ ?> <?php endforeach;
} else { ?>
<tr> <tr>
<td style="width:30%;"><select class="form-control" id="book" <td style="width:30%;"><select class="form-control" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required>
name="item_details[]" onchange="displayBookTag(this)">
<option value="">Select a book</option> <option value="">Select a book</option>
<?php foreach ($books as $book) : ?> <?php foreach ($books as $book) : ?>
<option value="<?= $book->book_id ?>"><?= $book->title ?> <option value="<?= $book->book_id ?>"><?= $book->title ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select></td> </select></td>
<td style="width:10%;"><input type="number" class="form-control" <td style="width:10%;"><input type="number" class="form-control" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
id="quantity" name="quantity[]"
oninput="calculateInvoice(this)" />
</td> </td>
<td style="width:10%;"><input type="text" class="form-control" id="rate" <td style="width:10%;"><input type="text" class="form-control" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
name="rate[]" oninput="calculateInvoice(this)" /></td> <td style="width:8%;"><input type="text" class="form-control item-tax" id="tax0" name="tax[]" /></td>
<td style="width:5%;"><input type="text" class="form-control item-tax" <td style="width:12%;"><input type="text" class="form-control item-amount" id="amount0" name="amount[]" />
id="tax" name="tax[]" /></td>
<td style="width:12%;"><input type="text"
class="form-control item-amount" id="amount" name="amount[]" />
</td> </td>
<td class="discount-cell" style="width:12%;"><input type="text" <td class="discount-cell" style="width:12%;"><input type="text" class="form-control item-discount-amount" id="item_discount_amount0" name="discount_amount[]" oninput="calculateInvoice(this,0)" />
class="form-control item-discount-amount"
name="discount_amount[]" oninput="calculateInvoice(this)" />
</td> </td>
<td style="width:12%;"> <td style="width:12%;">
<select class="form-control item-discount-type" <select class="form-control item-discount-type" id="<?= "discount_type0"; ?>" name="discount_type[]" oninput="calculateInvoice(this,0)">
name="discount_type[]" oninput="calculateInvoice(this)">
<option value=""></option> <option value=""></option>
<option value="%">%</option> <option value="%">%</option>
</select> </select>
</td> </td>
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId" <td><input type="hidden" class="form-control" id="hiddenInvoiceChildId0" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" />
name="invoice_child_id[]" value=""
placeholder="hidden for invoice child/item id" />
<center><i class="fa fa-trash remove-item "></i></center> <center><i class="fa fa-trash remove-item "></i></center>
</td> </td>
</tr> </tr>
@ -236,7 +168,7 @@
</tbody> </tbody>
</table> </table>
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<?php if ($invoice_type !== '1'): ?> <?php if ($invoice_type !== '1') : ?>
<!-- Show the "Add More Item" button only if invoice_type is not 1 --> <!-- Show the "Add More Item" button only if invoice_type is not 1 -->
<a class="btn" id="addItem"> <a class="btn" id="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4> <h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4>
@ -252,39 +184,32 @@
<h4>Calculation</h4> <h4>Calculation</h4>
<div class="form-group"> <div class="form-group">
<label for="subtotal">Subtotal</label> <label for="subtotal">Subtotal</label>
<input type="text" class="form-control" id="subtotal" name="sub_total" <input type="text" class="form-control" id="subtotal" name="sub_total" readonly value="<?= isset($invoice_details['subtotal']) ? $invoice_details['subtotal'] : 0 ?>">
readonly
value="<?= isset($invoice_details['subtotal']) ? $invoice_details['subtotal'] : '' ?>">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="invoicetax">Tax Amount</label> <label for="invoicetax">Tax Amount</label>
<input type="text" class="form-control" id="invoicetax" name="invoice_tax" <input type="text" class="form-control" id="invoicetax" name="invoice_tax" readonly value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : 0 ?>">
readonly
value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : '' ?>">
</div> </div>
<?php <?php
// Check if it's a subscription invoice // Check if it's a subscription invoice
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details'); $isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
// Conditionally set the "hidden" attribute for the fields // Conditionally set the "hidden" attribute for the fields
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : ''; $shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : ''; $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
?> ?>
<div class="form-group"> <div class="form-group">
<span style="<?= $shippingChargesStyle ?>"> <span style="<?= $shippingChargesStyle ?>">
<label for="shippingChargesLabel">Charge Name </label>
<input type="text" class="form-control" id="shippingChargesLabel" <input type="text" class="form-control" id="shippingChargesLabel" name="shippingChargesLabel" placeholder="Shipping Charges Label" value="<?= isset($invoice_details['shipping_label']) ? $invoice_details['shipping_label'] : 'Shipping Charge' ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
name="shippingChargesLabel" placeholder="Shipping Charges Label"
value="Shipping Charge" oninput="calculateOverallTotals()"
<?= $shippingChargesHidden ?>>
</span> </span>
</div>
<div class="form-group">
<span style="<?= $shippingChargesStyle ?>"> <span style="<?= $shippingChargesStyle ?>">
<label for="shippingCharges">Charge Amount </label>
<input type="text" class="form-control" id="shippingCharges" <input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? $invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
name="shippingCharges" placeholder="Shipping Charges"
oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
</span> </span>
</div> </div>
@ -292,46 +217,33 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
<div class="form-group"> <div class="form-group">
<label for="discount">Discount</label> <label for="discount">Discount</label>
<input type="number" class="form-control" id="discount" name="discount" <input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? $invoice_details['discount'] : 0 ?>">
onchange="calculateGrandTotal(this.value)"
value="<?= isset($invoice_details['discount']) ? $invoice_details['discount'] : '' ?>">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="grandtotal">Total</label> <label for="grandtotal">Total</label>
<input type="text" class="form-control" id="grandtotal" name="grand_total" <input type="text" class="form-control" id="grandtotal" name="grand_total" readonly value="<?= isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : 0 ?>">
readonly
value="<?= isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '' ?>">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="balanceAmount" >Balance <label for="balanceAmount">Balance Amount</label>
Amount:</label> <input type="number" class="form-control" id="balanceAmount" name="balanceAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
<input type="number" class="form-control" id="balanceAmount"
name="balanceAmount"
value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>"
oninput="calculateOverallTotals()" >
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="paidAmount">Paid Amount:</label> <label for="paidAmount">Paid Amount</label>
<input type="number" class="form-control" id="paidAmount" name="paidAmount" <input type="number" class="form-control" id="paidAmount" name="paidAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>"
oninput="calculateOverallTotals()" >
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group text-left col-md-12 "> <div class="form-group col-md-12">
<label for="notes">Notes</label> <label for="notes">Notes</label>
<textarea class="form-control" id="terms" name="notes"> <textarea class="form-control" id="notes" name="notes" rows="2"><?= isset($invoice_details['notes']) ? $invoice_details['notes'] : '' ?></textarea>
<?= isset($invoice_details['notes']) ? $invoice_details['notes'] : '' ?>
</textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog" <div class="modal fade" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true">
aria-labelledby="paymentModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -352,47 +264,38 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
</select> </select>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" name="saveas" value="Approved" id="saveapproved">Save as Approved</button>
<button type="submit" class="btn btn-primary" name="saveas" value="Approved"
id="saveapproved">Save as Approved</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" id="status" name="status" <input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : '' ?>">
value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : '' ?>"> <input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id" value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
<input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id"
value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved'): ?> <?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
<!-- Show the "Save as Draft" button only if the status is not "Approved" --> <!-- Show the "Save as Draft" button only if the status is not "Approved" -->
<button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" <button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
id="saveDraftButton">Save as Draft</button>
<?php endif; ?> <?php endif; ?>
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved'): ?> <?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
<!-- Show the "Save as Approved" button only if the status is not "Approved" --> <!-- Show the "Save as Approved" button only if the status is not "Approved" -->
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" <button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
value="Approved" id="saveApprovedButton">Save as Approved</button>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="invoice_type" <input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '1' : '2'; ?>">
value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '1' : '2'; ?>"> <input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : '' ?>">
<input type="hidden" id="status" name="status"
value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : '' ?>">
</div> </div>
</div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
document.getElementById("addItem").addEventListener("click", function() { document.getElementById("addItem").addEventListener("click", function() {
var bookArray = <?php echo json_encode($books); ?>; var bookArray = <?php echo json_encode($books); ?>;
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0]; var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var counter = table.rows.length;
var newRow = table.insertRow(table.rows.length); var newRow = table.insertRow(table.rows.length);
var cell1 = newRow.insertCell(0); var cell1 = newRow.insertCell(0);
@ -407,15 +310,14 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
const select = document.createElement('select'); const select = document.createElement('select');
select.className = 'form-control'; select.className = 'form-control';
select.id = 'book'; select.id = 'book' + counter;
select.name = 'item_details[]'; select.name = 'item_details[]';
select.onchange = function() { select.onchange = function() {
displayBookTag(select); displayBookTag(select, counter);
}; };
const defaultOption = document.createElement('option'); const defaultOption = document.createElement('option');
defaultOption.value = ''; defaultOption.value = '';
defaultOption.text = 'Select a book'; defaultOption.text = 'Select a book';
select.appendChild(defaultOption); select.appendChild(defaultOption);
// Use forEach to add options to the select element // Use forEach to add options to the select element
@ -427,62 +329,58 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
}); });
cell1.appendChild(select); cell1.appendChild(select);
// cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">'; // cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">';
cell2.innerHTML = cell2.innerHTML = '<input type="number" class="form-control" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
'<input type="number" class="form-control" id="quantity" name="quantity[]" oninput="calculateInvoice(this)">'; cell3.innerHTML = '<input type="text" class="form-control" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
cell3.innerHTML = cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax' + counter + '" name="tax[]">';
'<input type="text" class="form-control" id="rate" name="rate[]" oninput="calculateInvoice(this)">'; cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount' + counter + '" name="amount[]">';
cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax" name="tax[]">'; cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]">';
cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount" name="amount[]">'; cell7.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
cell6.innerHTML = cell8.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
'<input type="text" class="form-control item-discount-amount" name="discount_amount[]">';
cell7.innerHTML =
'<select class="form-control item-discount-type" style=""width:12%;" name="discount_type[]" oninput="calculateInvoice(this)"><option value="₹">₹</option><option value="%">%</option></select>';
cell8.innerHTML =
'<input type="hidden" class="form-control" id="hiddenInvoiceChildId" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
// Attach the calculateInvoice function to new input fields' change events // Attach the calculateInvoice function to new input fields' change events
// cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice); // cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
// cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice); // cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
// cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice); // cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
newRow.querySelector('.book-select').addEventListener("change", function() { newRow.querySelector('.book-select').addEventListener("change", function() {
displayBookTag(this); displayBookTag(this, counter);
}); });
newRow.querySelector('.quantity-input').addEventListener("input", function() { newRow.querySelector('.quantity-input').addEventListener("input", function() {
calculateInvoice(this); calculateInvoice(this, counter);
}); });
newRow.querySelector('.rate-input').addEventListener("input", function() { newRow.querySelector('.rate-input').addEventListener("input", function() {
calculateInvoice(this); calculateInvoice(this, counter);
}); });
newRow.querySelector('.discount-amount-input').addEventListener("input", function() { newRow.querySelector('.discount-amount-input').addEventListener("input", function() {
calculateInvoice(this); calculateInvoice(this, counter);
}); });
newRow.querySelector('.discount-type-select').addEventListener("change", function() { newRow.querySelector('.discount-type-select').addEventListener("change", function() {
calculateInvoice(this); calculateInvoice(this, counter);
}); });
}); });
// cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice); // cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
function displayBookTag(inputElement) { function displayBookTag(inputElement, counter) {
var row = inputElement.parentElement.parentElement; var row = inputElement.parentElement.parentElement;
var bookId = inputElement.value; var bookId = inputElement.value;
var bookArray = <?php echo json_encode($books); ?>; var bookArray = <?php echo json_encode($books); ?>;
const selectedBook = bookArray.find(book => book.book_id == bookId); const selectedBook = bookArray.find(book => book.book_id == bookId);
row.querySelector('#quantity' + counter).value = 1;
row.querySelector('#rate').value = selectedBook.price; row.querySelector('#rate' + counter).value = selectedBook.price;
row.querySelector('#rate').readOnly = true; row.querySelector('#rate' + counter).readOnly = true;
row.querySelector("#tax").value = selectedBook.tax ? selectedBook.tax : 0; row.querySelector("#tax" + counter).value = selectedBook.tax ? selectedBook.tax : 0;
row.querySelector("#tax").readOnly = true; row.querySelector("#tax" + counter).readOnly = true;
calculateInvoice(inputElement, counter);
} }
function calculateInvoice(inputElement) { function calculateInvoice(inputElement, counter) {
var row = inputElement.parentElement.parentElement; var row = inputElement.parentElement.parentElement;
var quantity = parseFloat(row.querySelector('#quantity').value); var quantity = parseFloat(row.querySelector('#quantity' + counter).value);
var rate = parseFloat(row.querySelector('#rate').value); var rate = parseFloat(row.querySelector('#rate' + counter).value);
var discountType = row.querySelector('select[name="discount_type[]"]').value; // Get the selected discount type var discountType = row.querySelector('select[name="discount_type[]"]').value; // Get the selected discount type
var discountAmount = parseFloat(row.querySelector('input[name="discount_amount[]"]').value) || 0; var discountAmount = parseFloat(row.querySelector('input[name="discount_amount[]"]').value) || 0;
@ -492,19 +390,19 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
if (discountType === '₹') { if (discountType === '₹') {
// Calculate discount based on ₹ // Calculate discount based on ₹
var discountedAmount = amount - discountAmount; var discountedAmount = amount - discountAmount;
row.querySelector('#amount').value = amount.toFixed(2); row.querySelector('#amount' + counter).value = amount.toFixed(2);
} else if (discountType === '%') { } else if (discountType === '%') {
// Calculate discount based on % // Calculate discount based on %
var discountPercentage = discountAmount; var discountPercentage = discountAmount;
var discountValue = (amount * discountPercentage) / 100; var discountValue = (amount * discountPercentage) / 100;
var discountedAmount = amount - discountValue; var discountedAmount = amount - discountValue;
row.querySelector('#amount').value = amount.toFixed(2); row.querySelector('#amount' + counter).value = amount.toFixed(2);
} else { } else {
// Invalid discount type // Invalid discount type
row.querySelector('#amount').value = amount.toFixed(2); // No discount applied row.querySelector('#amount' + counter).value = amount.toFixed(2); // No discount applied
} }
} else { } else {
row.querySelector('#amount').value = ''; // Clear the amount if either quantity or rate is not a number row.querySelector('#amount' + counter).value = ''; // Clear the amount if either quantity or rate is not a number
} }
calculateOverallTotals(); calculateOverallTotals();
@ -561,7 +459,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
var status = document.getElementById('status').value; var status = document.getElementById('status').value;
// $("#balanceAmount").val(totalElement); // $("#balanceAmount").val(totalElement);
if (status == 'Draft') { if (status == 'Draft' || status == '') {
$("#balanceAmount").val(totalElement); $("#balanceAmount").val(totalElement);
$("#paidAmount").val('0'); $("#paidAmount").val('0');
} else if (status == 'Approved') { } else if (status == 'Approved') {
@ -582,7 +480,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
var rows = document.querySelectorAll("#itemTable tbody tr"); var rows = document.querySelectorAll("#itemTable tbody tr");
rows.forEach(function(row) { rows.forEach(function(row) {
var item = { var item = {
subtotal: parseFloat(row.querySelector("#amount").value) || 0, subtotal: parseFloat(row.querySelector('input[name="amount[]"]').value) || 0,
discount_amount: parseFloat(row.querySelector('input[name="discount_amount[]"]').value) || discount_amount: parseFloat(row.querySelector('input[name="discount_amount[]"]').value) ||
0, 0,
discount_type: row.querySelector('select[name="discount_type[]"]').value discount_type: row.querySelector('select[name="discount_type[]"]').value
@ -679,10 +577,10 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
// var grandElement = grandTotal.toFixed(2); // var grandElement = grandTotal.toFixed(2);
// $("#grandtotal").val(grandElement); // $("#grandtotal").val(grandElement);
// } // }
</script> </script>
<!-- JavaScript for removing a row from the table --> <!-- JavaScript for removing a row from the table -->
<script> <script>
// Function to remove a row from the table // Function to remove a row from the table
function removeItem(row) { function removeItem(row) {
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0]; var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
@ -697,22 +595,21 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
removeItem(row); removeItem(row);
} }
}); });
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
var iid_arr = <?php echo json_encode($invoice_item_details); ?>; var iid_arr = <?php echo json_encode($invoice_item_details); ?>;
var cust_id = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>"; var cust_id = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
var ship_addr = var ship_addr_id = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
"<?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : ""; ?>";
var ship_addr_id =
"<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
var bill_addr =
"<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>";
if (cust_id != '') { if (cust_id != '') {
load_details1(ship_addr_id, cust_id); load_details1(ship_addr_id, cust_id);
load_details2(ship_addr_id, cust_id); load_details2(ship_addr_id, cust_id);
} }
var ship_addr = "";
var bill_addr = "";
// $("#customerName").val(customer_id).change(); // $("#customerName").val(customer_id).change();
$("#customerName").change(function() { $("#customerName").change(function() {
@ -770,7 +667,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
customer_billing_id = v.customer_address_id customer_billing_id = v.customer_address_id
}); });
} }
// console.log(customer_billing);
// var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr // var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr
// //
if ((bill_addr != "") && (bill_addr != customer_billing)) { if ((bill_addr != "") && (bill_addr != customer_billing)) {
@ -813,6 +710,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
} }
function load_details2(ship_addr_id, cust_id) { function load_details2(ship_addr_id, cust_id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<?= base_url() . 'load_details2' ?>", url: "<?= base_url() . 'load_details2' ?>",
@ -830,7 +728,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
.country + "." .country + "."
}); });
} }
// console.log(customer_shipping);
$("#storeShippingAddress").val(customer_shipping); $("#storeShippingAddress").val(customer_shipping);
}, },
error: function() { error: function() {
@ -858,14 +756,14 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
} }
}); });
</script> </script>
<script> <script>
document.getElementById('saveapproved').addEventListener('click', function() { document.getElementById('saveapproved').addEventListener('click', function() {
// Set the status field to 'Draft' before submitting // Set the status field to 'Draft' before submitting
document.getElementById('status').value = 'Approved'; document.getElementById('status').value = 'Approved';
}); });
</script> </script>
<script> <script>
// Get the Invoice Date input element by its ID // Get the Invoice Date input element by its ID
const invoiceDateInput = document.getElementById("invoiceDate"); const invoiceDateInput = document.getElementById("invoiceDate");
@ -879,25 +777,25 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
// Set the min and max date attributes // Set the min and max date attributes
invoiceDateInput.setAttribute("min", minDate); invoiceDateInput.setAttribute("min", minDate);
invoiceDateInput.setAttribute("max", maxDate); invoiceDateInput.setAttribute("max", maxDate);
</script> </script>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
// Get the Due Date input element by its ID // Get the Due Date input element by its ID
const dueDateInput = document.getElementById("dueDate"); // const dueDateInput = document.getElementById("dueDate");
// Get the current date // Get the current date
const currentDate = new Date(); // const currentDate = new Date();
// Set the minimum date attribute to today's date (YYYY-MM-DD format) // Set the minimum date attribute to today's date (YYYY-MM-DD format)
const minDate = currentDate.toISOString().split("T")[0]; // const minDate = currentDate.toISOString().split("T")[0];
dueDateInput.setAttribute("min", minDate); // dueDateInput.setAttribute("min", minDate);
// Optional: Set the default value to today's date // Optional: Set the default value to today's date
}); });
</script> </script>
<script> <script>
// When the "Save as Approved" button is clicked // When the "Save as Approved" button is clicked
document.getElementById('saveApprovedButton').addEventListener('click', function() { document.getElementById('saveApprovedButton').addEventListener('click', function() {
// Show the payment modal // Show the payment modal
@ -909,13 +807,13 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
var selectedPaymentMode = document.getElementById('paymentMode').value; var selectedPaymentMode = document.getElementById('paymentMode').value;
// You can now use the selected payment mode as needed // You can now use the selected payment mode as needed
console.log('Selected Payment Mode: ' + selectedPaymentMode); // console.log('Selected Payment Mode: ' + selectedPaymentMode);
// Close the modal // Close the modal
$('#paymentModal').modal('hide'); $('#paymentModal').modal('hide');
}); });
</script> </script>
<script> <script>
document.getElementById('saveapproved').addEventListener('click', function() { document.getElementById('saveapproved').addEventListener('click', function() {
// Get the balance amount // Get the balance amount
var balanceAmount = parseFloat(document.getElementById('balanceAmount').value) || 0; var balanceAmount = parseFloat(document.getElementById('balanceAmount').value) || 0;
@ -923,8 +821,4 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
// Replicate the balance amount value to the paid amount // Replicate the balance amount value to the paid amount
document.getElementById('paidAmount').value = balanceAmount; document.getElementById('paidAmount').value = balanceAmount;
}); });
</script> </script>
</body>
</html>

View File

@ -1,17 +1,15 @@
<html> <div class="row">
<head>
<div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="float-right"> <div class="float-right">
<a href="<?= base_url() . "new_book_invoice/0"; ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Invoice </a> <a href="<?= base_url() . "new_book_invoice/0"; ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Invoice </a>
</div>
<!-- HTML for the "Add New" button --> <!-- HTML for the "Add New" button -->
<!-- <div id="standard-modal" > <!-- <div id="standard-modal">
<div id="invoiceTypeModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div id="invoiceTypeModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"> <div class="modal-dialog modal-sm">
<div class="modal-dialog modal-sm">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" id="mySmallModalLabel">Select Invoice Type</h4> <h4 class="modal-title" id="mySmallModalLabel">Select Invoice Type</h4>
@ -28,10 +26,10 @@
<div class="modal-footer"> <div class="modal-footer">
<button id="confirmInvoiceType">Continue</button> <button id="confirmInvoiceType">Continue</button>
</div> </div>
</div>< /.modal-content --> </div>< /.modal-content
</div>
</div>
</div> </div> -->
<br> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
@ -56,60 +54,54 @@
<table id="scroll-horizontal-datatable_wrapper" class="table w-100 nowrap"> <table id="scroll-horizontal-datatable_wrapper" class="table w-100 nowrap">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th hidden></th> <th hidden></th>
<th>Invoice Number</th> <th>Invoice Number</th>
<th>Invoice Date</th> <th>Invoice Date</th>
<th>Customer Name</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>Status</th>
<th>Total</th> <th>Total</th>
<th align="center">Action</th> <th align="center">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($invoice as $row): ?> <?php foreach ($invoice as $row) :
if ($row['invoice_type'] == 2) : // Check if it's a subscription invoice
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
?>
<tr> <tr>
<?php if ($row['invoice_type'] == 2): // Check if it's a subscription invoice ?> <td hidden><?= $row['invoice_id']; ?></td>
<td hidden><?= $row['invoice_id'] ?></td>
<td><?= $row['invoice_number']; ?></td> <td><?= $row['invoice_number']; ?></td>
<td><?= $row['invoice_date']; ?></td> <td><?= $invoice_date; ?></td>
<td><?= $row['customer_name']; ?></td> <td><?= $row['customer_name']; ?></td>
<td><?= $row['status']; ?></td> <td><?= $row['status']; ?></td>
<td> <span data-plugin="counterup"><?= $row['total_amount']; ?></span></td> <td><?= "".$row['total_amount']; ?></td>
<td><a href="<?= base_url() . "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>&nbsp; <td>
<!-- <a href="<?= base_url() . "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>&nbsp; -->
<?php if ($row['invoice_type'] == 1): ?> <?php if ($row['invoice_type'] == 1) : ?>
<a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp; <a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<?php elseif ($row['invoice_type'] == 2): ?> <?php elseif ($row['invoice_type'] == 2) : ?>
<a href="<?= base_url() . "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp; <a href="<?= base_url() . "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<?php endif; ?> <?php endif; ?>
<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>&nbsp; <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>&nbsp;
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a></td>&nbsp; <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> </tr>
<?php endif; ?> <?php endif; endforeach; ?>
<?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> <!-- end card body--> </div> <!-- end card body-->
</div> <!-- end card --> </div> <!-- end card -->
</div><!-- end col--> </div><!-- end col-->
</div><!-- end row--> </div><!-- end row-->
<script>
<script> function openPdfInNewTab(pdfUrl) {
function openPdfInNewTab(pdfUrl) {
window.open(pdfUrl, '_blank'); window.open(pdfUrl, '_blank');
} }
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$("#addNewButton").click(function() { $("#addNewButton").click(function() {
// Show the pop-up modal // Show the pop-up modal
$("#invoiceTypeModal").modal("show"); $("#invoiceTypeModal").modal("show");
@ -133,16 +125,15 @@ $(document).ready(function() {
$("#invoiceTypeModal .close").click(function() { $("#invoiceTypeModal .close").click(function() {
$("#invoiceTypeModal").modal("hide"); $("#invoiceTypeModal").modal("hide");
}); });
}); });
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#scroll-horizontal-datatable_wrapper').DataTable({ $('#scroll-horizontal-datatable_wrapper').DataTable({
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table "order": [
[0, "desc"]
] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options // Other DataTables configuration options
}); });
}); });
</script> </script>

View File

@ -4,19 +4,16 @@
<div class="card-body"> <div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4> <h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p> <p class="sub-header"> </p>
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_scheme";?>"> <form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_scheme"; ?>">
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sname" class="col-form-label">Scheme Name<span class="text-danger">*</span></label> <label for="sname" class="col-form-label">Scheme Name</label>
<input type="text" class="form-control" id="sname" name="sname" value="<?= isset($scheme['title']) ? $scheme['title'] : '' ?>" placeholder=" Scheme Name" required /> <input type="text" class="form-control" id="sname" name="sname" value="<?= isset($scheme['title']) ? $scheme['title'] : '' ?>" placeholder=" Scheme Name" readonly />
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sprice" class="col-form-label">Price<span class="text-danger">*</span></label> <label for="sprice" class="col-form-label">Price</label>
<input type="number" class="form-control" name="sprice" value="<?= isset($scheme['price']) ? $scheme['price'] : '' ?>" placeholder="Price" required /> <input type="number" class="form-control" name="sprice" value="<?= isset($scheme['price']) ? $scheme['price'] : '' ?>" placeholder="Price" readonly />
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
@ -27,44 +24,41 @@
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sku" class="col-form-label">SKU ID<span class="text-danger">*</span></label> <label for="sku" class="col-form-label">SKU ID</label>
<input type="text" class="form-control" name="sku" value="<?= isset($scheme['sku']) ? $scheme['sku'] : '' ?>" placeholder="SKU ID" required /> <input type="text" class="form-control" name="sku" value="<?= isset($scheme['sku']) ? $scheme['sku'] : '' ?>" placeholder="SKU ID" readonly />
<div class="invalid-feedback"> Please provide. </div> </div>
</div> </div>
<div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sdescription" class="col-form-label">Description<span class="text-danger"></span></label> <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> <textarea readonly class="form-control" name="sdescription" placeholder="Description"><?= isset($scheme['description']) ? $scheme['description'] : '' ?></textarea>
</div> </div>
</div>
<div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="img_name" class="col-form-label">Scheme Picture</label> <label for="img_name" class="col-form-label">Scheme Picture</label>
<input type="file" name="img_name" accept="image/*" /> <input type="file" name="img_name" accept="image/*" />
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<?php if (isset($scheme) && !empty($scheme)): ?> <?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" /> <img id="imagePreview" src="<?= base_url('public/uploads/' . $scheme['img_name']) ?>" alt="Image Preview" style="max-width: 200px; display: block" />
<?php else: ?> <?php else : ?>
<img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" /> <img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" />
<?php endif; ?> <?php endif; ?>
</div>
</div> </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="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 ?>" /> <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"> <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' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($scheme) && $scheme['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>
</div> </div>
<br> <br>
<?php } ?> <?php } ?>
<br> <br> -->
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit"> <button class="btn btn-success waves-effect waves-light mr-1" type="submit">

View File

@ -2,9 +2,9 @@
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="float-right"> <!-- <div class="float-right">
<a href="new_scheme/0" class="btn btn-primary"><i class="ri-currency-line"></i> Add Scheme </a> <a href="<?= base_url() . "new_scheme/0" ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Scheme </a>
</div><!-- end col--> </div>--><!-- end col -->
<br> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
@ -47,7 +47,7 @@
<td hidden><?= $row['category_name']; ?></td> <td hidden><?= $row['category_name']; ?></td>
<td> <td>
<a href="<?= base_url() . "new_scheme/" . $row['book_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a> <a href="<?= base_url() . "new_scheme/" . $row['book_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<a href="<?= base_url() . "delete_scheme/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a> <!-- <a href="<?= base_url() . "delete_scheme/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a> -->
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -4,66 +4,63 @@
<div class="card-body"> <div class="card-body">
<div class="float-right"> <div class="float-right">
<!-- Add a "Print Addresses" button --> <!-- Add a "Print Addresses" button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#printAddressesModal">Print Addresses</button> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#printAddressesModal">Print Addresses</button>
<a href="<?= base_url() . "new_subscription_invoice/0"; ?>" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add Subscription</a>
<a href="<?= base_url()."new_subscription_invoice/0"; ?>" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add Subscription</a>
</div><!-- end col--> </div><!-- end col-->
<br> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive"> <div class="table-responsive">
<!-- <table id="alternative-page-datatable" class="table table-borderless table-hover table-centered m-0"> -->
<!-- <table class="table table-borderless table-hover table-centered m-0"> -->
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="scroll-horizontal-datatable_subcription" class="table w-100 nowrap"> <table id="scroll-horizontal-datatable_subcription" class="table w-100 nowrap">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th hidden></th> <th hidden></th>
<th>Invoice Number</th> <th>Invoice Number</th>
<th>Invoice Date</th> <th>Invoice Date</th>
<th>From Subscription</th>
<th>To Subscription</th>
<th>Customer Name</th> <th>Customer Name</th>
<th>Scheme Name</th>
<!-- <th>Book Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Discount</th>
<th>Tax</th> -->
<th>Status</th> <th>Status</th>
<th>Total</th> <th>Total</th>
<th align="center">Action</th> <th align="center">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($invoice as $row): ?> <?php
foreach ($invoice as $row) :
if ($row['invoice_type'] == 1) :
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
?>
<tr> <tr>
<?php if ($row['invoice_type'] == 1): ?>
<td hidden><?= $row['invoice_id'] ?></td> <td hidden><?= $row['invoice_id'] ?></td>
<td><?= $row['invoice_number']; ?></td> <td><?= $row['invoice_number']; ?></td>
<td><?= $row['invoice_date']; ?></td> <td><?= $invoice_date; ?></td>
<td><?= $row['from_subscription']; ?></td>
<td><?= $row['to_subscription']; ?></td>
<td><?= $row['customer_name']; ?></td> <td><?= $row['customer_name']; ?></td>
<td><?= $row['scheme_name']; ?></td>
<td><?= $row['status']; ?></td> <td><?= $row['status']; ?></td>
<td> <span data-plugin="counterup"><?= $row['total_amount']; ?></span></td> <td><?= "" . $row['total_amount']; ?></td>
<td><a href="<?= base_url() . "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>&nbsp; <td>
<!-- <a href="<?= base_url() . "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>&nbsp; -->
<?php if ($row['invoice_type'] == 1): ?> <?php if ($row['invoice_type'] == 1) : ?>
<a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp; <a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<?php elseif ($row['invoice_type'] == 2): ?> <?php elseif ($row['invoice_type'] == 2) : ?>
<a href="<?= base_url() . "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp; <a href="<?= base_url() . "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<?php endif; ?> <?php endif; ?>
<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>&nbsp; <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>&nbsp;
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a></td>&nbsp; <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> </tr>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<!-- Scheme List Modal --> <!-- Scheme List Modal -->
<!-- Create a modal for scheme selection --> <!-- Create a modal for scheme selection -->
<!-- Create a modal for scheme selection --> <div class="modal fade" id="printAddressesModal" tabindex="-1" role="dialog" aria-labelledby="printAddressesModalLabel" aria-hidden="true">
<div class="modal fade" id="printAddressesModal" tabindex="-1" role="dialog" aria-labelledby="printAddressesModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -75,7 +72,7 @@
<div class="modal-body"> <div class="modal-body">
<!-- Create a form to select schemes and download details --> <!-- Create a form to select schemes and download details -->
<!-- ... Inside the modal in subscriber_list.php ... --> <!-- ... Inside the modal in subscriber_list.php ... -->
<form action="<?= base_url('subscription/download_details'); ?>" method="post"> <form action="<?= base_url('subscription/download_details'); ?>" method="post">
<div class="form-group"> <div class="form-group">
<div class="form-group"> <div class="form-group">
<?php <?php
@ -92,18 +89,12 @@
} }
endforeach; endforeach;
?> ?>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Download Details</button> <button type="submit" class="btn btn-primary">Download Details</button>
</form> </form>
</div>
</div>
</div> <!-- end card body--> </div> <!-- end card body-->
</div> <!-- end card --> </div> <!-- end card -->
</div><!-- end col--> </div><!-- end col-->
@ -113,12 +104,13 @@
</div> </div>
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#scroll-horizontal-datatable_subcription').DataTable({ $('#scroll-horizontal-datatable_subcription').DataTable({
"order": [[0, "desc"]] // 0 is the column index "order": [
[0, "desc"]
] // 0 is the column index
}); });
}); });
</script> </script>

View File

@ -118,18 +118,18 @@
<span> Dashboard </span> <span> Dashboard </span>
</a> </a>
</li> </li>
<li>
<a href="<?= base_url()."invoice_list"; ?>">
<i class="fe-file-text"></i>
<span> Invoices </span>
</a>
</li>
<li> <li>
<a href="<?= base_url()."customer_list"; ?>"> <a href="<?= base_url()."customer_list"; ?>">
<i class="ri-map-pin-user-fill"></i> <i class="ri-map-pin-user-fill"></i>
<span> Customer </span> <span> Customer </span>
</a> </a>
</li> </li>
<li>
<a href="<?= base_url()."invoice_list"; ?>">
<i class="fe-file-text"></i>
<span> Invoices </span>
</a>
</li>
<li> <li>
<a href="<?= base_url()."subscribers_list"; ?>"> <a href="<?= base_url()."subscribers_list"; ?>">
<i class="ri-shield-user-line"></i> <i class="ri-shield-user-line"></i>

View File

@ -34,10 +34,8 @@
<th hidden ></th> <th hidden ></th>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
<th>Role</th>
<th>Mobile Number</th> <th>Mobile Number</th>
<th>File</th> <th>Role</th>
<th>Address</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
@ -60,15 +58,14 @@
$row['state'].($row['postal_code'] ? "-".$row['postal_code'] : ""), $row['state'].($row['postal_code'] ? "-".$row['postal_code'] : ""),
$row['country'] $row['country']
); );
// echo implode(', ', array_filter($addressParts)) . '.';
?> ?>
<tr> <tr>
<td hidden><?= $row['user_id'] ?></td> <td hidden><?= $row['user_id'] ?></td>
<td><?php echo $row['first_name'].' '.$row['last_name'] ; ?></td> <td><?php echo $row['first_name'].' '.$row['last_name'] ; ?></td>
<td><?php echo $row['email'] ; ?></td> <td><?php echo $row['email'] ; ?></td>
<td><?php echo $row['role'] ; ?></td>
<td><?php echo $row['mobile_no'] ; ?></td> <td><?php echo $row['mobile_no'] ; ?></td>
<td><?php echo $row['profile_picture'] ; ?></td> <td><?php echo $row['role'] ; ?></td>
<td><?php echo $row['address'] ? implode(', ', array_filter($addressParts)) . '.' : "" ; ?></td>
<td> <td>
<span class="<?php echo $class; ?>"><?php echo $message; ?></span> <span class="<?php echo $class; ?>"><?php echo $message; ?></span>
</td> </td>