Compare commits

...

2 Commits

Author SHA1 Message Date
RameshT 819dc9e876 commit 2024-07-29 18:04:29 +05:30
RameshT 4cdf3fdf5d initial 2024-07-29 14:47:16 +05:30
19 changed files with 3509 additions and 287 deletions

View File

@ -4,25 +4,18 @@ defined('BASEPATH') or exit('No direct script access allowed');
class Form_controller extends CI_Controller class Form_controller extends CI_Controller
{ {
public function index() {
// Fetch the data
$this->load->model('Form_model');
$this->load->model('Response_model');
$data['total_forms'] = $this->Form_model->get_total_forms();
$data['published_forms'] = $this->Form_model->get_published_forms();
$data['total_responses'] = $this->Response_model->get_total_responses();
// var_dump($data);
// Load the view and pass the data
$this->load->view('list_forms', $data);
}
public function index_forms($form_id = null) public function index_forms($form_id = null)
{ {
$this->load->model('Frontend_model'); $this->load->model('Frontend_model');
$this->load->model('Form_model');
$this->load->model('Response_model');
// Check if the user is logged in // Check if the user is logged in
if (!$this->session->userdata('logged_in')) { if (!$this->session->userdata('logged_in')) {
// If not logged in, redirect to login page // If not logged in, redirect to login page
redirect('users/login'); redirect('users/login');
} }
$user_id = $this->session->userdata('user_id');
// Retrieve form title from the forms table using form_id // Retrieve form title from the forms table using form_id
$form_title = 'Untitled Form'; // Default title $form_title = 'Untitled Form'; // Default title
@ -33,15 +26,20 @@ class Form_controller extends CI_Controller
} }
} }
// Fetch data from models
$data['total_forms'] = $this->Form_model->get_total_forms($user_id);
$data['published_forms'] = $this->Form_model->get_published_forms($user_id);
$data['total_responses'] = $this->Response_model->get_total_responses($user_id);
$data['forms'] = $this->Form_model->get_all_forms($user_id);
$data['form_title'] = $form_title;
// Load views and data if user is logged in // Load views and data if user is logged in
$this->load->view('templates/header'); $this->load->view('templates/header');
$this->load->view('Tables/list_forms', $data);
$data = $this->Frontend_model->getforms();
$this->load->view('Tables/list_forms', ['forms' => $data, 'form_title' => $form_title]);
$this->load->view('templates/footer'); $this->load->view('templates/footer');
} }
public function delete($id) public function delete($id)
{ {
if (!$this->session->userdata('logged_in')) { if (!$this->session->userdata('logged_in')) {

View File

@ -34,7 +34,7 @@ class Publish_controller extends CI_Controller {
$this->load->view('templates/header'); $this->load->view('templates/header');
$this->load->view('publish_view', $data); $this->load->view('publish_view', $data);
$this->load->view('templates/footer'); // $this->load->view('templates/footer');
} }

View File

@ -25,7 +25,7 @@ class Response_submit extends CI_Controller {
$this->load->view('templates/header'); $this->load->view('templates/header');
$this->load->view('responses_list', $data); $this->load->view('responses_list', $data);
$this->load->view('templates/footer'); // $this->load->view('templates/footer');
} }
@ -93,5 +93,37 @@ class Response_submit extends CI_Controller {
$this->load->view('templates/footer'); $this->load->view('templates/footer');
} }
public function summary($form_id)
{
$this->load->model('Form_model');
$this->load->model('Response_model');
// Check if the user is logged in
if (!$this->session->userdata('logged_in')) {
redirect('users/login');
}
// Fetch form details
$form = $this->Form_model->get_form_by_id($form_id);
if (!$form) {
show_404();
}
// Fetch summary data
$summary_data = $this->Response_model->get_summary_data($form_id);
$data['form'] = $form;
$data['summary_data'] = $summary_data;
$this->load->view('templates/header');
$this->load->view('Forms/summary', $data);
$this->load->view('templates/footer');
}
} }

View File

