I have a table of each request filed by the user with corresponding actions to it. When I click on the update button, it doesnt load the view after submitting it.
This is my html code:
<table id="dataTableRequestDrafts" class="table table-striped table-bordered data-table-drafts" style="width:100%">
<thead>
<tr>
<th style="display: none;">Request ID</th>
<th>Request Type</th>
<th>Date Requested</th>
<th>Date Last Updated</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($param_drafts as $drafts){?>
<tr>
<td class="id" style="display: none;"><?php echo $drafts['idx']?></td>
<td class="type"><?php echo $drafts['request_type']?></td>
<td><?php echo $drafts['date_requested']?></td>
<td><?php echo $drafts['date_updated']?></td>
<td class="text-warning"><?php echo $drafts['status']?></td>
<td align="center">
<form action="<?php echo base_url('dashboard/staff/request/update_request_view'); ?>" method="post">
<input type="text" name="request_id" value="<?php echo $drafts['idx']?>" style="display: none;">
<button type="button" class="btn waves-effect waves-light btn-primary view-button"><i class="fa fa-eye"></i> View</button> <button type="submit" class="btn waves-effect waves-light btn-info update-button"><i class="fa fa-edit"></i> Update</button> <button type="button" class="btn waves-effect waves-light btn-danger delete-button" data-url="<?php echo base_url('dashboard/staff/request/delete');?>"><i class="fa fa-trash-o"></i> Delete</button>
</form>
</td>
</td>
</tr>
<?php } ?>
</tbody>
</table>
This is my function in the controller:
public function update_request_view()
{
$data = new stdClass;
$data->param_menu = 'request';
$idx = $this->input->post('request_id');
$type = $this->staffrequisition_model->getRequestType($idx);
$typeLower = strtolower($string = str_replace(' ', '', $type));
$commonContents = $this->staffrequisition_model->selectItem(array('idx'=> $idx));
$uncommonContents = json_decode($commonContents->contents);
$data->param_request = array_merge((array) $commonContents, (array) $uncommonContents);
$this->load->view('dashboard/staff/update_'.$typeLower.'_view', $data);
}
The view is seen in the response but it doesnt load the view. I was gonna use ajax but it would be tedious to load the data of the request in each input in the view and I want to return the whole html page not just a div.
Can you show the response here.
sometimes the response can't handle by browser. so it can't appear
Related
I have one table and in this table, I have two button Update and Disable I want to hide those buttons
I trying like this
<table id="example1" class="table table-bordered table-striped table-sm" style=" overflow: auto; ">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php
$hide = 'OFF';
if($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis){?>
<tr>
<td><?php echo $dis->disp_ch_no;?></td>
<td><?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?></td>
<td><?php echo $dis->from_branch_name;?></td>
<td><a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a></td>
<td><a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
</tr>
<?php }?>
</table>
this is my table
How can I hide these buttons
Try this,
<?php
$thswitch = 'OFF';
if($thswitch == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
whenever you want to show just $thswitch = 'ON'; it
You have to check the if () for each row as we did in th. Like:
<table id="example1" class="table table-bordered table-striped table-sm" style="overflow: auto;">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php $hide = 'OFF';
if ($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis) { ?>
<tr>
<td> <?php echo $dis->disp_ch_no;?> </td>
<td> <?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?> </td>
<td> <?php echo $dis->from_branch_name;?> </td>
<?php if ($hide == 'ON') { ?>
<td>
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
<td>
<a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
Or by using CSS you can hide this columns as:
Create a CSS class like:
.hidethisColumn { display: none !important; }
Use it in you table as:
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Update</th>
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Delete</th>
Similarly in rows inside foreach():
<td class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
I'm using php and Angular JS and this is my code :
<table class="table table-bordered">
<thead>
<tr>
<th><Bold>Participation fille-société</Bold></th>
<th><Bold>Secteur d'activité</Bold></th>
<th><Bold>Date d'acquisition</Bold></th>
<th><Bold>Prix d'acquisition</Bold></th>
<th><Bold>Tri actualisé</Bold></th>
<th><Bold>Type d'operation</Bold></th>
<th><Bold>Participations meres</Bold></th>
<th><Bold>Action<Bold></th>
</tr>
</thead>
</tbody>
<tr >
<td><Bold><a href="consultationPFS.php?id_participationfilleS={{ps.id_participationfilleS}}">{{ps.nomParticipationFilleS}}</Bold></td>
<td><Bold>{{ps.secteurActivite}}</Bold></td>
<td><Bold>{{ps.date_aquisition}}</Bold></td>
<td><Bold>{{ps.Prix_acquisition}}</Bold></td>
<td><Bold>{{ps.tri_actualise}}</Bold></td>
<td><Bold>{{ps.tri_actualise}}</Bold></td>
<td ng-repeat="ac in DataPmers"><Bold>{{ac.nom_participation}} {{ac.pourcentage}}%</Bold></td>
<td><a type="submit" class="edit-row" href="UpdatePFS.php?id_participationfilleS={{ps.id_participationfilleS}}" title="Modifier" ><i class="fa fa-pencil"></i></a> | <a type="submit" class="delet-row" title="Supprimer" ng-click="supp(ps)"><i class="fa fa-trash"</i></button></a> | <a type="submit" class="edit-row" href="EtatPFS.php?id_participationfilleS={{ps.id_participationfilleS}}" title="Modifier" ><i class="fa fa-pencil"></i></a></td>
</tr>
</tbody>
</table><div class="box-footer clearfix">
And the result like in the picture below :
As u can see in Participations meres it give me only one data and other line of data in other column
How can I get all data of participation mere in the same column ?
Would this work for you - new row of the table for each DataPmers?
<table class="table table-bordered">
<thead>
<tr>
<th><Bold>Participation fille-société</Bold></th>
<th><Bold>Secteur d'activité</Bold></th>
<th><Bold>Date d'acquisition</Bold></th>
<th><Bold>Prix d'acquisition</Bold></th>
<th><Bold>Tri actualisé</Bold></th>
<th><Bold>Type d'operation</Bold></th>
<th><Bold>Participations meres</Bold></th>
<th><Bold>Action<Bold></th>
</tr>
</thead>
</tbody>
<tr ng-repeat="ac in DataPmers">
<td><Bold><a href="consultationPFS.php?id_participationfilleS={{ps.id_participationfilleS}}">{{ps.nomParticipationFilleS}}</Bold></td>
<td><Bold>{{ps.secteurActivite}}</Bold></td>
<td><Bold>{{ps.date_aquisition}}</Bold></td>
<td><Bold>{{ps.Prix_acquisition}}</Bold></td>
<td><Bold>{{ps.tri_actualise}}</Bold></td>
<td><Bold>{{ps.tri_actualise}}</Bold></td>
<td><Bold>{{ac.nom_participation}} {{ac.pourcentage}}%</Bold></td>
<td><a type="submit" class="edit-row" href="UpdatePFS.php?id_participationfilleS={{ps.id_participationfilleS}}" title="Modifier" ><i class="fa fa-pencil"></i></a> | <a type="submit" class="delet-row" title="Supprimer" ng-click="supp(ps)"><i class="fa fa-trash"</i></button></a> | <a type="submit" class="edit-row" href="EtatPFS.php?id_participationfilleS={{ps.id_participationfilleS}}" title="Modifier" ><i class="fa fa-pencil"></i></a></td>
</tr>
</tbody>
</table>
i have this code in index.php :
<?php require 'class.php';require_once './session.php';$conn = new db_class();$read = $conn->read();$data = [];while($fetch = $read->fetch_array()){
$data[] = $fetch;}?>
<table class = "table table-bordered table-responsive ">
<thead>
<tr>
<th>Segment</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($data as $fetch): ?>
<tr>
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id']?>">
<td class="segment" contenteditable="true"><?= $fetch['segment'] ?></td>
<td class="text-center">
<button class = "btn btn-default action-btn" data-id="<?= $fetch['id'] ?>" data-action="update">
<span class = "glyphicon glyphicon-edit"></span> Update
</button>
|
<button class = "btn btn-success action-btn" data-id="<?= $fetch['id'] ?>" type="submit" data-action="activate">
<span class = "glyphicon glyphicon-check"></span> Activate
</button>
|
<button class = "btn btn-danger action-btn" data-id="<?= $fetch['id'] ?>" data-action="deactivate">
<span class = "glyphicon glyphicon-folder-close"></span> deactivate
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
and this the function in class.php
public function read()
{
$stmt = $this->conn->prepare("SELECT id,segment FROM `segments`") or die($this->conn->error);
if ($stmt->execute()) {
$result = $stmt->get_result();
return $result;
}
}
all i want is to show if activation is disabled to show only activate button and if activation is on to show only the deactivate button,
i use 0 for deactivation and 1 for activation
First you need to hide the deactivate button use style display to hide
button. Write click event on activate button then use jquery hide/show to hide activate button & show deactivate button.
$(".activate-btn").click(function() {
$(this).hide();
$(".deactivate-btn").show();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class = "table table-bordered table-responsive ">
<thead>
<tr>
<th>Segment</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($data as $fetch): ?>
<tr>
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id']?>">
<td class="segment" contenteditable="true"><?= $fetch['segment'] ?></td>
<td class="text-center">
<button class = "btn btn-default action-btn" data-id="<?= $fetch['id'] ?>" data-action="update">
<span class = "glyphicon glyphicon-edit"></span> Update
</button>
|
<button class = "btn btn-success activate-btn action-btn" data-id="<?= $fetch['id'] ?>" type="submit" data-action="activate">
<span class = "glyphicon glyphicon-check"></span> Activate
</button>
<button style="display:none" class = "btn btn-danger deactivate-btn action-btn " data-id="<?= $fetch['id'] ?>" data-action="deactivate">
<span class = "glyphicon glyphicon-folder-close"></span> deactivate
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
From Here I am doing like I fetch data from database and display in table format still it is working fine, after I click the division_edit() function I want pass the value (id),how can do this.
<table id="dataTable" class="table table-bordered table-hover">
<thead>
<tr>
<th>S.No</th>
<th>Division</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $sql=m ysql_query( "SELECT * FROM division WHERE status !='1'"); for($i=1;$row=m ysql_fetch_assoc($sql);$i++){ ?>
<tr role="row" class="odd">
<td>
<?php echo $i;?>
</td>
<td>
<?php echo $row[ 'division'];?>
</td>
<td><a class="btn btn-success btn-xs" href="state_edit.php?id=<?php echo base64_encode($row['id']);?>" onclick="division_edit()" id="division_edit"><i class="fa fa-pencil-square-o"></i> Edit</a>
<button class="btn btn-danger btn-xs" data-href="state_delete.php?id=<?php echo base64_encode($row['id']);?>"
data-toggle="modal" data-target="#confirm-delete"><i class="fa fa-trash"></i> Delete</button>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th>S.No</th>
<th>Division</th>
<th>Action</th>
</tr>
</tfoot>
</table>
May this help you:
<table id="dataTable" class="table table-bordered table-hover">
<thead>
<tr>
<th>S.No</th>
<th>Division</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $sql=m ysql_query( "SELECT * FROM division WHERE status !='1'"); for($i=1;$row=m ysql_fetch_assoc($sql);$i++){ ?>
<tr role="row" class="odd">
<td>
<?php echo $i;?>
</td>
<td>
<?php echo $row[ 'division'];?>
</td>
<td><a class="btn btn-success btn-xs" href="state_edit.php?id=<?php echo base64_encode($row['id']);?>" onclick="division_edit(<?php echo $row['id']; ?>)" id="division_edit"><i class="fa fa-pencil-square-o"></i> Edit</a>
<button class="btn btn-danger btn-xs" data-href="state_delete.php?id=<?php echo base64_encode($row['id']);?>"
data-toggle="modal" data-target="#confirm-delete"><i class="fa fa-trash"></i> Delete</button>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th>S.No</th>
<th>Division</th>
<th>Action</th>
</tr>
</tfoot>
</table>
Try this..
<a class="btn btn-success btn-xs" href="state_edit.php?id=<?php echo base64_encode($row['id']);?>" onclick="division_edit(<?php echo $row['id'] ?>)" id="division_edit"><i class="fa fa-pencil-square-o"></i> Edit</a>
I am trying to add a delete button to my DataTables table, but I don't know how I can post the username of the selected row when Delete button is pressed.
Here is how the DataTables is printed:
<div class="panel-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Fullname</th>
<th>Class ID</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
while($listDetailsRow = mysql_fetch_array($listDetails)){
?>
<tr>
<td class="success"><?=$listDetailsRow['username']?></td>
<td class="info"><?=$listDetailsRow['email']?></td>
<td class="success"><?=$listDetailsRow['fullname']?></td>
<td class="info"><?=$listDetailsRow['class_id']?></td>
<td>
<form id='delete' action='deleteUser.php' method='post'>
<button type="submit" name="submit" class="btn btn-danger" href="deleteUser.php">
Delete
</button>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
So it is printed by php until all has been printedm then it stops...
The deleteUsers.php file is as follows:
include('../details.php');
$userDel = $_POST($listDetailsRow['username']);
echo $userDel;
// mysql_query("DELETE * FROM users WHERE username='$userDel'") or die(mysql_error());
I am just trying to get it to print the username from the row of which the delete button was pressed.
Is this possible? Not very good with JS or Ajax so all help is appreciated.
<form id='delete' action='deleteUser.php' method='post'>
<input type='hidden' name='username' value="<?=$listDetailsRow['username'];?>" > <--add this line
<button type="submit" name="submit" class="btn btn-danger" href="deleteUser.php">
Delete
</button>
</form>
php:
$userDel = $_POST['username'];
You can use an a element instead of a form within a button element. See this code:
<tbody>
<?php
while($listDetailsRow = mysql_fetch_array($listDetails)){
?>
<tr>
<td class="success"><?=$listDetailsRow['username']?></td>
<td class="info"><?=$listDetailsRow['email']?></td>
<td class="success"><?=$listDetailsRow['fullname']?></td>
<td class="info"><?=$listDetailsRow['class_id']?></td>
<td>
<!------------- New -------------->
<?php
$params = array( 'username' => $listDetailsRow['username'] );
$href = "deleteUser.php?" . http_build_query($params);
?>
<a class="btn btn-danger" href="<?php echo $href; ?>" > Delete </a>
<!------------- End New -------------->
</td>
</tr>
<?php
}
?>
</tbody>
In deleteUser.php do this:
$userDel = isset($_GET['username']) ? $_GET['username'] : null;