quicksearch.blade.php 9.88 KB
<style>
	.table_hrm_heading_green{
		padding: 7px 9px;
		text-align: center;
		background-color: #D5FFF5;
		border: 5px solid #fff;
		font-weight: 600;
	}
	.table_hrm_heading_green:first-child{
		border-left: 0px;
	}
	.table_hrm_cells{
		padding: 5px 7px;
		color:#434a54;
	}
	.table_hrm_cells a{
		color:#434a54;
	}
	.table_hrm_celltext{
		border: 1px solid #ccd0d9;
		border-color: #ccd0d9 !important;
		border-radius: 3px !important;
		padding: 3px 7px;
		text-align: center;
	}
</style>
<?php
$searchstr=array();
$users=array();

$searchstr1=trim(Input::get('maintextsearch_1_txt'));
$searchkey1=trim(Input::get('maintextsearch_1_span'));

$searchstr2=trim(Input::get('maintextsearch_2_txt'));
$searchkey2=trim(Input::get('maintextsearch_2_span'));

$searchstr3=trim(Input::get('maintextsearch_3_txt'));
$searchkey3=trim(Input::get('maintextsearch_3_span'));

$searchstr4=trim(Input::get('maintextsearch_4_txt'));
$searchkey4=trim(Input::get('maintextsearch_4_span'));


$uids=array();

if($searchstr1!="")
{
    $key='';$tusers=array();
    if($searchkey1=="ID")$key='id';
    if($searchkey1=="FirstName")$key='firstname';
    if($searchkey1=="LastName")$key='lastname';
    if($searchkey1=="Client")$key='client';
    if($searchkey1=="Mobile")$key='mobile';
    if($searchkey1=="Email")$key='emailid';
    if($searchkey1=="Passport")$key='passportno';
    if($searchkey1=="IBAN")$key='ibannumber';
    if($searchkey1=="Status")$key='currentstatus';
    if($searchkey1=="PersonalID")$key='laborcardpersonalid';
    if($searchkey1=="InternalID")$key='clientinternalid';
    if($searchkey1=="ClientCode")$key='clientcode';
    
    if($key!='')
    {
        if($key=='id')$uids=array(intval($searchstr1));
        else 
        {
            $matchkeys=array();
            $prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
            
            $res=$wakka->LoadAll("select distinct $key from records $prematchstr");
            foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr1))$matchkeys[]="'".$tres[$key]."'";
            
            $prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
            if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
            $uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
        }
    }
}
if($searchstr2!="")
{
    $key='';$tusers=array();
    if($searchkey2=="ID")$key='id';
    if($searchkey2=="FirstName")$key='firstname';
    if($searchkey2=="LastName")$key='lastname';
    if($searchkey2=="Client")$key='client';
    if($searchkey2=="Mobile")$key='mobile';
    if($searchkey2=="Email")$key='emailid';
    if($searchkey2=="Passport")$key='passportno';
    if($searchkey2=="IBAN")$key='ibannumber';
    if($searchkey2=="Status")$key='currentstatus';
    if($searchkey2=="PersonalID")$key='laborcardpersonalid';
    if($searchkey2=="InternalID")$key='clientinternalid';
    if($searchkey2=="ClientCode")$key='clientcode';
    
    if($key!='')
    {
        if($key=='id')$uids=array(intval($searchstr2));
        else 
        {
            $matchkeys=array();
            $prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
            
            $res=$wakka->LoadAll("select distinct $key from records $prematchstr");
            foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr2))$matchkeys[]="'".$tres[$key]."'";
            
            $prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
            if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
            $uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
        }
    }
}
if($searchstr3!="")
{
    $key='';$tusers=array();
    if($searchkey3=="ID")$key='id';
    if($searchkey3=="FirstName")$key='firstname';
    if($searchkey3=="LastName")$key='lastname';
    if($searchkey3=="Client")$key='client';
    if($searchkey3=="Mobile")$key='mobile';
    if($searchkey3=="Email")$key='emailid';
    if($searchkey3=="Passport")$key='passportno';
    if($searchkey3=="IBAN")$key='ibannumber';
    if($searchkey3=="Status")$key='currentstatus';
    if($searchkey3=="PersonalID")$key='laborcardpersonalid';
    if($searchkey3=="InternalID")$key='clientinternalid';
    if($searchkey3=="ClientCode")$key='clientcode';
    
    if($key!='')
    {
        if($key=='id')$uids=array(intval($searchstr3));
        else 
        {
            $matchkeys=array();
            $prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
            
            $res=$wakka->LoadAll("select distinct $key from records $prematchstr");
            foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr3))$matchkeys[]="'".$tres[$key]."'";
            
            $prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
            if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
            $uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
        }
    }
}
if($searchstr4!="")
{
    $key='';$tusers=array();
    if($searchkey4=="ID")$key='id';
    if($searchkey4=="FirstName")$key='firstname';
    if($searchkey4=="LastName")$key='lastname';
    if($searchkey4=="Client")$key='client';
    if($searchkey4=="Mobile")$key='mobile';
    if($searchkey4=="Email")$key='emailid';
    if($searchkey4=="Passport")$key='passportno';
    if($searchkey4=="IBAN")$key='ibannumber';
    if($searchkey4=="Status")$key='currentstatus';
    if($searchkey4=="PersonalID")$key='laborcardpersonalid';
    if($searchkey4=="InternalID")$key='clientinternalid';
    if($searchkey4=="ClientCode")$key='clientcode';
    
    if($key!='')
    {
        if($key=='id')$uids=array(intval($searchstr4));
        else 
        {
            $matchkeys=array();
            $prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
            
            $res=$wakka->LoadAll("select distinct $key from records $prematchstr");
            foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr4))$matchkeys[]="'".$tres[$key]."'";
            
            $prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
            if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
            $uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
        }
    }
}
                        $roclientstr=array();
			if($wakka->GetBBBUserData("readotherdata")=="No")
			{
				$oclientlst=$wakka->clientsReadAccess();
				foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
			}
			if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";

