BUG Fixes 1 : ps
This commit is contained in:
parent
6b0066c732
commit
e701736130
@ -302,14 +302,14 @@ class Customer extends BaseController
|
||||
$session_bid = get_business_id();
|
||||
|
||||
$data['field'] = [
|
||||
'' => 'Choose the Field',
|
||||
'C.type' => 'Type',
|
||||
'CA.city' => 'City',
|
||||
'CA.state' => 'State',
|
||||
'CM.name' => 'Category',
|
||||
'I.invoice_date' => 'Invoice Date',
|
||||
'S.to_subscription' => 'Due Date',
|
||||
];
|
||||
['value'=>'','fieldflag'=>1,'text'=> 'Choose the Field','disable' => false],
|
||||
['value'=>'C.type','fieldflag'=>1,'text'=> 'Type','disable' => false],
|
||||
['value'=>'CA.city','fieldflag'=>1,'text'=> 'City','disable' => false],
|
||||
['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]];
|
||||
|
||||
$data['operator'] = [
|
||||
'' => 'Choose the operator',
|
||||
'equal' => 'Equal to (=)',
|
||||
@ -498,7 +498,6 @@ class Customer extends BaseController
|
||||
LEFT JOIN category CM on CM.id = S.scheme_id
|
||||
WHERE C.isactive = 1 AND ".$whereCondition." GROUP BY C.customer_id";
|
||||
$this->logger->info("Customer Group: SQL = ".$sql);
|
||||
// echo $sql;
|
||||
// Execute the query
|
||||
$query = $db->query($sql);
|
||||
|
||||
|
||||
@ -88,25 +88,63 @@ public function getCampaignDetails(){
|
||||
foreach ($result as $i => $item) {
|
||||
$group_id = unserialize($item['group_id']);
|
||||
$group_names = [];
|
||||
|
||||
$group_query = [];
|
||||
foreach ($group_id as $j) {
|
||||
$cg_data = $this->db->table('customer_groups as CG')
|
||||
->select('CG.group_id, CG.group_name, CG.isactive')
|
||||
->select('CG.group_id, CG.group_name,CG.group_query, CG.isactive')
|
||||
->where(['CG.isactive' => 1, 'CG.group_id' => $j])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if ($cg_data) {
|
||||
$group_names[] = $cg_data['group_name'];
|
||||
$group_query[] = $cg_data['group_query'];
|
||||
// array_push($group_sql, $cg_data['group_query']);
|
||||
}
|
||||
}
|
||||
|
||||
$result[$i]['group_name'] = !empty($group_names) ? implode(", ", $group_names) : '';
|
||||
$result[$i]['customer_group'] = !empty($group_query) ? $this->customerGroupQueryExecution($group_query) : '';
|
||||
$result[$i]['customer_group_count'] = !empty($result[$i]['customer_group']) ? count($this->customerGroupQueryExecution($group_query)) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function customerGroupQueryExecution($queries){
|
||||
|
||||
$results = [];
|
||||
|
||||
// Execute the queries
|
||||
foreach ($queries as $query) {
|
||||
if(!empty($query)){
|
||||
$queryResult = $this->db->query($query)->getResult();
|
||||
$results[] = $queryResult;}
|
||||
}
|
||||
// echo "<pre>";
|
||||
// print_r($results);
|
||||
// echo "</pre>";
|
||||
// Create a new array to store the unique results based on customer_id
|
||||
$uniqueCustomers = array();
|
||||
|
||||
foreach ($results as $innerArray) {
|
||||
foreach ($innerArray as $customer) {
|
||||
$customerId = $customer->customer_id;
|
||||
|
||||
// Check if the customer_id already exists in $uniqueCustomers
|
||||
if (!isset($uniqueCustomers[$customerId])) {
|
||||
$uniqueCustomers[$customerId] = $customer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the $uniqueCustomers array back to a numerically indexed array
|
||||
$uniqueCustomers = array_values($uniqueCustomers);
|
||||
return $uniqueCustomers;
|
||||
// echo "<pre>";
|
||||
// print_r($uniqueCustomers);
|
||||
// echo "</pre>";
|
||||
// die;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
<th>Campaign Name</th>
|
||||
<th>Template Name</th>
|
||||
<th>Group Name</th>
|
||||
<th>Total Customer</th>
|
||||
<th>Scheduled at</th>
|
||||
<th>Created at</th>
|
||||
<th>Created by</th>
|
||||
@ -56,6 +57,7 @@
|
||||
<td><?= $c['campaign_name']; ?></td>
|
||||
<td><?= $c['template_name']; ?></td>
|
||||
<td><?= $c['group_name']; ?></td>
|
||||
<td><?= $c['customer_group_count']; ?></td>
|
||||
<td><?= $scheduled_date." ".$scheduled_time; ?></td>
|
||||
<td><?= $c['formatted_created_on']; ?></td>
|
||||
<td><?= $c['created_by_name']; ?></td>
|
||||
|
||||
@ -30,24 +30,24 @@
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cfname" class="col-form-label">First Name<span class="text-danger">*</span></label>
|
||||
<label for="cfname" class="col-form-label">First Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="cfname" name="cfname" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="csname" class="col-form-label">Last Name<span class="text-danger">*</span></label>
|
||||
<label for="csname" class="col-form-label">Last Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cmail" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" />
|
||||
|
||||
<label for="cmail" class="col-form-label">Email</label>
|
||||
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)"/>
|
||||
<span id="emailValidationMessage"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cmobile" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<label for="cmobile" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
|
||||
<div class="input-group mb-2">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">+91</div>
|
||||
@ -62,9 +62,9 @@
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gen" class="col-form-label">Gender<span class="text-danger">*</span></label>
|
||||
<label for="gen" class="col-form-label">Gender<span class="text-danger"> *</span></label>
|
||||
<select class="form-control" name="gen" required>
|
||||
<option> Select the Gender</option>
|
||||
<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>
|
||||
@ -75,11 +75,10 @@
|
||||
<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>
|
||||
<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>
|
||||
@ -101,29 +100,29 @@
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="bfname" class="col-form-label">First Name<span class="text-danger">*</span></label>
|
||||
<label for="bfname" class="col-form-label">First Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="bfname" name="bfname[]" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="blname" class="col-form-label">Last Name<span class="text-danger">*</span></label>
|
||||
<label for="blname" class="col-form-label">Last Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="blname" name="blname[]" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bcname" class="col-form-label">Company<span class="text-danger">*</span></label>
|
||||
<label for="bcname" class="col-form-label">Company<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="bcname" name="bcname[]" value="<?= isset($customer['Company']) ? $customer['Company'] : '' ?>" placeholder="Company" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bemail" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<label for="bemail" class="col-form-label">Email<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="bemail" name="bemail[]" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bmobile" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<label for="bmobile" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
|
||||
<input type="number" class="form-control" id="bmobile" name="bmobile[]" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
@ -131,19 +130,19 @@
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="baddress1" class="col-form-label">Address 1<span class="text-danger">*</span></label>
|
||||
<label for="baddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="baddress1" name="baddress1[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="baddress2" class="col-form-label">Address 2<span class="text-danger">*</span></label>
|
||||
<label for="baddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="baddress2" name="baddress2[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bcountry" class="col-form-label">Country<span class="text-danger">*</span></label>
|
||||
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
|
||||
<select class="form-control" id="bcountry" name="bcountry[]" required>
|
||||
<option value="">Choose your Country</option>
|
||||
<?php foreach ($country_details as $value) { ?>
|
||||
@ -155,17 +154,18 @@
|
||||
<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>
|
||||
<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<span class="text-danger">*</span></label>
|
||||
<label for="bistate" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State"/>
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
<div id="billdropdown" style="display: none">
|
||||
<label for="bdstate" class="col-form-label">State<span class="text-danger">*</span></label>
|
||||
<label for="bdstate" class="col-form-label">State</label>
|
||||
<select class="form-control" id="bdstate" name="bdstate[]">
|
||||
<option value="">Choose your State</option>
|
||||
<?php foreach ($state_details as $value) { ?>
|
||||
@ -174,11 +174,12 @@
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
|
||||
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="bzip" name="bzip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
@ -201,19 +202,19 @@
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="saddress1" class="col-form-label">Address 1<span class="text-danger">*</span></label>
|
||||
<label for="saddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="saddress1" name="saddress1[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="saddress2" class="col-form-label">Address 2<span class="text-danger">*</span></label>
|
||||
<label for="saddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="saddress2" name="saddress2[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="scountry" class="col-form-label">Country<span class="text-danger">*</span></label>
|
||||
<label for="scountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
|
||||
<select class="form-control" id="scountry0" name="scountry[]" onchange="changeFields(this)" required>
|
||||
<option value="">Choose your Country</option>
|
||||
<?php foreach ($country_details as $value) { ?>
|
||||
@ -225,13 +226,13 @@
|
||||
<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>
|
||||
<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<span class="text-danger">*</span></label>
|
||||
<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">
|
||||
<option value="">Choose your State</option>
|
||||
@ -241,11 +242,14 @@
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</select>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- <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>
|
||||
<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" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
@ -274,12 +278,11 @@
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitButton" onclick="handleButtonClick()">
|
||||
Submit
|
||||
</button>
|
||||
<button type="reset" class="btn btn-primary waves-effect mr-1">
|
||||
Reset
|
||||
</button>
|
||||
<!-- <button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button> -->
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
|
||||
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
<!-- Display Subscription Details -->
|
||||
@ -525,4 +528,38 @@
|
||||
$(this).tab('show');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function validateEmail(email) {
|
||||
// Regular expression for a basic email validation
|
||||
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
|
||||
|
||||
var emailInput = document.getElementById("cmail");
|
||||
var validationMessage = document.getElementById("emailValidationMessage");
|
||||
|
||||
if (emailPattern.test(email)) {
|
||||
validationMessage.textContent = "";
|
||||
}else if(email == ""){
|
||||
validationMessage.textContent = "";
|
||||
}
|
||||
else {
|
||||
validationMessage.textContent = "Invalid email address";
|
||||
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>
|
||||
@ -30,17 +30,18 @@
|
||||
<?php if(!empty($customer_group) && !empty($customer_group['column'])){ for ($i = 0; $i < count($customer_group['column']); $i++) { ?>
|
||||
<tr>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="column" name="column[]">
|
||||
<?php foreach ($field as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php if(isset($customer_group['column'][$i]) && $customer_group['column'][$i] == $value ){echo "selected";}?> >
|
||||
<?php echo $label; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
|
||||
<select class="form-control" data-toggle="select2" id=<?= "column".$i; ?> name="column[]" >
|
||||
<?php foreach ($field as $f) : ?>
|
||||
<option value="<?= $f['value']; ?>"
|
||||
fieldflag="<?= $f['fieldflag']; ?>"
|
||||
<?php if ($f['disable']) echo 'disabled'; ?>
|
||||
<?php if(isset($customer_group['column'][$i]) && $customer_group['column'][$i] == $f['value'] ){echo "selected";}?>>
|
||||
<?= $f['text']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="operator" name="operator[]">
|
||||
<select class="form-control" data-toggle="select2" id=<?= "operator".$i; ?> name="operator[]" onchange="FieldChange(this,<?= $i; ?>)">
|
||||
<?php foreach ($operator as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php if(isset($customer_group['operator'][$i]) && $customer_group['operator'][$i] == $value ){echo "selected";}?> >
|
||||
<?php echo $label; ?>
|
||||
@ -49,8 +50,24 @@
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<input type="text" class="form-control" id="values" name="values[]" placeholder="Enter the Values"
|
||||
<?php if ($customer_group['operator'][$i] == 'greater than' || $customer_group['operator'][$i] == 'greater than or equal to' || $customer_group['operator'][$i] == 'less than' || $customer_group['operator'][$i] == 'less than or equal to') { ?>
|
||||
<input type="date" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Date" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
<?php }else if($customer_group['operator'][$i] === 'between') {
|
||||
$dates = (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? explode(',', $customer_group['values'][$i]) : [] ;
|
||||
?>
|
||||
<div style="display: inline-flex;">
|
||||
<input type="date" class="form-control" id=<?= "values".$i.'1'; ?> placeholder="Enter the Start Date" onchange="concatBetween(<?= $i ?>)" value="<?= (isset($dates[0]) && $dates[0] != "" ) ? str_replace(' ', '', $dates[0]) : '' ?>" />
|
||||
<input type="date" class="form-control ml-1" id=<?= "values".$i.'2'; ?> placeholder="Enter the End Date" onchange="concatBetween(<?= $i ?>)" value="<?= (isset($dates[1]) && $dates[1] != "" ) ? str_replace(' ', '', $dates[1]) : '' ?>" />
|
||||
</div>
|
||||
<input type="hidden" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="values" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
<?php } else if(($customer_group['operator'][$i] === 'contain' || $customer_group['operator'][$i] == 'not contain')) { ?>
|
||||
<input type="text" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Multiple Values with comma Seprator" onkeypress="return restriction(event,'M')" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
<?php }else if($customer_group['operator'][$i] === 'is null' || $customer_group['operator'][$i] == 'is not null') { ?>
|
||||
<input type="hidden" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Values" value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
<?php } else { ?>
|
||||
<input type="text" class="form-control" id=<?= "values".$i; ?> name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,2)"
|
||||
value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item "><i class="fa fa-trash"></i></button>
|
||||
@ -59,17 +76,17 @@
|
||||
<?php } }else{ ?>
|
||||
<tr>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="column" name="column[]">
|
||||
<?php foreach ($field as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>">
|
||||
<?php echo $label; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
|
||||
<select class="form-control" data-toggle="select2" id="column0" name="column[]" >
|
||||
<?php foreach ($field as $f) : ?>
|
||||
<option value="<?= $f['value']; ?>"
|
||||
fieldflag="<?= $f['fieldflag']; ?>"
|
||||
<?php if ($f['disable']) echo 'disabled'; ?> >
|
||||
<?= $f['text']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="operator" name="operator[]">
|
||||
<select class="form-control" data-toggle="select2" id="operator0" name="operator[]" onchange="FieldChange(this,0)">
|
||||
<?php foreach ($operator as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>">
|
||||
<?php echo $label; ?>
|
||||
@ -78,7 +95,7 @@
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<input type="text" class="form-control" id="values" name="values[]" placeholder="Enter the Values" />
|
||||
<input type="text" class="form-control" id="values0" name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,1)" />
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item "><i class="fa fa-trash"></i></button>
|
||||
@ -103,9 +120,7 @@
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" class="btn btn-purple waves-effect mr-1" data-toggle="modal" data-target="#scrollable-modal">Save</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_group"; ?>" class="btn btn-secondary waves-effect mr-3">Cancel</a>
|
||||
</div>
|
||||
<div class="modal" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true">
|
||||
@ -149,6 +164,7 @@
|
||||
</div>
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
|
||||
<script>
|
||||
const myArray = [];
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var fieldArray = <?php echo json_encode($field); ?>;
|
||||
var operatorArray = <?php echo json_encode($operator); ?>;
|
||||
@ -156,6 +172,7 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
var hasValue = false;
|
||||
var rowCounter = rows.length; // Get the current number of rows
|
||||
|
||||
// Check if any existing fields are empty
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
@ -165,7 +182,7 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
if (input && input.value.trim() === "") {
|
||||
alert("Field in row " + (i + 1) + " is empty.");
|
||||
return; // Exit the loop after the first empty field is found.
|
||||
}else {
|
||||
} else {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
@ -176,31 +193,52 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
return; // Exit the function to prevent adding a new row.
|
||||
}
|
||||
|
||||
var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
var newRow = table.insertRow(rowCounter);
|
||||
|
||||
var cell1 = newRow.insertCell(0);
|
||||
var cell2 = newRow.insertCell(1);
|
||||
var cell3 = newRow.insertCell(2);
|
||||
var cell4 = newRow.insertCell(3);
|
||||
|
||||
|
||||
const select1 = document.createElement('select');
|
||||
select1.className = 'form-control';
|
||||
select1.name = 'column[]';
|
||||
select1.setAttribute("data-toggle", "select2");
|
||||
|
||||
select1.id = 'column' + rowCounter; // Set a dynamic ID for the select input
|
||||
// select1.onchange = function() {
|
||||
// disableSelectedOptions(this,rowCounter);
|
||||
// };
|
||||
|
||||
const select2 = document.createElement('select');
|
||||
select2.className = 'form-control';
|
||||
select2.name = 'operator[]';
|
||||
select2.setAttribute("data-toggle", "select2");
|
||||
select2.id = 'operator' + rowCounter; // Set a dynamic ID for the select input
|
||||
select2.onchange = function() {
|
||||
FieldChange(this, rowCounter);
|
||||
};
|
||||
|
||||
exstingColumnId = 'column'+(rowCounter-1);
|
||||
// if($('#' + exstingColumnId).val() != ""){
|
||||
// myArray.push($('#' + exstingColumnId).val());
|
||||
// }
|
||||
// console.log(myArray);
|
||||
|
||||
for (const fieldvalue in fieldArray) {
|
||||
const fieldoption = document.createElement('option');
|
||||
fieldoption.value = fieldvalue;
|
||||
fieldoption.text = fieldArray[fieldvalue];
|
||||
select1.appendChild(fieldoption);
|
||||
}
|
||||
fieldArray.forEach((option) => {
|
||||
const fieldoption = document.createElement('option');
|
||||
fieldoption.value = option.value;
|
||||
fieldoption.setAttribute("fieldflag", option.fieldflag);
|
||||
fieldoption.text = option.text;
|
||||
// fieldoption.disabled = option.disable ? true : (option.disable == myArray[0] ? true : false);
|
||||
// if (myArray.includes(option.value)) {
|
||||
// fieldoption.disabled = true;
|
||||
// }
|
||||
// else{
|
||||
// fieldoption.disabled = false;
|
||||
// }
|
||||
select1.appendChild(fieldoption);
|
||||
});
|
||||
|
||||
for (const value in operatorArray) {
|
||||
const optionElement = document.createElement('option');
|
||||
@ -214,6 +252,7 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
inputElement.className = 'form-control';
|
||||
inputElement.name = 'values[]';
|
||||
inputElement.placeholder = 'Enter the Values';
|
||||
inputElement.id = 'values' + rowCounter; // Set a dynamic ID for the input field
|
||||
|
||||
cell1.appendChild(select1);
|
||||
cell2.appendChild(select2);
|
||||
@ -223,6 +262,82 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
$(select1).select2();
|
||||
$(select2).select2();
|
||||
});
|
||||
|
||||
|
||||
// document.getElementById("addItemold").addEventListener("click", function() {
|
||||
// var fieldArray = <?php echo json_encode($field); ?>;
|
||||
// var operatorArray = <?php echo json_encode($operator); ?>;
|
||||
|
||||
// var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
// var rows = table.getElementsByTagName("tr");
|
||||
// var hasValue = false;
|
||||
|
||||
// // Check if any existing fields are empty
|
||||
// for (var i = 0; i < rows.length; i++) {
|
||||
// var cells = rows[i].getElementsByTagName("td");
|
||||
// for (var j = 0; j < cells.length; j++) {
|
||||
// var input = cells[j].querySelector('input, select');
|
||||
// if (input && input.value.trim() === "") {
|
||||
// alert("Field in row " + (i + 1) + " is empty.");
|
||||
// return; // Exit the loop after the first empty field is found.
|
||||
// }else {
|
||||
// hasValue = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!hasValue) {
|
||||
// alert("At least one row should contain a value.");
|
||||
// return; // Exit the function to prevent adding a new row.
|
||||
// }
|
||||
|
||||
// var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
// var cell1 = newRow.insertCell(0);
|
||||
// var cell2 = newRow.insertCell(1);
|
||||
// var cell3 = newRow.insertCell(2);
|
||||
// var cell4 = newRow.insertCell(3);
|
||||
|
||||
// const select1 = document.createElement('select');
|
||||
// select1.className = 'form-control';
|
||||
// select1.name = 'column[]';
|
||||
// select1.setAttribute("data-toggle", "select2");
|
||||
|
||||
|
||||
// const select2 = document.createElement('select');
|
||||
// select2.className = 'form-control';
|
||||
// select2.name = 'operator[]';
|
||||
// select2.setAttribute("data-toggle", "select2");
|
||||
|
||||
|
||||
// for (const fieldvalue in fieldArray) {
|
||||
// const fieldoption = document.createElement('option');
|
||||
// fieldoption.value = fieldvalue;
|
||||
// fieldoption.text = fieldArray[fieldvalue];
|
||||
// select1.appendChild(fieldoption);
|
||||
// }
|
||||
|
||||
// for (const value in operatorArray) {
|
||||
// const optionElement = document.createElement('option');
|
||||
// optionElement.value = value;
|
||||
// optionElement.text = operatorArray[value];
|
||||
// select2.appendChild(optionElement);
|
||||
// }
|
||||
|
||||
// const inputElement = document.createElement('input');
|
||||
// inputElement.type = 'text';
|
||||
// inputElement.className = 'form-control';
|
||||
// inputElement.name = 'values[]';
|
||||
// inputElement.placeholder = 'Enter the Values';
|
||||
|
||||
// cell1.appendChild(select1);
|
||||
// cell2.appendChild(select2);
|
||||
// cell3.appendChild(inputElement);
|
||||
// cell4.innerHTML = '<button type="button" class="btn btn-soft-danger btn-rounded waves-effect waves-light mr-1 remove-item"><i class="fa fa-trash"></i></button>';
|
||||
|
||||
// $(select1).select2();
|
||||
// $(select2).select2();
|
||||
// });
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@ -231,6 +346,15 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
if (rows.length > 1) {
|
||||
var rowIndex = row.rowIndex; // Get the row index
|
||||
console.log(rowIndex);
|
||||
var exstingColumnId = 'column' + (rowIndex-1);
|
||||
var valueToRemove = $('#' + exstingColumnId).val();
|
||||
// var indexToRemove = myArray.indexOf(valueToRemove);
|
||||
// if (indexToRemove !== -1) {
|
||||
// myArray.splice(indexToRemove, 1); // Remove the element at the specified index
|
||||
// }
|
||||
// console.log('myArray',myArray);
|
||||
table.removeChild(row);
|
||||
} else {
|
||||
alert('At least one row should contain a value.');
|
||||
@ -343,7 +467,108 @@ document.getElementById("addItem").addEventListener("click", function() {
|
||||
$("#save").on("click", function () {
|
||||
$("#string_flag").val("save");
|
||||
});
|
||||
</script>
|
||||
|
||||
function FieldChange(selectElement, rowCounter) {
|
||||
var id = selectElement.id;
|
||||
var selectedOperator = selectElement.value;
|
||||
var inputId = 'values' + rowCounter;
|
||||
var column = $("#column"+rowCounter).find(':selected').attr('fieldflag');
|
||||
if (column == 2 && (selectedOperator == 'greater than' || selectedOperator == 'greater than or equal to' || selectedOperator == 'less than' || selectedOperator == 'less than or equal to')) {
|
||||
$('#' + inputId).replaceWith('<input type="date" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Date" />');
|
||||
}else if(column == 2 && selectedOperator === 'between') {
|
||||
var inputHtml = '<div style="display: inline-flex;"><input type="date" class="form-control" id="' + inputId + '1" placeholder="Enter the Start Date" onchange="concatBetween(' + rowCounter + ')" />' +
|
||||
'<input type="date" class="form-control ml-1" id="' + inputId + '2" placeholder="Enter the End Date" onchange="concatBetween(' + rowCounter + ')" /></div>'+
|
||||
'<input type="hidden" class="form-control" id="' + inputId + '" name="values[]" placeholder="values" />';
|
||||
$('#' + inputId).replaceWith(inputHtml);
|
||||
}
|
||||
else if(column == 1 && (selectedOperator === 'contain' || selectedOperator == 'not contain')) {
|
||||
$('#' + inputId).replaceWith('<input type="text" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Multiple Values with comma Seprator" onkeypress="return restriction(event,2)" />');
|
||||
}else if(selectedOperator === 'is null' || selectedOperator == 'is not null') {
|
||||
$('#' + inputId).replaceWith('<input type="hidden" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Values" value="0" />');
|
||||
} else {
|
||||
$('#' + inputId).replaceWith('<input type="text" class="form-control" id="' + inputId + '" name="values[]" placeholder="Enter the Values" onkeypress="return restriction(event,1)" />');
|
||||
}
|
||||
|
||||
}
|
||||
function concatBetween(Counter) {
|
||||
// This function will be called when the date input changes
|
||||
var Id = 'values' + Counter;
|
||||
var started = $('#' +Id+'1').val();
|
||||
var ended = $('#' +Id+'2').val();
|
||||
if(started != "" && ended != ""){
|
||||
$("#"+Id).val(started + ',' + ended);
|
||||
}
|
||||
// console.log("id: " + Id);
|
||||
// console.log("counter: " + Counter);
|
||||
// console.log("sv: " + started);
|
||||
// console.log("ev: " + ended);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function restriction(event,temporary_flag) {
|
||||
var charCode = event.which || event.keyCode;
|
||||
if (Number(temporary_flag) == 2 &&
|
||||
((charCode >= 65 && charCode <= 90) || // A-Z
|
||||
(charCode >= 97 && charCode <= 122) || // a-z
|
||||
(charCode >= 48 && charCode <= 57) || // 0-9
|
||||
charCode == 44 // comma
|
||||
)){
|
||||
return true;
|
||||
}
|
||||
else if (Number(temporary_flag) == 1 &&
|
||||
((charCode >= 48 && charCode <= 57) || // 0-9
|
||||
(charCode >= 65 && charCode <= 90) || // A-Z
|
||||
(charCode >= 97 && charCode <= 122) // a-z
|
||||
)) {
|
||||
return true;
|
||||
} else {
|
||||
event.preventDefault(); // Prevent the character from being entered
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// // Function to disable options in the "Choose the Field" dropdowns
|
||||
// function disableOptions(selectId) {
|
||||
// console.log('inside');
|
||||
// // Get all select elements with the specified name attribute
|
||||
// var selectElements = document.querySelectorAll('select[name="column[]"]');
|
||||
|
||||
// // Iterate through the select elements
|
||||
// selectElements.forEach(function (select) {
|
||||
// console.log(select.id,selectId);
|
||||
// if (select.id !== selectId) {
|
||||
// console.log('if');
|
||||
// // Find the "Choose the Field" option and disable it
|
||||
// var chooseOption = select.querySelector('option[value=""]');
|
||||
// if (chooseOption) {
|
||||
// console.log('if-if');
|
||||
// chooseOption.disabled = true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// // Event listener for changes in the "Choose the Field" dropdowns
|
||||
// document.addEventListener('change', function (e) {
|
||||
// var target = e.target;
|
||||
// console.log(target,'target');
|
||||
// if (target.name === 'column[]' && target.value === '') {
|
||||
// console.log('if');
|
||||
// // Disable the "Choose the Field" option in other dropdowns
|
||||
// disableOptions(target.id);
|
||||
// }else{
|
||||
// console.log('else');
|
||||
// }
|
||||
// });
|
||||
|
||||
// function disableSelectedOptions(selectElement, rowCounter) {
|
||||
|
||||
// var id = selectElement.id;
|
||||
// var selectedOperator = selectElement.value;
|
||||
// }
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<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>
|
||||
<a href="<?= base_url() . "new_book_invoice/0"; ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Invoice </a>
|
||||
<!-- HTML for the "Add New" button -->
|
||||
|
||||
<!-- <div id="standard-modal" >
|
||||
|
||||
@ -797,6 +797,8 @@
|
||||
alert.classList.add('d-none');
|
||||
});
|
||||
}, 5000); // Adjust the time (in milliseconds) as needed
|
||||
|
||||
function refreshPage() { location.reload(); }
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
@ -103,7 +103,8 @@
|
||||
<?php } ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="profile_picture" class="col-form-label">Profile Picture</label>
|
||||
<input type="file" name="profile_picture" value="<?= isset($details['profile_picture']) ? $details['profile_picture'] : '' ?>" />
|
||||
<input type="file" name="profile_picture" value="<?= isset($details['profile_picture']) ? $details['profile_picture'] : '' ?>" accept="image/*" onchange="validateFile(this)" />
|
||||
<div id="error_message" style="color: red;"></div>
|
||||
</div>
|
||||
|
||||
<?php if ($loggedin_person_role === 'sadmin') { ?>
|
||||
@ -170,4 +171,19 @@
|
||||
|
||||
// Set the min attribute of the date input field to "1965-01-01"
|
||||
document.getElementById('date_of_birth').setAttribute('min', '1965-01-01');
|
||||
function validateFile(input) {
|
||||
const file = input.files[0];
|
||||
const errorMessage = document.getElementById("error_message");
|
||||
|
||||
if (file) {
|
||||
if (file.type.startsWith("image/")) {
|
||||
// It's an image file, no error
|
||||
errorMessage.textContent = "";
|
||||
} else {
|
||||
// Invalid file type
|
||||
errorMessage.textContent = "Invalid file type. Please select an image.";
|
||||
input.value = ""; // Clear the input field
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -54,7 +54,12 @@
|
||||
$message = 'In-Active';
|
||||
}
|
||||
$edit_page_route = base_url()."user_page/".$row['user_id'];
|
||||
|
||||
$addressParts = array(
|
||||
$row['address'],
|
||||
$row['city'],
|
||||
$row['state'].($row['postal_code'] ? "-".$row['postal_code'] : ""),
|
||||
$row['country']
|
||||
);
|
||||
?>
|
||||
<tr>
|
||||
<td hidden><?= $row['user_id'] ?></td>
|
||||
@ -63,8 +68,7 @@
|
||||
<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'] ? $row['address'].', '.$row['city'].', '.$row['state'].'- '.$row['postal_code'].'. '.$row['country'] : "" ; ?></td>
|
||||
<td><?php echo $row['address'] ? implode(', ', array_filter($addressParts)) . '.' : "" ; ?></td>
|
||||
<td>
|
||||
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
|
||||
</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user