Compare commits

..

No commits in common. "819dc9e876d1bc0d67640592ee12179dc2315637" and "2d73e91eb8650704f2707b53cdafa55a002021ba" have entirely different histories.

19 changed files with 285 additions and 3507 deletions

View File

@ -4,18 +4,25 @@ defined('BASEPATH') or exit('No direct script access allowed');
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)
{
$this->load->model('Frontend_model');
$this->load->model('Form_model');
$this->load->model('Response_model');
// Check if the user is logged in
if (!$this->session->userdata('logged_in')) {
// If not logged in, redirect to login page
redirect('users/login');
}
$user_id = $this->session->userdata('user_id');
// Retrieve form title from the forms table using form_id
$form_title = 'Untitled Form'; // Default title
@ -26,20 +33,15 @@ 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
$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');
}
public function delete($id)
{
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('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('responses_list', $data);
// $this->load->view('templates/footer');
$this->load->view('templates/footer');
}
@ -93,37 +93,5 @@ class Response_submit extends CI_Controller {
$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,38 +4,22 @@ defined('BASEPATH') or exit('No direct script access allowed');
class Form_model extends CI_Model
{
// Function to get form details by ID
public function get_form_by_id($form_id)
// Get the total number of forms
public function get_total_forms()
{
$this->load->database();
$this->db->where('id', $form_id);
$query = $this->db->get('forms');
return $query->row();
}
// Get the total number of forms
public function get_total_forms($user_id) {
// Ensure user_id is passed as a parameter and used in the query
$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');
}
// Function to count 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->db->where('user_id', $user_id);
$this->db->where('is_published', 1);
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)
// Get the number of published forms
public function get_published_forms()
{
$this->db->where('user_id', $user_id);
$this->db->order_by('created_at', 'DESC');
$query = $this->db->get('forms');
return $query->result();
}
$this->load->database();
$this->db->where('is_published', 1);
return $this->db->count_all_results('forms');
}
public function save_form($form_data)
{
$this->db->trans_start();

View File

@ -6,14 +6,8 @@ class Response_model extends CI_Model
}
// Get the total number of responses
public function get_total_responses($user_id) {
// 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 get_total_responses() {
return $this->db->count_all('responses');
}
public function insert_response($data)
@ -119,54 +113,5 @@ class Response_model extends CI_Model
$query = $this->db->get();
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

@ -1,100 +0,0 @@
<!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,9 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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="<?php echo base_url(); ?>assets/css/styles.css"> -->
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/header_styles.css">
<link rel="stylesheet" href="styles.css"> <!-- Link to your stylesheet -->
<style>
.title-column {
color: darkblue; /* Dark blue color for title */
@ -94,4 +92,5 @@
rows.forEach(row => tbody.appendChild(row));
});
</script>
</body>
</html>

View File