if(!empty($uids))$users=$wakka->getPersons("id in (".implode(",",$uids).") $roclientstr limit 200");

if(!empty($users))
{
	if(Auth::check()&&Auth::user()->moduleACL("Dialer",true,false,false))
	{
		$extracalldataH="<td class='table_hrm_heading_green'>CallStatus</td>";
	}

  $searchresultH="<table class='footable table' cellpadding='0' cellspacing='0' style='border-bottom:black 2px solid;margin-bottom:20px'><thead><tr>
		<td class='table_hrm_heading_green'>Status</td>
		<td class='table_hrm_heading_green'></td>
		<td class='table_hrm_heading_green'></td>
		$extracalldataH
		<td class='table_hrm_heading_green'>Name</td>
		<td class='table_hrm_heading_green'>Values<span style='float:right'><a href=# onclick='recordClose();'>Close</a></span></td>
  </tr></thead>";

  $searchresult="";
  foreach($users as $user)
  {
    $ppldata=unserialize($user['peopledata']);
    
		$extracalldata='';
		if(Auth::check()&&Auth::user()->moduleACL("Dialer",true,false,false))
		{
			$lastuserdatastr="";
			if(isset($ppldata["dialer_userdata"]))
			{
				if(!empty($ppldata["dialer_userdata"]))foreach($ppldata["dialer_userdata"] as $key=>$val)
				{
					$lastuserdatastr.="$key : $val<br>";
				}
			}
			if($user['dialer_lastcall']=='0000-00-00 00:00:00')$user['dialer_lastcall']='';
			$extracalldata="<td><span><i class='fa fa-file tooltip' title='$lastuserdatastr' style='opacity:1;position:relative'></i>&nbsp;&nbsp;</span><span title='$user[dialer_substatus] : $user[dialer_remarks]'>$user[dialer_lastcall] : $user[dialer_status]</span></td>";
		}
    
    $searchresult.="<tr class='recSearchResTbl' style='cursor:pointer' onclick='recTRClick(this);'>
    <td onclick='showRecruit(\"$user[id]\");return false;'>$user[currentstatus]</td>
    <td onclick='showRecruit(\"$user[id]\");return false;'>$user[legalstatus]</td>
    <td onclick='showRecruit(\"$user[id]\");return false;'>$user[status]</td>
    $extracalldata
    <td onclick='showRecruit(\"$user[id]\");return false;'>".$ppldata['firstname']." ".$ppldata['lastname']."</td>
    <td>ID:$user[id], [".$ppldata['nationality'].":".$ppldata['passportno']."] Mob:".$ppldata['mobile'].", Client:".$ppldata['client'].", ClientCode ".$user['clientcode']."<span style='float:right'><a href=# onclick='window.open(\"home#h-$user[id]\");'><i class='fa fa-mail-forward'></i></a></span></td>
    </tr>";
  }

  $searchresultF='</table><div style="clear:both"></div><div id=divworking></div><div style="clear:both"></div>';

  if($searchresult!="")$searchresult=$searchresultH.$searchresult.$searchresultF;
	else $searchresult="<legend class='task_legend'>No Records Found!</legend>";

  echo "<legend class='task_legend'>Search Results</legend>";
  echo $searchresult;
	echo "<script>
	function recordClose()
	{
		$('#divworking').html('');
		kSetDData('C','crmid','');
	}
	function recTRClick(el)
	{
		$('.recSearchResTbl').css({'background':'#fff'});
		$(el).css({'background':'#eee'});
	}
	</script>";

}
else 
{
    echo "<legend class='task_legend'>No Records Found!</legend>";
}

?>