@ -4,22 +4,38 @@ defined('BASEPATH') or exit('No direct script access allowed');
class Form_model extends CI_Model class Form_model extends CI_Model
{ {
// Function to get form details by ID
public function get_form_by_id($form_id)
{
$this->load->database();
$this->db->where('id', $form_id);
$query = $this->db->get('forms');
return $query->row();
}
// Get the total number of forms // Get the total number of forms
public function get_total_forms() public function get_total_forms($user_id) {
{ // Ensure user_id is passed as a parameter and used in the query
$this->load->database(); $this->db->where('user_id', $user_id);
return $this->db->count_all_results('forms'); // Use count_all_results to ensure WHERE conditions are applied
return $this->db->count_all('forms');
} }
// Get the number of published forms // Function to count published forms
public function get_published_forms() public function get_published_forms($user_id) {
{ // Ensure user_id and is_published are passed as parameters and used in the query
$this->load->database(); $this->db->where('user_id', $user_id);
$this->db->where('is_published', 1); $this->db->where('is_published', 1);
return $this->db->count_all_results('forms'); return $this->db->count_all_results('forms'); // Use count_all_results to ensure WHERE conditions are applied
} }
// Function to get all forms
public function get_all_forms($user_id)
{
$this->db->where('user_id', $user_id);
$this->db->order_by('created_at', 'DESC');
$query = $this->db->get('forms');
return $query->result();
}
public function save_form($form_data) public function save_form($form_data)
{ {
$this->db->trans_start(); $this->db->trans_start();

View File

@ -6,8 +6,14 @@ class Response_model extends CI_Model
} }
// Get the total number of responses // Get the total number of responses
public function get_total_responses() { public function get_total_responses($user_id) {
return $this->db->count_all('responses'); // Join the responses table with the forms table
$this->db->select('responses.id');
$this->db->from('responses');
$this->db->join('forms', 'responses.form_id = forms.id');
// Filter by user_id in the forms table
$this->db->where('forms.user_id', $user_id);
return $this->db->count_all_results();
} }
public function insert_response($data) public function insert_response($data)
@ -113,5 +119,54 @@ class Response_model extends CI_Model
$query = $this->db->get(); $query = $this->db->get();
return $query->row(); return $query->row();
} }
// Function to get summary data for a form
public function get_summary_data($form_id)
{
$this->load->database();
$summary_data = array();
// Get questions for the form
$this->db->select('id,text,type');
$this->db->where('form_id', $form_id);
$questions = $this->db->get('questions')->result_array();
// Get responses count
$this->db->where('form_id', $form_id);
$responses = $this->db->get('responses')->result_array();
if (count($responses) > 0) {
$response_ids = array_column($responses, 'id');
// Get response answers
$this->db->where_in('response_id', $response_ids);
$response_answers = $this->db->get('response_answers')->result_array();
// Process response answers
foreach ($questions as $question) {
$question_id = $question['id'];
$summary_data[$question_id] = [
'text' => $question['text'],
'type' => $question['type'],
'answers' => []
];
}
foreach ($response_answers as $answer) {
$question_id = $answer['question_id'];
$answered_text = $answer['answered_text'];
if (!isset($summary_data[$question_id]['answers'][$answered_text])) {
$summary_data[$question_id]['answers'][$answered_text] = 1;
} else {
$summary_data[$question_id]['answers'][$answered_text]++;
}
}
}
return $summary_data;
}
} }

View File

@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form Summary</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
.chart-container {
width: 50%;
margin: 0 auto;
margin-bottom: 50px; /* Add margin to avoid overlap */
}
.short-answer, .paragraph {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 mt-4">
<div class="card">
<div class="card-header">
<h3>Summary for "<?php echo $form->title; ?>"</h3>
<a href="<?php echo base_url('forms/view/' . $form->id); ?>" class="btn btn-primary">Back to Responses</a>
</div>
<div class="card-body">
<div id="charts">
<?php foreach ($summary_data as $question): ?>
<h5><?php echo $question['text']; ?></h5>
<?php if (is_array($question['answers'])): ?>
<div class="chart-container">
<canvas id="chart-<?php echo $question['question_id']; ?>"></canvas>
</div>
<?php else: ?>
<div class="short-answer">
<ul>
<?php foreach ($question['answers'] as $answer): ?>
<li><?php echo $answer; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var summaryData = <?php echo json_encode($summary_data); ?>;
console.log('Summary Data:', summaryData); // Debugging information
summaryData.forEach(function(question) {
var answers = question['answers'];
if (typeof answers === 'object') {
var ctx = document.getElementById('chart-' + question['question_id']).getContext('2d');
var labels = Object.keys(answers);
var data = Object.values(answers);
console.log('Question ID:', question['question_id'], 'Labels:', labels, 'Data:', data); // Debugging information
var chartType = (question['type'] === 'checkboxes') ? 'bar' : 'pie';
new Chart(ctx, {
type: chartType,
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: [
'#FF6384',
'#36A2EB',
'#FFCE56',
'#4BC0C0',
'#9966FF',
'#FF9F40'
]
}]
},
options: {
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: question['text']
}
}
});
}
});
});
</script>
</body>
</html>

