I'm a newbie in CodeIgniter and I'm trying to pass my form inputs from the view to the controller. I was able to pass it, and was able to insert it on the database. However, I want to use Ajax for this so the whole page won't reload when I press the submit button. I have watched and tried this youtube tutorial: https://www.youtube.com/watch?v=IURutxKvukA, but it doesn't work for me. :( Thank you in advance!
This is my controller, Teacher.php
public function insert_quiz($quiztitle, $quizdescription, $value="")
{
$data = $this->input->post();
$numData = count($data);
$response = array();
$stringChoices = "";
if($numData > 1)
{
for ($i=4; $i < $numData; $i++)
{
$num = $i-3;
$offset = "inputChoice$num";
if ($i == 4)
{
$stringChoices = $data[$offset];
}
else if ($i != 4)
{
$stringChoices = $stringChoices . "," . $data[$offset];
}
}
}
$quizitems = array('Question' => $data['inputQuestion'], 'Choices' => $stringChoices, 'Correct' => $data['correctanswer'], 'NumSequence' => $data['questionnumber']);
$quizitemid = $this->Teacher_model->insertQuizItemOnQuizItems($quizitems);
if (count($quizitemid) == 1)
{
$quizdeedid = $this->Teacher_model->getQuizDeedId($quiztitle);
$quizdatasetitem = array('QuizSet' => $data['quizsetnumber'], 'QuizItemID' => $quizitemid, 'QuizDeedID' => $quizdeedid);
$quizdatasetid = $this->Teacher_model->insertQuizOnQuizDataSet($quizdatasetitem);
if(count($quizdatasetid) == 1)
{
$response = array(
'status' => "success"
);
echo json_encode($response);
}
}
}
and this is my quiz form, in quizView.php
<div class="container-fluid container-cards-pf container-pf-nav-pf-vertical
nav-pf-persistent-secondary">
<div class="row row-cards-pf">
<!-- Important: if you need to nest additional .row within a .row.row-cards-pf, do *not* use .row-cards-pf on the nested .row -->
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="card-pf">
<div class="card-pf-heading">
<h1 align="center">
<strong><?php echo str_replace("%20", " ", $quizTitle); ?></strong>
</h1>
<h2 class="card-pf-title" align="center">
<label><?php echo str_replace("%20", " ", $quizDescription); ?></label>
</h2>
</div>
<div class="card-pf-body" id="divquizset" style="height: 50px">
<div class="col-sm-2">
</div>
<div class="col-sm-9" id="divquizset">
<div class="col-sm-3">
<p align="right"> QUIZ SET: </p>
</div>
<div class="col-sm-4">
<input align="center" type="text" id="quizset" class="form-control"></input>
</div>
<button class="btn btn-default col-sm-2" align="left" onclick="saveQuizSet()">Save</button>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="container">
<div class="col-sm-12">
<div id="status">
</div>
</div>
</div>
</div>
<div class="container-fluid container-cards-pf container-pf-nav-pf-vertical
nav-pf-persistent-secondary" id="list1" style="padding-top: 0px">
<!-- LIST VIEW PART 1 -->
<div id = "div1" style="padding-top: 0px">
<?php echo form_open("Teacher/insert_quiz/$quizTitle/$quizDescription", "id='myForm'", $hidden= array()); ?>
<div>
<div class="list-group list-view-pf list-view-pf-view">
<div class="list-group-item">
<div class="list-group-item-header" id="div2">
<div class="list-view-pf-expand">
<span class="fa fa-angle-right"></span>
</div>
<div class="list-view-pf-checkbox">
<input type="text" name="questionnumber" id="inputquestionnumber1" class="form-control">
<!-- <b id="questionnumber" name="questionlabel" for="inputQuestion">Question 1: </b> -->
<input type="hidden" name="quizsetnumber" id="quizsetnum" class="form-control" value="">
</div>
<div class="list-view-pf-actions">
<?php echo form_submit('submit', 'Save', $attributes=array("class" => "btn btn-default")); ?>
<!-- <button class="btn btn-default" style="width: 100px">Save</button> -->
<button class="btn btn-default" style="width: 100px">Edit</button>
<button class="btn btn-default" style="width: 100px">Delete</button>
</div>
<div class="list-view-pf-main-info">
<div class="list-view-pf-body">
<div class="list-view-pf-description">
<div class="list-group-item-text form-group">
<input type="text" name="inputQuestion" id="input1" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="list-group-item-container container-fluid hidden" id="containerDiv">
<div class="close">
<span class="pficon pficon-close"></span>
</div>
<div class="row">
<!-- LIST VIEW SUB VIEW -->
<div class="col-md-12">
<form class="form-horizontal" style="padding-left: 100px">
<div class="form-group">
<div class="col-sm-7" align="center">
<dt> CHOICES </dt>
</div>
<div class="col-sm-5" align="center">
<dt> CORRECT ANSWER </dt>
</div>
<div class="col-sm-7">
<div id="divCorrect" style="padding-top: 10px">
<input type="text" name="correctanswer" id="inputcorrectanswer1" class="form-control">
</div>
</div>
<div class="col-sm-5" id="divChoiceContainer1">
<div id="divChoice" style="padding-top: 10px">
<input type="text" name="inputChoice1" id="inpChoice1" class="form-control">
</div>
</div>
<div class="col-sm-7" id="otherDivChoiceContainer1">
</div>
<div class="col-sm-7" align="center" style="padding-top: 20px">
<button type="button" class="btn btn-primary btn-lg btn-block col-xs-9" id = "1" align="center" onclick="addChoiceFunction(this.id)" >Add Choices</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?= form_close() ?>
</form>
</div>
</div>
</div>
<div class="col-sm-3 container-fluid container-cards-pf container-pf-nav-pf-vertical nav-pf-persistent-secondary">
<button type="button" class="btn btn-primary btn-lg btn-block col-md-9" align="center" onclick="addQuestionFunction()">Add Question</button>
</div>
These are the scripts I used, they're also in the quizView.php:
<script>
jQuery(document).ready(function($) {
$('#myForm').ajaxForm({
beforeSubmit: function(formData, jqForm, options){
$("div#status").html('');
},
success: function(response){
var result = $.parseJSON(response);
$("div#status").html('<div class="alert alert-' + result.status + '" role="alert"> HI </div>');
}
});
});
</script>
<script>
$(document).ready(function () {
// click the list-view heading then expand a row
$(".list-group-item-header").click(function(event){
if(!$(event.target).is("button, a, input, .fa-ellipsis-v")){
$(this).find(".fa-angle-right").toggleClass("fa-angle-down")
.end().parent().toggleClass("list-view-pf-expand-active")
.find(".list-group-item-container").toggleClass("hidden");
} else {
}
})
// click the close button, hide the expand row and remove the active status
$(".list-group-item-container .close").on("click", function (){
$(this).parent().addClass("hidden")
.parent().removeClass("list-view-pf-expand-active")
.find(".fa-angle-right").removeClass("fa-angle-down");
})
});
</script>
<script>
function addQuestionFunction() {
$num = $('div .list-view-pf-view').length + 1;
$divId = "#" + $num;
$toClone = $('#div1').clone(true).find("input").val("").end();
$($toClone).find("#containerDiv").addClass("hidden").end();
$($toClone).find("#otherDivChoiceContainer1").attr("id", "otherDivChoiceContainer"+ $num);
$($toClone).find("#otherDivChoiceContainer" + $num).find("#divChoice").remove().end();
$($toClone).find("#1").attr("id", $num);
$($toClone).find("#questionnumber").text("Question " + $num + ": ");
if($($toClone).find("span").hasClass("fa-angle-down")) {
$($toClone).find(".fa-angle-right").removeClass("fa-angle-down").end();
}
$('#list1').append($toClone);
}
function addChoiceFunction(clicked_id) {
$num = parseInt(clicked_id);
$divId = "#otherDivChoiceContainer" + $num;
$numChoice = $($divId + " input").length + 2;
$toClone = $('#divChoice').clone(true).find("input").val("").end();
$toClone.find("#inpChoice1").attr("id", "inpChoice" + $numChoice).attr("name", "inputChoice" + $numChoice);
// $toClone.find("#inpChoice" + $num).attr("name", $("#inpChoice"+$num).attr("name").replace(/\\[\d+\\]/,"inputChoice" + $num));
//alert($numChoice);
$($divId).append($($toClone));
}
function saveQuizSet() {
$('#quizsetnum').val($('#quizset').val());
$quizsetval = $('#quizset').val();
$('#divquizset').empty();
$('#divquizset').append(' <p align="center"> QUIZ SET: '+ $quizsetval + '</p>');
// $('#divquizset').append(" <p align="center"> QUIZ SET: A </p>");
}
</script>
And for my script sources I used these:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
<script src="http://www.patternfly.org/components/jquery/dist/jquery.min.js"></script>
<script src="http://www.patternfly.org/components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="http://www.patternfly.org/components/patternfly-bootstrap-combobox/js/bootstrap-combobox.js"></script>
<script src="http://www.patternfly.org/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js"></script>
<script src="http://www.patternfly.org/components/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<script src="http://www.patternfly.org/components/d3/d3.min.js"></script>
<script src="http://www.patternfly.org/components/c3/c3.min.js"></script>
<script src="http://www.patternfly.org/components/datatables/media/js/jquery.dataTables.js"></script>
<script src="http://www.patternfly.org/components/google-code-prettify/bin/prettify.min.js"></script>
<script src="http://www.patternfly.org/components/clipboard/dist/clipboard.min.js"></script>
<script src="http://www.patternfly.org/components/patternfly/dist/js/patternfly.min.js"></script>
<script src="http://www.patternfly.org/components/jquery-match-height/dist/jquery.matchHeight-min.js"></script>
<script src="http://www.patternfly.org/assets/js/patternfly-site.min.js"></script>
<link rel="canonical" href="http://www.patternfly.org/pattern-library/navigation/vertical-navigation/vertical-navigation.html">
This is what my form looks like
quizviewform
And this is what it's returning
returnpage
It's inserting on my database, but it doesn't return on the page and ajax doesn't work. :( I hope someone can help me here. Thanks!
Related
I am creating a comment system in PHP (laravel5.5), and jQuery, but when I comment using ajax and then showing the just commented string it overlaps to the previous commented div. How can I show the new comment just after the previous comment?.
my code are as follow:
<div class="container">
<div class="col-md-12">
<div class="panel panel-default widget">
<div class="panel-heading" style="background: #D8E4FC">
<i class="fa fa-comments-o" aria-hidden="true" style="font-size: large"></i>
<h3 class="panel-title">Recent Comments </h3>
<span class="label label-info">{{ $total_comments }}</span>
</div>
<div class="comment-box" id="comment_box">
<?php
foreach ($comments as $comment):
if($comment->video_id == $content_record->code && $comment->comment_type == 1){
?>
<div class="comment" id="comment<?php echo $comment['user_id']; ?>">
<div class="author-thumbnail">
<img src="{{ getProfilePath($comment['image'], 'thumb') }}" alt="<?php echo $comment['video_id']; ?>">
</div>
<div class="comment-text"><strong>
<?php echo $comment['user_id']; ?></strong> - posted
{{ $comment['created_at']->diffForHumans()}}
</div>
<div class="text">
{{ $comment['comment'] }}
</div>
</div>
<?php
foreach ($replys as $reply):
if($reply->video_id == $content_record->code && $reply->replay_for == $comment->id){
?>
<div class="comment coment-replay">
<div class="author-thumbnail"><img src="{{ getProfilePath($reply['image'], 'thumb') }}" alt=""></div>
<div class="comment-text"><strong><?php echo $reply['user_id']; ?></strong> - posted
{{ $reply['created_at']->diffForHumans()}}
</div>
<div class="text">
{{ $reply['comment'] }}
</div>
</div>
<?php
}
endforeach;
?>
<?php
// if(($replys_method =='both' || $replys_method =='ovoo')) :
?>
<div class="comment coment-replay">
<form>
<textarea name="reply" id="reply_{{$comment['id']}}" class="form-control" rows="2" placeholder="Repay" required></textarea>
<input type="hidden" name="video_id1" value="{{$content_record->code}}">
<input type="hidden" id="reply_for_{{$comment['id']}}" name="url1" value="{{$comment['id']}}">
<input type="hidden" name="comment_type1" id="comment_type1" value="2">
<input type="hidden" name="publication1" id="publication1" value="1">
<div>
<?php
$user = auth()->user();
if(!empty($user->id))
{
?>
<button type="submit" value="submit" class="btn btn-success btn-sm pull-right reply ">
<span class="btn-label">
<i class="fi ion-ios-undo-outline"></i></span>Replay </button>
<?php }else{ ?>
<a class="btn btn-success" href="{{URL_USERS_LOGIN}}" style=" margin: 10px 13px;float: right; padding: 5px 7px 5px 10px;"> <span class="btn-label"><i class="fi ion-log-in"></i></span>Login to Replay </a>
<?php } ?>
</div>
</form>
</div>
<script type="text/javascript">
$(".reply").click(function(e){
e.preventDefault();
var namer = '{{$content_record->code}}';
var passwordr = $("#reply_for_{{$comment['id']}}").val();
var comntr = $("#reply_{{$comment['id']}}").val();
var comnttyper = $("#comment_type1").val();
var publicationr = $("#publication1").val();
var tokenr = '{{ csrf_token() }}';
$.ajax({
type:'POST',
url: '{{ URL_COMMENTS_ADD }}',
data:{video_id:namer, url:passwordr, comment:comntr, _token:tokenr, publication:publicationr, comment_type:comnttyper},
success:function(data){
alert('Your comment has been post wait for approval');
console.log(data);
$("#reply").val("");
},
error: function (error) {
alert('Please Login First Before Comment.');
}
});
});
</script>
<?php
}
// endif;
endforeach;
if($total_comments == 0){
echo "<style> #comment-container{margin-top:0px !important} </style>";
}else{
echo "<style> #comment-container{margin-top:50px !important} </style>";
}
?>
</div>
<div id="comment-container">
<div class="movie-heading overflow-hidden"> <span class="wow fadeInUp" data-wow-duration="0.8s">Leave a comment</span>
<div class="disable-bottom-line wow zoomIn" data-wow-duration="0.8s"></div>
</div>
<!-- {!! Form::open(array('url' => URL_COMMENTS_ADD, 'method' => 'POST', 'files' => true, 'name'=>'formComments ', 'novalidate'=>'')) !!} -->
<form>
<input type="hidden" name="video_id" value="{{$content_record->code}}">
<input type="hidden" name="url" value="{{ $video_src }}">
<input type="hidden" name="comment_type" id="comment_type" value="1">
<input type="hidden" name="publication" id="publication" value="0">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea name="comment" id="cmnt-user-msg" rows="4" class="form-control" placeholder="Write comment here" required></textarea>
<div class="input-top-line"></div>
<div class="input-bottom-line"></div>
</div>
</div>
<div class="col-sm-12">
<?php
$user = auth()->user();
if(!empty($user->id))
{
?>
<button type="submit" value="submit" class="btn btn-success" id="commen"> <span class="btn-label"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> </span> Post Comments </button>
<?php
}
else
{
?>
<a class="btn btn-success" href="{{URL_USERS_LOGIN}}"> <span class="btn-label"><i class="fi ion-log-in"></i></span>Login to Comments </a>
<?php
}
?>
</div>
</div>
</form>
<!-- {!! Form::close() !!} -->
</div>
</div>
</div>
</div>
my jquery code is as following
$("#commen").click(function(e){
e.preventDefault();
var name = '{{$content_record->code}}';
var password = $("input[name=url]").val();
var comnt = $("#cmnt-user-msg").val();
var comnttype = $("#comment_type").val();
var publication = $("#publication").val();
var token = '{{ csrf_token() }}';
$.ajax({
type:'POST',
url: '{{ URL_COMMENTS_ADD }}',
data:{video_id:name, url:password, comment:comnt, _token:token, publication:publication, comment_type:comnttype},
success:function(data){
console.log(data);
$('#comment_box').html('<div class="comment" id="comment"'+data.id+'"><div class="author-thumbnail"><img src="{{ getProfilePath("'+data.user_image+'", "thumb") }}" alt="'+data.video_id+'"></div><div class="comment-text"><strong>'+data.user_name+'</strong> - posted just now </div> <div class="text">'+data.comment+'</div> </div>');
alert('Your comment has been post wait for approval');
$("#cmnt-user-msg").val("");
},
error: function (error) {
alert('Comments after some time later.');
}
});
But it shows this instead in the image shared right here below
only the single comment shows and overlap the previous one, I want to add it after previous commented comment if comment
You are using the html() method which only returns the content of an element, instead use the append() method which adds the content of an element to the end of a parent element.
Use append like this:
$('#comment_box').append('<div class="comment"
id="comment"'+data.id+'"><div class="author-thumbnail"><img src="{{ getProfilePath("'+data.user_image+'", "thumb") }}" alt="'+data.video_id+'"></div><div class="comment-text"><strong>'+data.user_name+'</strong> - posted just now </div> <div class="text">'+data.comment+'</div> </div>');
This will add the div class of "comment" at the end of the parent id "comment_box"
I have a button inside a loop.
When the user clicks on the button I want to create a $_SESSION variable with the value of a variable inside the loop.
For example, the variable $id_puja is 767 at this loop item, when the user clicks on the button I want to create the session variable $_SESSION['clicked_puja'] = $row['id_puja'].
This is the button:
while{...
$id_puja = $row['id_puja'];
...
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
...
}
I
EDITED, full loop code:
<?php
$resultadopujas=0;
global $mysqli;
$loop = mysqli_query($mysqli, "SELECT * FROM tb_pujas
WHERE subasta_puja = '".$subasta."'")
or die (mysqli_error($mysqli));
$orden = 0;
$resultado = $loop ->num_rows;
if ($resultado == 0){
?> <div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-md-6">
<p><?php echo $resultado."NO HAY PUJAS"?></p>
</div>
</div>
</div>
</div>
<?php
}
$numpuja=0;
while ($row = mysqli_fetch_array($loop))
{$numpuja = $numpuja+1;
$originalDate = $row['datetime_puja'];
$newDate = date("d-m-Y H:i:s",strtotime($originalDate))
?>
<div class="container">
<div class="jumbotron" style="background-color: white">
<div class="row">
<div class="col-md-2">
<img style="width: 80px;height: auto;align-self: " src="garantia.png">
</div>
<div class="col-md-2">
<img style="width: 80px;height: auto;align-self: " src="ok.png">
</div>
<div class="col-md-2">
<img style="width: 80px;height: auto;align-self: " src="extra.png">
</div>
<div class="col-md-2">
<p><strong>Dia/Hora puja: </strong><?php echo $newDate?></p>
</div>
<div class="col-md-2">
<p><strong>Precio puja: </strong><?php echo $row['precio_puja']." €"?></p>
</div>
<div class="col-md-2">
<p><?php echo "<strong>Puja núm:</strong> ".$numpuja?></p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p><?php echo "<strong>Comentarios:</strong> ".$row['comentarios_puja']?></p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<img style="width: 100%;height: auto;align-self: " src="https://cribbeo.com/pujas/<?php echo $row['foto1']?>">
</div>
<div class="col-md-4">
<img style="width: 100%;height: auto;align-self: " src="https://cribbeo.com/pujas/<?php echo $row['foto2']?>">
</div>
<div class="col-md-4">
<img style="width: 100%;height: auto;align-self: " src="https://cribbeo.com/pujas/<?php echo $row['foto3']?>">
</div>
</div>
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
<script>
function myclick(){
alert (<?php echo $row['precio_puja']?>);
}
</script>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" id="boton" onclick="myclick()" data-target="#myModal">Open Modal</button>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
EDITED modal part
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Mensajes de la subasta <?php echo $referencia."VAR=".$_COOKIE['puja']?></h4>
</div>
<div class="modal-body" style="background-color:#486A86; color: white">
<div class="container">
<header class="header">
<h1>Chat</h1>
</header>
<main>
<img src="images/logohorizontal.png" alt="Cribbeo" width="200px">
<div class="userSettings">
<label for="userName">Usuario: <?php echo $_SESSION['usuario']?></label>
<input id="userName" type="hidden" placeholder="Username" maxlength="32" value=" <?php echo $_SESSION['usuario']?>">
</div>
<div class="chat">
<div id="chatOutput"></div>
<input id="chatInput" type="text" style="background-color:white; color: #486A86" placeholder="Escribe aquí el texto de tu mensaje" maxlength="128">
<button id="chatSend" style="background-color:#486A86; color: white">Enviar</button>
</div>
</main>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
And this is chat.js
$(document).ready(function() {
var chatInterval = 250; //refresh interval in ms
var $userName = $("#userName");
var $chatOutput = $("#chatOutput");
var $chatInput = $("#chatInput");
var $chatSend = $("#chatSend");
function sendMessage() {
var userNameString = $userName.val();
var chatInputString = $chatInput.val();
$.get("./write.php", {
username: userNameString,
text: chatInputString
});
$userName.val("");
retrieveMessages();
}
function retrieveMessages() {
$.get("./read.php", function(data) {
$chatOutput.html(data); //Paste content into chat output
});
}
$chatSend.click(function() {
sendMessage();
});
setInterval(function() {
retrieveMessages();
}, chatInterval);
});
Try this-
//START OF LOOP...
//Add data-var attribute to your button to store the value of the session variable to be picked up by jQuery.
<button type="button" class="btn btn-info btn-lg session-btn" data-toggle="modal" data-target="#myModal" data-var="<?php echo $id_puja;?>">Open Modal</button>
//END OF LOOP..
// jQuery CDN link
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
$('.session-btn').on('click', function(){
var session_var = $(this).data('var');
console.log(session_var); // prints the session variable value to the console.
$(document).ready(checkModal);
function checkModal() {
if($('#myModal').is(':visible')){
//if the modal is visible on the page
$.ajax({
url: 'read.php',
type: 'POST',
data: {session_var: session_var},
success: function(){
alert('success');
}
});
}
}
});
</script>
In read.php file
<?php
require("connect.php");
session_start():
//connect to db
$db = new mysqli($db_host,$db_user, $db_password, $db_name);
if ($db->connect_errno) {
//if the connection to the db failed
echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
}
if(isset($_POST['session_var'])){
$_SESSION['session_var'] = $_POST['session_var'];
echo $_SESSION['session_var'];
$query="SELECT * FROM chat WHERE id_puja ='".$_SESSION['session_var']."' ORDER BY id ASC";
//execute query
if ($db->real_query($query)) {
//If the query was successful
$res = $db->use_result();
while ($row = $res->fetch_assoc()) {
$username=$row["username"];
$text=$row["text"];
$time=date('G:i', strtotime($row["time"])); //outputs date as # #Hour#:#Minute#
echo "<p>$time | $username: $text</p>\n";
}
}else{
//If the query was NOT successful
echo "An error occured";
echo $db->errno;
}
} else {
echo 'variable is not posted!';
}
$db->close();
?>
if i click on view button in my table it should open an modal form and
display all table values to view it.But i'm getting error as undefined
variable in the textbox inside of location,where i called only location
in the table.kindly help out me with how to get datas from dbs as php
code.thanks in advance.
UPDATE: I had updated my code.Kindly check it out,as i called ajax ,but modal box open with empty ,no informations loaded.kindly help it out.
<!-- Main content -->
<div class="main-content">
<h1 class="page-title">OUR POP DETAILS</h1>
<!-- Breadcrumb -->
<ol class="breadcrumb breadcrumb-2">
<li><i class="fa fa-home"></i>Home</li>
<li>Metro Pop</li>
<li class="active"><strong>Action</strong></li>
</ol>
<div class="row">
<div class="col-md-12"></div>
<div class="col-md-4">
<?php $apage = array('id'=>'','name'=>'');?>
<script>var page_0 = <?php echo json_encode($apage)?></script>
<h3><a data="page_0" class="model_form btn btn-sm btn-danger" href="#"><span class="glyphicon glyphicon-plus"></span> Add new record</a></h3>
</div>
</div>
<div id="table-container">
<div class="row">
<div class="col-md-12">
<table id="table" class="table table-striped table-sortable table-condensed " cellspacing="0" width="100%"
data-show-columns="true"
>
<tbody>
<?php if(isset($result) && ($data_record) > 0) : $i=1; ?>
<?php while ($users = mysqli_fetch_object($result)) { ?>
<tr class="<?=$users->id?>_del">
<td><?=$i;?></td>
<td><?=$users->zonee;?></td>
<td><?=$users->location;?></td>
<td><?=$users->pop_type;?></td>
<td><?=$users->switch_name;?></td>
<td><?=$users->switch_ip;?></td>
<td><?=$users->switch_make;?></td>
<td><?=$users->switch_serial;?></td>
<td><?=$users->switch_model;?></td>
<td> <i class="material-icons"></i></td>
<script>var page_<?php echo $users->id ?> = <?php echo json_encode($users);?></script>
<td><a data="<?php echo 'page_'.$users->id ?>" class="model_form btn btn-info btn-sm" href="#"> <span class="glyphicon glyphicon-pencil"></span></a>
<a data="<?php echo $users->id ?>" title="Delete <?php echo $users->name;?>" class="tip delete_check btn btn-info btn-sm "><span class="glyphicon glyphicon-remove"></span> </a>
<button data-toggle="modal" data-target="#view-modal" data-id="<?php echo $users->id; ?>" class=" view_check btn btn-sm btn-info"><i class="glyphicon glyphicon-eye-open"></i></button>
</td>
</tr>
<?php $i++;
} ?>
<?php else : echo '<tr><td colspan="8"><div align="center">-------No record found -----</div></td></tr>'; ?>
<?php endif; ?>
</tbody>
</table>
<?php
if(isset($_SESSION['flash_msg'])) :
$message = $_SESSION['flash_msg'];
echo $error= '<div class="alert alert-success" role="alert">
<span class="glyphicon glyphicon-envelope"></span> <strong>'.$message.'</strong> </div>';
unset($_SESSION['flash_msg']);
endif;
?>
</div>
</div>
</div>
<div id="view-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">
<i class="glyphicon glyphicon-user"></i> POP Information
</h4>
</div>
<div class="modal-body" id="employee_detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Form modal -->
<div id="form_modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><i class="icon-paragraph-justify2"></i><span id="pop_title">ADD</span> POP INFORMATION</h4>
</div>
<!-- Form inside modal -->
<form method="post" action="add_edit.php" id="cat_form">
<div class="modal-body with-padding">
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>zonee :</label>
<input type="text" name="zonee" id="zonee" class="form-control required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" class="form-control required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>pop_type :</label>
<input type="text" name="pop_type" id="pop_type" class="form-control required number">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_name:</label>
<input type="text" name="switch_name" id="switch_name" class="form-control required number">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_ip :</label>
<input type="text" name="switch_ip" id="switch_ip" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_make :</label>
<input type="text" name="switch_make" id="switch_make" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_serial :</label>
<input type="text" name="switch_serial" id="switch_serial" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_model :</label>
<input type="text" name="switch_model" id="switch_model" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>Latitude:</label>
<input type="text" name="latitude" id="latitude" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>Longitude:</label>
<input type="text" name="longitude" id="longitude" class="form-control required" >
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<span id="add">
<input type="hidden" name="id" value="" id="id">
<button type="submit" name="form_data" class="btn btn-primary">Submit</button>
</span>
</div>
</form>
</div>
</div>
</div>
<!-- /form modal -->
<script type="text/javascript">
$(document).ready(function() {
$(document).on('click','.model_form',function(){
$('#form_modal').modal({
keyboard: false,
show:true,
backdrop:'static'
});
var data = eval($(this).attr('data'));
$('#id').val(data.id);
$('#zonee').val(data.zonee);
$('#location').val(data.location);
$('#pop_type').val(data.pop_type);
$('#switch_name').val(data.switch_name);
$('#switch_ip').val(data.switch_ip);
$('#switch_make').val(data.switch_make);
$('#switch_serial').val(data.switch_serial);
$('#switch_model').val(data.switch_model);
$('#latitude').val(data.latitude);
$('#longitude').val(data.longitude);
if(data.id!="")
$('#pop_title').html('Edit');
else
$('#pop_title').html('Add');
});
$(document).on('click','.delete_check',function(){
if(confirm("Are you sure to delete data")){
var current_element = $(this);
url = "add_edit.php";
$.ajax({
type:"POST",
url: url,
data: {ct_id:$(current_element).attr('data')},
success: function(data) { //location.reload();
$('.'+$(current_element).attr('data')+'_del').animate({ backgroundColor: "#003" }, "slow").animate({ opacity: "hide" }, "slow");
}
});
}
});
$(document).on('click', '.view_check', function(){
//$('#dataModal').modal();
var employee_id = $(this).attr("id");
$.ajax({
url:"view.php",
method:"POST",
data:{employee_id:employee_id},
success:function(data){
$('#employee_detail').html(data);
$('#view-modal').modal('show');
}
});
});
});
});
</script>
**view.php**
<?php
include("config.php");
if(isset($_POST["employee_id"]))
{
$output = '';
$connect = mysqli_connect("localhost", "root", "", "mine");
$query = "SELECT * FROM user WHERE id = '".$_POST["employee_id"]."'";
$result = mysqli_query($connect, $query);
$output .= '
<div class="table-responsive">
<table class="table table-bordered">';
while($row = mysqli_fetch_object($result))
{
$output .= '
<tr>
<td width="30%"><label>Name</label></td>
<td width="70%">'.$users["location"].'</td>
</tr>
<tr>
<td width="30%"><label>Address</label></td>
<td width="70%">'.$users["zonee"].'</td>
</tr>
<tr>
<td width="30%"><label>Gender</label></td>
<td width="70%">'.$users["pop_type"].'</td>
</tr>
';
}
$output .= '</table></div>';
echo $output;
}
?>
Add quota('') like $row['location'] , you are using $row[location]
Or use below code
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" value="<?php
echo $row['location'];?>" />
</div>
Your variable name is $users not $row so you can write this
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" value="<?php
echo $users['location'];?>" />
</div>
Try this Code
<tbody>
<?php if(isset($result) && ($data_record) > 0) : $i=1; ?>
<?php while ($users = mysqli_fetch_object($result)) { ?>
<tr class="<?=$users->id?>_del">
<td><?=$i;?></td>
<td><?=$users->zonee;?></td>
<td><?=$users->location;?></td>
<td><?=$users->pop_type;?></td>
<td><?=$users->switch_name;?></td>
<td><?=$users->switch_ip;?></td>
<td><?=$users->switch_make;?></td>
<td><?=$users->switch_serial;?></td>
<td><?=$users->switch_model;?></td>
<td> <a href="http://maps.google.com/?q=<?=$users-
>latitude;?>,<?=$users->longitude;?>" target=\"_blank\"><i
class="material-icons"></i></a></td>
<script>var page_<?php echo $users->id ?> = <?php
echo json_encode($users);?></script>
<td><a data="<?php echo 'page_'.$users->id ?>"
class="model_form btn btn-info btn-sm" href="#"> <span
class="glyphicon glyphicon-pencil"></span></a>
<a data="<?php echo $users->id ?>" title="Delete <?
php echo $users->name;?>" class="tip delete_check btn btn-info
btn-sm "><span
class="glyphicon glyphicon-remove"></span> </a>
<button data-toggle="modal" data-target="#view-
modal" data-id="<?php echo $users->id; ?>" id="getUser"
class="btn btn-sm
btn-info"><i class="glyphicon glyphicon-eye-open"></i>
</button>
</td>
</tr>
<?php $i++;
echo "<div class='modal-body'>
<div id='dynamic-content'>
<div class='form-group'>
<div class='row'>
<div class='col-sm-12'>
<label>location :</label>
<input type='text' name='location' id='location' value='$users->location' />
</div>
</div>
</div>
</div>
</div> "
} ?>
<?php else : echo '<tr><td colspan="8"><div align="center">-------No
record found -----</div></td></tr>'; ?>
<?php endif; ?>
</tbody>
On Click Call Function
<script>
function launch_modal(id)
{
//Store id in variable
var newId = id;
//Ajax Start
$.ajax({
type: "POST",
url: "your_php_page.php",
//send id to php page
data: {theId:newId},
success: function(data){
//to display data in paragraph of Modal
$('.modal-body').html(data);
//to display modal
$('#myModal').modal("show");
},
});
}
</script>
your_php_page.php
<?php
$theId = $_POST['theId'];
if($theId){
$output = '';
$sql = $conn->query("select * from table where id = '$theId'");
$fetch = $sql->fetch_object();
//Append
$output .= '<table class="table table-bordered">
<tr>
<td>Name :</td>
<td>'.$fetch->name.'</td>
</tr>
<tr>
<td>Number :</td>
<td>'.$fetch->number.'</td>
</tr>
';
echo $output;
}
?>
I'm using Laravel 4 on this. I have a form with a list of departments in which there are members per department. I used an accordion to place all members under one checkbox of department. Now when I check the checkbox and submit it I want it to be posted on my ajax.
Here's what I can do but found an error.
Syntax error, unrecognized expression: input[name=dept_id:checked
HTML
<div class="col-md-6 col-sm-6">
<div class="blue-steel box portlet">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-calendar"></i>Bulk select Department off day
</div>
</div><!-- /.portlet-title -->
<div class="portlet-body form">
<div class="form-body">
{{Form::open(['url'=>url('admin/schedule'), 'id' => 'department_bulk_off_day', 'class'=>'form-horizontal', 'method'=>'GET'])}}
<div class="form-group">
<label class="col-md-3 control-label" style="padding-left: 0px;">Select Department</label>
<div class="col-md-9">
<!-- <div id="accordion">
<h3><span id="id"><input type="checkbox"/></span>Text More text </h3>
<div>content etc</div>
</div> -->
<div class="employee_checkbox_wrapper" id="accordion">
<?php $department = DB::table('department')->get(); ?>
#foreach($department as $key => $val)
<label><span id="id"><input type="checkbox" name="dept_id[]" value="{{ $val->id }}"/></span>{{ $val->deptName }} </label>
<div>
<?php
$dept_id = $val->id;
$schedule = '';
$desig_ids = DB::table('designation')->where('deptID', $dept_id)->get();
foreach ($desig_ids as $desig_id) {
$emp_des = $desig_id->id;
$employee_desigs = DB::table('employees')->where('designation', $emp_des)->get();
foreach ($employee_desigs as $employee_desig) {
?>
<label style="margin-left: 15px;"><!-- <input type="checkbox" name="employee_id[]" value="{{ $employee_desig->id }}"/> -->
{{ $employee_desig->fullName }}
</label>
<a data-toggle="modal" data-id="{{ $employee_desig->id }}" data-target="#myModal" title="Add this item" class="open-AddBookDialog btn " href="#addBookDialog">
Change Department
</a>
</br>
<?php
}
}
?>
</div>
#endforeach
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3" style="margin-top: 20px;">Select Date</label>
<div class="col-md-3">
<div class="input-group input-medium date date-picker" data-date-format="dd-mm-yyyy" data-date-viewmode="years" style="margin-top: 20px;">
<input type="text" class="form-control" name="off_day" value="{{ date('d-m-Y') }}">
<span class="input-group-btn">
<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-12 text-center">
{{Form::token()}}
<input type="hidden" name="department_bulk_off_day" value="2">
<button class="btn btn-button button-tip-form-submit">Update</button>
</div><!-- /.col-md-12 text-center -->
</div>
</form><!-- /.form-horizontal -->
</div><!-- /.form-body -->
{{ Form::close() }}
</div><!-- /.portlet-body form -->
</div><!-- /.blue-steel box portlet -->
</div><!-- /.col-md-6 col-sm-6 -->
And here's my JS
<script>
$('#department_bulk_off_day').on('submit', function(e){
e.preventDefault();
var checkValues = jQuery('input[name=dept_id:checked').map(function()
{
return $(this).val();
}).get();
alert(checkValues);
</script>
you can try the following code
var checkValues = jQuery('input[name="dept_id"]').map(function()
{
var this_var = $(this);
if($(this):checked){
return this_var.val();
}
}).get();
Try This. You have the selectors all messed up.
$('#department_bulk_off_day').on('submit', function(e){
e.preventDefault();
var checkValues = $('input[name="dept_id"]:checked').map(function()
{
return $(this).val();
}).get();
alert(checkValues);
I am not able to update multiple columns of the same row with the row matching the userid in codeigniter.
My controller Code is :
exits.php
function update_act_on_resignation(){
global $SITE,$USER;
$data = array();
$data['row'] = new stdClass();
$data['row'] = $this->admin_init_elements->set_post_vals($this->input->post());
$data['offices']=$this->mod_common->get_all_offices();
$clients = currentuserclients();
$data['roles'] = $this->mod_common->get_cat_array('designation','status',"1' AND id > '0",'designation');
get_city_state_country_array($data,array('cityid'=>$data['row']->cityid));
$data['error_message'] = '';
$data['row']->id = $this->uri->segment(3);
$data['id'] = $this->uri->segment(3);
$data['action'] = 'add';
$data['heading'] = 'Add';
$data['msg_class'] = 'sukses';
$data['path']=$path;
$post_action = $this->input->post('action');
if($post_action=='add' || $post_action =='update' ){
$post_array = $this->input->post();
$action = ($post_action == 'add')?'inserted':'updated';
//echo '<pre>';print_r($SITE);die;
echo $post_array['exit_type'] = 'Employee Initiated';
echo $post_array[$id] = $USER->id;
echo $post_array['custom-105965'];
echo $post_array['manager_comments'];
echo $post_array['accept'];
echo $post_array['agreed_last_date'];
$data['success_message'] = $this->exit_common->update_get_resignation_to_act($post_array,$action);
if($data['success_message'] == 'Record '.$action.' successfully'){
$data['row'] = new stdClass();
$data['row']->id = $this->uri->segment(3);
$data['row']->status = 1;
}
}
$this->data['maincontent'] = $this->load->view('maincontents/view_resignation_action', $data,true);
echo "Resignation withdrawn successfully!";
$this->load->view('layout', $this->data);
}
I am echoing the results got from a form to check if i am receiving the sent form elements and i have received everything properly. i.e i am recieving 67 for $post_array[$id] Yes for $post_array['custom-105965'] asd for $post_array['manager_comments'] Accept for $post_array['accept'] and 01-01-1970 as $post_array['agreed_last_date'] after the echo.
My Model code is:
exit_common.php
function update_get_resignation_to_act($post_array,$action){
$this->load->database();
$this->db->where('userids', $post_array['id']);
$dbdata['discussion'] = $post_array['custom-105965'];
$dbdata['manager_comments'] = $post_array['manager_comments'];
$dbdata['last_status'] = $post_array['accept'];
$dbdata['agreed_date'] = $post_array['agreed_last_date'];
$this->db->update('pr_resignation_requests', $dbdata);
return;
}
I think something is wrong with the model update function. But not able to figure out what is wrong as a similar function is working for updating a single column in db. Am i missing something? Its a mysql db.
My View Code is:
view_resignation_action.php
<style>
label{font-weight:bold;}
.hbox .col {
display: table-cell;
float: none;
height: 100%;
vertical-align: top;
width:100%;
}
</style>
<div class="new">
<section class="content-header">
<h1>
Resignation Action
</h1>
<ol class="breadcrumb" >
<li><i class="fa fa-home"></i> Home</li>
<li>People Connect</li>
<li>Exit Tracker</li>
<li class="active">Exit Details</li>
</ol>
</section>
<input type="hidden" id="page_name" value="requests">
<div class="container-fluid">
<div class="row">
<!-- Thought Day-->
<div class="panel wrapper clearfix m-b-none">
<!-- Horizontal Form -->
<div class="box-header with-border">
</div><!-- /.box-header -->
<!-- form start -->
<?php if($error_message!=''){?>
<div class="row-fluid return-message success-message <?php echo $msg_class; ?>"><?php echo $error_message;?></div>
<?php } else { ?>
<?php echo form_open('exits/update_act_on_resignation/',array('name'=>'addostcstevent','id'=>'addostcstevent','method'=>'post','autocomplete'=>'on','class'=>'form-horizontal'))?>
<?php echo form_hidden(array('id'=>$USER->id,'action'=>$action));?>
<?php foreach($rows as $row){ ?>
<div class="panel-body">
<div class="control-group form-group">
<div class="col-md-6">
<div class="controls">
<div class="col-md-5">
<label class="control-label" style="text-align:left">Name of the employee </label>
<div class="controls"><?php echo $row->firstname; ?>
</div>
</div>
<div class="col-md-5">
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label" style="text-align:left">Date of request </label><div class="controls">
<?php echo $row->resignations_date; ?>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="control-group form-group">
<div class="col-md-6 ">
<label class="control-label" style="text-align:left">Requested Last Working Date</label>
<div class="controls">
<div class="col-md-10">
<?php echo $row->requested_date; ?>
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label">Reason</label>
<div class="controls">
<div class="col-md-9">
<?php echo $row->exit_type; ?>
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label">Comments from Employee</label>
<div class="controls">
<div class="col-md-9">
<?php echo $row->comments; ?>
</div>
</div>
</div>
<br><br><br><br><br><br><br>
<fieldset id="f1" class="col-md-6 pull-left"> <!-- start fieldset -->
<div class="label">
</label>
</div>
<div class="input">
</div>
</div>
</td>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" style="text-align:left">
<label class="control-label" style="text-align:left">Have you had a discussion with Employee?</label>
<table>
<td valign="top">
<input id="custom-105965_0" class="custom-105965" name="custom-105965" value="Yes" type="radio">
<label for="custom-105965_0">Yes
<br>
</label>
</td>
<td valign="top">
<input id="custom-105965_1" class="custom-105965" name="custom-105965" value="No" type="radio">
<label for="custom-105965_1">No
</label>
</td>
</table>
<td valign="top">
<div class="fieldset" id="bsd-field-custom-105967-group">
<div class="col-md-6 pull-left">
<label class="control-label">Please enter your comments</label>
<div class="controls">
<div class="col-md-12">
<textarea required class="form-control" name="manager_comments"></textarea>
<!--<input placeholder="Please enter your comments" class="" id="dateofrequest" type="text" name="todays_date" value=""/> <br><br>-->
</div>
</div>
<label class="control-label">Action</label>
<div class="controls">
<div class="col-md-9">
<?php $dd_list = array(
'Accept' => 'Accepted',
'Reject' => 'Rejected',
);
echo form_dropdown('accept', $dd_list, 'Accept');
?>
</div>
</div>
<label class="control-label">Agreed Last Working day</label>
<div class="controls">
<div class="col-md-9">
<input placeholder="Agreed Last Working day" class=" m-wrap col-md-8 form-control " id="startdt" type="text" name="agreed_last_date" value="<?php if($row->requested_date!='') echo date("d-m-Y",$row->requested_date); ?>" required/>
</div>
</div>
<br><br>
<div class="col-md-9">
</div>
</div>
</div>
<!-- If its a no -->
<div class="fieldset" id="bsd-field-custom-105867-group">
<div class="col-md-6 pull-left">
<div class="alert alert-success alert-dismissable">
<label type="button"></label>
Please have a discussion with the employee.
</div>
</div>
</div>
</td>
</table>
</td>
</tr>
</fieldset><!-- End Fiedset -->
</div>
</div>
<?php }?>
<div class="clearfix"></div>
<div class=" box-footer">
<button type="submit" class="btn btn-info pull-right" style="margin:0px 10px">submit</button>
</div>
</form>
<?php } ?>
<div class="clearfix"></div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/select2/select2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
<script>
$(".fieldset").hide();
$(document).ready(function () {
$("[id^=bsd-field-custom-1059]").hide();
$(".custom-105965").change(function () {
$("[id^=bsd-field-custom-1059]").toggle(this.value == 'Yes');
});
});
$(document).ready(function () {
$("[id^=bsd-field-custom-1059]").hide();
$(".custom-105965").change(function () {
$("[id^=bsd-field-custom-1058]").toggle(this.value == 'No');
$('.alert').show()
});
});
$(document).ready(function(){
$("#startdt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
endDate: new Date(),
autoclose: true
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddt').datepicker('setStartDate', minDate);
});
$("#enddt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
endDate: new Date()
});
$(".date-picker").datepicker();
$('.timepicker-default').timepicker();
$('#report_date').datepicker( {
format: "mm-yyyy",
viewMode: "months",
minViewMode: "months"
});
$(".select2").select2({
placeholder: "Select an option",
allowClear: true
});
$("#asset_type").change(function(){
if($(this).val() == '-1') {
$("#new_type").show();
}
else
{
$("#new_type").hide();
}
});
$("#manufacturer").change(function(){
if($(this).val() == '-1') {
$("#new_manufacturer").show();
}
else
{
$("#new_manufacturer").hide();
}
});
$("#supplier").change(function(){
if($(this).val() == '-1') {
$("#new_supplier").show();
}
else
{
$("#new_supplier").hide();
}
});
});
</script>
Mysql Table is :
Try Below Snippet
function update_get_resignation_to_act($post_array,$action)
{
$this->load->database();
$this->db->where('userids', $post_array['id']);
$dbdata = array(
"discussion" => $post_array['custom-105965'],
"manager_comments" => $post_array['manager_comments'],
"last_status" => $post_array['accept'],
"agreed_date" => $post_array['agreed_last_date']
);
$this->db->update('pr_resignation_requests', $dbdata);
/**
* if required add this code here to check
*
* echo $this->db->last_query();
*/
return;
}