@ -6,99 +6,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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="styles.css"> -->
<link rel="stylesheet" href="styles.css"> <!-- Link to your stylesheet -->
<style>
/* CSS styles */
.title-column {
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;
color: darkblue; /* Dark blue color for title */
}
</style>
</head>
<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="col-md-12 mt-4 ">
<div class="col-md-12 mt-4">
<div class="card">
<div class="card-header">
<?php if ($this->session->flashdata('status')): ?>
@ -106,37 +24,36 @@
<?= $this->session->flashdata('status'); ?>
</div>
<?php endif; ?>
<h3>List of Forms</h3>
<h3>Drafts</h3>
</div>
<div class="card-body">
<!-- here your table will occur -->
<table id="basetable1" class="table table-bordered">
<thead>
<tr>
<th>Forms</th>
<th>Drafts</th>
<th>Title</th>
<th>Description</th>
<th>Created On</th>
<th>Status</th>
<th>Responses</th>
<th>Edit</th>
<th>Delete</th>
<th>Preview</th>
</tr>
</thead>
<tbody>
<?php
$serialNumber = 1; // Initialize the counter variable
foreach ($forms as $row): ?>
<tr class="<?php echo ($row->is_published ? '' : 'draft-row'); ?>">
<tr>
<td><?php echo $serialNumber++; ?></td>
<td class="title-column">
<a href="<?php echo base_url('publish/' . $row->id); ?>"><?php echo $row->title; ?></a>
</td>
<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 class="title-column"><?php echo $row->title; ?></td>
<td><?php echo date('Y-m-d H:i:s', strtotime($row->created_at)); ?></td> <!-- Ensure date is in a sortable format -->
<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>
<td>
<a href="<?php echo base_url('responses/' . $row->id); ?>">
<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>
</td>
<td>
<a href="<?php echo base_url('publish/' . $row->id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon -->
</a>
</td>
@ -149,3 +66,31 @@
</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,18 +22,7 @@
<body>
<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>
<!-- Navbar -->
@ -151,15 +140,7 @@
$(document).ready(function () {
var base_url = '<?php echo base_url(); ?>';
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() {
if (activeSection) {
var position = activeSection.position();
@ -313,7 +294,7 @@
positionAddSectionButton();
});
// positionAddSectionButton();
positionAddSectionButton();
$(document).ready(function () {
var base_url = '<?php echo base_url(); ?>';

View File

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

View File

@ -1,3 +1,95 @@
<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="row">
<div class="col-md-12 mt-4">
@ -8,7 +100,9 @@
<?= $this->session->flashdata('status'); ?>
</div>
<?php endif; ?>
<h3>Published Forms</h3>
<h3>
Published Forms
</h3>
</div>
<div class="card-body">
<!-- here your table will occur -->
@ -27,17 +121,24 @@
foreach ($forms as $row): ?>
<tr>
<td><?php echo $serialNumber++; ?></td>
<td class="title-column"><?php echo $row->title; ?></td>
<td class="title-column">
<?php echo $row->title; ?>
</td>
<td>
<a href="<?php echo $row->response_link; ?>" target="_blank"><?php echo $row->response_link; ?></a>
<a href="<?php echo $row->response_link; ?>"
target="_blank"><?php echo $row->response_link; ?></a>
</td>
<td>
<label class="switch">
<input type="checkbox" class="toggle-switch" data-form-id="<?php echo $row->id; ?>" <?php echo $row->is_responsive ? 'checked' : ''; ?>>
<input type="checkbox" class="toggle-switch"
data-form-id="<?php echo $row->id; ?>" <?php echo $row->is_responsive ? 'checked' : ''; ?>>
<span class="slider round"></span>
<span class="tooltip"><?php echo $row->is_responsive ? 'Active' : 'Inactive'; ?></span>
<span
class="tooltip"><?php echo $row->is_responsive ? 'Active' : 'Disabled'; ?>
</span>
</label>
</td>
<td>
<a href="<?php echo base_url('form_preview/' . $row->id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon -->
@ -49,50 +150,3 @@
</table>
</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,46 +59,17 @@
.popup-message {
display: none;
position: fixed;
top: 10%;
left: 40%;
transform: translate(-20%, -40%);
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
padding: 30px;
width: 80%;
max-width: 600px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
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>
</head>
<body>
<div class="container">
<!-- <div class="form-header">

View File

@ -1,75 +1,51 @@
<!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>
.username-column {
color: darkblue; /* Dark blue color for title */
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 mt-4">
<div class="card">
<div class="card-header">
<?php if ($this->session->flashdata('status')): ?>
<div class="alert alert-success">
<?= $this->session->flashdata('status'); ?>
</div>
<?php endif; ?>
<h3>Responses for "<?php echo $form->title; ?>"</h3>
<!-- <a href="<?php echo base_url('Response_submit/summary/' . $form->id); ?>" class="btn btn-primary">View Summary</a> -->
</div>
<div class="card-body">
<table id="basetable1" class="table table-bordered">
<thead>
color: darkblue; /* Dark blue color for title */
}
</style>
<div class="container">
<div class="row">
<div class="col-md-12 mt-4">
<div class="card">
<div class="card-header">
<?php if ($this->session->flashdata('status')): ?>
<div class="alert alert-success">
<?= $this->session->flashdata('status'); ?>
</div>
<?php endif; ?>
<h3>
Responses for "<?php echo $form->title; ?>"
</h3>
</div>
<div class="card-body">
<table id="basetable1" class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Submitted At</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php foreach ($responses as $response): ?>
<tr>
<th>Username</th>
<th>Submitted At</th>
<th>View</th>
<td class="username-column"><?php echo $response->username; ?></td>
<td><?php echo $response->submitted_at; ?></td>
<td>
<a href="<?php echo base_url('responses/view/' . $response->response_id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon -->
</a>
</td>
</tr>
</thead>
<tbody>
<?php foreach ($responses as $response): ?>
<tr>
<td class="username-column"><?php echo $response->username; ?></td>
<td><?php echo $response->submitted_at; ?></td>
<td>
<a href="<?php echo base_url('responses/view/' . $response->response_id); ?>">
<i class="fas fa-eye"></i> <!-- Eye icon -->
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endforeach; ?>
</tbody>
</table>
</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>
</div>
</body>
</html>

View File

@ -1,78 +1,17 @@
<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": 5 } // Disable sorting for the "View" column (index 5)
],
"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);
});
});
$('#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": 2 } // Disable sorting for the "View" column (index 2)
],
"order": [[1, "desc"]] // Default sort by "Filled At" column (index 1) in descending order
});
});
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() {
// Fade out flash messages after 2 seconds
setTimeout(function() {
@ -139,7 +78,7 @@ $(document).ready(function() {
});
// Login form validation
$('#login-form').submit(function(e) {
$('#login-form').submit(function(e) {
e.preventDefault(); // Prevent default form submission
// Clear all previous errors
@ -166,6 +105,35 @@ $('#login-form').submit(function(e) {
}
});
});
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>
</body>
</html>

View File

@ -30,86 +30,6 @@
text-decoration: none !important; /* Ensures no underline 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>
<nav class="navbar navbar-inverse" style="background-color: rgb(103, 58, 183);">

View File

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

View File

2750
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +0,0 @@
{
"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"
}
}