<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script>
function newindow4(call_status,prospector_id)
{
var as=call_status.split("-");
if((as[1]!='Callback')&&(as[1]!='Scheduled for Demo')&&(as[1]!='No answer')&&(as[1]!='Familiar with Royal'))
{
get_rejected(as[0]);
   }
else
{   
	if(as[1]=='Callback')
	{
	var url="telemarketing/new_calls/call_again_demo.php";
	url=url+"?prospector_id="+as[0]+"&status="+as[1];
	url=url+"&sid="+Math.random();
var googlewin=dhtmlwindow.open("ajaxbox", "ajax", url,"","width=750px,height=422px,left=100,top=900,resize=1,scrolling=1,center=1", "recal")
	}
	if(as[1]=='Scheduled for Demo')
	{
	var url="telemarketing/new_calls/scheduled_demo.php";
	url=url+"?prospector_id="+as[0]+"&status="+as[1];
	url=url+"&sid="+Math.random();
var googlewin=dhtmlwindow.open("ajaxbox", "ajax", url,"","width=740px,height=450px,left=100,top=900,resize=1,scrolling=1,center=1", "recal")
	}
	if((as[1]=='No answer'))
	{
	get_new_no_answer_status(as[0]);
	}
   	if(as[1]=='Familiar with Royal')
	{
	fix_familiar_status_newcalls_form(as[0]);
	}
 }
}

//***************************************************************************************************************************************//


function lead_view(url,type)
{
	//alert();
var heading='';
//Define arbitrary function to run desired DHTML Window widget codes
var googlewin=dhtmlwindow.open("ajaxbox", "ajax", url,"","width=1200px,height=600px,left=100,top=900,resize=1,scrolling=1,center=1", "recal")
}
//**************************************referal lead_view**********************************************************//
  var table = $('table');
    
    $('#facility_header, #city_header')
        .wrapInner('<span title="sort this column"/>')
        .each(function(){
            
            var th = $(this),
                thIndex = th.index(),
                inverse = false;
            
            th.click(function(){
                
                table.find('td').filter(function(){
                    
                    return $(this).index() === thIndex;
                    
                }).sortElements(function(a, b){
                    
                    return $.text([a]) > $.text([b]) ?
                        inverse ? -1 : 1
                        : inverse ? 1 : -1;
                    
                }, function(){
                    
                    // parentNode is the element we want to move
                    return this.parentNode; 
                    
                });
                
                inverse = !inverse;
                    
            });
                
        });
​
</script>

</head>
<body>
<div id="table-content">
<?php 
/***************************** PREVIOUS NEXT CODING ****************************************/
/*$show=10;
$num_links =9;
$from = $_GET['from'];
if (empty($from))
{
$from = "0";
 } 
else 
{
$html_query=$html_query. "&from=$from";
}
$sql="select * from new_lead_approval where (telemarketer_status='No answer' or telemarketer_status='' or telemarketer_status='No Time') and source_type!='Referal' and approval_status!='Reject' and approval_status!='Refer to manager'  order by prospector_id desc ";
$html_query ="main_fram.php?file=new_calls_form";
$result=mysql_query($sql);
$num_results=mysql_num_rows($result);
if ($num_results == 0) 
{
$confirmation = "No Product Details!";
} 
elseif ($num_results == 1) 
{
$confirmation = "Found 1 Product Details.";
} 
else 
{
$confirmation = "Found $num_results Product Details.";
} 

$sortby=$_GET[sort_by];

if(($sort_by==''))
{
$sort_bys="prospector_id desc";
}
if(($sort_by==$sortby." desc"))
{
$sort_bys=$sortby." asc";
}
if(($sort_by=='prospector_id')||($sort_by==$sortby." asc"))
{
$sort_bys=$sortby." desc";
}*/
/********************************************************************************************************************/
?>
<form id="new_call_form" name="new_call_form" action="">
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table"  >
      	<tr>
      	  <th colspan="12" align="center" valign="middle"><table width="100%" border="0" id="">
      <tr>
        <th width="5%" align="left" class="table-header-repeat line-left minwidth-1" id="facility_header">
        <?php //if (($_GET[sort]=='')||($_GET[sort]=='id_desc'))		{?>