View File

@ -6,7 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form List</title> <title>Form List</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="styles.css"> <!-- Link to your stylesheet --> <!-- <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/styles.css"> -->
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/header_styles.css">
<style> <style>
.title-column { .title-column {
color: darkblue; /* Dark blue color for title */ color: darkblue; /* Dark blue color for title */
@ -92,5 +94,4 @@
rows.forEach(row => tbody.appendChild(row)); rows.forEach(row => tbody.appendChild(row));
}); });
</script> </script>
</body>
</html>

View File

@ -6,15 +6,97 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form List</title> <title>Form List</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="styles.css"> <!-- Link to your stylesheet --> <!-- <link rel="stylesheet" href="styles.css"> -->
<style> <style>
/* CSS styles */
.title-column { .title-column {
color: darkblue; /* Dark blue color for title */ color: darkblue;
/* Dark blue color for title */
}
.draft-row {
background-color: #f0f0f0;
/* Light grey background for draft status */
}
.card-stats {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
padding: 20px;
text-align: center;
transition: transform 0.2s, box-shadow 0.2s;
}
.card-stats:hover {
transform: translateY(-10px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.card-title {
color: rgb(103, 58, 183); /* Match the color theme */
margin-bottom: 10px;
font-size: 20px; /* Increase the font size of the title */
font-weight: bold; /* Make the title bold */
}
.card-text {
font-size: 28px; /* Increase the font size */
font-weight: bold; /* Make the text bold */
}
.card-text.green {
color: #28a745;
}
.card-text.red {
color: #dc3545;
}
.card-text.blue {
color: #007bff;
}
.card-text.yellow {
color: #ffc107;
}
.card-text.purple {
color: #6f42c1;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="row">
<div class="col-md-4">
<div class="card card-stats">
<div class="card-body">
<h5 class="card-title">Total Forms Created</h5>
<p class="card-text" id="total-forms"><?php echo $total_forms; ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-stats">
<div class="card-body">
<h5 class="card-title">Published Forms</h5>
<p class="card-text" id="published-forms"><?php echo $published_forms; ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-stats">
<div class="card-body">
<h5 class="card-title">Responses Submitted</h5>
<p class="card-text" id="total-responses"><?php echo $total_responses; ?></p>
</div>
</div>
</div>
</div>
<!-- Your existing table code here -->
<div class="row"> <div class="row">
<div class="col-md-12 mt-4 "> <div class="col-md-12 mt-4 ">
<div class="card"> <div class="card">
@ -24,36 +106,37 @@
<?= $this->session->flashdata('status'); ?> <?= $this->session->flashdata('status'); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<h3>Drafts</h3> <h3>List of Forms</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<!-- here your table will occur -->
<table id="basetable1" class="table table-bordered"> <table id="basetable1" class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>Drafts</th> <th>Forms</th>
<th>Title</th> <th>Title</th>
<th>Description</th>
<th>Created On</th> <th>Created On</th>
<th>Edit</th> <th>Status</th>
<th>Delete</th> <th>Responses</th>
<th>Preview</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$serialNumber = 1; // Initialize the counter variable $serialNumber = 1; // Initialize the counter variable
foreach ($forms as $row): ?> foreach ($forms as $row): ?>
<tr> <tr class="<?php echo ($row->is_published ? '' : 'draft-row'); ?>">
<td><?php echo $serialNumber++; ?></td> <td><?php echo $serialNumber++; ?></td>
<td class="title-column"><?php echo $row->title; ?></td> <td class="title-column">
<td><?php echo date('Y-m-d H:i:s', strtotime($row->created_at)); ?></td> <!-- Ensure date is in a sortable format --> <a href="<?php echo base_url('publish/' . $row->id); ?>"><?php echo $row->title; ?></a>
<td> </td>
<a href="<?php echo base_url('edit/' . $row->id); ?>" class="btn btn-success btn-sm" style="background-color: rgb(103, 58, 183); border-color: rgb(103, 58, 183); color: white;">Edit</a> <td><?php echo $row->description; ?></td>
<td><?php echo $row->created_at; ?></td>
<td style="color: <?php echo ($row->is_published ? '#006400' : 'red'); ?>;">
<?php echo ($row->is_published ? 'Published' : 'Draft'); ?>
</td> </td>
<td> <td>
<a href="<?php echo base_url('forms/delete/' . $row->id); ?>" class="btn btn-danger btn-sm" style="background-color: rgb(103, 58, 183); border-color: rgb(103, 58, 183); color: white;">Delete</a> <a href="<?php echo base_url('responses/' . $row->id); ?>">
</td>
<td>
<a href="<?php echo base_url('publish/' . $row->id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon --> <i class="fas fa-eye"></i> <!-- Eye icon -->
</a> </a>
</td> </td>
@ -66,31 +149,3 @@
</div> </div>
</div> </div>
</div> </div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const table = document.getElementById('basetable1');
const tbody = table.querySelector('tbody');
const rows = Array.from(tbody.querySelectorAll('tr'));
rows.sort((rowA, rowB) => {
const dateTextA = rowA.cells[2].textContent.trim();
const dateTextB = rowB.cells[2].textContent.trim();
const dateA = new Date(dateTextA);
const dateB = new Date(dateTextB);
if (isNaN(dateA.getTime())) {
return 1;
}
if (isNaN(dateB.getTime())) {
return -1;
}
return dateB - dateA;
});
rows.forEach(row => tbody.appendChild(row));
});
</script>
</body>
</html>

View File

@ -22,7 +22,18 @@
<body> <body>
<style> <style>
.custom-select {
width: 220px;
height: 44px;
display: block;
padding: -20px 15px;
font-size: 15px;
line-height: 1.42857143;
background-color: #ffffff;
background-image: none;
border: 1px solid #dce4ec;
border-radius: 4px;
}
</style> </style>
<!-- Navbar --> <!-- Navbar -->
@ -140,7 +151,15 @@
$(document).ready(function () { $(document).ready(function () {
var base_url = '<?php echo base_url(); ?>'; var base_url = '<?php echo base_url(); ?>';
var activeSection = null; var activeSection = null;
$('#form-container').sortable({
placeholder: 'ui-state-highlight',
start: function (event, ui) {
ui.placeholder.height(ui.item.height());
},
stop: function (event, ui) {
positionAddSectionButton();
}
});
function positionAddSectionButton() { function positionAddSectionButton() {
if (activeSection) { if (activeSection) {
var position = activeSection.position(); var position = activeSection.position();
@ -294,7 +313,7 @@
positionAddSectionButton(); positionAddSectionButton();
}); });
positionAddSectionButton(); // positionAddSectionButton();
$(document).ready(function () { $(document).ready(function () {
var base_url = '<?php echo base_url(); ?>'; var base_url = '<?php echo base_url(); ?>';

View File

@ -8,10 +8,7 @@
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/form_preview.css"> <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/form_preview.css">
</head> </head>
<body> <body>
<style>.form-header {
margin-left: 251px; /* Adjust the value as needed */
}
</style>
<div class="container"> <div class="container">
<div class="form-header"> <div class="form-header">
<h2><?php echo $form->title; ?></h2> <h2><?php echo $form->title; ?></h2>

View File

@ -1,95 +1,3 @@
<style>
/* CSS styles */
.title-column {
color: darkblue;
/* Dark blue color for title */
}
.draft-row {
background-color: #f0f0f0;
/* Light grey background for draft status */
}
.switch {
position: relative;
display: inline-block;
width: 34px;
height: 20px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 14px;
width: 14px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .4s;
}
input:checked+.slider {
background-color: #673AB7;
}
input:checked+.slider:before {
transform: translateX(14px);
}
/* Rounded sliders */
.slider.round {
border-radius: 20px;
}
.slider.round:before {
border-radius: 50%;
}
.switch {
position: relative;
display: inline-block;
}
.switch .tooltip {
visibility: hidden;
width: 70px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%;
/* Position above the switch */
left: 290%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.switch:hover .tooltip {
visibility: visible;
opacity: 1;
}
</style>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12 mt-4"> <div class="col-md-12 mt-4">
@ -100,9 +8,7 @@
<?= $this->session->flashdata('status'); ?> <?= $this->session->flashdata('status'); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<h3> <h3>Published Forms</h3>
Published Forms
</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<!-- here your table will occur --> <!-- here your table will occur -->
@ -121,24 +27,17 @@
foreach ($forms as $row): ?> foreach ($forms as $row): ?>
<tr> <tr>
<td><?php echo $serialNumber++; ?></td> <td><?php echo $serialNumber++; ?></td>
<td class="title-column"> <td class="title-column"><?php echo $row->title; ?></td>
<?php echo $row->title; ?>
</td>
<td> <td>
<a href="<?php echo $row->response_link; ?>" <a href="<?php echo $row->response_link; ?>" target="_blank"><?php echo $row->response_link; ?></a>
target="_blank"><?php echo $row->response_link; ?></a>
</td> </td>
<td> <td>
<label class="switch"> <label class="switch">
<input type="checkbox" class="toggle-switch" <input type="checkbox" class="toggle-switch" data-form-id="<?php echo $row->id; ?>" <?php echo $row->is_responsive ? 'checked' : ''; ?>>
data-form-id="<?php echo $row->id; ?>" <?php echo $row->is_responsive ? 'checked' : ''; ?>>
<span class="slider round"></span> <span class="slider round"></span>
<span <span class="tooltip"><?php echo $row->is_responsive ? 'Active' : 'Inactive'; ?></span>
class="tooltip"><?php echo $row->is_responsive ? 'Active' : 'Disabled'; ?>
</span>
</label> </label>
</td> </td>
<td> <td>
<a href="<?php echo base_url('form_preview/' . $row->id); ?>"> <a href="<?php echo base_url('form_preview/' . $row->id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon --> <i class="fas fa-eye"></i> <!-- Eye icon -->
@ -150,3 +49,50 @@
</table> </table>
</div> </div>
</div> </div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#basetable1').DataTable({
"pagingType": "full_numbers", // Full pagination controls
"lengthMenu": [10, 25, 50], // Options for number of rows per page
"language": {
"search": "Filter records:", // Custom search label
"lengthMenu": "Show _MENU_ entries" // Custom length menu label
},
"columnDefs": [
{ "orderable": false, "targets": 4 } // Disable sorting for the "View" column (index 4)
],
"order": [[0, "asc"]] // Default sort by "Title" column (index 1) in descending order
});
});
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.toggle-switch').forEach(function(switchElement) {
switchElement.addEventListener('change', function() {
var formId = this.getAttribute('data-form-id');
var isResponsive = this.checked ? 1 : 0;
fetch(`<?php echo base_url('Publish_controller/toggle_responsive/'); ?>${formId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
body: `is_responsive=${isResponsive}`
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Optionally, handle success
} else {
// Optionally, handle failure
}
})
.catch(error => {
console.error('Error:', error);
});
});
});
});
</script>

View File

@ -59,17 +59,46 @@
.popup-message { .popup-message {
display: none; display: none;
position: fixed; position: fixed;
top: 50%; top: 10%;
left: 50%; left: 40%;
transform: translate(-50%, -50%); transform: translate(-20%, -40%);
background-color: white; background-color: white;
padding: 20px; padding: 30px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); width: 80%;
max-width: 600px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
z-index: 1000; z-index: 1000;
border-top: 10px solid rgb(103, 58, 183);
border-radius: 8px;
text-align: center;
}
.popup-message h2 {
margin-top: 0;
color: rgb(103, 58, 183);
font-size: 24px; /* Increase font size */
}
.popup-message p {
font-size: 18px; /* Increase font size */
}
.popup-message button {
background-color: rgb(103, 58, 183);
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
.popup-message button:hover {
background-color: darkviolet;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<!-- <div class="form-header"> <!-- <div class="form-header">

View File

@ -1,9 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Other head elements -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responses for "<?php echo $form->title; ?>"</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style> <style>
.username-column { .username-column {
color: darkblue; /* Dark blue color for title */ color: darkblue; /* Dark blue color for title */
} }
</style> </style>
</head>
<body>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12 mt-4"> <div class="col-md-12 mt-4">
@ -14,9 +23,8 @@
<?= $this->session->flashdata('status'); ?> <?= $this->session->flashdata('status'); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<h3> <h3>Responses for "<?php echo $form->title; ?>"</h3>
Responses for "<?php echo $form->title; ?>" <!-- <a href="<?php echo base_url('Response_submit/summary/' . $form->id); ?>" class="btn btn-primary">View Summary</a> -->
</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<table id="basetable1" class="table table-bordered"> <table id="basetable1" class="table table-bordered">
@ -30,7 +38,6 @@
<tbody> <tbody>
<?php foreach ($responses as $response): ?> <?php foreach ($responses as $response): ?>
<tr> <tr>
<td class="username-column"><?php echo $response->username; ?></td> <td class="username-column"><?php echo $response->username; ?></td>
<td><?php echo $response->submitted_at; ?></td> <td><?php echo $response->submitted_at; ?></td>
<td> <td>
@ -47,5 +54,22 @@
</div> </div>
</div> </div>
</div> </div>
<script>
$(document).ready(function() {
$('#basetable1').DataTable({
"pagingType": "full_numbers",
"lengthMenu": [10, 25, 50],
"language": {
"search": "Filter records:",
"lengthMenu": "Show _MENU_ entries"
},
"columnDefs": [
{ "orderable": false, "targets": 2 }
],
"order": [[1, "desc"]]
});
});
</script>
</body> </body>
</html> </html>

View File

@ -1,5 +1,6 @@
<script> <script>
$(document).ready(function() {
$('#basetable1').DataTable({ $('#basetable1').DataTable({
"pagingType": "full_numbers", // Full pagination controls "pagingType": "full_numbers", // Full pagination controls
"lengthMenu": [10, 25, 50], // Options for number of rows per page "lengthMenu": [10, 25, 50], // Options for number of rows per page
@ -8,10 +9,70 @@
"lengthMenu": "Show _MENU_ entries" // Custom length menu label "lengthMenu": "Show _MENU_ entries" // Custom length menu label
}, },
"columnDefs": [ "columnDefs": [
{ "orderable": false, "targets": 2 } // Disable sorting for the "View" column (index 2) { "orderable": false, "targets": 5 } // Disable sorting for the "View" column (index 5)
], ],
"order": [[1, "desc"]] // Default sort by "Filled At" column (index 1) in descending order "order": [[3, "desc"]] // Default sort by "Created On" column (index 3) in descending order
}); });
updateCardColors();
});
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.toggle-switch').forEach(function(switchElement) {
switchElement.addEventListener('change', function() {
var formId = this.getAttribute('data-form-id');
var isResponsive = this.checked ? 1 : 0;
fetch(`<?php echo base_url('Publish_controller/toggle_responsive/'); ?>${formId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
body: `is_responsive=${isResponsive}`
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Optionally, handle success
} else {
// Optionally, handle failure
}
})
.catch(error => {
console.error('Error:', error);
});
});
});
});
function updateCardColors() {
const totalForms = document.getElementById('total-forms');
const publishedForms = document.getElementById('published-forms');
const totalResponses = document.getElementById('total-responses');
const totalFormsValue = parseInt(totalForms.textContent);
const publishedFormsValue = parseInt(publishedForms.textContent);
const totalResponsesValue = parseInt(totalResponses.textContent);
// Update colors based on values
if (totalFormsValue) {
totalForms.classList.add('blue');
} else {
totalForms.classList.add('red');
}
if (publishedFormsValue) {
publishedForms.classList.add('green');
} else {
publishedForms.classList.add('red');
}
if (totalResponsesValue) {
totalResponses.classList.add('red');
} else {
totalResponses.classList.add('red');
}
}
$(document).ready(function() { $(document).ready(function() {
// Fade out flash messages after 2 seconds // Fade out flash messages after 2 seconds
setTimeout(function() { setTimeout(function() {
@ -105,35 +166,6 @@ $(document).ready(function() {
} }
}); });
}); });
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.toggle-switch').forEach(function(switchElement) {
switchElement.addEventListener('change', function() {
var formId = this.getAttribute('data-form-id');
var isResponsive = this.checked ? 1 : 0;
fetch(`<?php echo base_url('Publish_controller/toggle_responsive/'); ?>${formId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
body: `is_responsive=${isResponsive}`
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Optionally, handle success
} else {
// Optionally, handle failure
}
})
.catch(error => {
console.error('Error:', error);
});
});
});
});
</script> </script>
</body>
</html>

View File

@ -30,6 +30,86 @@
text-decoration: none !important; /* Ensures no underline on hover */ text-decoration: none !important; /* Ensures no underline on hover */
background: none !important; /* Ensures no background color on hover */ background: none !important; /* Ensures no background color on hover */
} }
.title-column {
color: darkblue;
}
.draft-row {
background-color: #f0f0f0;
}
.switch {
position: relative;
display: inline-block;
width: 34px;
height: 20px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 14px;
width: 14px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .4s;
}
input:checked + .slider {
background-color: #673AB7;
}
input:checked + .slider:before {
transform: translateX(14px);
}
.slider.round {
border-radius: 20px;
}
.slider.round:before {
border-radius: 50%;
}
.switch .tooltip {
visibility: hidden;
width: 70px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 290%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.switch:hover .tooltip {
visibility: visible;
opacity: 1;
}
</style> </style>
<nav class="navbar navbar-inverse" style="background-color: rgb(103, 58, 183);"> <nav class="navbar navbar-inverse" style="background-color: rgb(103, 58, 183);">

View File

@ -78,7 +78,7 @@ body {
.btn-success { .btn-success {
margin-top: 20px; margin-top: 20px;
position: relative; position: relative;
left: 240px; left: 247px;
background-color: rgb(103, 58, 183); background-color: rgb(103, 58, 183);
border-color: rgb(103, 58, 183); border-color: rgb(103, 58, 183);
color: white; color: white;

2750
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

88
package.json Normal file
View File

@ -0,0 +1,88 @@
{
"name": "google_forms",
"version": "1.0.0",
"description": "What is CodeIgniter ###################",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install",
"lint": "eslint .",
"lint:fix": "phpcbf && eslint . --fix"
},
"repository": {
"type": "git",
"url": "https://git.aissel.com/RameshT/google_forms.git"
},
"lint-staged": {
"*.php": [
"phpcbf",
"git add"
],
"*.js": [
"eslint --fix",
"git add"
]
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@eslint/js": "^9.8.0",
"eslint": "^9.8.0",
"globals": "^15.8.0",
"husky": "^8.0.0",
"lint-staged": "^15.2.7"
},
"dependencies": {
"ansi-escapes": "^7.0.0",
"ansi-regex": "^6.0.1",
"ansi-styles": "^6.2.1",
"braces": "^3.0.3",
"chalk": "^5.3.0",
"cli-cursor": "^5.0.0",
"cli-truncate": "^4.0.0",
"colorette": "^2.0.20",
"commander": "^12.1.0",
"cross-spawn": "^7.0.3",
"debug": "^4.3.6",
"emoji-regex": "^10.3.0",
"environment": "^1.1.0",
"eventemitter3": "^5.0.1",
"execa": "^8.0.1",
"fill-range": "^7.1.1",
"get-east-asian-width": "^1.2.0",
"get-stream": "^8.0.1",
"human-signals": "^5.0.0",
"is-fullwidth-code-point": "^4.0.0",
"is-number": "^7.0.0",
"is-stream": "^3.0.0",
"isexe": "^2.0.0",
"lilconfig": "^3.1.2",
"listr2": "^8.2.4",
"log-update": "^6.1.0",
"merge-stream": "^2.0.0",
"micromatch": "^4.0.7",
"mimic-fn": "^4.0.0",
"mimic-function": "^5.0.1",
"ms": "^2.1.2",
"npm-run-path": "^5.3.0",
"onetime": "^6.0.0",
"path-key": "^3.1.1",
"picomatch": "^2.3.1",
"pidtree": "^0.6.0",
"restore-cursor": "^5.1.0",
"rfdc": "^1.4.1",
"shebang-command": "^2.0.0",
"shebang-regex": "^3.0.0",
"signal-exit": "^4.1.0",
"slice-ansi": "^5.0.0",
"string-argv": "^0.3.2",
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"strip-final-newline": "^3.0.0",
"to-regex-range": "^5.0.1",
"which": "^2.0.2",
"wrap-ansi": "^9.0.0",
"yaml": "^2.4.5"
}
}