From e7017361301626f3847f1b2c29a07a5c869e2a4f Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 31 Oct 2023 12:41:45 +0530 Subject: [PATCH] BUG Fixes 1 : ps --- app/Controllers/Customer.php | 17 +- app/Models/NotificationModel.php | 46 ++++- app/Views/campaign_creation.php | 2 + app/Views/customer_form.php | 103 +++++++---- app/Views/customer_group_form.php | 289 ++++++++++++++++++++++++++---- app/Views/invoice_list.php | 2 +- app/Views/template/footer.php | 2 + app/Views/user_form.php | 18 +- app/Views/user_list.php | 10 +- 9 files changed, 406 insertions(+), 83 deletions(-) diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index 04ddaedc..bfd7f1be 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -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); diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index 926e2189..6d42bd89 100644 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -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 "
";
+    // print_r($results);
+    // echo "
"; + // 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 "
";
+    // print_r($uniqueCustomers);
+    // echo "
"; + // die; + } + } diff --git a/app/Views/campaign_creation.php b/app/Views/campaign_creation.php index 6f3793dd..f82ef560 100644 --- a/app/Views/campaign_creation.php +++ b/app/Views/campaign_creation.php @@ -33,6 +33,7 @@ Campaign Name Template Name Group Name + Total Customer Scheduled at Created at Created by @@ -56,6 +57,7 @@ + diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index d1a612f9..d5d2d0e6 100644 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -30,24 +30,24 @@
- +
Please provide.
- +
Please provide.
- - - + + +
- +
+91
@@ -62,9 +62,9 @@
- + @@ -75,11 +75,10 @@
- +
Please provide.
@@ -101,29 +100,29 @@
+
+
- +
Please provide.
@@ -201,19 +202,19 @@
- +
Please provide.
- +
Please provide.
- +
Please provide.
- + + + +
- +
Please provide.
@@ -274,12 +278,11 @@
- - + + " class="btn btn-secondary waves-effect">Cancel
@@ -525,4 +528,38 @@ $(this).tab('show'); }); }); + + \ No newline at end of file diff --git a/app/Views/customer_group_form.php b/app/Views/customer_group_form.php index fc7f3a37..3d0d9f41 100644 --- a/app/Views/customer_group_form.php +++ b/app/Views/customer_group_form.php @@ -30,17 +30,18 @@ - name="column[]" > + + + - name="operator[]" onchange="FieldChange(this,)"> $label) { ?> + - $label) { ?>
+ +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(''); + }else if(column == 2 && selectedOperator === 'between') { + var inputHtml = '
' + + '
'+ + ''; + $('#' + inputId).replaceWith(inputHtml); + } + else if(column == 1 && (selectedOperator === 'contain' || selectedOperator == 'not contain')) { + $('#' + inputId).replaceWith(''); + }else if(selectedOperator === 'is null' || selectedOperator == 'is not null') { + $('#' + inputId).replaceWith(''); + } else { + $('#' + inputId).replaceWith(''); + } +} +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); +} + + + + + diff --git a/app/Views/invoice_list.php b/app/Views/invoice_list.php index 03b99b62..e553e5cd 100644 --- a/app/Views/invoice_list.php +++ b/app/Views/invoice_list.php @@ -5,7 +5,7 @@