<!--        <a href="main_fram.php?file=<?php //echo $_GET['file'];?>&sort=id_asc">Id</a>
       <?php // }else if ($_GET[sort]=='id_asc'){?>
        <a href="main_fram.php?file=<?php echo $_GET['file'];?>&sort=id_desc">Id</a><?php //}?>--> 
        <a href="">Id</a>
        </th>        
        <th colspan="2" align="left" class="table-header-repeat line-left minwidth-1" id="city_header"><a href="">Prospect Name</a> </th>
        <th width="14%" align="left" class="table-header-repeat line-left minwidth-1"><a href="">Source Type</a></th>
        <th width="14%" align="left" class="table-header-repeat line-left minwidth-1">
        <?php if (($_GET[sort]=='')||($_GET[sort]=='sales_name_desc'))
		{?>
        <a href="main_fram.php?file=<?php echo $_GET['file'];?>&sort=sales_name_asc">Sales name</a>
        <?php }else if ($_GET[sort]=='sales_name_asc'){?><a href="main_fram.php?file=<?php echo $_GET['file'];?>&sort=sales_name_desc">Sales name</a><?php }?>
        </th>
        <th width="10%" align="left" class="table-header-repeat line-left minwidth-1">
        <a href="">Phone No</a></th>
        <th width="9%" align="left" class="table-header-repeat line-left minwidth-1"><a href="">Last status</a></th>
        <th width="19%" align="left" class="table-header-repeat line-left minwidth-1"><a href="">Call   Status</a></th>
        <th width="14%" align="left" class="table-header-repeat line-left minwidth-1"><a href="">Action</a></th>
      </tr>
      <tr>
	  <?php include("db.php");  
	  function source_type($prospector_id)
	  {
	    	$sql2="select * from prospector_details  where prospector_id='$prospector_id'";
			$rs2=mysql_query($sql2);
			$rscount2=mysql_num_rows($rs2);
			if($rscount2!=0)
			{
			while($rsdata2=mysql_fetch_object($rs2))
			{
	    	$source_type=$rsdata2->source_type;
     		}
			return $source_type;
			}
		}
//******************************************************sales personget*****************************************************************//
 function get_sales_name($prospector_id)
	  {
	    	$sql2="select * from prospector_to_sales_allocation where prospector_id='$prospector_id'";
			$rs2=mysql_query($sql2);
			$rscount2=mysql_num_rows($rs2);
			$sno=0;
			if($rscount2!=0)
			{
			while($rsdata2=mysql_fetch_object($rs2))
			{
	    	   $sales_person_id=$rsdata2->sales_person_id;
			   $sql3="select * from user_details where 	user_id='$sales_person_id'";
			   $rs3=mysql_query($sql3);
			   while($rsdata3=mysql_fetch_object($rs3))
			   {
			      $user_name =$rsdata3->user_name ;
			   }
     		}
			return $user_name;
			}
		}
	
//**************************************************survey_location*************************************************************//
 function get_survey_location($prospector_id)	
	  {
	    	$sql2="select * from prospector_details where prospector_id='$prospector_id'";
			$rs2=mysql_query($sql2);
			$rscount2=mysql_num_rows($rs2);
		   while($rsdata2=mysql_fetch_object($rs2))
			{
	    	   $survey_location=$rsdata2->survey_location;
			}
			return $survey_location;
			
		}
