Internal Discussion 31st : ps
This commit is contained in:
parent
e2449f18d6
commit
b2c2793df2
@ -19,7 +19,7 @@ class ApiIntegration extends ResourceController
|
||||
public function __construct()
|
||||
{
|
||||
$this->global_variable_business_id = 1;
|
||||
$this->global_variable_role = "online";
|
||||
$this->global_variable_role = "Online";
|
||||
$api_model = new ApiIntegrationModel();
|
||||
$table = 'users';
|
||||
$where = ['role'=>$this->global_variable_role,'business_id'=>(int)$this->global_variable_business_id];
|
||||
|
||||
@ -91,20 +91,15 @@ class Customer extends BaseController
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_role = get_user_role();
|
||||
$model = new CustomerModel();
|
||||
$dob = $this->request->getPost('dob');
|
||||
$dob = (isset($dob) && $dob != "") ? $dob : NULL ;
|
||||
$data = [
|
||||
'first_name' => $this->request->getPost('cfname'),
|
||||
'last_name' => $this->request->getPost('csname'),
|
||||
'mobile_no' => $this->request->getPost('cmobile'),
|
||||
'address' => $this->request->getPost('address'),
|
||||
'city' => $this->request->getPost('ccity'),
|
||||
'email' => $this->request->getPost('cmail'),
|
||||
'state' => $this->request->getPost('cstate'),
|
||||
'postal_code' => $this->request->getPost('czip'),
|
||||
'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'),
|
||||
'date_of_birth' => $dob,
|
||||
'mode' => "Offline",
|
||||
'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'=>'CM.name','fieldflag'=>1,'text'=> 'Category','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'] = [
|
||||
'' => 'Choose the operator',
|
||||
|
||||
@ -48,7 +48,7 @@ public function new_event($id)
|
||||
$data['page_name'] = 'Add Event';
|
||||
$data['event'] = [];
|
||||
} else if ($id !== '0') {
|
||||
$data['page_name'] = 'Edit Scheme';
|
||||
$data['page_name'] = 'Edit Event';
|
||||
$model = new EventModel();
|
||||
$model->setTable('events');
|
||||
$edit_event_details = $model->where(['id' => $id])->first();
|
||||
|
||||
@ -50,19 +50,19 @@ class Invoice extends BaseController
|
||||
$data['books'] = $model->getNonMembershipCategoryBooks('books', $where);
|
||||
|
||||
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['invoice_type'] = '2';
|
||||
$data['invoice_details'] = [];
|
||||
$data['invoice_item_details'] = [];
|
||||
} 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['invoice_type'] ='2';
|
||||
$data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first();
|
||||
$data['invoice_item_details'] = $this->get_invoice_item($id);
|
||||
}
|
||||
|
||||
// print_r($data['invoice_details']);die;
|
||||
$this->render_page('invoice_form', $data);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ class Subscription extends BaseController
|
||||
|
||||
$model = new InvoiceModel();
|
||||
$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']));
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ public function getGroupDetails()
|
||||
return $this->db->table('customer_groups as CG' )
|
||||
->join('users as U1', 'U1.user_id = CG.created_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])
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
@ -44,6 +44,33 @@ public function updateData($table, $data, $where)
|
||||
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)
|
||||
{
|
||||
|
||||
@ -127,14 +154,14 @@ public function updateData($table, $data, $where)
|
||||
|
||||
}
|
||||
// this function Also Used For Approve Notification.
|
||||
|
||||
public function getInvoiceItems($id)
|
||||
{
|
||||
$data = $this->db->table('invoiceitems')
|
||||
->where(['invoice_id' => $id, 'invoiceitems.isactive' => 1])
|
||||
->join('books as B', 'B.book_id = invoiceitems.product', 'left')
|
||||
// ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left')
|
||||
->select('invoiceitems.*,B.*')
|
||||
->join('book_categories as BC', 'BC.book_id = invoiceitems.product', 'left')
|
||||
->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
|
||||
//->limit(1,0)
|
||||
->get()
|
||||
|
||||
@ -41,7 +41,7 @@ class NotificationModel extends Model
|
||||
return $this->db->table('templates as T' )
|
||||
->join('users as U1', 'U1.user_id = T.created_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();
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public function getCampaignDetails(){
|
||||
->join('users as U1', 'U1.user_id = NC.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = NC.updated_by', '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();
|
||||
|
||||
if (!empty($result)) {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<!-- <div class="float-right">
|
||||
<a href="<?= base_url() . "book_page/0"; ?>" class="btn btn-primary waves-effect"> <span> <i class="mdi mdi-book-plus"></i></span> Add Book </a>
|
||||
</div>
|
||||
</div> -->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
@ -38,7 +38,7 @@
|
||||
<th>Year Of Release</th>
|
||||
<th>Price of the Book</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
<!-- <th>Action</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -58,17 +58,18 @@
|
||||
<td><?php echo $row['publisher']; ?></td>
|
||||
<td><?php echo $row['name']; ?></td>
|
||||
<td><?php echo $row['language']; ?></td>
|
||||
<td><?php echo date('Y', strtotime($row['publication_date'])); ?></td>
|
||||
<td>₹ <span data-plugin="counterup"><?php echo $row['price']; ?></span></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>₹ <?php echo $row['price']; ?></td>
|
||||
<td>
|
||||
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<!-- <td>
|
||||
|
||||
<a href="<?php echo $edit_page_route; ?>" class="edit-button"> <i class="ri-pencil-line"></i></a>
|
||||
<a href="<?= base_url() . "delete_books/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
|
||||
</td>
|
||||
</td> -->
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<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>
|
||||
</li>
|
||||
<?php if ($page_name === 'Edit Customer') : ?>
|
||||
<?php if ($page_name === 'Edit Customer Details') : ?>
|
||||
<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>
|
||||
</li>
|
||||
@ -59,30 +59,9 @@
|
||||
<div class="form-group col-md-4">
|
||||
<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" />
|
||||
|
||||
</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 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="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>
|
||||
@ -153,11 +132,6 @@
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please provide. </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 id="billinput" style="display: block">
|
||||
<label for="bistate" class="col-form-label">State</label>
|
||||
@ -178,6 +152,11 @@
|
||||
</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">
|
||||
<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" />
|
||||
@ -197,7 +176,7 @@
|
||||
<label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="after-add-smore">
|
||||
<div class="after-shipping-addr-add-more">
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
@ -226,12 +205,6 @@
|
||||
<div class="invalid-feedback"> Please provide. </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">
|
||||
|
||||
<label for="" class="col-form-label">State</label>
|
||||
<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">
|
||||
@ -242,12 +215,13 @@
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</select>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- <div class="invalid-feedback"> Please provide. </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">
|
||||
<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" />
|
||||
@ -260,16 +234,13 @@
|
||||
<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" />
|
||||
</div>
|
||||
<div class="form-group col-md-9 schange 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-danger waves-effect waves-light mr-1 sremove">- Remove </a>
|
||||
<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 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>
|
||||
</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)) { ?>
|
||||
<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' : '' ?>>
|
||||
@ -278,9 +249,7 @@
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitButton">
|
||||
Submit
|
||||
</button>
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit">Submit</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>
|
||||
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
@ -431,9 +400,9 @@
|
||||
j=0;
|
||||
for (var i = 0; i < sarray.length; i++) {
|
||||
if (i == 0) {
|
||||
var html = $(".after-add-smore").first();
|
||||
var html = $(".after-shipping-addr-add-more").first();
|
||||
} 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']) &&
|
||||
(barray[0]['city'] == sarray[i]['city']) &&
|
||||
@ -459,35 +428,32 @@
|
||||
|
||||
html.find('input#szip').val(sarray[i]['postal_code']);
|
||||
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(".schange").html("<a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>");
|
||||
html.insertAfter(".after-add-smore:last");
|
||||
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.insertAfter(".after-shipping-addr-add-more:last");
|
||||
}
|
||||
if (sarray.length == 1) { $(".schange").hide(); }
|
||||
j++;
|
||||
toggleButtons();
|
||||
}
|
||||
} else {
|
||||
$(".sremove").hide();
|
||||
$(".add-smore").show();
|
||||
toggleButtons();
|
||||
}
|
||||
|
||||
$("body").on("click", ".add-smore", function() {
|
||||
var html = $(".after-add-smore").first().clone();
|
||||
var count = $(".after-add-smore").length;
|
||||
$("body").on("click", ".shipping-addr-add-more", function() {
|
||||
var html = $(".after-shipping-addr-add-more").first().clone();
|
||||
var count = $(".after-shipping-addr-add-more").length;
|
||||
html.find('select#scountry0').attr('id','scountry'+count).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').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(".schange").html("<a class='btn btn-danger waves-effect waves-light mr-1 sremove'>- Remove </a>");
|
||||
html.insertAfter(".after-add-smore:last");
|
||||
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.insertAfter(".after-shipping-addr-add-more:last");
|
||||
toggleButtons();
|
||||
});
|
||||
|
||||
$("body").on("click", ".sremove", function() {
|
||||
var rows = $(".after-add-smore");
|
||||
$("body").on("click", ".shipping-addr-remove", function() {
|
||||
var rows = $(".after-shipping-addr-add-more");
|
||||
if (rows.length > 1) {
|
||||
$(this).parents(".after-add-smore").remove();
|
||||
$(this).parents(".after-shipping-addr-add-more").remove();
|
||||
} else {
|
||||
alert("At least one Shipping Address must be displayed.");
|
||||
}
|
||||
@ -495,14 +461,32 @@
|
||||
});
|
||||
|
||||
function toggleButtons() {
|
||||
var elementCount = $(".after-add-smore").length;
|
||||
var elementCount = $(".after-shipping-addr-add-more").length;
|
||||
console.log('elementCount == '+elementCount);
|
||||
if (elementCount > 1) {
|
||||
$(".schange").show();
|
||||
$(".shipping-addr-remove").show(); // Show the "shipping-addr-remove" buttons
|
||||
} 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) {
|
||||
@ -553,19 +537,4 @@ function validateEmail(email) {
|
||||
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>
|
||||
@ -53,7 +53,7 @@
|
||||
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></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 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 } ?>
|
||||
</td>
|
||||
</tr>
|
||||
@ -69,7 +69,7 @@
|
||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
||||
<div class="modal-content">
|
||||
<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">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@ -112,7 +112,7 @@ $(document).ready(function() {
|
||||
// Get the data-primary-key attribute from the modal trigger
|
||||
var primaryKey = $(event.relatedTarget).data('primary-key');
|
||||
var groupName = $(event.relatedTarget).data('group-name');
|
||||
$('#scrollableModalTitle').text(groupName + ' - Data Preview');
|
||||
$('#scrollableModalTitle').text(groupName + ' - Customer list');
|
||||
|
||||
// Get the table reference
|
||||
var table = $("#data-table tbody");
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
||||
<div class="modal-content">
|
||||
<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">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@ -434,7 +434,7 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
dataType: "json", // Expect JSON response
|
||||
success: function(response) {
|
||||
if (response.length > 0) {
|
||||
$('#scrollableModalTitle').text(groupName + ' - Data Preview');
|
||||
$('#scrollableModalTitle').text(groupName + ' - Customer list');
|
||||
// Clear existing rows
|
||||
table.empty();
|
||||
$x=0;
|
||||
|
||||
@ -30,11 +30,9 @@
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Name</th>
|
||||
<th>Mobile Number</th>
|
||||
<th>Email</th>
|
||||
|
||||
<th>Mode</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
@ -42,8 +40,7 @@
|
||||
<?php foreach ($customer as $value) :?>
|
||||
<tr>
|
||||
<td hidden><?$value['customer_id'];?></td>
|
||||
<td><?= $value['first_name']; ?></td>
|
||||
<td><?= $value['last_name']; ?></td>
|
||||
<td><?= $value['first_name'].' '.$value['last_name'] ; ?></td>
|
||||
<td><?= $value['mobile_no']; ?></td>
|
||||
<td><?= $value['email']; ?></td>
|
||||
<td><?= $value['mode']; ?></td>
|
||||
|
||||
@ -1,398 +1,301 @@
|
||||
<html>
|
||||
|
||||
<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="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<!-- <p class="sub-header"><?php print_r($invoice_details); ?> </p> -->
|
||||
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice";?>" >
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerName">Customer Name</label>
|
||||
<select class="form-control" id="customerName" name="customer_name" required>
|
||||
<option value="">Select a customer</option>
|
||||
<?php foreach ($customers as $customer) : ?>
|
||||
<option value="<?= $customer->customer_id ?>"
|
||||
<?php if (isset($invoice_details['customer_id']) && ($invoice_details['customer_id'] === $customer->customer_id)) echo "selected"; ?>>
|
||||
<?= $customer->first_name.' '.$customer->last_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<br>
|
||||
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerName">Customer Name<span class="text-danger"> *</span></label>
|
||||
<select class="form-control" id="customerName" name="customer_name" required>
|
||||
<option value="">Select a customer</option>
|
||||
<?php foreach ($customers as $customer) : ?>
|
||||
<option value="<?= $customer->customer_id ?>" <?php if (isset($invoice_details['customer_id']) && ($invoice_details['customer_id'] === $customer->customer_id)) echo "selected"; ?>>
|
||||
<?= $customer->first_name . ' ' . $customer->last_name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please select customer. </div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="loadShippingDropdown">Shipping Address</label>
|
||||
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id">
|
||||
<option value="">Select an address</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="loadShippingDropdown">Shipping Address</label>
|
||||
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id">
|
||||
<option value="">Select an address</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="storeBillingAddress"> Billing Address  ( <input type="checkbox"
|
||||
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'] : '' ?>" />
|
||||
<textarea class="form-control" id="storeBillingAddress" name="billing_address"
|
||||
rows="4"
|
||||
readonly><?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : '' ?></textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="storeShippingAddress">Shipping Address</label>
|
||||
<textarea class="form-control" id="storeShippingAddress" name="shipping_address"
|
||||
rows="4"
|
||||
readonly><?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : '' ?></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="storeBillingAddress"> Billing Address  ( <input type="checkbox" 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'] : '' ?>" />
|
||||
<textarea class="form-control" id="storeBillingAddress" name="billing_address" rows="4" readonly><?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : '' ?></textarea>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="event" class="col-form-label">Events<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="hidden" id="hiddenEventNextId" name="event_next_id"
|
||||
placeholder="hidden for event next id" />
|
||||
<select class="form-control" id="event" name="event_id" required>
|
||||
<option value="">Select an Events</option>
|
||||
<?php foreach ($events as $event) : ?>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="storeShippingAddress">Shipping Address</label>
|
||||
<textarea class="form-control" id="storeShippingAddress" name="shipping_address" rows="4" readonly><?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : '' ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="event" class="col-form-label">Events</label>
|
||||
<input type="hidden" id="hiddenEventNextId" name="event_next_id" placeholder="hidden for event next id" />
|
||||
<select class="form-control" id="event" name="event_id">
|
||||
<option value="">Select an Events</option>
|
||||
<?php foreach ($events as $event) : ?>
|
||||
<!-- <option value="<?= $event->id ?>"><?= $event->event_name ?></option> -->
|
||||
<option value="<?= $event->id ?>"
|
||||
<?php if (isset($invoice_details['event_id']) && ($invoice_details['event_id'] === $event->id)) echo "selected"; ?>>
|
||||
<option value="<?= $event->id ?>" <?php if (isset($invoice_details['event_id']) && ($invoice_details['event_id'] === $event->id)) echo "selected"; ?>>
|
||||
<?= $event->event_name ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please select an events. </div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceNumber">Invoice Number</label>
|
||||
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number" value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="orderNumber">Order Number</label>
|
||||
<input type="text" class="form-control" id="orderNumber" name="order_number" value="<?= isset($invoice_details['order_number']) ? $invoice_details['order_number'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
|
||||
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceNumber">Invoice Number</label>
|
||||
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number"
|
||||
value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="orderNumber">Order Number</label>
|
||||
<input type="text" class="form-control" id="orderNumber" name="order_number"
|
||||
value="<?= isset($invoice_details['order_number']) ? $invoice_details['order_number'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceDate">Invoice Date</label>
|
||||
<input type="date" class="form-control" id="invoiceDate" name="invoice_date"
|
||||
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 class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<?php if ($invoice_type === '1'): ?>
|
||||
<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 class="form-group col-md-6">
|
||||
<label for="tosubcription">To Subcription</label>
|
||||
<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'] : '' ?>">
|
||||
<?php endif; ?>
|
||||
<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'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
<br />
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Qty</th>
|
||||
<th>Rate</th>
|
||||
<th>Tax</th>
|
||||
<th>Amount </th>
|
||||
<th style="text-align: center !important" colspan="2">Discount</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Dynamically add rows for item details -->
|
||||
<?php if (!empty($invoice_item_details)) {
|
||||
foreach ($invoice_item_details as $inx => $ii_details) : ?>
|
||||
<tr>
|
||||
<td><select class="form-control" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required>
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
|
||||
<?= $book->title ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<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'] : '' ?>" />
|
||||
</td>
|
||||
<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 />
|
||||
</td>
|
||||
<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 />
|
||||
</td>
|
||||
<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'] : '' ?>" />
|
||||
</td>
|
||||
<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'] : '' ?>" />
|
||||
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<select class="form-control item-discount-type" id="<?= "discount_type" . $inx; ?>" name="discount_type[]" oninput="calculateInvoice(this,<?= $inx; ?>)">
|
||||
<option value="₹" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '₹') echo "selected"; ?>>
|
||||
₹</option>
|
||||
<option value="%" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
|
||||
%</option>
|
||||
</select>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
<br />
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
<thead>
|
||||
</td>
|
||||
<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'] : '' ?>" />
|
||||
<center><i class="fa fa-trash remove-item "></i></center>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach;
|
||||
} else { ?>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Qty</th>
|
||||
<th>Rate</th>
|
||||
<th>Tax</th>
|
||||
<th>Amount </th>
|
||||
<th class="discount-header" colspan="2">Discount</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Dynamically add rows for item details -->
|
||||
<?php if(!empty($invoice_item_details)){ foreach ($invoice_item_details as $ii_details): ?>
|
||||
<tr>
|
||||
<td><select class="form-control" id="book" name="item_details[]"
|
||||
onchange="displayBookTag(this)" required>
|
||||
<td style="width:30%;"><select class="form-control" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required>
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>"
|
||||
<?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
|
||||
<?= $book->title ?></option>
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control"
|
||||
id="quantity" name="quantity[]" oninput="calculateInvoice(this)"
|
||||
value="<?= isset($ii_details['product']) ? $ii_details['quantity'] : '' ?>" />
|
||||
<td style="width:10%;"><input type="number" class="form-control" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="rate"
|
||||
name="rate[]" oninput="calculateInvoice(this)"
|
||||
value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" />
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:8%;"><input type="text" class="form-control item-tax" id="tax0" name="tax[]" /></td>
|
||||
<td style="width:12%;"><input type="text" class="form-control item-amount" id="amount0" name="amount[]" />
|
||||
</td>
|
||||
<td style="width:5%;"><input type="text" class="form-control item-tax"
|
||||
id="tax" name="tax[]"
|
||||
value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" />
|
||||
</td>
|
||||
<td style="width:12%;"><input type="text"
|
||||
class="form-control item-amount" id="amount" name="amount[]"
|
||||
value="<?= isset($ii_details['subtotal']) ? $ii_details['subtotal'] : '' ?>" />
|
||||
</td>
|
||||
<td style="width:12%;"><input type="text"
|
||||
class="form-control item-discount-amount"
|
||||
name="discount_amount[]" oninput="calculateInvoice(this)"
|
||||
value="<?= isset($ii_details['discount_amount']) ? $ii_details['discount_amount'] : '' ?>" />
|
||||
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<select class="form-control item-discount-type"
|
||||
name="discount_type[]" oninput="calculateInvoice(this)">
|
||||
<option value="₹"
|
||||
<?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '₹') echo "selected"; ?>>
|
||||
₹</option>
|
||||
<option value="%"
|
||||
<?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
|
||||
%</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId"
|
||||
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>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; }else{ ?>
|
||||
<tr>
|
||||
<td style="width:30%;"><select class="form-control" id="book"
|
||||
name="item_details[]" onchange="displayBookTag(this)">
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control"
|
||||
id="quantity" name="quantity[]"
|
||||
oninput="calculateInvoice(this)" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="rate"
|
||||
name="rate[]" oninput="calculateInvoice(this)" /></td>
|
||||
<td style="width:5%;"><input type="text" class="form-control item-tax"
|
||||
id="tax" name="tax[]" /></td>
|
||||
<td style="width:12%;"><input type="text"
|
||||
class="form-control item-amount" id="amount" name="amount[]" />
|
||||
</td>
|
||||
<td class="discount-cell" style="width:12%;"><input type="text"
|
||||
class="form-control item-discount-amount"
|
||||
name="discount_amount[]" oninput="calculateInvoice(this)" />
|
||||
<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)" />
|
||||
|
||||
</td>
|
||||
<td style="width:12%;">
|
||||
<select class="form-control item-discount-type"
|
||||
name="discount_type[]" oninput="calculateInvoice(this)">
|
||||
<select class="form-control item-discount-type" id="<?= "discount_type0"; ?>" name="discount_type[]" oninput="calculateInvoice(this,0)">
|
||||
<option value="₹">₹</option>
|
||||
<option value="%">%</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId"
|
||||
name="invoice_child_id[]" value=""
|
||||
placeholder="hidden for invoice child/item id" />
|
||||
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId0" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" />
|
||||
<center><i class="fa fa-trash remove-item "></i></center>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<?php if ($invoice_type !== '1'): ?>
|
||||
<?php } ?>
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<?php if ($invoice_type !== '1') : ?>
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
<a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="offset-md-7 col-md-5 card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="text" class="form-control" id="subtotal" name="sub_total"
|
||||
readonly
|
||||
value="<?= isset($invoice_details['subtotal']) ? $invoice_details['subtotal'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="invoicetax">Tax Amount</label>
|
||||
<input type="text" class="form-control" id="invoicetax" name="invoice_tax"
|
||||
readonly
|
||||
value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : '' ?>">
|
||||
</div>
|
||||
<?php
|
||||
// Check if it's a subscription invoice
|
||||
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
||||
|
||||
// Conditionally set the "hidden" attribute for the fields
|
||||
|
||||
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
||||
|
||||
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
?>
|
||||
<div class="form-group">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
|
||||
<input type="text" class="form-control" id="shippingChargesLabel"
|
||||
name="shippingChargesLabel" placeholder="Shipping Charges Label"
|
||||
value="Shipping Charge" oninput="calculateOverallTotals()"
|
||||
<?= $shippingChargesHidden ?>>
|
||||
</span>
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
|
||||
<input type="text" class="form-control" id="shippingCharges"
|
||||
name="shippingCharges" placeholder="Shipping Charges"
|
||||
oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount"
|
||||
onchange="calculateGrandTotal(this.value)"
|
||||
value="<?= isset($invoice_details['discount']) ? $invoice_details['discount'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="grandtotal">Total</label>
|
||||
<input type="text" class="form-control" id="grandtotal" name="grand_total"
|
||||
readonly
|
||||
value="<?= isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '' ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="balanceAmount" >Balance
|
||||
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()" >
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="paidAmount">Paid Amount:</label>
|
||||
<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()" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group text-left col-md-12 ">
|
||||
<label for="notes">Notes</label>
|
||||
<textarea class="form-control" id="terms" name="notes">
|
||||
<?= isset($invoice_details['notes']) ? $invoice_details['notes'] : '' ?>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="paymentModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="paymentModalLabel">Select Mode of Payment</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div class="form-row">
|
||||
<div class="offset-md-7 col-md-5 card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="text" class="form-control" id="subtotal" name="sub_total" readonly value="<?= isset($invoice_details['subtotal']) ? $invoice_details['subtotal'] : 0 ?>">
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Add your mode of payment options here -->
|
||||
<select class="form-control" id="paymentMode" name="payment_method">
|
||||
<option value="credit">Credit Card</option>
|
||||
<option value="debit">Debit Card</option>
|
||||
<option value="cash">Cash</option>
|
||||
<option value="upi">UPI</option>
|
||||
<option value="banktransfer">Bank Transfer</option>
|
||||
<!-- Add more options as needed -->
|
||||
</select>
|
||||
<div class="form-group">
|
||||
<label for="invoicetax">Tax Amount</label>
|
||||
<input type="text" class="form-control" id="invoicetax" name="invoice_tax" readonly value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : 0 ?>">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary"
|
||||
data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary" name="saveas" value="Approved"
|
||||
id="saveapproved">Save as Approved</button>
|
||||
<?php
|
||||
// Check if it's a subscription invoice
|
||||
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
||||
|
||||
// Conditionally set the "hidden" attribute for the fields
|
||||
|
||||
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
||||
|
||||
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
?>
|
||||
<div class="form-group">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
<label for="shippingChargesLabel">Charge Name </label>
|
||||
<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 ?>>
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
<label for="shippingCharges">Charge Amount </label>
|
||||
<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 ?>>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? $invoice_details['discount'] : 0 ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="grandtotal">Total</label>
|
||||
<input type="text" class="form-control" id="grandtotal" name="grand_total" readonly value="<?= isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : 0 ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="balanceAmount">Balance 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>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="paidAmount">Paid Amount</label>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="status" name="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'] : '' ?>" />
|
||||
<div class="form-group text-right m-b-0">
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved'): ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="notes">Notes</label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="2"><?= isset($invoice_details['notes']) ? $invoice_details['notes'] : '' ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="paymentModalLabel">Select Mode of Payment</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Add your mode of payment options here -->
|
||||
<select class="form-control" id="paymentMode" name="payment_method">
|
||||
<option value="credit">Credit Card</option>
|
||||
<option value="debit">Debit Card</option>
|
||||
<option value="cash">Cash</option>
|
||||
<option value="upi">UPI</option>
|
||||
<option value="banktransfer">Bank Transfer</option>
|
||||
<!-- Add more options as needed -->
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary" name="saveas" value="Approved" id="saveapproved">Save as Approved</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="status" name="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'] : '' ?>" />
|
||||
<div class="form-group text-right m-b-0">
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== '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"
|
||||
id="saveDraftButton">Save as Draft</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved'): ?>
|
||||
<button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== '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"
|
||||
value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="invoice_type"
|
||||
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'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="invoice_type" 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'] : '' ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var bookArray = <?php echo json_encode($books); ?>;
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var counter = table.rows.length;
|
||||
var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
var cell1 = newRow.insertCell(0);
|
||||
@ -407,15 +310,14 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
|
||||
const select = document.createElement('select');
|
||||
select.className = 'form-control';
|
||||
select.id = 'book';
|
||||
select.id = 'book' + counter;
|
||||
select.name = 'item_details[]';
|
||||
select.onchange = function() {
|
||||
displayBookTag(select);
|
||||
displayBookTag(select, counter);
|
||||
};
|
||||
const defaultOption = document.createElement('option');
|
||||
defaultOption.value = '';
|
||||
defaultOption.text = 'Select a book';
|
||||
|
||||
select.appendChild(defaultOption);
|
||||
|
||||
// Use forEach to add options to the select element
|
||||
@ -427,62 +329,58 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
});
|
||||
cell1.appendChild(select);
|
||||
// cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">';
|
||||
cell2.innerHTML =
|
||||
'<input type="number" class="form-control" id="quantity" name="quantity[]" oninput="calculateInvoice(this)">';
|
||||
cell3.innerHTML =
|
||||
'<input type="text" class="form-control" id="rate" name="rate[]" oninput="calculateInvoice(this)">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount" name="amount[]">';
|
||||
cell6.innerHTML =
|
||||
'<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>';
|
||||
cell2.innerHTML = '<input type="number" class="form-control" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax' + counter + '" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount' + counter + '" name="amount[]">';
|
||||
cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_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>';
|
||||
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>';
|
||||
|
||||
// Attach the calculateInvoice function to new input fields' change events
|
||||
// cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
newRow.querySelector('.book-select').addEventListener("change", function() {
|
||||
displayBookTag(this);
|
||||
displayBookTag(this, counter);
|
||||
});
|
||||
newRow.querySelector('.quantity-input').addEventListener("input", function() {
|
||||
calculateInvoice(this);
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.rate-input').addEventListener("input", function() {
|
||||
calculateInvoice(this);
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-amount-input').addEventListener("input", function() {
|
||||
calculateInvoice(this);
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-type-select').addEventListener("change", function() {
|
||||
calculateInvoice(this);
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
|
||||
|
||||
|
||||
function displayBookTag(inputElement) {
|
||||
function displayBookTag(inputElement, counter) {
|
||||
var row = inputElement.parentElement.parentElement;
|
||||
var bookId = inputElement.value;
|
||||
var bookArray = <?php echo json_encode($books); ?>;
|
||||
|
||||
const selectedBook = bookArray.find(book => book.book_id == bookId);
|
||||
|
||||
row.querySelector('#rate').value = selectedBook.price;
|
||||
row.querySelector('#rate').readOnly = true;
|
||||
row.querySelector("#tax").value = selectedBook.tax ? selectedBook.tax : 0;
|
||||
row.querySelector("#tax").readOnly = true;
|
||||
|
||||
row.querySelector('#quantity' + counter).value = 1;
|
||||
row.querySelector('#rate' + counter).value = selectedBook.price;
|
||||
row.querySelector('#rate' + counter).readOnly = true;
|
||||
row.querySelector("#tax" + counter).value = selectedBook.tax ? selectedBook.tax : 0;
|
||||
row.querySelector("#tax" + counter).readOnly = true;
|
||||
calculateInvoice(inputElement, counter);
|
||||
}
|
||||
|
||||
function calculateInvoice(inputElement) {
|
||||
function calculateInvoice(inputElement, counter) {
|
||||
var row = inputElement.parentElement.parentElement;
|
||||
var quantity = parseFloat(row.querySelector('#quantity').value);
|
||||
var rate = parseFloat(row.querySelector('#rate').value);
|
||||
var quantity = parseFloat(row.querySelector('#quantity' + counter).value);
|
||||
var rate = parseFloat(row.querySelector('#rate' + counter).value);
|
||||
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;
|
||||
|
||||
@ -492,19 +390,19 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
if (discountType === '₹') {
|
||||
// Calculate discount based on ₹
|
||||
var discountedAmount = amount - discountAmount;
|
||||
row.querySelector('#amount').value = amount.toFixed(2);
|
||||
row.querySelector('#amount' + counter).value = amount.toFixed(2);
|
||||
} else if (discountType === '%') {
|
||||
// Calculate discount based on %
|
||||
var discountPercentage = discountAmount;
|
||||
var discountValue = (amount * discountPercentage) / 100;
|
||||
var discountedAmount = amount - discountValue;
|
||||
row.querySelector('#amount').value = amount.toFixed(2);
|
||||
row.querySelector('#amount' + counter).value = amount.toFixed(2);
|
||||
} else {
|
||||
// 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 {
|
||||
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();
|
||||
@ -561,7 +459,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
var status = document.getElementById('status').value;
|
||||
|
||||
// $("#balanceAmount").val(totalElement);
|
||||
if (status == 'Draft') {
|
||||
if (status == 'Draft' || status == '') {
|
||||
$("#balanceAmount").val(totalElement);
|
||||
$("#paidAmount").val('0');
|
||||
} else if (status == 'Approved') {
|
||||
@ -582,7 +480,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
var rows = document.querySelectorAll("#itemTable tbody tr");
|
||||
rows.forEach(function(row) {
|
||||
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) ||
|
||||
0,
|
||||
discount_type: row.querySelector('select[name="discount_type[]"]').value
|
||||
@ -679,10 +577,10 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
// var grandElement = grandTotal.toFixed(2);
|
||||
// $("#grandtotal").val(grandElement);
|
||||
// }
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<!-- JavaScript for removing a row from the table -->
|
||||
<script>
|
||||
<!-- JavaScript for removing a row from the table -->
|
||||
<script>
|
||||
// Function to remove a row from the table
|
||||
function removeItem(row) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
@ -697,22 +595,21 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
removeItem(row);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
var iid_arr = <?php echo json_encode($invoice_item_details); ?>;
|
||||
var cust_id = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
||||
var ship_addr =
|
||||
"<?= 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'] : ""; ?>";
|
||||
var ship_addr_id = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
|
||||
if (cust_id != '') {
|
||||
|
||||
load_details1(ship_addr_id, cust_id);
|
||||
load_details2(ship_addr_id, cust_id);
|
||||
}
|
||||
var ship_addr = "";
|
||||
var bill_addr = "";
|
||||
// $("#customerName").val(customer_id).change();
|
||||
|
||||
$("#customerName").change(function() {
|
||||
@ -770,7 +667,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
customer_billing_id = v.customer_address_id
|
||||
});
|
||||
}
|
||||
// console.log(customer_billing);
|
||||
|
||||
// var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr
|
||||
//
|
||||
if ((bill_addr != "") && (bill_addr != customer_billing)) {
|
||||
@ -813,6 +710,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
}
|
||||
|
||||
function load_details2(ship_addr_id, cust_id) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?= base_url() . 'load_details2' ?>",
|
||||
@ -830,7 +728,7 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
.country + "."
|
||||
});
|
||||
}
|
||||
// console.log(customer_shipping);
|
||||
|
||||
$("#storeShippingAddress").val(customer_shipping);
|
||||
},
|
||||
error: function() {
|
||||
@ -858,14 +756,14 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById('saveapproved').addEventListener('click', function() {
|
||||
// Set the status field to 'Draft' before submitting
|
||||
document.getElementById('status').value = 'Approved';
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
<script>
|
||||
// Get the Invoice Date input element by its ID
|
||||
const invoiceDateInput = document.getElementById("invoiceDate");
|
||||
|
||||
@ -879,25 +777,25 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
// Set the min and max date attributes
|
||||
invoiceDateInput.setAttribute("min", minDate);
|
||||
invoiceDateInput.setAttribute("max", maxDate);
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Get the Due Date input element by its ID
|
||||
const dueDateInput = document.getElementById("dueDate");
|
||||
// const dueDateInput = document.getElementById("dueDate");
|
||||
|
||||
// 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)
|
||||
const minDate = currentDate.toISOString().split("T")[0];
|
||||
dueDateInput.setAttribute("min", minDate);
|
||||
// const minDate = currentDate.toISOString().split("T")[0];
|
||||
// dueDateInput.setAttribute("min", minDate);
|
||||
|
||||
// Optional: Set the default value to today's date
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
<script>
|
||||
// When the "Save as Approved" button is clicked
|
||||
document.getElementById('saveApprovedButton').addEventListener('click', function() {
|
||||
// Show the payment modal
|
||||
@ -909,13 +807,13 @@ $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
var selectedPaymentMode = document.getElementById('paymentMode').value;
|
||||
|
||||
// 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
|
||||
$('#paymentModal').modal('hide');
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById('saveapproved').addEventListener('click', function() {
|
||||
// Get the balance amount
|
||||
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
|
||||
document.getElementById('paidAmount').value = balanceAmount;
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</script>
|
||||
@ -1,148 +1,139 @@
|
||||
<html>
|
||||
<head>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<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>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<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>
|
||||
</div>
|
||||
<!-- 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 class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="mySmallModalLabel">Select Invoice Type</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="subscription"> Subscription Invoice
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="book"> Book Invoice
|
||||
</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="confirmInvoiceType">Continue</button>
|
||||
</div>
|
||||
</div>< /.modal-content
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<div class="table-responsive">
|
||||
<table id="scroll-horizontal-datatable_wrapper" class="table w-100 nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Customer Name</th>
|
||||
<th>Status</th>
|
||||
<th>Total</th>
|
||||
<th align="center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?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>
|
||||
<td hidden><?= $row['invoice_id']; ?></td>
|
||||
<td><?= $row['invoice_number']; ?></td>
|
||||
<td><?= $invoice_date; ?></td>
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['status']; ?></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> -->
|
||||
<?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>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="invoiceTypeModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="mySmallModalLabel">Select Invoice Type</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="subscription"> Subscription Invoice
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="book"> Book Invoice
|
||||
</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="confirmInvoiceType">Continue</button>
|
||||
</div>
|
||||
</div>< /.modal-content -->
|
||||
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>
|
||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<div class="table-responsive">
|
||||
<table id="scroll-horizontal-datatable_wrapper" class="table w-100 nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
|
||||
<th hidden></th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Customer Name</th>
|
||||
|
||||
<!-- <th>Book Name</th>
|
||||
<th>Quantity</th>
|
||||
<th>Price</th>
|
||||
<th>Discount</th>
|
||||
<th>Tax</th> -->
|
||||
<th>Status</th>
|
||||
<th>Total</th>
|
||||
<th align="center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($invoice as $row): ?>
|
||||
<tr>
|
||||
<?php if ($row['invoice_type'] == 2): // Check if it's a subscription invoice ?>
|
||||
<td hidden><?= $row['invoice_id'] ?></td>
|
||||
<td><?= $row['invoice_number']; ?></td>
|
||||
<td><?= $row['invoice_date']; ?></td>
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['status']; ?></td>
|
||||
<td>₹ <span data-plugin="counterup"><?= $row['total_amount']; ?></span></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>
|
||||
|
||||
<?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>
|
||||
<?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>
|
||||
<?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>
|
||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div><!-- end row-->
|
||||
|
||||
<script>
|
||||
function openPdfInNewTab(pdfUrl) {
|
||||
window.open(pdfUrl, '_blank');
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#addNewButton").click(function() {
|
||||
// Show the pop-up modal
|
||||
$("#invoiceTypeModal").modal("show");
|
||||
});
|
||||
|
||||
$("#confirmInvoiceType").click(function() {
|
||||
// Get the selected invoice type
|
||||
var selectedType = $("input[name='invoiceType']:checked").val();
|
||||
|
||||
// Redirect the user to the appropriate form based on the selected type
|
||||
if (selectedType === "subscription") {
|
||||
// Redirect to the subscription invoice form
|
||||
window.location.href = "<?= base_url('new_subscription_invoice/0'); ?>"; // Update the URL as needed
|
||||
} else if (selectedType === "book") {
|
||||
// Redirect to the book invoice form
|
||||
window.location.href = "<?= base_url('new_book_invoice/0'); ?>"; // Update the URL as needed
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div><!-- end row-->
|
||||
<script>
|
||||
function openPdfInNewTab(pdfUrl) {
|
||||
window.open(pdfUrl, '_blank');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#addNewButton").click(function() {
|
||||
// Show the pop-up modal
|
||||
$("#invoiceTypeModal").modal("show");
|
||||
});
|
||||
|
||||
// Close the modal when the close button is clicked
|
||||
$("#invoiceTypeModal .close").click(function() {
|
||||
$("#invoiceTypeModal").modal("hide");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_wrapper').DataTable({
|
||||
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
|
||||
// Other DataTables configuration options
|
||||
});
|
||||
});
|
||||
</script>
|
||||
$("#confirmInvoiceType").click(function() {
|
||||
// Get the selected invoice type
|
||||
var selectedType = $("input[name='invoiceType']:checked").val();
|
||||
|
||||
|
||||
|
||||
// Redirect the user to the appropriate form based on the selected type
|
||||
if (selectedType === "subscription") {
|
||||
// Redirect to the subscription invoice form
|
||||
window.location.href = "<?= base_url('new_subscription_invoice/0'); ?>"; // Update the URL as needed
|
||||
} else if (selectedType === "book") {
|
||||
// Redirect to the book invoice form
|
||||
window.location.href = "<?= base_url('new_book_invoice/0'); ?>"; // Update the URL as needed
|
||||
}
|
||||
});
|
||||
|
||||
// Close the modal when the close button is clicked
|
||||
$("#invoiceTypeModal .close").click(function() {
|
||||
$("#invoiceTypeModal").modal("hide");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_wrapper').DataTable({
|
||||
"order": [
|
||||
[0, "desc"]
|
||||
] // 4 is the column index of "created_on" in your table
|
||||
// Other DataTables configuration options
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -4,19 +4,16 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<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-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sname" class="col-form-label">Scheme Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="sname" name="sname" value="<?= isset($scheme['title']) ? $scheme['title'] : '' ?>" placeholder=" Scheme Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
<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" readonly />
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sprice" class="col-form-label">Price<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="sprice" value="<?= isset($scheme['price']) ? $scheme['price'] : '' ?>" placeholder="Price" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
<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" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -27,44 +24,41 @@
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sku" class="col-form-label">SKU ID<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="sku" value="<?= isset($scheme['sku']) ? $scheme['sku'] : '' ?>" placeholder="SKU ID" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
<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" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sdescription" class="col-form-label">Description<span class="text-danger"></span></label>
|
||||
<textarea class="form-control" name="sdescription" placeholder="Description" ><?= isset($scheme['description']) ? $scheme['description'] : '' ?></textarea>
|
||||
|
||||
<textarea readonly class="form-control" name="sdescription" placeholder="Description"><?= isset($scheme['description']) ? $scheme['description'] : '' ?></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="img_name" class="col-form-label">Scheme Picture</label>
|
||||
<input type="file" name="img_name" accept="image/*" />
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<?php if (isset($scheme) && !empty($scheme)): ?>
|
||||
<img id="imagePreview" src="<?= base_url('public/uploads/' . $scheme['img_name']) ?>" alt="Image Preview" style="max-width: 200px; display: block" />
|
||||
<?php else: ?>
|
||||
<img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<label for="img_name" class="col-form-label">Scheme Picture</label>
|
||||
<input type="file" name="img_name" accept="image/*" />
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<?php if (isset($scheme) && !empty($scheme)) : ?>
|
||||
<img id="imagePreview" src="<?= base_url('public/uploads/' . $scheme['img_name']) ?>" alt="Image Preview" style="max-width: 200px; display: block" />
|
||||
<?php else : ?>
|
||||
<img id="imagePreview" src="" alt="Image Preview" style="max-width: 200px; display: none" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<input type="hidden" id="book_id" name="book_id" placeholder="hidden for scheme id" value="<?= isset($scheme['book_id']) ? $scheme['book_id'] : '' ?>" />
|
||||
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
|
||||
<?php if (!empty($scheme)) { ?>
|
||||
<!-- <?php if (!empty($scheme)) { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($scheme) && $scheme['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
</div>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<br>
|
||||
<br> -->
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit">
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<a href="new_scheme/0" class="btn btn-primary"><i class="ri-currency-line"></i> Add Scheme </a>
|
||||
</div><!-- end col-->
|
||||
<!-- <div class="float-right">
|
||||
<a href="<?= base_url() . "new_scheme/0" ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Scheme </a>
|
||||
</div>--><!-- end col -->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
@ -47,7 +47,7 @@
|
||||
<td hidden><?= $row['category_name']; ?></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() . "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>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -3,122 +3,114 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<!-- Add a "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>
|
||||
|
||||
<!-- Add a "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>
|
||||
</div><!-- end col-->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<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">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th hidden></th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>From Subscription</th>
|
||||
<th>To Subscription</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>Total</th>
|
||||
<th align="center">Action</th>
|
||||
</tr>
|
||||
<th>Scheme Name</th>
|
||||
<th>Status</th>
|
||||
<th>Total</th>
|
||||
<th align="center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($invoice as $row): ?>
|
||||
<tr>
|
||||
<?php if ($row['invoice_type'] == 1): ?>
|
||||
<td hidden><?= $row['invoice_id'] ?></td>
|
||||
<td><?= $row['invoice_number']; ?></td>
|
||||
<td><?= $row['invoice_date']; ?></td>
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['status']; ?></td>
|
||||
<td>₹ <span data-plugin="counterup"><?= $row['total_amount']; ?></span></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>
|
||||
|
||||
<?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>
|
||||
<?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>
|
||||
<?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>
|
||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
foreach ($invoice as $row) :
|
||||
if ($row['invoice_type'] == 1) :
|
||||
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
|
||||
?>
|
||||
<tr>
|
||||
<td hidden><?= $row['invoice_id'] ?></td>
|
||||
<td><?= $row['invoice_number']; ?></td>
|
||||
<td><?= $invoice_date; ?></td>
|
||||
<td><?= $row['from_subscription']; ?></td>
|
||||
<td><?= $row['to_subscription']; ?></td>
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['scheme_name']; ?></td>
|
||||
<td><?= $row['status']; ?></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> -->
|
||||
<?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>
|
||||
<?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>
|
||||
<?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>
|
||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Scheme List Modal -->
|
||||
<!-- 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-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="printAddressesModalLabel">Select Schemes to Print Addresses</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<!-- Scheme List Modal -->
|
||||
<!-- 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-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="printAddressesModalLabel">Select Schemes to Print Addresses</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Create a form to select schemes and download details -->
|
||||
<!-- ... Inside the modal in subscriber_list.php ... -->
|
||||
<form action="<?= base_url('subscription/download_details'); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<?php
|
||||
$uniqueSchemes = [];
|
||||
foreach ($subscriber as $scheme) :
|
||||
if (!in_array($scheme['title'], $uniqueSchemes)) {
|
||||
$uniqueSchemes[] = $scheme['title'];
|
||||
?>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="selected_schemes[]" value="<?= $scheme['title']; ?>">
|
||||
<label class="form-check-label"><?= $scheme['title']; ?></label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Download Details</button>
|
||||
</form>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Create a form to select schemes and download details -->
|
||||
<!-- ... Inside the modal in subscriber_list.php ... -->
|
||||
<form action="<?= base_url('subscription/download_details'); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<?php
|
||||
$uniqueSchemes = [];
|
||||
foreach ($subscriber as $scheme) :
|
||||
if (!in_array($scheme['title'], $uniqueSchemes)) {
|
||||
$uniqueSchemes[] = $scheme['title'];
|
||||
?>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="selected_schemes[]" value="<?= $scheme['title']; ?>">
|
||||
<label class="form-check-label"><?= $scheme['title']; ?></label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Download Details</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_subcription').DataTable({
|
||||
"order": [
|
||||
[0, "desc"]
|
||||
] // 0 is the column index
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_subcription').DataTable({
|
||||
"order": [[0, "desc"]] // 0 is the column index
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</script>
|
||||
@ -118,18 +118,18 @@
|
||||
<span> Dashboard </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."invoice_list"; ?>">
|
||||
<i class="fe-file-text"></i>
|
||||
<span> Invoices </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."customer_list"; ?>">
|
||||
<i class="ri-map-pin-user-fill"></i>
|
||||
<span> Customer </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."invoice_list"; ?>">
|
||||
<i class="fe-file-text"></i>
|
||||
<span> Invoices </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."subscribers_list"; ?>">
|
||||
<i class="ri-shield-user-line"></i>
|
||||
|
||||
@ -34,10 +34,8 @@
|
||||
<th hidden ></th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Mobile Number</th>
|
||||
<th>File</th>
|
||||
<th>Address</th>
|
||||
<th>Role</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
@ -60,15 +58,14 @@
|
||||
$row['state'].($row['postal_code'] ? "-".$row['postal_code'] : ""),
|
||||
$row['country']
|
||||
);
|
||||
// echo implode(', ', array_filter($addressParts)) . '.';
|
||||
?>
|
||||
<tr>
|
||||
<td hidden><?= $row['user_id'] ?></td>
|
||||
<td><?php echo $row['first_name'].' '.$row['last_name'] ; ?></td>
|
||||
<td><?php echo $row['email'] ; ?></td>
|
||||
<td><?php echo $row['role'] ; ?></td>
|
||||
<td><?php echo $row['mobile_no'] ; ?></td>
|
||||
<td><?php echo $row['profile_picture'] ; ?></td>
|
||||
<td><?php echo $row['address'] ? implode(', ', array_filter($addressParts)) . '.' : "" ; ?></td>
|
||||
<td><?php echo $row['role'] ; ?></td>
|
||||
<td>
|
||||
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
|
||||
</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user