Customer group,notify template creation : ps
This commit is contained in:
parent
3f695542fe
commit
a22dde67de
@ -77,6 +77,13 @@ $routes->get("new_customer/(:any)", "Customer::new_customer/$1");
|
||||
$routes->post("insert_customer", "Customer::insert_customer");
|
||||
$routes->get("delete_customer/(:any)", "Customer::delete_customer/$1");
|
||||
|
||||
# Routes for Customer group
|
||||
$routes->get('customer_group/', 'Customer::customer_group');
|
||||
$routes->get('view_customer_group/(:any)', 'Customer::view_customer_group/$1');
|
||||
$routes->get('preview_customer_group/(:any)', 'Customer::preview_customer_group/$1');
|
||||
$routes->get('delete_customer_group/(:any)', 'Customer::delete_customer_group/$1');
|
||||
$routes->post("insert_customer_group", "Customer::insert_customer_group");
|
||||
|
||||
# Scheme Routes
|
||||
$routes->get("scheme_list/", "Scheme::index");
|
||||
$routes->get("new_scheme/(:any)", "Scheme::new_scheme/$1");
|
||||
@ -115,7 +122,20 @@ $routes->get('print_address/(:num)', 'Invoice::print_address/$1');
|
||||
$routes->get('send_whatsapp_message/', 'Notifications::send_whatsapp_message');
|
||||
$routes->post('whatsapp_custom_notifications/', 'Notifications::whatsapp_custom_notifications');
|
||||
$routes->match(['post', 'get'], 'mail_custom_notifications', 'Notifications::mail_custom_notifications');
|
||||
$routes->get('customer_group_notifications/', 'Notifications::customer_group_notifications');
|
||||
// $routes->match(['post', 'get'], 'due_date_notifications', 'Notifications::due_date_notifications');
|
||||
// $routes->get('due_date_notifications/(:any)', 'Notifications::due_date_notifications/$1');
|
||||
$routes->get('due_date_notifications', 'Notifications::due_date_notifications');
|
||||
$routes->get('template_creation/', 'Notifications::template_creation');
|
||||
$routes->get('template_creation_form/(:any)', 'Notifications::template_creation_form/$1');
|
||||
$routes->get('template_creation_delete/(:any)', 'Notifications::template_creation_delete/$1');
|
||||
$routes->post("template_creation_insert", "Notifications::template_creation_insert");
|
||||
|
||||
$routes->get('campaign_creation/', 'Notifications::campaign_creation');
|
||||
$routes->get('campaign_creation_form/(:any)', 'Notifications::campaign_creation_form/$1');
|
||||
$routes->get('campaign_creation_delete/(:any)', 'Notifications::campaign_creation_delete/$1');
|
||||
$routes->post("campaign_creation_insert", "Notifications::campaign_creation_insert");
|
||||
|
||||
|
||||
|
||||
# Api integration Routes
|
||||
$routes->post('api/(:any)', 'ApiIntegration::api_integration/$1');
|
||||
|
||||
@ -83,7 +83,7 @@ class Customer extends BaseController
|
||||
public function insert_customer()
|
||||
{
|
||||
$requestData = $this->request->getPost();
|
||||
print_r($requestData);die;
|
||||
// print_r($requestData);die;
|
||||
$this->logger->info("Customer: Inserting/Updating Details");
|
||||
try {
|
||||
helper('session');
|
||||
@ -290,5 +290,221 @@ class Customer extends BaseController
|
||||
$state_details = $model->orderBy('state_id', 'ASC')->findAll();
|
||||
return $state_details;
|
||||
}
|
||||
|
||||
public function customer_group(){
|
||||
$data['page_name'] = 'Customer Group';
|
||||
$model = new CustomerModel();
|
||||
$data['customer_group'] = $model->getGroupDetails();
|
||||
$this->render_page('customer_group', $data);
|
||||
}
|
||||
public function view_customer_group($id){
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
|
||||
$data['field'] = [
|
||||
'' => 'Choose the Field',
|
||||
'city' => 'City',
|
||||
'state' => 'State',
|
||||
'type' => 'Type',
|
||||
'postal code' => 'Postal Code',
|
||||
'schemes' => 'Schemes',
|
||||
'category' => 'Category'
|
||||
];
|
||||
$data['operator'] = [
|
||||
'' => 'Choose the operator',
|
||||
'equal' => 'equal to (=)',
|
||||
'not equal' => 'not equal (!=)',
|
||||
'like' => 'like (%)',
|
||||
'contain' => 'contain (in)',
|
||||
'not contain' => 'not contain (not in)',
|
||||
'between' => 'between (between)',
|
||||
'greater than' => 'greater than (>)',
|
||||
'greater than or equal to' => 'greater than or equal to (>=)',
|
||||
'less than' => 'lesser than (<)',
|
||||
'less than or equal to' => 'greater than or equal to (<=)'
|
||||
];
|
||||
$data['customer_group'] = [];
|
||||
if ($id === '0') {
|
||||
// Add Customer
|
||||
$data['page_name'] = 'Customer Group From';
|
||||
} else if ($id !== '0') {
|
||||
// Edit Customer
|
||||
$data['page_name'] = 'Customer Group From';
|
||||
|
||||
// Load your Customer Model
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_groups');
|
||||
$where = ['group_id'=>$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
|
||||
if (!empty($result)) {
|
||||
$data['customer_group']['groupname'] = $result[0]['group_name'];
|
||||
$data['customer_group']['column'] = unserialize($result[0]['column']);
|
||||
$data['customer_group']['operator'] = unserialize($result[0]['operator']);
|
||||
$data['customer_group']['values'] = unserialize($result[0]['value']);
|
||||
$data['customer_group']['group_id'] = $result[0]['group_id'];
|
||||
$data['customer_group']['isactive'] = $result[0]['isactive'];
|
||||
}
|
||||
}
|
||||
$this->render_page('customer_group_form', $data);
|
||||
}
|
||||
public function preview_customer_group($id){
|
||||
helper('session');
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_groups');
|
||||
$where = ['isactive' => 1,'group_id'=>$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
$db = \Config\Database::connect();
|
||||
$sql = (string)$result[0]['group_query'];
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
return $this->response->setJSON($results);
|
||||
}
|
||||
public function delete_customer_group($id){
|
||||
try {
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_groups');
|
||||
$where = ['isactive' => 1,'group_id'=>(int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if ($result) {
|
||||
$this->logger->Info("Customer Group: Going to Inactive ID = ".$id);
|
||||
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'group_id'=>(int)$id];
|
||||
$statement = $model->saveGroupDetails($data);// just updating Inactive status only.
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Customer Group: Err Occur on data the Customer Group Inactive");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Customer Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('customer_group');
|
||||
|
||||
}
|
||||
public function insert_customer_group(){
|
||||
|
||||
try {
|
||||
$this->logger->info("Customer Group: Inserting/Updating Details");
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$request_data = $this->request->getPost();
|
||||
$string_flag = $request_data['string_flag'];
|
||||
// $this->logger->info("Customer Group: Request data = ".json_encode($request_data));
|
||||
|
||||
$model = new CustomerModel();
|
||||
// Array ( [groupname] => nil [column] => Array ( [0] => city [1] => state ) [operator] => Array ( [0] => not contain [1] => not equal ) [values] => Array ( [0] => 2 [1] => 3 ) )
|
||||
$data = [
|
||||
'group_name' => $request_data['groupname'],
|
||||
'column' => serialize($request_data['column']),
|
||||
'operator' => serialize($request_data['operator']),
|
||||
'value' => serialize($request_data['values'])
|
||||
];
|
||||
// Initialize an empty array to store the conditions
|
||||
$conditions = array();
|
||||
|
||||
// Loop through the elements and build the conditions
|
||||
for ($i = 0; $i < count($request_data['column']); $i++) {
|
||||
$column = $request_data['column'][$i];
|
||||
$operator = $request_data['operator'][$i];
|
||||
$value = $request_data['values'][$i];
|
||||
|
||||
// Handle different operators and build corresponding conditions
|
||||
switch ($operator) {
|
||||
case 'equal':
|
||||
$conditionStrings[] = "$column = '$value'";
|
||||
break;
|
||||
case 'not equal':
|
||||
$conditionStrings[] = "$column <> '$value'";
|
||||
break;
|
||||
case 'like':
|
||||
$conditionStrings[] = "$column LIKE '%$value%'";
|
||||
break;
|
||||
case 'contain':
|
||||
case 'where in':
|
||||
$values = explode(',', $value);
|
||||
$conditions[] = "$column IN ('" . implode("', '", $values) . "')";
|
||||
break;
|
||||
case 'not contain':
|
||||
case 'where not in':
|
||||
$values = explode(',', $value);
|
||||
$conditions[] = "$column NOT IN ('" . implode("', '", $values) . "')";
|
||||
break;
|
||||
case 'between':
|
||||
$dates = explode(',', $value);
|
||||
$conditionStrings[] = "$column BETWEEN '$dates[0]' AND '$dates[1]'";
|
||||
break;
|
||||
case 'greater than':
|
||||
$conditionStrings[] = "$column > $value";
|
||||
break;
|
||||
case 'greater than or equal to':
|
||||
$conditionStrings[] = "$column >= $value";
|
||||
break;
|
||||
case 'less than':
|
||||
$conditionStrings[] = "$column < $value";
|
||||
break;
|
||||
case 'less than or equal to':
|
||||
$conditionStrings[] = "$column <= $value";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Join the conditions with 'AND'
|
||||
$whereCondition = implode(' AND ', $conditionStrings);
|
||||
// echo "*************** whereCondition =>>> ";
|
||||
// echo $whereCondition;
|
||||
// If a groupname is specified, include it in the condition
|
||||
// if ($conditionsArray['groupname'] !== 'nil') {
|
||||
// $whereCondition = "($whereCondition) AND groupname = '{$conditionsArray['groupname']}'";
|
||||
// }
|
||||
|
||||
// Now you can use $whereCondition in your SQL query
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "SELECT customer_id,CONCAT(first_name,'',last_name) as customer_name,email,mobile_no FROM customers WHERE ".$whereCondition;
|
||||
|
||||
// echo $sql;
|
||||
// Execute the query
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Get the result
|
||||
$results = $query->getResult();
|
||||
$group_id = $request_data['group_id']; // Get the ID for update
|
||||
$isactive = $request_data['isactive'];
|
||||
if($string_flag == "save"){
|
||||
$data['group_query'] = $sql;
|
||||
$data['group_id'] = $group_id;
|
||||
$data['isactive'] = $group_id ? (($isactive == 'on') ? 1 : 0) : 1;
|
||||
$data['created_by'] = $session_uid;
|
||||
$data['updated_by'] = $session_uid;
|
||||
$statement = $model->saveGroupDetails($data);
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->info($statement['log']);
|
||||
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Customer Group: Err Occur on data the Save");
|
||||
}
|
||||
|
||||
}else if($string_flag == "preview"){
|
||||
return $this->response->setJSON($results);
|
||||
}else{
|
||||
throw new \Exception("Data Not Found");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Customer Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('customer_group');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -74,9 +74,14 @@ class Notifications extends BaseController
|
||||
|
||||
public function due_date_notifications()
|
||||
{
|
||||
$date = $this->request->getGet('date');
|
||||
|
||||
$model = new NotificationModel();
|
||||
$details = $model->getSubscriptionDueDetail();
|
||||
|
||||
$details = $model->getSubscriptionDueDetail($date);
|
||||
// echo "<pre>";
|
||||
// print_r($details);
|
||||
// echo "</pre>";
|
||||
// die;
|
||||
$records = [];
|
||||
$recipient_name = "";
|
||||
$recipient_email = "";
|
||||
@ -135,7 +140,223 @@ class Notifications extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function customer_group_notifications(){
|
||||
echo "customer_group_notifications";die;
|
||||
public function template_creation(){
|
||||
$data['page_name'] = 'Template';
|
||||
$model = new NotificationModel();
|
||||
$data['template'] = $model->getTemplateDetails();
|
||||
$this->render_page('template_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
|
||||
public function template_creation_form($id){
|
||||
|
||||
$data['group_details'] = $this->get_group_details();
|
||||
$model = new NotificationModel();
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Template Creation: In Add Page");
|
||||
$data['page_name'] = 'Add Template';
|
||||
$data['template_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Template Creation: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Template';
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id'=>(int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
$data['template_details'] = !empty($result[0]) ? $result[0] : [];
|
||||
}
|
||||
// print_r($data['template_details']);die();
|
||||
$this->render_page('template_creation_form', $data);
|
||||
}
|
||||
|
||||
public function template_creation_delete($id){
|
||||
try {
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id'=>(int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if ($result) {
|
||||
$this->logger->Info("Template: Going to Inactive ID = ".$id);
|
||||
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'template_id'=>(int)$id];
|
||||
$statement = $model->saveDetails($data,'template_id','templates');// just updating Inactive status only.
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Template: Err Occur on data the Template Inactive");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Template: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('template_creation');
|
||||
|
||||
}
|
||||
|
||||
public function get_group_details()
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('customer_groups');
|
||||
$details = $model->where('isactive',1)->orderBy('group_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
public function get_template_details(){
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$details = $model->where('isactive',1)->orderBy('template_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
|
||||
public function template_creation_insert(){
|
||||
$this->logger->info("Template: Inserting/Updating Details");
|
||||
try {
|
||||
## Declarions
|
||||
helper('session');
|
||||
$model = new NotificationModel();
|
||||
$session_uid = get_logged_user_id();
|
||||
$id = $this->request->getPost('template_id');
|
||||
$subject = $this->request->getPost('subject') ? $this->request->getPost('subject') : NULL;
|
||||
$isactive = $this->request->getPost('isactive');
|
||||
$data = [
|
||||
'template_id' => $id,
|
||||
'template_name' => $this->request->getPost('templatename'),
|
||||
'subject' => $subject,
|
||||
'message' => $this->request->getPost('templatemessage'),
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'group_id' => $this->request->getPost('group_id'),
|
||||
'isactive' => $id ? (($isactive == 'on') ? 1 : 0) : 1,
|
||||
'created_by' => $session_uid,
|
||||
'updated_by' => $session_uid
|
||||
];
|
||||
$statement = $model->saveDetails($data,'template_id','templates');
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Template: Err Occur");
|
||||
}
|
||||
|
||||
|
||||
}catch(\Exception $e) {
|
||||
$this->logger->error("Template: Err Occur =".$e->getMessage());
|
||||
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
|
||||
}
|
||||
return redirect()->route('template_creation');
|
||||
}
|
||||
|
||||
public function campaign_creation(){
|
||||
$data['page_name'] = 'Campaign';
|
||||
$model = new NotificationModel();
|
||||
$data['campaign'] = $model->getCampaignDetails();
|
||||
$this->render_page('campaign_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
|
||||
public function campaign_creation_form($id){
|
||||
|
||||
$data['group_details'] = $this->get_group_details();
|
||||
$data['template_details'] = $this->get_template_details();
|
||||
$model = new NotificationModel();
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Campaign Creation: In Add Page");
|
||||
$data['page_name'] = 'Add Campaign';
|
||||
$data['campaign_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Campaign Creation: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Campaign';
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['campaign_id'=>(int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $i => $item) {
|
||||
$result[$i]['group_id'] = unserialize($item['group_id']);
|
||||
}
|
||||
}
|
||||
$data['campaign_details'] = !empty($result[0]) ? $result[0] : [];
|
||||
|
||||
}
|
||||
$this->render_page('campaign_creation_form', $data);
|
||||
}
|
||||
|
||||
public function campaign_creation_delete($id){
|
||||
try {
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$where = ['campaign_id'=>(int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if ($result) {
|
||||
$this->logger->Info("Campaign: Going to Inactive ID = ".$id);
|
||||
$data = ['isactive' => 0 , 'updated_by' => $session_uid,'campaign_id'=>(int)$id];
|
||||
$statement = $model->saveDetails($data,'campaign_id','notification_campaign');// just updating Inactive status only.
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "" );
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Campaign: Err Occur on data the Template Inactive");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Campaign: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('campaign_creation');
|
||||
|
||||
}
|
||||
|
||||
public function campaign_creation_insert(){
|
||||
$this->logger->info("Campaign: Inserting/Updating Details");
|
||||
try {
|
||||
## Declarions
|
||||
helper('session');
|
||||
$model = new NotificationModel();
|
||||
$session_uid = get_logged_user_id();
|
||||
$id = $this->request->getPost('campaign_id');
|
||||
$isactive = $this->request->getPost('isactive');
|
||||
// print_r($this->request->getPost());die;
|
||||
$data = [
|
||||
'campaign_id' => $id,
|
||||
'campaign_name' => $this->request->getPost('campaign_name'),
|
||||
'template_id' => $this->request->getPost('template_id'),
|
||||
'scheduled_date' => $this->request->getPost('scheduled_date'),
|
||||
'scheduled_time' => $this->request->getPost('scheduled_time'),
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'group_id' => serialize($this->request->getPost('group_id')),
|
||||
'isactive' => $id ? (($isactive == 'on') ? 1 : 0) : 1,
|
||||
'created_by' => $session_uid,
|
||||
'updated_by' => $session_uid
|
||||
];
|
||||
$statement = $model->saveDetails($data,'campaign_id','notification_campaign');
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
}else{
|
||||
throw new \Exception("Campaign: Err Occur");
|
||||
}
|
||||
|
||||
|
||||
}catch(\Exception $e) {
|
||||
$this->logger->error("Campaign: Err Occur =".$e->getMessage());
|
||||
session()->setFlashdata('error', 'Message: ' .$e->getMessage());
|
||||
}
|
||||
return redirect()->route('campaign_creation');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -115,5 +115,48 @@ public function getSubscriberDataByCustomerId($customerId)
|
||||
return $builder->get()->getResult();
|
||||
}
|
||||
|
||||
public function saveGroupDetails($data){
|
||||
$id = $data['group_id'];
|
||||
if($id != ''){
|
||||
unset($data['group_id']); // Remove the id from the data to avoid updating it
|
||||
unset($data['created_by']); // bcoz here data Updating here.
|
||||
if ($this->db->table('customer_groups')->where('group_id', $id)->update($data)) {
|
||||
$affectedRows = $this->db->affectedRows();
|
||||
$statement['success'] = 'Customer Group has been updated successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = "Customer Group: has been updated successfully. Updated Customer Group ID = " .$id." Affected Rows = ".$affectedRows;
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = 'Customer group update failed. Please try again.';
|
||||
$statement['log'] = "Customer Group: Err Failed to update ID = " .$id ;
|
||||
}
|
||||
}else{
|
||||
unset($data['updated_by']);
|
||||
if ($this->db->table('customer_groups')->insert($data)) {
|
||||
$insertID = $this->db->insertID();
|
||||
$statement['success'] = 'Customer Group has been Inserted successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = "Customer Group : has been added successfully. Inserted ID = " .$insertID ;
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = "Customer could not be added. Please try again..";
|
||||
$statement['log'] = "Customer: Err could not be added. Please try again.";
|
||||
}
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
|
||||
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')
|
||||
// ->where(['CG.isactive' => 1])
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@ -20,19 +20,94 @@ class NotificationModel extends Model
|
||||
// ->findAll();
|
||||
// }
|
||||
|
||||
public function getSubscriptionDueDetail(){
|
||||
$now = date('Y-m-d');
|
||||
$lastWeek = date('Y-m-d', strtotime('+7 days'));
|
||||
public function getSubscriptionDueDetail($date){
|
||||
// $now = date('Y-m-d');
|
||||
// $lastWeek = date('Y-m-d', strtotime('+7 days'));
|
||||
// $date_format = date('Y-m-d', $date);
|
||||
return $this->db->table('subscription as S' )
|
||||
->join('customers as C', 'C.customer_id = S.customer_id', 'left')
|
||||
->join('category as CM', 'CM.id = S.scheme_id', 'left')
|
||||
->join('business as B', 'B.business_id = S.business_id', 'left')
|
||||
->join('book_categories as BC', 'BC.category_id = S.scheme_id', 'left')
|
||||
->join('books as BK', 'BC.book_id = BK.book_id', 'left')
|
||||
->select('CM.name,concat(C.first_name, " ", C.last_name) as customer_name,C.email as customer_email,C.mobile_no as customer_mobile,S.sub_id,S.scheme_id,S.customer_id,S.from_subscription,S.to_subscription,S.business_id,B.title as business_name,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.to_subscription,S.from_subscription,BK.title,BK.book_id')
|
||||
->where('S.to_subscription >=', $now)->where('S.to_subscription <=',$lastWeek)
|
||||
->select('concat("Your subscription going to expried in ",DATEDIFF(S.to_subscription, CURDATE())," days") as statement,DATEDIFF(S.to_subscription, CURDATE()) as countdays,CM.name,concat(C.first_name, " ", C.last_name) as customer_name,C.email as customer_email,C.mobile_no as customer_mobile,S.sub_id,S.scheme_id,S.customer_id,S.from_subscription,S.to_subscription,S.business_id,B.title as business_name,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.to_subscription,S.from_subscription,BK.title,BK.book_id')
|
||||
// ->where('S.to_subscription >=', $now)->where('S.to_subscription <=',$lastWeek)
|
||||
->where('S.to_subscription =',date('Y-m-d', strtotime($date)))
|
||||
->groupBy('S.sub_id')
|
||||
->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getTemplateDetails(){
|
||||
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')
|
||||
->join('customer_groups as CG', 'CG.group_id = T.group_id', 'left')
|
||||
->select('T.template_id,T.template_name,T.mode,CG.group_id,CG.group_name,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();
|
||||
}
|
||||
|
||||
public function saveDetails($data,$pk_name,$t_name){
|
||||
$id = $data[$pk_name];
|
||||
if($id != ''){
|
||||
unset($data[$pk_name]); // Remove the id from the data to avoid updating it
|
||||
unset($data['created_by']); // bcoz here data Updating here.
|
||||
if ($this->db->table($t_name)->where($pk_name, $id)->update($data)) {
|
||||
$affectedRows = $this->db->affectedRows();
|
||||
$statement['success'] = ucfirst($t_name).' has been updated successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = ucfirst($t_name).": has been updated successfully. Updated ".$pk_name." = " .$id." Affected Rows = ".$affectedRows;
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = ucfirst($t_name).' update failed. Please try again.';
|
||||
$statement['log'] = ucfirst($t_name).": Err Failed to update ID = " .$id ;
|
||||
}
|
||||
}else{
|
||||
unset($data['updated_by']);
|
||||
if ($this->db->table($t_name)->insert($data)) {
|
||||
$insertID = $this->db->insertID();
|
||||
$statement['success'] = ucfirst($t_name).' has been Inserted successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = ucfirst($t_name).": has been added successfully. Inserted ID = " .$insertID ;
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = ucfirst($t_name)." could not be added. Please try again..";
|
||||
$statement['log'] = ucfirst($t_name).": Err could not be added. Please try again.";
|
||||
}
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
|
||||
public function getCampaignDetails(){
|
||||
$result = $this->db->table('notification_campaign as NC' )
|
||||
->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')
|
||||
->get()->getResultArray();
|
||||
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $i => $item) {
|
||||
$group_id = unserialize($item['group_id']);
|
||||
$group_names = [];
|
||||
|
||||
foreach ($group_id as $j) {
|
||||
$cg_data = $this->db->table('customer_groups as CG')
|
||||
->select('CG.group_id, CG.group_name, CG.isactive')
|
||||
->where(['CG.isactive' => 1, 'CG.group_id' => $j])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if ($cg_data) {
|
||||
$group_names[] = $cg_data['group_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$result[$i]['group_name'] = !empty($group_names) ? implode(", ", $group_names) : '';
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
86
app/Views/campaign_creation.php
Normal file
86
app/Views/campaign_creation.php
Normal file
@ -0,0 +1,86 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<a href="<?= base_url()."campaign_creation_form/0"; ?>" class="btn btn-primary"><i class="ri-file-edit-line"></i> Add campaign </a>
|
||||
</div><!-- end col-->
|
||||
<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_customer" class="table w-100 nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th>Campaign Name</th>
|
||||
<th>Template Name</th>
|
||||
<th>Group Name</th>
|
||||
<th>Scheduled at</th>
|
||||
<th>Created at</th>
|
||||
<th>Created by</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ($campaign as $c) :
|
||||
if ($c['isactive']) {
|
||||
$class = 'badge badge-soft-success';
|
||||
$message = 'Active';
|
||||
} else {
|
||||
$class = 'badge badge-soft-danger';
|
||||
$message = 'In-Active';
|
||||
}
|
||||
$scheduled_date = date('d/m/Y', strtotime($c['scheduled_date']));
|
||||
$scheduled_time = date('h:i A', strtotime($c['scheduled_time']));
|
||||
?>
|
||||
<tr>
|
||||
<td hidden><?= $c['campaign_id']; ?></td>
|
||||
<td><?= $c['campaign_name']; ?></td>
|
||||
<td><?= $c['template_name']; ?></td>
|
||||
<td><?= $c['group_name']; ?></td>
|
||||
<td><?= $scheduled_date." ".$scheduled_time; ?></td>
|
||||
<td><?= $c['formatted_created_on']; ?></td>
|
||||
<td><?= $c['created_by_name']; ?></td>
|
||||
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
|
||||
<td>
|
||||
<a href="<?= base_url()."campaign_creation_form/".$c['campaign_id']; ?>" class="edit-button" title="Click to Edit Campaign" ><i class="ri-pencil-line"></i></a>
|
||||
<?php if ($c['isactive']) { ?> <a href="<?php echo "campaign_creation_delete/".$c['campaign_id']; ?>" class="delete-button" title="Click to Delete Campaign" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div><!-- end row-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_customer').DataTable({
|
||||
"order": [
|
||||
[0, "desc"]
|
||||
] // 4 is the column index of "created_on" in your table
|
||||
// Other DataTables configuration options
|
||||
});
|
||||
});
|
||||
</script>
|
||||
139
app/Views/campaign_creation_form.php
Normal file
139
app/Views/campaign_creation_form.php
Normal file
@ -0,0 +1,139 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<form class="parsley-examples" action="<?= base_url() . "campaign_creation_insert"; ?>" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="campaign_name" class="col-form-label">Campaign Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="campaign_name" name="campaign_name" value="<?= isset($campaign_details['campaign_name']) ? $campaign_details['campaign_name'] : '' ?>" placeholder="Campaign Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="group_id" class="col-form-label">Group<span class="text-danger"></span></label>
|
||||
<!-- <select id="group_id" name="group_id[]" class="form-control select2-multiple" data-toggle="select2" multiple="multiple" data-placeholder="Choose ..." required> -->
|
||||
<select id="group_id" name="group_id[]" class="form-control" multiple="multiple" required>
|
||||
<option value="">Choose the Group</option>
|
||||
<?php foreach ($group_details as $value) { ?>
|
||||
<option value="<?php echo $value['group_id']; ?>"
|
||||
<?php if (isset($campaign_details['group_id']) && in_array($value['group_id'], $campaign_details['group_id'])) echo "selected"; ?>>
|
||||
<?php echo $value['group_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="template_id" class="col-form-label">Template<span class="text-danger"></span></label>
|
||||
<select id="template_id" name="template_id" class="form-control" onchange="changeFields(this)" required>
|
||||
<option value="">Choose the Template</option>
|
||||
<?php foreach ($template_details as $value) { ?>
|
||||
<option value="<?php echo $value['template_id']; ?>" <?php if (isset($campaign_details['template_id']) && ($campaign_details['template_id'] === $value['template_id'])) echo "selected"; ?>>
|
||||
<?php echo $value['template_name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="mode" class="col-form-label col-md-3">Mode<span class="text-danger"></span></label>
|
||||
<div class="col-md-9 mt-1">
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input type="radio" id="emailRadio" name="mode" class="custom-control-input" value="Email" checked>
|
||||
<label class="custom-control-label" for="emailRadio">Email</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input type="radio" id="whatsappRadio" name="mode" class="custom-control-input" value="Whatsapp">
|
||||
<label class="custom-control-label" for="whatsappRadio">Whatsapp</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<label for="scheduled" class="col-form-label">Scheduled date/Time<span class="text-danger"></span></label>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<input class="form-control" type="date" name="scheduled_date" id="example-date" value="<?= isset($campaign_details['scheduled_date']) ? $campaign_details['scheduled_date'] : '' ?>">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<input class="form-control" type="time" name="scheduled_time" id="example-time" value="<?= isset($campaign_details['scheduled_time']) ? $campaign_details['scheduled_time'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group col-md-12">
|
||||
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
||||
<textarea id="summernote-basic" name="templatemessage" class="form-control" rows="7">
|
||||
<?php if(isset($campaign_details['message'])){ echo $campaign_details['message']; }else{ ?>
|
||||
<h5>Hello {User}, </h5>
|
||||
<p>Please, write text here!</p>
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="campaign_id" name="campaign_id" placeholder="hidden for template id" value="<?= isset($campaign_details['campaign_id']) ? $campaign_details['campaign_id'] : '' ?>" />
|
||||
<?php if (!empty($campaign_details)) { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($campaign_details) && $campaign_details['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
</div>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<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>
|
||||
<a href="<?= base_url() . "campaign_creation"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
</div><!-- end row -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Listen for changes in the radio buttons
|
||||
// $('input[name="mode"]').on('change', function() {
|
||||
// var selectedValue = $(this).val();
|
||||
// if (selectedValue === 'Email') {
|
||||
// $('#emailSubject').show();
|
||||
// } else {
|
||||
// $('#emailSubject').hide();
|
||||
// }
|
||||
// });
|
||||
|
||||
var mode = "<?= isset($campaign_details['mode']) ? $campaign_details['mode'] : ""; ?>";
|
||||
if(mode != ""){
|
||||
var emailRadio = document.getElementById("emailRadio");
|
||||
var whatsappRadio = document.getElementById("whatsappRadio");
|
||||
if(mode == 'Email'){
|
||||
emailRadio.checked = true;
|
||||
whatsappRadio.checked = false;
|
||||
|
||||
}else if(mode == 'Whatsapp'){
|
||||
emailRadio.checked = false;
|
||||
whatsappRadio.checked = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function changeFields(element) {
|
||||
var selectedValue = $(element).val();
|
||||
var emailRadio = document.getElementById("emailRadio");
|
||||
var whatsappRadio = document.getElementById("whatsappRadio");
|
||||
if(mode == 'Email'){
|
||||
emailRadio.checked = true;
|
||||
whatsappRadio.checked = false;
|
||||
$('#emailSubject').show();
|
||||
}else if(mode == 'Whatsapp'){
|
||||
emailRadio.checked = false;
|
||||
whatsappRadio.checked = true;
|
||||
$('#emailSubject').hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
151
app/Views/customer_group.php
Normal file
151
app/Views/customer_group.php
Normal file
@ -0,0 +1,151 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<a href="<?= base_url()."view_customer_group/0"; ?>" class="btn btn-primary"><i class="ri-team-line"></i> Add Customer Group </a>
|
||||
</div><!-- end col-->
|
||||
<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_customer" class="table w-100 nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th>Group Name</th>
|
||||
<th>Created at</th>
|
||||
<th>Created by</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ($customer_group as $group) :
|
||||
if ($group['isactive']) {
|
||||
$class = 'badge badge-soft-success';
|
||||
$message = 'Active';
|
||||
} else {
|
||||
$class = 'badge badge-soft-danger';
|
||||
$message = 'In-Active';
|
||||
} ?>
|
||||
<tr>
|
||||
<td hidden><?= $group['group_id']; ?></td>
|
||||
<td><?= $group['group_name']; ?></td>
|
||||
<td><?= $group['formatted_created_on']; ?></td>
|
||||
<td><?= $group['created_by_name']; ?></td>
|
||||
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
|
||||
<td>
|
||||
<a href="<?= "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>
|
||||
<?php if ($group['isactive']) { ?> <a href="<?= "delete_customer_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<div class="modal" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true">
|
||||
<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>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="ajax-content">
|
||||
<table id="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:40%;">Name</th>
|
||||
<th style="width:30%;">Email</th>
|
||||
<th style="width:30%;">Mobile</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Table rows will be populated here -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
<!-- end row-->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_customer').DataTable({
|
||||
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
|
||||
// Other DataTables configuration options
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#scrollable-modal').on('show.bs.modal', function(event) {
|
||||
// Get the data-primary-key attribute from the modal trigger
|
||||
var primaryKey = $(event.relatedTarget).data('primary-key');
|
||||
console.log(primaryKey);
|
||||
var groupName = $(event.relatedTarget).data('group-name');
|
||||
$('#scrollableModalTitle').text(groupName + ' - Data Preview');
|
||||
console.log(groupName);
|
||||
|
||||
var route = "<?= base_url().'preview_customer_group/'?>"+primaryKey;
|
||||
console.log(route);
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: route,
|
||||
success: function(response) {
|
||||
if (response.length > 0) {
|
||||
// Get the table reference
|
||||
var table = $("#data-table tbody");
|
||||
|
||||
// Clear existing rows
|
||||
table.empty();
|
||||
|
||||
// Loop through the response and create table rows
|
||||
$.each(response, function (index, item) {
|
||||
var row = $("<tr>");
|
||||
row.append($("<td style='width:40%;'>").text(item.customer_name));
|
||||
row.append($("<td style='width:30%;'>").text(item.email));
|
||||
row.append($("<td style='width:30%;'>").text(item.mobile_no));
|
||||
table.append(row);
|
||||
});
|
||||
} else {
|
||||
// Handle the case where there is no data
|
||||
table.empty();
|
||||
table.append("<tr><td colspan='3' style='width:100%;'>No data available</td></tr>");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("An error occurred.");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
292
app/Views/customer_group_form.php
Normal file
292
app/Views/customer_group_form.php
Normal file
@ -0,0 +1,292 @@
|
||||
<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"></p>
|
||||
<form id="myForm" class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?php echo base_url(); ?>insert_customer_group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="groupname" class="col-form-label">Group Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="groupname" name="groupname" value="<?= isset($customer_group['groupname']) ? $customer_group['groupname'] : '' ?>" placeholder="Group Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Select Criteria</h4>
|
||||
<br />
|
||||
<table class="table table-borderless" id="itemTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Field</th>
|
||||
<th>Condition</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(!empty($customer_group)){ 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>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="operator" name="operator[]">
|
||||
<?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; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<input type="text" class="form-control" id="values" name="values[]" placeholder="Enter the Values"
|
||||
value="<?= (isset($customer_group['values'][$i]) && $customer_group['values'][$i] != "" ) ? $customer_group['values'][$i] : '' ?>" />
|
||||
</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>
|
||||
</td>
|
||||
</tr>
|
||||
<?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>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<select class="form-control" data-toggle="select2" id="operator" name="operator[]">
|
||||
<?php foreach ($operator as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>">
|
||||
<?php echo $label; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<input type="text" class="form-control" id="values" name="values[]" placeholder="Enter the Values" />
|
||||
</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>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" id="addItem" class="btn btn-soft-dark btn-rounded waves-effect waves-light mr-3 add-item"> + Add New Criteria</button>
|
||||
<!-- <a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4>
|
||||
</a> -->
|
||||
</div>
|
||||
<?php if (!empty($customer_group)) { ?>
|
||||
<div class="form-group text-right checkbox checkbox-purple mr-3">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer_group) && $customer_group['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<input type="hidden" id="string_flag" name="string_flag" placeholder="hidden" value="preview" />
|
||||
<input type="hidden" id="group_id" name="group_id" placeholder="hidden for primary id" value="<?= isset($customer_group['group_id']) ? $customer_group['group_id'] : '' ?>" />
|
||||
</div>
|
||||
</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>
|
||||
<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">
|
||||
<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>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="ajax-content">
|
||||
<table id="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:40%;">Name</th>
|
||||
<th style="width:30%;">Email</th>
|
||||
<th style="width:30%;">Mobile</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Table rows will be populated here -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="save" class="btn btn-success waves-effect waves-light mr-1" type="submit"> Submit </button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var fieldArray = <?php echo json_encode($field); ?>;
|
||||
var operatorArray = <?php echo json_encode($operator); ?>;
|
||||
// <select class="form-control" data-toggle="select2" id="operator" name="operator[]">
|
||||
// <select class="form-control" data-toggle="select2" id="column" name="column[]">
|
||||
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
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.id = 'column';
|
||||
select1.name = 'column[]';
|
||||
|
||||
const select2 = document.createElement('select');
|
||||
select2.className = 'form-control';
|
||||
select2.id = 'operator';
|
||||
select2.name = 'operator[]';
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
cell1.appendChild(select1);
|
||||
cell2.appendChild(select2);
|
||||
cell3.innerHTML = '<input type="text" class="form-control" id="values" name="values[]" placeholder="Enter the Values" />';
|
||||
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>';
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Function to remove a row from the table
|
||||
function removeItem(row) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
table.removeChild(row);
|
||||
}
|
||||
|
||||
// Attach the removeItem function to the Remove buttons using event delegation
|
||||
document.querySelector("#itemTable tbody").addEventListener("click", function(event) {
|
||||
if (event.target.classList.contains("remove-item")) {
|
||||
var row = event.target.closest("tr"); // Find the closest row to the clicked button
|
||||
removeItem(row);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- <script>
|
||||
document.getElementById('previewButton').addEventListener('click', function() {
|
||||
const name = "sanjeev";
|
||||
const email = "document.getElementById('email').value";
|
||||
|
||||
// Update the modal with the preview data
|
||||
// document.getElementById('previewName').textContent = name;
|
||||
// document.getElementById('previewEmail').textContent = email;
|
||||
|
||||
// Show the modal
|
||||
const modal = document.getElementById('previewModal');
|
||||
modal.style.display = 'block';
|
||||
|
||||
// Close the modal when the close button is clicked
|
||||
document.getElementById('closeModal').addEventListener('click', function() {
|
||||
modal.style.display = 'none';
|
||||
});
|
||||
|
||||
// Close the modal when clicking outside of it
|
||||
window.onclick = function(event) {
|
||||
if (event.target === modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
};
|
||||
});
|
||||
</script> -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#scrollable-modal').on('show.bs.modal', function() {
|
||||
var formData = $("#myForm").serialize();
|
||||
var groupName = $("#groupname").val();
|
||||
// Use AJAX to load content into the modal
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?= base_url() . 'insert_customer_group' ?>",
|
||||
data: formData,
|
||||
dataType: "json", // Expect JSON response
|
||||
success: function(response) {
|
||||
if (response.length > 0) {
|
||||
// Get the table reference
|
||||
var table = $("#data-table tbody");
|
||||
|
||||
$('#scrollableModalTitle').text(groupName + ' - Data Preview');
|
||||
// Clear existing rows
|
||||
table.empty();
|
||||
|
||||
// Loop through the response and create table rows
|
||||
$.each(response, function (index, item) {
|
||||
var row = $("<tr>");
|
||||
row.append($("<td style='width:40%;'>").text(item.customer_name));
|
||||
row.append($("<td style='width:30%;'>").text(item.email));
|
||||
row.append($("<td style='width:30%;'>").text(item.mobile_no));
|
||||
table.append(row);
|
||||
});
|
||||
} else {
|
||||
// Handle the case where there is no data
|
||||
table.empty();
|
||||
table.append("<tr><td colspan='3' style='width:100%;'>No data available</td></tr>");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("An error occurred.");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$("#save").on("click", function () {
|
||||
$("#string_flag").val("save");
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -784,9 +784,12 @@
|
||||
|
||||
<!-- Summernote js -->
|
||||
<script src="<?= base_url() . "public/assets/libs/summernote/summernote-bs4.min.js" ?>"></script>
|
||||
|
||||
<!-- <script src="<?= base_url() . "public/assets/libs/select2/js/select2.min.js" ?>"></script> -->
|
||||
<!-- <script src="<?= base_url() . "public/assets/libs/bootstrap-maxlength/bootstrap-maxlength.min.js" ?>"></script> -->
|
||||
<!-- Init js -->
|
||||
<script src="<?= base_url() . "public/assets/js/pages/form-summernote.init.js" ?>"></script>
|
||||
<!-- <script src="<?= base_url() . "public/assets/js/pages/form-advanced.init.js" ?>"></script> -->
|
||||
|
||||
<script>
|
||||
// Automatically close both success and error messages after 5 seconds (5000 milliseconds)
|
||||
setTimeout(function() {
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
<link rel="shortcut icon" href="<?= $favicon; ?>">
|
||||
|
||||
<!-- plugin css -->
|
||||
<link href="<?= base_url()."public/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css" ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public/assets/libs/multiselect/css/multi-select.css" ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public/assets/libs/select2/css/select2.min.css" ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public/assets/libs/selectize/css/selectize.bootstrap3.css" ?>" rel="stylesheet" type="text/css" />
|
||||
|
||||
<!-- third party css -->
|
||||
<link href="<?= base_url()."public/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
|
||||
@ -177,18 +179,32 @@
|
||||
<?php endif; ?>
|
||||
<?php if ($loggedin_person_role !== 'manager') : ?>
|
||||
<li>
|
||||
<a href="<?= base_url()."mail_custom_notifications"; ?>">
|
||||
<i class="ri-notification-3-fill"></i>
|
||||
<span> Custom Notifications </span>
|
||||
<a href="<?= base_url()."customer_group"; ?>">
|
||||
<i class="ri-team-line"></i>
|
||||
<span> Customer Group </span>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if ($loggedin_person_role !== 'manager') : ?>
|
||||
<li>
|
||||
<a href="<?= base_url()."customer_group_notifications"; ?>">
|
||||
<i class="ri-team-fill"></i>
|
||||
<span> Customer Group </span>
|
||||
<?php if ($loggedin_person_role !== 'manager') : ?>
|
||||
<li>
|
||||
<a href="#notificationsLayouts" data-toggle="collapse">
|
||||
<i class="ri-notification-3-line"></i>
|
||||
<span> Notifications </span>
|
||||
<span class="menu-arrow"></span>
|
||||
</a>
|
||||
<div class="collapse" id="notificationsLayouts">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="<?= base_url()."template_creation"; ?>">Template Creation</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."campaign_creation"; ?>">Notification Campaign</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."mail_custom_notifications"; ?>">Custom Notifications</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
91
app/Views/template_creation.php
Normal file
91
app/Views/template_creation.php
Normal file
@ -0,0 +1,91 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<a href="<?= base_url()."template_creation_form/0"; ?>" class="btn btn-primary"><i class="ri-file-edit-line"></i> Add Template </a>
|
||||
</div><!-- end col-->
|
||||
<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_customer" class="table w-100 nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th hidden></th>
|
||||
<th>Template Name</th>
|
||||
<th>Group Name</th>
|
||||
<th>Mode</th>
|
||||
<th>Created at</th>
|
||||
<th>Created by</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ($template as $temp) :
|
||||
if ($temp['isactive']) {
|
||||
$class = 'badge badge-soft-success';
|
||||
$message = 'Active';
|
||||
} else {
|
||||
$class = 'badge badge-soft-danger';
|
||||
$message = 'In-Active';
|
||||
} ?>
|
||||
<tr>
|
||||
<td hidden><?= $temp['template_id']; ?></td>
|
||||
<td><?= $temp['template_name']; ?></td>
|
||||
<td><?= $temp['group_name']; ?></td>
|
||||
<td><?= $temp['mode']; ?></td>
|
||||
<td><?= $temp['formatted_created_on']; ?></td>
|
||||
<td><?= $temp['created_by_name']; ?></td>
|
||||
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
|
||||
<td>
|
||||
<a href="<?= base_url()."template_creation_form/".$temp['template_id']; ?>" class="edit-button" title="Click to Edit Template" ><i class="ri-pencil-line"></i></a>
|
||||
<?php if ($temp['isactive']) { ?> <a href="<?php echo "template_creation_delete/".$temp['template_id']; ?>" class="delete-button" title="Click to Delete Template" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div><!-- end row-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#scroll-horizontal-datatable_customer').DataTable({
|
||||
"order": [
|
||||
[0, "desc"]
|
||||
] // 4 is the column index of "created_on" in your table
|
||||
// Other DataTables configuration options
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- <script>
|
||||
$(document).ready(function() {
|
||||
$('#bs-example-modal-lg').on('show.bs.modal', function(event) {
|
||||
var primaryKey = $(event.relatedTarget).data('primary-key');
|
||||
console.log(primaryKey);
|
||||
var groupName = $(event.relatedTarget).data('modal-title');
|
||||
$('#myLargeModalLabel').text(groupName);
|
||||
});
|
||||
});
|
||||
</script> -->
|
||||
104
app/Views/template_creation_form.php
Normal file
104
app/Views/template_creation_form.php
Normal file
@ -0,0 +1,104 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<form class="parsley-examples" action="<?= base_url() . "template_creation_insert"; ?>" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="templatename" class="col-form-label">Template Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="templatename" name="templatename" value="<?= isset($template_details['template_name']) ? $template_details['template_name'] : '' ?>" placeholder="Template Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="group_id" class="col-form-label">Group<span class="text-danger"></span></label>
|
||||
<select id="group_id" name="group_id" class="form-control" required>
|
||||
<option value="">Choose the Group</option>
|
||||
<?php foreach ($group_details as $value) { ?>
|
||||
<option value="<?php echo $value['group_id']; ?>" <?php if (isset($template_details['group_id']) && ($template_details['group_id'] === $value['group_id'])) echo "selected"; ?>>
|
||||
<?php echo $value['group_name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="mode" class="col-form-label col-md-3">Mode<span class="text-danger"></span></label>
|
||||
<div class="col-md-9 mt-1">
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input type="radio" id="emailRadio" name="mode" class="custom-control-input" value="Email" checked>
|
||||
<label class="custom-control-label" for="emailRadio">Email</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio custom-control-inline">
|
||||
<input type="radio" id="whatsappRadio" name="mode" class="custom-control-input" value="Whatsapp">
|
||||
<label class="custom-control-label" for="whatsappRadio">Whatsapp</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12" id="emailSubject" style="display: block;">
|
||||
<label for="templatename" class="col-form-label">subject</label>
|
||||
<input type="text" class="form-control" id="subject" name="subject" value="<?= isset($template_details['subject']) ? $template_details['subject'] : '' ?>" placeholder="Subject" />
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
||||
<textarea id="summernote-basic" name="templatemessage" class="form-control" rows="7">
|
||||
<?php if(isset($template_details['message'])){ echo $template_details['message']; }else{ ?>
|
||||
<h5>Hello {User}, </h5>
|
||||
<p>Please, write text here!</p>
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="template_id" name="template_id" placeholder="hidden for template id" value="<?= isset($template_details['template_id']) ? $template_details['template_id'] : '' ?>" />
|
||||
<?php if (!empty($template_details)) { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($template_details) && $template_details['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
<label for="isactive"> Is Active</label>
|
||||
</div>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<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>
|
||||
<a href="<?= base_url() . "template_creation"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
</div><!-- end row -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Listen for changes in the radio buttons
|
||||
$('input[name="mode"]').on('change', function() {
|
||||
var selectedValue = $(this).val();
|
||||
if (selectedValue === 'Email') {
|
||||
$('#emailSubject').show();
|
||||
} else {
|
||||
$('#emailSubject').hide();
|
||||
}
|
||||
});
|
||||
|
||||
var mode = "<?= isset($template_details['mode']) ? $template_details['mode'] : ""; ?>";
|
||||
if(mode != ""){
|
||||
var emailRadio = document.getElementById("emailRadio");
|
||||
var whatsappRadio = document.getElementById("whatsappRadio");
|
||||
if(mode == 'Email'){
|
||||
emailRadio.checked = true;
|
||||
whatsappRadio.checked = false;
|
||||
$('#emailSubject').show();
|
||||
}else if(mode == 'Whatsapp'){
|
||||
emailRadio.checked = false;
|
||||
whatsappRadio.checked = true;
|
||||
$('#emailSubject').hide();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user