/admin/modules/users/credit_customer_2.php
PHP | 521 lines | 420 code | 77 blank | 24 comment | 64 complexity | 35fb32ed86be38830b205a55abe9f033 MD5 | raw file
Possible License(s): LGPL-2.1
- <?
- session_start();
- if(!isset($_SESSION['login']))
- {
- header('Location: index.php');
- exit;
- }
-
- $where = " WHERE credit_customer !=1 AND credit_customer !=0";
- ########################################### PAGING WITH PER PAGE #####################################
- $file_name = "index"; // this is file name which is used during paging , included at the bottom of the page
- $paging_table_name = "user";
- $paging_query = $where;
- $next_page_condition = "&page=credit_customer";
- include("paging/paging_query.inc.php");
-
- ############################################ END PAGING WITH PER PAGE ##############################################
-
-
- if(!isset($_REQUEST['action']))
- {
- $sql = "SELECT * FROM user WHERE credit_customer !=1 AND credit_customer !=0 ORDER BY email LIMIT $eu, $limit ";
-
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }
-
- if(isset($_REQUEST['email']) && $_REQUEST['email']!='')
- {
-
- $email = $_REQUEST['email'];
-
- $query2 = "SELECT * FROM user where email like '%$email%' order by email ";
- $rec = mysql_query($query2);
- $nume = mysql_num_rows($rec);
-
- $email = $_REQUEST['email'];
-
- $sql = "SELECT * FROM user where email like '%$email%' order by email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }
-
-
- ################################# DELETE #########################################
- if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete')
- {
- $id = $_REQUEST['id'];
- $sql = "delete from user where id='$id' ";
- $result = mysql_query($sql);
-
- if(isset($_REQUEST['email']) && $_REQUEST['email']!='')
- {
- $query2 = "SELECT * FROM user where first_name like '$email%' order by email ";
- $rec = mysql_query($query2);
- $nume = mysql_num_rows($rec);
-
- $login = $_REQUEST['email'];
-
- $sql = "SELECT * FROM user where first_name like '$email%' order by email ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }else{
- header("location: ?page=credit_customer");
- }
-
-
- }
-
- ################################# END DELETE #########################################
-
- ################################# DELETE MORE #########################################
-
- if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_more')
- {
-
- $len = count($_REQUEST['check']);
-
- for($i=0;$i<$len;$i++)
- {
- $sql = mysql_query("delete from user where id = '".$_REQUEST['check'][$i]."' ");
- }
- $sql = mysql_query("select * from user ORDER BY email LIMIT $eu, $limit ");
- $num_rows = mysql_num_rows($sql);
- if(isset($_REQUEST['after_search']) && $_REQUEST['after_search']!='')
- {
- $email = $_REQUEST['after_search'];
- $sql = "SELECT * FROM user where first_name like '$email%' order by email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }else{
-
- $sql = "SELECT * FROM user ORDER BY first_name LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }
-
- }
-
- ################################# END DELETE MORE #########################################
-
-
- ################################# SUSPEND MORE #########################################
- if(isset($_REQUEST['action']) && $_REQUEST['action']=='suspend_more')
- {
-
- $len = count($_REQUEST['check']);
-
- for($i=0;$i<$len;$i++)
- {
- $sql = "UPDATE user set status='0' where id='".$_REQUEST['check'][$i]."' ";
- $result = mysql_query($sql);
- }
-
- $sql = mysql_query("select * from user ORDER BY email LIMIT $eu, $limit ");
- $num_rows = mysql_num_rows($sql);
- if(isset($_REQUEST['after_search']) && $_REQUEST['after_search']!='')
- {
- //$login = $_REQUEST['after_search'];
- $email = $_REQUEST['after_search'];
- $sql = "SELECT * FROM user where first_name like '$email%' order by email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }else{
-
- $sql = "SELECT * FROM user ORDER BY email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }
-
- }
-
- ################################# END SUSPEND MORE #########################################
-
-
- ################################# ACTIVE MORE #########################################
-
- if(isset($_REQUEST['action']) && $_REQUEST['action']=='active_more')
- {
-
- $len = count($_REQUEST['check']);
-
- for($i=0;$i<$len;$i++)
- {
- $sql = "UPDATE user set status='1' where id='".$_REQUEST['check'][$i]."' ";
- $result = mysql_query($sql);
-
- }
- $sql = mysql_query("select * from user ORDER BY email LIMIT $eu, $limit ");
- $num_rows = mysql_num_rows($sql);
- if(isset($_REQUEST['after_search']) && $_REQUEST['after_search']!='')
- {
- //$email = $_REQUEST['after_search'];
- $email = $_REQUEST['after_search'];
- $sql = "SELECT * FROM user where first_name like '$email%' order by email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }else{
-
- $sql = "SELECT * FROM user ORDER BY email LIMIT $eu, $limit ";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- }
-
- }
-
-
- ################################# END ACTIVE MULTIPLE RECORDS #########################################
-
-
- ################################# STATUS CHANGE #########################################
-
- if(isset($_REQUEST['status']))
- {
- $id = $_REQUEST['id'];
- $status = $_REQUEST['status'];
- if($status=='1')
- {
- $sql = "UPDATE user SET status='0' where id='$id' ";
- $result = mysql_query($sql);
- }else{
- $sql = "UPDATE user SET status='1' where id='$id' ";
- $result = mysql_query($sql);
- }
- if($_REQUEST['email']!='')
- {
- $sql = "SELECT * FROM user where id='$id' ORDER BY email LIMIT $eu, $limit";
- }
- else
- {
- $sql = "SELECT * FROM user ORDER BY email LIMIT $eu, $limit";
- }
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
-
- }
-
- ################################# END STATUS CHANGE #########################################
- ?>
- <td width="100%" align="center" valign="top" bgcolor="" class="red">
- <table width="100%" border="0" align="center" cellpadding="0"
- cellspacing="0" bordercolor="#000000">
- <tr>
- <td valign="middle" height="20" align="left">
- <table width="767" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="399" height="30" class="head_ing">Credit Customers</td>
- <td width="368" align="right"> </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td bordercolor="#FFFFFF" valign="top" align="center">
- <form name="form1" method="post" action="?page=credit_customer">
- <table width="100%" border="0" cellspacing="4" cellpadding="0">
- <? if(isset($_REQUEST['message'])) {?>
- <tr align="center">
- <td colspan="7" class="red style1"><?=$_REQUEST['message'];?></td>
- </tr>
- <? } ?>
- <tr>
- <td align="center" valign="top">
- <table width="100%%" border="0" align="center" cellpadding="3"
- cellspacing="1" bgcolor="#CCCCCC">
- <tr align="center" bgcolor="#ffffff">
- <td height="25" colspan="10" align="left" bgcolor="#FFFFFF">
- <table width="100%" border="0" height="15">
-
- <tr>
- <td width="316" height="15">
- <div align="right">Search by Email</div>
- </td>
- <td width="368">
- <div align="left"><label> <input name="email" type="text"
- id="email" value="<?=$_REQUEST['email'];?>"> </label> <label>
- <input type="submit" name="Submit" value="Search"> </label> <? //include("paging/no_of_records.inc.php"); ?>
- </div>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr align="center" bgcolor="#000000">
- <!--<td width="11%" height="25" align="left" class="white" >Login Name </td>-->
- <td width="10%" class="white">Email</td>
- <td width="8%" height="25" class="white">Name</td>
- <!-- <td width="13%" class="white">Address</td> -->
- <td width="10%" class="white"><span>City</span></td>
- <!--<td width="13%" class="white">Password</td> -->
- <td width="10%" class="white">Phone</td>
- <td width="10%" class="white">Credit Customer</td>
- <td width="10%" class="white">Payment History</td>
- <td width="10%" class="white">Status</td>
- <td width="8%" class="white">Delete</td>
- <!-- <td width="9%" ><div align="center"><span class="white">Status</td> -->
- <!--<td width="9%" ><div class="white">Edit</div></td> -->
- <td width="7%" class="white">Select</td>
- </tr>
- <?
- if($result){
- while($row=mysql_fetch_array($result))
- {?>
- <tr align="center" bgcolor="#f5f5f5">
- <!--<td height="33" align="center" bgcolor="#FFFFFF"><div align="center">
- <?=ucfirst($row['login'])?>
- </td>-->
- <td align="left" bgcolor="#FFFFFF"><?=$row['email'];?>
-
- </td>
- <td align="center" bgcolor="#FFFFFF"><?=ucfirst($row['first_name'])?>
-
- </td>
- <!-- <td align="center" bgcolor="#FFFFFF"><?=$row['address'];?>
-
- </td> -->
- <td align="center" bgcolor="#FFFFFF"><?=ucfirst($row['city']);?>
-
- </td>
- <!-- <td align="center" bgcolor="#FFFFFF"><?=$row['password']?> -->
-
- </td>
- <td height="33" align="center" bgcolor="#FFFFFF"><?=ucfirst($row['telephone'])?></td>
- <td height="33" align="center" bgcolor="#FFFFFF">
- <?php
- if($row['credit_customer'] == 0){
- $display_credit_customer = "No";
- }elseif($row['credit_customer'] == 1){
- $display_credit_customer = "Assign limit";
- }else{
- $display_credit_customer = $row['credit_customer'];
- }
-
- ?>
- <a title="<?=$row['email']?>" id="<?=$row['id']?>" class="credit_customer" href="#"><?php echo $display_credit_customer; ?></a>
- </td>
- <td height="33" align="center" bgcolor="#FFFFFF">
- <?php
- if($row['credit_customer'] != 0 && $row['credit_customer'] != 1){
- echo "<a href='?page=payment&user_id=$row[id]'> View </a>";
- }
- ?>
-
-
- </td>
-
- <td align="center" bgcolor="#FFFFFF"><a
- href="?page=credit_customer&status=<?=$row['status']?>&id=<?=$row['id']?>&email=<?=$_REQUEST['email'];?>">
- <? echo ($row['status'] == 1)? "Active" : "Suspended"; ?> </a>
-
- </td>
- <td width="8%" align="center" bgcolor="#FFFFFF"><a
- href="?page=credit_customer&action=delete&id=<?=$row['id']; if(isset($email)){?>&email=<?=$email;}?>"
- onClick=" javascript: return confirm('Are you sure You want to Delete User ');"><img
- src="../images/del.gif" border="0" /></a>
-
- </td>
- <!--<td height="33" align="center" bgcolor="#FFFFFF" ><a href="user.php?status=<?=$row['status']; ?>&id=<?=$row['id']; ?>"><?=ucfirst($row['status'])?></a>
- </td> -->
- <!--<td height="33" align="left" bgcolor="#FFFFFF"><div align="center"><a href="add_new_city.php?action=edit&city_id=<?=$row['id'];?>"><img src="images/Edit.gif" width="12" height="12" border="0" /></a></td> -->
- <td width="7%" align="center" bgcolor="#FFFFFF"><input
- type="checkbox" name="check[]" id="check"
- value="<?=$row['id']?>"></td>
- </tr>
- <? }
- }else{?>
- <tr bgcolor="#FFFFFF">
- <td height="33" colspan="15" align="center" bgcolor="#ffffff"
- class="red style1">No User Exists</td>
- </tr>
- <? }?>
-
- <tr bgcolor="#FFFFFF">
- <td height="20" colspan="15" align="right" bgcolor="#ffffff">
- <div id="text_message" align="right" class="bod-text">Check all</div>
- <input type="checkbox" name="check_abc" onClick="select_all();">
- </td>
- </tr>
-
- <tr bgcolor="#000000">
- <td height="33" colspan="15" align="right">
- <div align="right"><input type="hidden" name="after_search"
- value="<?=$email;?>">
- <input type="button" name="button222"
- value="Show All" onClick="javascript:window.location='?page=credit_customer'">
- <input type="button" name="button22"
- value="Suspend" onClick="do_more('suspend_more');">
- <input type="button" name="button2"
- value="Active" onClick="do_more('active_more');">
- <input type="button" name="button"
- value="Delete" onClick="do_more('delete_more');"></div>
- </td>
- </tr>
- <!-- Paging starts here -->
- <? include("paging/paging_row.inc.php") ?>
- <!-- Paging ends starts here -->
- </table>
- </td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
- </td>
- <div class="overlay">
- <div class="confirmbox"></div>
- </div>
- <script language="JavaScript">
- function navigate(url_page)
- {
- window.location=url_page;
- /*document.form1.action=url_page;
- document.form1.submit();
- */
- }
-
- function select_all()
- {
- var doc = document.form1;
- var len = document.form1.check.length;
-
- if(doc.check_abc.checked==true)
- {
- if(len){
- for(var i=0;i<len;i++){
- doc.check[i].checked = true;
- }
- }else{
- doc.check.checked = true;
- }
- document.getElementById("text_message").innerHTML='Uncheck All';
- }
- else{
- if(len){
- for(var i=0;i<len;i++){
- doc.check[i].checked = false;
- }
- }else {
- doc.check.checked = false;
- }
- document.getElementById("text_message").innerHTML='Check All';
- }
- }
-
- function do_more(action)
- {
- //alert(action);
- var doc = document.form1;
- var len = document.form1.check.length;
- var flag = 0;
-
- if(len){
- for(var i=0;i<len;i++){
- //alert(i);
- //alert(doc.check[i].checked);
- if(doc.check[i].checked == true)
- {
- flag = 1;
- }
- }
- }
- else{
- if(doc.check.checked == true){
- flag = 1;
- }
- }
-
- // checking if any checkbox has been checked or not
- // if checked then it will call the same page or otherwise display a messagwe
- if(flag==1){
- if(action=='delete_more'){ // in the case of delete it will ask for confirmation
- if(confirm('Do you really want to delete the users')){
- document.form1.action="?page=credit_customer&action="+action;
- document.form1.submit();
- }
- }else if(action=='send_newsletter'){
- document.form1.action="send_newsletter.php?action="+action;
- document.form1.submit();
- }else{
- document.form1.action="?page=credit_customer&action="+action;
- document.form1.submit();
- }
- }
- else{
- alert('Please select atleast one checkbox');
- }
-
- }
-
-
- $(function(){
- // Show credit limit form
- $('.credit_customer').live('click',function(){
- var user_id = $(this).attr('id');
- var old_credit_value = $(this).text();
- var email = $(this).attr('title');
- if(old_credit_value == "Assign limit"){
- old_credit_value = "";
- }else if(old_credit_value == "No"){
- old_credit_value = "";
- if(!confirm("Request has not been raised to become a credit customer. Do you want to assign Credit limit to this user ?")){
- return false;
- }
- }
-
- var form_data = {'user_id':user_id,'old_credit_value':old_credit_value,'email':email};
- $.ajax({
- async: false,
- type: "POST",
- url: site_url+"/modules/users/index.php?page=ajax_actions&action=show_credit_limit_form",
- data: form_data,
- success: function(result){
- $(".overlay").show('slow');
- $(".confirmbox").html(result);
- }
- });
-
- });
-
- //Assign Credit Limit
- $('#assign_credit_limit').live('click',function(){
- var user_id = $('#user_id').val();
- var credit_limit = $('#credit_limit').val();
- var email = $('#email').val();
- var form_data = {'user_id':user_id,'credit_limit':credit_limit,'email':email};
- if(credit_limit == ""){
- alert("Please enter Credit limit");
- return false;
- }else if(isNaN(credit_limit)){
- alert("Please enter numbers only in Credit limit")
- return false;
- }
-
- $.ajax({
- async: false,
- type: "POST",
- url: site_url+"/modules/users/index.php?page=ajax_actions&action=save_credit_limit",
- data: form_data,
- success: function(result){
- var resultObj = jQuery.parseJSON(result);
- if(resultObj.status == "success"){
- alert(resultObj.message);
- if(credit_limit == 0){
- $("#"+user_id).text("No");
- }else{
- $("#"+user_id).text(credit_limit);
- }
- $('.confirmbox').html('');
- $('.overlay').hide('slow');
- }else{
- alert(resultObj.message);
- }
- }
- });
- });
-
- }); // End of main function
-
- </script>
-