//********************************************SALES PERSON NOTES***********************************************************//
function get_sales_person_notes($prospector_id)
{
$sql="select * from new_lead_approval  where prospector_id ='$prospector_id'";
 $rs=mysql_query($sql);
  $rscount=mysql_num_rows($rs);
  while($rsdata=mysql_fetch_object($rs))

  {
   	   $notes_to_telemarketer=$rsdata->notes_to_telemarketer;
  }
  return $notes_to_telemarketer;
  }	
//********************************************************************************************************************************************************************//
  $sql1="select * from new_lead_approval where (telemarketer_status='No answer' or telemarketer_status='' or telemarketer_status='No Time') and source_type!='Referal'  and approval_status!='Reject' and approval_status!='Refer to manager' ";

	/*if (($_GET[sort]=='')||($_GET[sort]==id_asc))
	{ $sql1.="order by prospector_id asc";}
	else if($_GET[sort]==id_desc)
	{ $sql1.="order by prospector_id desc";}/*
	
/*	if (($_GET[sort]=='')||($_GET[sort]==sales_name_asc))
	{ $sql1.="order by prospector_id asc";}
	else if($_GET[sort]==sales_name_desc)
	{ $sql1.="order by prospector_id desc";}
*/
	   
  $rs1=mysql_query($sql1);
  $rscount1=mysql_num_rows($rs1);
  $sno=0;
  if($rscount1!=0)
  {
  while($rsdata=mysql_fetch_object($rs1))
  {
   $prospector_id=$rsdata->prospector_id;
   $lead_first_name=$rsdata->lead_first_name;
   $lead_last_name1=$rsdata->lead_last_name1;
   $lead_last_name2=$rsdata->lead_last_name2;
   $get_source_type=source_type($prospector_id);
   $sales_name=get_sales_name($prospector_id);
   $telemarketer_status=$rsdata->telemarketer_status;
   $approval_status=$rsdata->approval_status;
   $phone_no=$rsdata->phone_no;
   $approval_status=$rsdata->approval_status;
   $approve_date=$rsdata->createdate;
   $sales_person_notes=get_sales_person_notes($prospector_id);
   if((($get_source_type=="Prospector")||($get_source_type=="SalesPerson")||($get_source_type=="Referal"))&&($approval_status!="")){
   $form_link="onclick=javascript:lead_view('telemarketing/new_calls/new_calls_lead_view.php?prospector_id=$prospector_id&get_source_type=$get_source_type')";
   }
   $leadname=$lead_first_name."&nbsp;".$lead_last_name1."&nbsp;".$lead_last_name2;
   
   	  $fyear=substr($approve_date,0,4);
	  $fmonth=substr($approve_date,5,2);
	  $fday=substr($approve_date,8,2);
	  $approve_date = $fmonth."-".$fday."-".$fyear;
      $sno=$sno+1;
			  $row=$row+1;
			  $row1=$row%2;
			  if($row1==0)
			  {
			  $bgcolor="#ececec";
			  }
			  else
			  {
			  $bgcolor="#ffffff";
			   } ?>
        <td height="46" bgcolor="<?php echo $bgcolor;?>"><?php echo $prospector_id; ?>
<input type="hidden" name="prospector_id" id="prospector_id" class="inp-form" value="<?php echo $prospector_id;?>"  maxlength="25"/>        </td>
        <td width="3%" bgcolor="<?php echo $bgcolor;?>"><?php if($sales_person_notes!=''){ ?>
          <p><img src="images/icon_acc_personal.gif"  title="Sales person notes."/></p>
        <?php }?></td>
        <td width="12%" bgcolor="<?php echo $bgcolor;?>"><a href="#" onclick="lead_view('telemarketing/new_calls/new_calls_lead_view.php?prospector_id=<?php echo $prospector_id?>&get_source_type=<?php echo $get_source_type?>')"><span style="color:#009900; text-decoration:underline; font-weight:bold;"><?php echo $lead_first_name."&nbsp;".$lead_last_name1."&nbsp;".$lead_last_name2; ?></span></a></td>
        <td bgcolor="<?php echo $bgcolor;?>">
		<?php  if($get_source_type=='Prospector'){$survey_location=get_survey_location($prospector_id);echo $survey_location.'</br>'.'(Prospector)';}else{echo $get_source_type;} ?>        </td>
        <td bgcolor="<?php echo $bgcolor;?>"><?php echo $sales_name;?>
      <input type="hidden" name="sales_person_name" disabled="true" id="sales_person_name" class="inp-form" value="<?php echo "Sales person";?>"  maxlength="25"/></td>
        <td bgcolor="<?php echo $bgcolor;?>"><?php echo $phone_no;?></td>
        <td bgcolor="<?php echo $bgcolor;?>"><?php if($telemarketer_status!=''){echo $telemarketer_status;}else{echo "New call";}?></td>
        <td align="center" bgcolor="<?php echo $bgcolor;?>">
         <div style="visibility:hidden" id="<?php echo $prospector_id; ?>">
         <div class="inp-form">
         <select name="call_status"  style="display:none;" id="call_status" >
            <option value="">-Select Current Demo Status--</option>
          </select>
         <select name="call_status" id="call_status"   style="width:188px; background-color:#ffffff; color:#393939; border:none; display:inline"  onchange="newindow4(this.value,prospector_id.value)">
          <option value="">--Select Call Status--</option>
          <option value="<?php echo $prospector_id.'-';?>Callback">Call Again</option>
          <option value="<?php echo $prospector_id.'-';?>No answer">No Answer</option>
          <option value="<?php echo $prospector_id.'-';?>Number out of service"> Number out of service</option>
          <option value="<?php echo $prospector_id.'-';?>Not Interested">Not Interested</option>
          <option value="<?php echo $prospector_id.'-';?>No Time">No Time</option>
          <option value="<?php echo $prospector_id.'-';?>Familiar with Royal">Familiar with Royal</option>
          <option value="<?php echo $prospector_id.'-';?>Already Clients">Already Clients</option>
          <option value="<?php echo $prospector_id.'-';?>Person doesn't live there">Person doesn't live there</option>
          <option value="<?php echo $prospector_id.'-';?>Number doesnt exists">Number doesnt exists</option>
          <option value="<?php echo $prospector_id.'-';?>Scheduled for Demo">Scheduled for Demo</option>
        </select>
        </div>
        </div></td>
        <td align="left" valign="middle" bgcolor="<?php echo $bgcolor;?>">
         <?php if($approval_status!=""){?>
        <input type="button" name="action" id="action" value="Call" class="call_button-primary" onclick="add_call_log('<?php echo $prospector_id;?>','<?php echo $lead_first_name;?>','<?php echo $lead_last_name1;?>','<?php echo $lead_last_name2;?>','<?php echo $get_source_type;?>'),validate_call(call_status.value)"/>
        <?php } else{?>
        
                <input type="button" name="action" id="action" value="Call" class="call_button-primary" onclick="get_all_details();"/>

        <?php }?>        </td>
      </tr>
     
      
      <?php }} ?>
               </table></th>
   	  </tr>
       <tr>
        <td colspan="10" align="right" bgcolor="">
		<?php /* if ($num_results > $show) 
			  {
			  $show;
			  include("include/footer_links.php");
			  }*/?></td>
      </tr> 
      	<tr>
      	  <th colspan="4" align="center" valign="middle">&nbsp;</th>
      	  <th colspan="4" align="left" valign="middle"><input type="hidden" name="call_values" id="call_values" value="" /></th>
          <th colspan="4" align="left">&nbsp;</th>
   	  </tr>
      	<tr>
      	  <th colspan="4" align="center" valign="middle"><div id="call_status_div"></div><div id="call_status_add_div"></div></th>
	      <th colspan="4" align="left" valign="middle">&nbsp;</th>
   	  </tr>
    </table>
    <!--  end product-table................................... -->
  </form>	
</div>

</body>

</html>
