Preview: pinlist.php
Size: 8.92 KB
/home/jambtst2015/public_html/giraffeng.com/admin/pinlist.php
<?php include("includes/head.php"); ?>
<?php include("includes/header.php"); ?>
<?php
if($_REQUEST['delete']=="del" && $_REQUEST['delete_id']!='')
{
mysql_query("delete from pin_master where id='".$_REQUEST['delete_id']."'");
//mysql_query("delete from sat_users_history where user_id='".$_REQUEST['delete_id']."'");
$delmsg="Details deleted successfully";
header('location:pinlist.php?success=2');
exit();
}
?>
<script type="text/javascript" language="javascript">
function open_src()
{
if(document.getElementById("div_src").style.display=='none')
{
//document.getElementById("div_src").style.display='block';
$("#div_src").show("slow");
}
else
{
//document.getElementById("div_src").style.display='none';
$("#div_src").hide("slow");
}
}
$(document).ready(function(){
setTimeout(function(){
$(".mydiv").fadeOut("slow", function () {
$(".mydiv").remove("slow");
});
}, 4000);
});
</script>
<?php
if (isset($_POST['submit']) && $_FILES['filename']['name']!="") {
//$deleterecords = "TRUNCATE TABLE pin_master"; //empty the table of its current records
//mysql_query($deleterecords);
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
// echo "<h1>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." . "</h1>";
// echo "<h2>Displaying contents:</h2>";
// readfile($_FILES['filename']['tmp_name']);
}
//Import uploaded file to Database
$handle = fopen($_FILES['filename']['tmp_name'], "r");
GLOBAL $i;
$i=0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$i++;
if($i!=1)
{
$import="INSERT into pin_master(user_scratch_id,user_scratch_password,source,pin_type,used_status) values('$data[0]','$data[1]','$data[2]','$data[3]','Not Use')";
mysql_query($import) or die(mysql_error());
}
}
fclose($handle);
header('location:pinlist.php?msg=Data Imported');
exit();
}else {
?>
<div class="upload_section">
<?php
print "<h1>Upload new csv by browsing to file and clicking on Upload</h1>\n";
if($_GET['msg']!="")
{
echo $_GET['msg'];
}
print "<form enctype='multipart/form-data' action='pinlist.php' method='post'>";
print "<h2>File name to import:</h2>\n";
print "<input size='50' type='file' name='filename'>\n";
print "<input type='submit' name='submit' value='Upload'></form>";
}
?>
</div>
<div class="container_bottom_section">
<?php if($delmsg!=''){ ?>
<p class="mydiv" style="color:#F00; float:left; font-family:Verdana, Geneva, sans-serif; font-size:13px; text-align:left;"><?php echo $delmsg; ?></p>
<?php } ?>
<?php if($_REQUEST['success']=='2'){ ?>
<p class="mydiv" style="color:#090; float:left; font-family:Verdana, Geneva, sans-serif; font-size:13px; text-align:left;">Details Deleted Successfully</p>
<?php } ?>
<!--<a href="javascript:open_src();" class="require" style="margin-right:5px; margin-bottom:5px;"><i class="fa fa-search"></i> Search</a>-->
<?php if($level==1){ ?>
<?php /*?><a href="users_export_xls.php" class="require" style="margin-right:5px; margin-bottom:5px;">Export</a><?php */?>
<a href="userform.php" class="require org" style="margin-right:5px; margin-bottom:5px;"><i class="fa fa-plus"></i> Add User</a>
<?php } ?>
<div class="clear"></div>
<?php if(empty($_REQUEST['submit2'])){$_REQUEST['submit2']='';} ?>
<div class="search-box" style="padding:5px; <?php if($_REQUEST['submit2']=='') { ?>display:none;<?php } ?> border:1px solid #C4C4C4; margin-bottom:10px;" id="div_src">
<div class="require_add">
<h3 style="font-family:Arial, Helvetica, sans-serif; font-size:18px; float:left; color:#2597C9; padding-bottom:5px;"><i class="fa fa-search"></i> Search By</h3>
<div class="clear"></div>
</div>
<form name="myfrm" action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_search">
<tr>
<td colspan="8" height="10"></td>
</tr>
<tr>
<td width="10%" height="25" valign="top" class="require_table_search">Pin Type:</td>
<td colspan="4" align="left" valign="top">
<input type="text" name="pin_type" class="textfield require_field" value="<?php echo $_REQUEST['pin_type']; ?>" />
</td>
<td width="3%"> </td>
</tr>
<tr>
<td colspan="12">
<!--<span style="float:right;margin: 0px 22px 0px 0px;">
<input name="submit2" type="submit" value="Search" class="require sm" style="margin-top:0px !important;" />
<a href="pintype.php" style="text-decoration:none;" class="require org"> Show All
</a>
</span>-->
</td>
</tr>
</table>
</form>
</div>
<table width="1100" border="1" cellspacing="0" cellpadding="0" bordercolor="#616161" style="border-collapse:collapse;" class="list-table">
<tr>
<td width="170" class="head_text">ID</td>
<td width="101" class="head_text">Scratch Id</td>
<td width="84" class="head_text">Password</td>
<td class="head_text">Source</td>
<td width="161" class="head_text">Status</td>
<td width="62" class="head_text text-center">Action</td>
</tr>
<?php
if(empty($_REQUEST['order']))
{
$_REQUEST['order']='';
}
$qry_contact = "select * from pin_master";
if($_REQUEST['pin_type']!='')
{
$qry_contact .= " where pin_master like '%".trim($_REQUEST['pin_type']," ")."%'";
}
$qry_contact .= " order by id ".$oredr; //sorting by id //
$_SESSION['sqlUser']='';
$sel_events=mysql_query($qry_contact);
/////////////////////////////////////Start pagination/////////////////////////////////////////////////
if(empty($_REQUEST['page'])) { $_REQUEST['page']=''; }
$page=$_REQUEST['page'];
if($page=="")
{
$page = 1;
}
if($_REQUEST['submit2']!='' && $page!=1)
{
$page = $page;
}
$max_results = 30;
$prev = ($page - 1);
$next = ($page + 1);
$from = (($page * $max_results) - $max_results);
$total_results = mysql_num_rows($sel_events);
$total_pages = ceil($total_results / $max_results);
$pagination = '';
if($page > 1)
{
$pagination .= " <a href=\"pinlist.php?page=$prev\"more_link_pagination_prev\">Previous</a>";
$pagination.=" ";
}
for($i = 1; $i <=$total_pages; $i++)
{
if(($page) == $i)
{
$pagination .= $i;
$pagination.=' ';
}
else
{
$pagination .= " <a href=\"pinlist.php?page=$i\"more_link_pagination\"> $i </a>";
$pagination.=' ';
}
}
if($page < $total_pages)
{
$pagination .= "<a href=\"pinlist.php?page=$next\"more_link_pagination_prev\"> Next </a>";
$pagination.=" ";
}
$qry_contact.=" limit $from,$max_results";
$qry_contact; //Limit print//
$result=mysql_query($qry_contact);
//print_r($qry_contact); //Display Result//
////////////////////////////////End pagination////////////////////////////////////
if(mysql_num_rows($result)>0)
{
$inc=1;
while($row_contact_details=mysql_fetch_array($result))
{
$id = $row_contact_details['id'];
$user_scratch_id = $row_contact_details['user_scratch_id'];
$user_scratch_password = $row_contact_details['user_scratch_password'];
$source = $row_contact_details['source'];
$used_status= $row_contact_details['used_status'];
$status = $row_contact_details['status'];
/////////////////////////////////////////////////////
?>
<tr>
<td class="head_text2">
<?php echo $id; ?>
</td>
<td class="head_text2">
<?php echo $user_scratch_id; ?>
</td>
<td class="head_text2"><?php echo $user_scratch_password; ?></td>
<td class="head_text2"><?php echo $source; ?></td>
<td class="head_text2"><?php echo $used_status; ?></td>
<td class="head_text2 text-center">
<!--<a href="pin_edit.php?id=<?php echo $row_contact_details['id'];?>"><img src="images/edit.png" alt="Edit" title="Edit" userclass="Edit" /></a>-->
<?php
if($row_contact_details['used_status']!="Use")
{
?>
<a href="pinlist.php?delete=del&delete_id=<?php echo $row_contact_details['id'];?>" onclick="return confirm('Are you sure you want to delete this?');" style="text-decoration:none;"><img src="images/delete.png" alt="Delete" title="Delete" /></a>
<?php
}
else
{
echo "<font color='red'>currently used</font>";
}
?>
</td>
</tr>
<?php } ?>
<tr>
<td colspan="11" class="tbl-footer pagination-nw" style="background-color:;"><?php echo $pagination; ?></td>
</tr>
<?php } else {?>
<tr>
<td colspan="11" class="head_text" style="background-color:#B2CEFC;">No data found</td>
</tr>
<?php } ?>
</table>
<div class="clear"></div>
</div>
<?php include("includes/footer.php"); ?>
Directory Contents
Dirs: 17 × Files: 180