<?php include("_config/dbconfig.php"); ?>
<?php include("_includes/head.php");?>
<title>Assigning</title>

<style>
    .table-bordered > thead > tr > th, .table-bordered > thead > tr > td, .table-bordered  tr  td {
        border-width: 1px !important; 
        //border: 1px solid #676767 !important;
    }
    .boxscroll {
	height: 500px;
	border: 0px solid #000;
	overflow: auto;
    }
   .modal-body table td small {
    font-size: 12px;
    padding: 5px;
}

.p_button{
    font-size: 11px !important;
    padding: 3px 5px 1px !important;
    background: #f7f7f7; /* Old browsers */
    background: -moz-linear-gradient(top, #f7f7f7 0%, #e7e7e7 100%); /* FF3.6-15 */
    background: -webkit-linear-gradient(top, #f7f7f7 0%,#e7e7e7 100%); /* Chrome10-25,Safari5.1-6 */
    background: linear-gradient(to bottom, #f7f7f7 0%,#e7e7e7 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#e7e7e7',GradientType=0 ); /* IE6-9 */
    border-color: #c5c4c6;
    border-radius:0;
    margin-right: 4px !important;
    }
    
#edit_form small{width: 100px; display: inline-block;}
    
</style>

<?php include("_includes/header.php");

if(isset($_SESSION['user_session'])){
$agent_id = $_SESSION['user_session'];
}else {
$agent_id = 0;
}

$ee = explode("/", $_SERVER["PHP_SELF"]); 
$link  =  end($ee).'?'.$_SERVER["QUERY_STRING"] ;

if(isset($_POST['deniedReason'])){
    
    $assign_id = $_POST['assign_id'];
    $reason_id = $_POST['reason'];
     
    $obj_jobs_class->updateDeniedReasonsClient($assign_id,$reason_id);
    $obj_jobs_class->updateClientsAssign($assign_id, 'deny', '0');
       
    echo "<script>window.location='".$link."'</script>";
    die();
}



if(isset($_POST['AddTaskSubmit'])){
    
    $task_title = $_POST['title_task'];
    $assign_id = $_POST['assign_id'];
    $event_id = $_POST['event_id'];
    $client_id = $_POST['client_id'];
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    $contact_person = $_POST['contact_person'];

    $obj_jobs_class->addEventTask($assign_id, $event_id, $client_id, $task_title, $start_date, $end_date, $contact_person, $agent_id);
    
    echo "<script>window.location='".$link."'</script>";
    die();
}

if(isset($_POST['CommentSubmit'])){

    //echo '<pre>'; print_r($_POST); echo '</pre>'; 
    $assign_id = $_POST['assign_id'];
    $event_id = $_POST['event_id'];
    $client_id = $_POST['client_id'];
    $comments  = $_POST['comments'];
    
    $obj_jobs_class->addEventComment($assign_id, $event_id, $client_id, $comments, $agent_id);
    
    echo "<script>window.location='".$link."'</script>";
    die();
}



if(isset($_POST['delete_now'])){ 

    if(count($_POST['select'])>0)
    $sel_event = base64_decode($_GET['event']);
    foreach($_POST['select'] as $client_list){
        $obj_jobs_class->removeAssignClients($sel_event, $client_list,$agent_id);
    }
      
   echo "<script>window.location='".$link."'</script>";
  die();
}


if(isset($_POST['submit_now'])){
    
    $sel_event = base64_decode($_GET['event']);
    "<script>window.location='".$link."'</script>";
    //die();
}
        
if(isset($_GET['st']) && !empty($_GET['st']) && !empty($_GET['as']) && isset($_GET['as']) ){
        
            $asign_id   = base64_decode($_GET['as']);
            $status     =  base64_decode($_GET['st']);
            if($status == 1){
                $status2     = 'accept';
            }else if($status == 0){
                $status2     = 'deny';
            }else if($status == 4){
                $status2     = 'pipeline';
            }
            //die();
            
            
            if(isset($_GET['st_code'])){
                
                $st_code = $_GET['st_code'];
                
                $obj_jobs_class->updateClientsAssign($asign_id, $status2, $status, $st_code);
            }else {
                $obj_jobs_class->updateClientsAssign($asign_id, $status2, $status);
            }
            
            echo "<script>window.location='assign_client_step2.php?event=".$_GET['event']."'</script>";
            die();
            
}

if(isset($_GET['event']) && !empty($_GET['event'])){
    
    $exhibition_id = base64_decode($_GET['event']); 
    $event = $obj_events_class->getEvent($exhibition_id);
    $AssignClients =  $obj_jobs_class->getAssignClients($exhibition_id, $agent_id);
    
    $DeniedReasons =  $obj_jobs_class->getDeniedReasons();
    
    /*echo '<pre>';
    print_r($AssignClients);
    echo '</pre>';   */
}
else {
    
     echo "<script>window.location='events.php'</script>";
     die();
}

$modal = '';
?>

      
<div class="col-sm-12 right_form">
    
     <div class="title">
                
                    <h1><?php echo $event['event_name'];?>
                    
                    
                    <p class="date_d">
                        <?php 
                        if(!empty($event['start_date']))
                        echo $obj_jobs_class->change_date2($event['start_date']);
                        
                        if(!empty($event['end_date']))
                        echo ' to '.$obj_jobs_class->change_date2( $event['end_date']); ?> 
                    
                    </p>
                    </h1>
                
        </div>
    
       
    <ol class="breadcrumb white">
          <li><a href="dashboard.php">Dashboard</a></li>
          <li><a href="events.php">Exhibitions</a></li>
          <li><a href="assign_client.php?event=<?php echo $_GET['event']?>">Assign Client Step 1</a></li>
          
          
          
          <li class="active">Assign Client Step 2</li>
          <li class="right"><a href="assign_client_step3.php?event=<?php echo $_GET['event']?>">Assign Client Step 3 </a> &nbsp; / &nbsp;<a href="send_sms.php?event=<?php echo $_GET['event']?>"> Send SMS </a></li>
    </ol>
    
    
  <!--  <div class="col-md-12 col-sm-12">  
        <button type="button" onclick="submit_form();" name="submit_now" class="btn btn-default btn-o btn-primary add-event" >Save</button>
                </div> -->
    
<div class="col-sm-12 a_client">
     
	<div class="row">
      <div class="col-sm-12">
          
      <div class="table-result table-responsive ">  

          <form action="<?php echo $link;?>" method="POST" id="assignForm">

              <div class="boxscroll">
		<table class="table table-bordered " id="exampleNew">
                    <thead>
                            <tr>
                            	<th style="width:1%;"  >Sr. </th>
                                <th>Company Name </th>
				<th style="width:300px;">Contact Persons </th>
                                <th class='center-align' >Call 
                                    <br> <input id="check_call" type="checkbox" name="CallAll" value="all" onclick="checkAll('call');"> 
                                </th>
                                <th class='center-align' >SMS 
                                    <br> <input id="check_sms" type="checkbox" name="SMSAll" value="all" onclick="checkAll('sms');">
                                </th>
                                <th class='center-align'>Email
                                    <br> <input id="check_email" type="checkbox" name="EmailAll" value="all" onclick="checkAll('email');">
                                </th>
                                <th class='center-align'>Tasks </th>
                                <th>Comments</th>
                                <th class='center-align'> Status </th>
                            </tr>
                        </thead>
                	<tbody>
                        
<?php $i =1; foreach($AssignClients as $a_client){
    
        $row_color = '';
        $assign_id = $a_client['assign_id'];
        $assign_CallSMSEmail = $obj_jobs_class->getClientsAssignDetails($a_client['assign_id']);
        if($a_client['status_order'] == 1){$row_color = 'style="background-color:#BBEF7E;"';}
        else if($a_client['status_order'] ==  0){$row_color = 'style="background-color:#FFAAAA"';}
        else if($a_client['status_order'] ==  4){
            
            if($a_client['pipeline'] ==  80){
                $row_color = 'style="background-color:#FDF704"';
            }
            else if($a_client['pipeline'] ==  50){
                $row_color = 'style="background-color:#fffb6b"';
            }
            else if($a_client['pipeline'] ==  10){
                $row_color = 'style="background-color:#fdf99e"';
            }
            ?>
                            
<tr id="tr_row_<?=$assign_id ?>" <?=$row_color?>>
    <td style="width:1%;"  ><?= $i++ ?></td>
    
    <td><?php echo $a_client['company_name'] ?>
    <br><span style="color:#F47721" ><?php echo $obj_category_class->getCategoriesName($a_client['categories']);?></span>
     </td>
    
    <td><?php 
            if(isset($a_client['persons']))
            if(count($a_client['persons'])>0){
                foreach($a_client['persons'] as $ac_person){
                        echo $ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') / ';
                }
        ?>
            <a data-toggle="modal" data-target="#persons_<?= $a_client['client_id']?>" style="cursor: pointer;" href="#">
                <i class='fa fa-list-ul'></i>
            </a>
       <?php  } ?>
                                

<div id="persons_<?= $a_client['client_id']?>" class="modal fade left-align" role="dialog" >

  <div class="modal-dialog client-modal">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Contact Persons</h4>
        <span onclick="getEditPersons(<?= $a_client['client_id']?>);" style="float: right; right: 50px; position: relative; bottom: 22px; font-size: 14px;">Edit</span>
      </div>
      <div class="modal-body">
	  
          <table style="table-layout: fixed; width: 100%" class="ttttt">
             <tbody><tr>
                 <td width="50%" style="border-top:none !important; "><small>Company: </small> <strong> <?php echo $a_client['company_name'] ?></strong> </td>
                <td width="50%" style="border-top:none !important; "><small>Owner's Name: </small> <strong> <?php echo $a_client['owner_name'] ?> </strong> </td>
            </tr>
             
            <tr>  <td width="50%"><br></td>
                  <td width="50%"> <br></td>
            </tr>
            
            
<?php if(count($a_client['persons'])>0){$per=1; 
                foreach($a_client['persons'] as $ac_person){ ?> 
              
            <!--<tr>
                <td colspan="2" width="100%" style="background-color: #eee;">  <strong>Contact Persons <?php echo $per++; ?></strong></td>
            </tr>-->
            
        <tr>
            <td width='50%' style="background-color: #eee;" > 
                <small> Name: </small> 
                <strong  ><?php echo $ac_person['f_name'].' '.$ac_person['l_name']; ?></strong>
            </td>
            <td width='50%' style="background-color: #eee;"> 
                <small>Designation: </small> 
                <strong  ><?php echo  $ac_person['designation']; ?></strong>
            </td>
        </tr>
            
            
    <tr>
        <td width='50%' colspan="2"> 
        <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_email');">Email: </small> 
        <strong  id="_<?php  echo $ac_person['person_id'];  ?>_email"><?php echo str_replace(", ", ", ", $ac_person['email']); ?></strong>
        </td>
    </tr>
            
    <tr>
        <td width='50%'>
            <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_mobile');">Mobile: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_mobile"><?php echo str_replace(", ", ", ",$ac_person['mobile']); ?></strong>
        </td>
                
        <td width='50%'> 
            <small class="pointer " onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_phone');">Land Line: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_phone"> <?php echo str_replace(", ", ", ",$ac_person['landline']); ?></strong> 
        </td>
            </tr>
            <tr>
                <td width="50%" colspan="2"><small>Ext: </small> <strong> <?php echo $ac_person['line_ext']; ?> </strong></td>
            </tr>
<?php  }      }   ?>
            
        </tbody></table>
        
      </div>
      
    </div>

  </div>
</div>
	         

       </td>
       <td class='center-align callBoxes'>
           <input type="checkbox" class="all_call" onclick="setStatus_call_sms(<?= $assign_id ?>, 'call')"; name="call[<?= $assign_id ?>]" value="1">
    <span id="row_call_<?= $assign_id ?>"><?php 
       
       if(isset($assign_CallSMSEmail['call']) && !empty($assign_CallSMSEmail['call']) && $assign_CallSMSEmail['call']!='0000-00-00 00:00:00'){ 
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['call']); 
           ?>
       <?php }?></span>
        </td>
        <td class='center-align smsBoxes'>
            
            <input type="checkbox" class="all_sms" onclick="setStatus_call_sms(<?= $assign_id ?>, 'sms')"; name="sms[<?= $assign_id  ?>]" value="1">
            <span id="row_sms_<?= $assign_id ?>">
        <?php if(isset($assign_CallSMSEmail['sms']) && !empty($assign_CallSMSEmail['sms']) && $assign_CallSMSEmail['sms']!='0000-00-00 00:00:00'){
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['sms']); 
         }  ?></span>
        </td>
        <td class='center-align emailBoxes'>
            <input type="checkbox" class="all_email"   onclick="setStatus_call_sms(<?= $assign_id ?>, 'email')";   name="email[<?= $assign_id ?>]" value="1">
                <span id="row_email_<?= $assign_id ?>">
            <?php if(isset($assign_CallSMSEmail['email']) && !empty($assign_CallSMSEmail['email']) && $assign_CallSMSEmail['email']!='0000-00-00 00:00:00'){ 
                        echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['email']); 
                } ?>
                </span>
        </td>
        <td class='center-align'>
            <a data-toggle="modal" data-target="#task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-plus"></i></a> &nbsp;  |   &nbsp;
        
 <?php $modal .= '<div id="task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Task</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
                <tr><td width="100%" colspan="2"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td></tr>
                <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"><span>Task Title: </span> <input type="text" class="task_input" required="required" name="title_task" > 
                <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    
                </td>
            </tr>
        <tr>
            <td width="100%" colspan="2"><span>Start Date: </span> <input type="text" class="task_input start_date"  required="required" name="start_date"> </td>
        </tr>
        <tr>
           <td width="100%" colspan="2"><span>End Date: </span> <input type="text" class="task_input end_date"  required="required" name="end_date"> </td>
            </tr> 
			<tr>
                <td width="100%" colspan="2"><span>Contact Person: </span> 
                    <select class="task_input" name="contact_person">' ;
 
        
 if(isset($a_client['persons']))   
 foreach($a_client['persons'] as $ac_person){
              $modal .=  '<option value="'.$ac_person['person_id'].'">'.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].')</option>';
      }
      
      $modal .='</select>
<input type="hidden" name="agent_id" value="'.$agent_id.'" >           
</td></tr> <tr>
                <td width="100%" colspan="2"><input type="button" onclick="addTask_form('.$assign_id.'); " class="orange-btn" value="Submit" name="AddTaskSubmit"></td>
            </tr> 
        </tbody></table></form>
      </div></div></div></div>';
?>       
        
<?php 
//// GET EVENT_TASKS....
$tasks_events = $obj_jobs_class->getEventTasks($assign_id, $event['event_id']);
//print_r($tasks_events);
?>
    <a data-toggle="modal" data-target="#pending_task_<?= $assign_id ?>_" style="cursor: pointer;"  ><i class="fa fa-eye"></i> 
        (<span id="pend_count_<?php echo $assign_id?>_"> <?php echo  count($tasks_events) ?></span>) <small></small>
        </a>   &nbsp;|   &nbsp;
    <?php 
//if(count($tasks_events)>0)
    {
    
$modal .= '<div id="pending_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Pending Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table>';
 
    foreach($tasks_events as $tee ){
        
$modal .='<div class="listing_outline"  id="task_id_'.$tee['task_id'].'_" >
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>
                <tr id="last_row_task_'.$tee['task_id'].'_">
                    <td width="100%" >
                ';
            if(!empty($ac_person['line_ext'])){
                $modal .='<small>Ext: </small> '.$ac_person['line_ext'];
            }
            break;
        }
    }
    $modal .='</td><td>
        <input type="button" class="orange-btn" value="Task Complete" name="TaskCompleteSubmit" onclick="completeTask(\''.$tee['task_id'].'\', \''.$assign_id.'\' ); ">
        <input type="button" class="orange-btn" value="Delete Task " name="DeleteTaskSubmit" onclick="deleteTask('.$tee['task_id'].' , '.$assign_id.')">
            
            </td>
        </tr>
        </tbody></table>
</div>';        

    }
 
$modal .='</form>
      </div></div></div></div>';
 
    }
    
    $completed_tasks_events = $obj_jobs_class->getEventCompletedTasks($assign_id, $event['event_id']);    
?>
        
<a data-toggle="modal" data-target="#completed_task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-check-circle"></i> 
    (<span id="comp_count_<?php echo $assign_id?>_"><?php echo count($completed_tasks_events); ?></span>)
</a>


<?php 

//print_r($tasks_events);
//if(count($completed_tasks_events)>0)
    {
    
$modal .= '<div id="completed_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Completed Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_1'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table> <div class="task_list_box_all">';
 
    foreach($completed_tasks_events  as $tee ){
        
    $modal .='<div class="listing_outline">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>';
            
            if(!empty($ac_person['line_ext'])){
                $modal .='<tr><td width="100%" > <small>Ext: </small> '.$ac_person['line_ext'].'</td><td></td></tr>';
            }
            break;
        }
    }
        $modal .='</tbody></table> </div>';
    }

    $modal .='</div></form>
      </div></div></div></div>';
}
?>
        
</td>
<td> 
<?php
$comment_events = $obj_jobs_class->getEventComments($assign_id, $event['event_id']);
//print_r($comment_events);

if(count($comment_events)>0){
            echo "<span id='f_comnt_".$assign_id."_'>".$comment_events[0]['comments']."</span>";
}else{
            echo "<span id='f_comnt_".$assign_id."_'></span>";
}
    {
    
    $cinr = 1;
    $coment_modal = '';
    foreach($comment_events as $cmn_eve){ 

        $coment_modal .= '<tr><td width="100%">
            <span class="small-gray" style="width:100%;">'.$obj_jobs_class->change_date($cmn_eve['ts']).'</span><br>
            <i class="fa fa-angle-right"></i> '.$cmn_eve['comments'].'
        </td></tr>';
        
        $cinr++;
    } ?>
    <br>
    <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>_" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;  |  &nbsp;
    <a data-toggle="modal" data-target="#comment_view_<?= $assign_id ?>_" style="cursor: pointer;" >
        <i class="fa fa-eye"></i> (<span id="coment_count_<?= $assign_id ?>_"><?php echo count($comment_events)?></span>)    
    </a>
        
        <?php 

echo  '<div id="comment_view_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Comments</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST"><div id="comment_view_list_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
			<tr><td width="100%" ><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>

                
                    '.$coment_modal.'
                           
        </tbody></table></form></div>  
    </div>
  </div>
</div>';


}
    
   /* else { ?>
        <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;
<?php } */
?>  
<?php $modal .=' <div id="comment_add_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Comment</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST" id="form_comment_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"> Comment: <br>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    <input type="hidden" name="agent_id" value="'.$agent_id.'">
                        
                    <textarea class="comment_box" type="text" maxlength="100" class="task_input" required="required" name="comments"  ></textarea>
                </td>
            </tr>
            <tr><td width="100%" colspan="2">
            <input type="button" class="orange-btn" value="Submit"  onclick="add_comment(\''.$assign_id.'\' ); " name="CommentSubmit"></td></tr>
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
</td>
<td class='center-align large-icons'>
    <a   onclick="changeStatus(<?php echo $assign_id ?>, 1);"  style="cursor: pointer;">
        <i class="fa fa-check-square"></i></a> 
    |  
    
        <a data-toggle="modal" data-target="#denied_<?= $a_client['client_id']?>_" style="cursor: pointer;" >
        <i class="fa fa-times-circle"></i></a> 
    
    |  
    <select style="font-size:12px; border:1px solid #ccc; border-radius: 2px; color:cadetblue; padding:5px;" id="pipe_<?php echo $assign_id; ?>_"  onchange="changePipeline('<?php echo ($assign_id)?>', '<?php echo base64_encode($assign_id)?>');">
            <option value="">--Select--</option>
            <option <?php if($a_client['pipeline']==80) echo 'selected="selected"'; ?>  value="80">Hot</option>
            <option <?php if($a_client['pipeline']==50) echo 'selected="selected"'; ?> value="50">Warm</option>
            <option <?php if($a_client['pipeline']==10) echo 'selected="selected"'; ?>value="10">Cold</option>
        </select>

<?php $modal .=' <div id="denied_'.$a_client['client_id'].'_" class="modal fade left-align" role="dialog" style="color: #666;">
    <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Denied Reason</h4>
      </div>
      <div class="modal-body">
	<form action="" method="POST">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> 
                </td></tr>
            <tr>
                <td width="100%" colspan="2"> <br>
                <span style="display:block; float:left; line-height:30px;">
                    Denied Reason: </span>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" id="den_client_'.$assign_id.'_"  name="client_id" value="'.$a_client['client_id'].'">
                        <select id="den_res_'.$assign_id.'_" class="form-control" name="reason" style="width:auto; height:auto;" required="required">
                                <option value="" >---Select--- </option>';
                        foreach ($DeniedReasons as $drr){
                             $modal .= '<option value="'.$drr['id'].'">'.$drr['reason'] .'</option>';
                        }
                //<option value="" > </option>
                                        
    $modal .='</select>
        <br>
        
                </td>
            </tr>
            <tr><td width="100%" colspan="2"><input type="button" onclick="denyStatus('.$assign_id.');" class="orange-btn" value="Submit" name="deniedReason"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
    
        
</td>

            </tr>
                        
 <?php }      
 } 
 
 
 
 
 foreach($AssignClients as $a_client){
    
        $row_color = '';
        $assign_id = $a_client['assign_id'];
        $assign_CallSMSEmail = $obj_jobs_class->getClientsAssignDetails($a_client['assign_id']);
        if($a_client['status_order'] == 1){$row_color = 'style="background-color:#BBEF7E;"';
?>        
                
<tr id="tr_row_<?=$assign_id ?>" <?=$row_color?>>
    <td style="width:1%;"  ><?= $i++ ?></td>
    
    <td><?php echo $a_client['company_name'] ?>
    <br><span style="color:#F47721" ><?php echo $obj_category_class->getCategoriesName($a_client['categories']);?></span>
     </td>
    
    <td><?php 
            if(isset($a_client['persons']))
            if(count($a_client['persons'])>0){
                foreach($a_client['persons'] as $ac_person){
                        echo $ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') / ';
                }
        ?>
            <a data-toggle="modal" data-target="#persons_<?= $a_client['client_id']?>" style="cursor: pointer;" href="#">
                <i class='fa fa-list-ul'></i>
            </a>
       <?php  } ?>
                                

<div id="persons_<?= $a_client['client_id']?>" class="modal fade left-align" role="dialog" >

  <div class="modal-dialog client-modal">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Contact Persons</h4>
        <span onclick="getEditPersons(<?= $a_client['client_id']?>);" style="float: right; right: 50px; position: relative; bottom: 22px; font-size: 14px;">Edit</span>
      </div>
      <div class="modal-body">
	  
          <table style="table-layout: fixed; width: 100%" class="ttttt">
             <tbody><tr>
                 <td width="50%" style="border-top:none !important; "><small>Company: </small> <strong> <?php echo $a_client['company_name'] ?></strong> </td>
                <td width="50%" style="border-top:none !important; "><small>Owner's Name: </small> <strong> <?php echo $a_client['owner_name'] ?> </strong> </td>
            </tr>
             
            <tr>  <td width="50%"><br></td>
                  <td width="50%"> <br></td>
            </tr>
            
            
<?php if(count($a_client['persons'])>0){$per=1; 
                foreach($a_client['persons'] as $ac_person){ ?> 
              
            <!--<tr>
                <td colspan="2" width="100%" style="background-color: #eee;">  <strong>Contact Persons <?php echo $per++; ?></strong></td>
            </tr>-->
            
        <tr>
            <td width='50%' style="background-color: #eee;" > 
                <small> Name: </small> 
                <strong  ><?php echo $ac_person['f_name'].' '.$ac_person['l_name']; ?></strong>
            </td>
            <td width='50%' style="background-color: #eee;"> 
                <small>Designation: </small> 
                <strong  ><?php echo  $ac_person['designation']; ?></strong>
            </td>
        </tr>
            
            
    <tr>
        <td width='50%' colspan="2"> 
        <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_email');">Email: </small> 
        <strong  id="_<?php  echo $ac_person['person_id'];  ?>_email"><?php echo str_replace(", ", ", ", $ac_person['email']); ?></strong>
        </td>
    </tr>
            
    <tr>
        <td width='50%'>
            <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_mobile');">Mobile: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_mobile"><?php echo str_replace(", ", ", ",$ac_person['mobile']); ?></strong>
        </td>
                
        <td width='50%'> 
            <small class="pointer " onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_phone');">Land Line: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_phone"> <?php echo str_replace(", ", ", ",$ac_person['landline']); ?></strong> 
        </td>
            </tr>
            <tr>
                <td width="50%" colspan="2"><small>Ext: </small> <strong> <?php echo $ac_person['line_ext']; ?> </strong></td>
            </tr>
<?php  }      }   ?>
            
        </tbody></table>
        
      </div>
      
    </div>

  </div>
</div>
	         

       </td>
       <td class='center-align callBoxes'>
           <input type="checkbox" class="all_call" onclick="setStatus_call_sms(<?= $assign_id ?>, 'call')"; name="call[<?= $assign_id ?>]" value="1">
    <span id="row_call_<?= $assign_id ?>"><?php 
       
       if(isset($assign_CallSMSEmail['call']) && !empty($assign_CallSMSEmail['call']) && $assign_CallSMSEmail['call']!='0000-00-00 00:00:00'){ 
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['call']); 
           ?>
       <?php }?></span>
        </td>
        <td class='center-align smsBoxes'>
            
            <input type="checkbox" class="all_sms" onclick="setStatus_call_sms(<?= $assign_id ?>, 'sms')"; name="sms[<?= $assign_id  ?>]" value="1">
            <span id="row_sms_<?= $assign_id ?>">
        <?php if(isset($assign_CallSMSEmail['sms']) && !empty($assign_CallSMSEmail['sms']) && $assign_CallSMSEmail['sms']!='0000-00-00 00:00:00'){
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['sms']); 
         }  ?></span>
        </td>
        <td class='center-align emailBoxes'>
            <input type="checkbox" class="all_email"   onclick="setStatus_call_sms(<?= $assign_id ?>, 'email')";   name="email[<?= $assign_id ?>]" value="1">
                <span id="row_email_<?= $assign_id ?>">
            <?php if(isset($assign_CallSMSEmail['email']) && !empty($assign_CallSMSEmail['email']) && $assign_CallSMSEmail['email']!='0000-00-00 00:00:00'){ 
                        echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['email']); 
                } ?>
                </span>
        </td>
        <td class='center-align'>
            <a data-toggle="modal" data-target="#task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-plus"></i></a> &nbsp;  |   &nbsp;
        
 <?php $modal .= '<div id="task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Task</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
                <tr><td width="100%" colspan="2"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td></tr>
                <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"><span>Task Title: </span> <input type="text" class="task_input" required="required" name="title_task" > 
                <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    
                </td>
            </tr>
        <tr>
            <td width="100%" colspan="2"><span>Start Date: </span> <input type="text" class="task_input start_date"  required="required" name="start_date"> </td>
        </tr>
        <tr>
           <td width="100%" colspan="2"><span>End Date: </span> <input type="text" class="task_input end_date"  required="required" name="end_date"> </td>
            </tr> 
			<tr>
                <td width="100%" colspan="2"><span>Contact Person: </span> 
                    <select class="task_input" name="contact_person">' ;
 
        
 if(isset($a_client['persons']))   
 foreach($a_client['persons'] as $ac_person){
              $modal .=  '<option value="'.$ac_person['person_id'].'">'.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].')</option>';
      }
      
      $modal .='</select>
<input type="hidden" name="agent_id" value="'.$agent_id.'" >           
</td></tr> <tr>
                <td width="100%" colspan="2"><input type="button" onclick="addTask_form('.$assign_id.'); " class="orange-btn" value="Submit" name="AddTaskSubmit"></td>
            </tr> 
        </tbody></table></form>
      </div></div></div></div>';
?>       
        
<?php 
//// GET EVENT_TASKS....
$tasks_events = $obj_jobs_class->getEventTasks($assign_id, $event['event_id']);
//print_r($tasks_events);
?>
    <a data-toggle="modal" data-target="#pending_task_<?= $assign_id ?>_" style="cursor: pointer;"  ><i class="fa fa-eye"></i> 
        (<span id="pend_count_<?php echo $assign_id?>_"> <?php echo  count($tasks_events) ?></span>) <small></small>
        </a>   &nbsp;|   &nbsp;
    <?php 
//if(count($tasks_events)>0)
    {
    
$modal .= '<div id="pending_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Pending Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table>';
 
    foreach($tasks_events as $tee ){
        
$modal .='<div class="listing_outline"  id="task_id_'.$tee['task_id'].'_" >
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>
                <tr id="last_row_task_'.$tee['task_id'].'_">
                    <td width="100%" >
                ';
            if(!empty($ac_person['line_ext'])){
                $modal .='<small>Ext: </small> '.$ac_person['line_ext'];
            }
            break;
        }
    }
    $modal .='</td><td>
        <input type="button" class="orange-btn" value="Task Complete" name="TaskCompleteSubmit" onclick="completeTask(\''.$tee['task_id'].'\', \''.$assign_id.'\' ); ">
        <input type="button" class="orange-btn" value="Delete Task " name="DeleteTaskSubmit" onclick="deleteTask('.$tee['task_id'].' , '.$assign_id.')">
            
            </td>
        </tr>
        </tbody></table>
</div>';        

    }
 
$modal .='</form>
      </div></div></div></div>';
 
    }
    
    $completed_tasks_events = $obj_jobs_class->getEventCompletedTasks($assign_id, $event['event_id']);    
?>
        
<a data-toggle="modal" data-target="#completed_task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-check-circle"></i> 
    (<span id="comp_count_<?php echo $assign_id?>_"><?php echo count($completed_tasks_events); ?></span>)
</a>


<?php 

//print_r($tasks_events);
//if(count($completed_tasks_events)>0)
    {
    
$modal .= '<div id="completed_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Completed Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_1'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table> <div class="task_list_box_all">';
 
    foreach($completed_tasks_events  as $tee ){
        
    $modal .='<div class="listing_outline">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>';
            
            if(!empty($ac_person['line_ext'])){
                $modal .='<tr><td width="100%" > <small>Ext: </small> '.$ac_person['line_ext'].'</td><td></td></tr>';
            }
            break;
        }
    }
        $modal .='</tbody></table> </div>';
    }

    $modal .='</div></form>
      </div></div></div></div>';
}
?>
        
</td>
<td> 
<?php
$comment_events = $obj_jobs_class->getEventComments($assign_id, $event['event_id']);
//print_r($comment_events);

if(count($comment_events)>0){
            echo "<span id='f_comnt_".$assign_id."_'>".$comment_events[0]['comments']."</span>";
}else{
            echo "<span id='f_comnt_".$assign_id."_'></span>";
}
    {
    
    $cinr = 1;
    $coment_modal = '';
    foreach($comment_events as $cmn_eve){ 

        $coment_modal .= '<tr><td width="100%">
            <span class="small-gray" style="width:100%;">'.$obj_jobs_class->change_date($cmn_eve['ts']).'</span><br>
            <i class="fa fa-angle-right"></i> '.$cmn_eve['comments'].'
        </td></tr>';
        
        $cinr++;
    } ?>
    <br>
    <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>_" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;  |  &nbsp;
    <a data-toggle="modal" data-target="#comment_view_<?= $assign_id ?>_" style="cursor: pointer;" >
        <i class="fa fa-eye"></i> (<span id="coment_count_<?= $assign_id ?>_"><?php echo count($comment_events)?></span>)    
    </a>
        
        <?php 

echo  '<div id="comment_view_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Comments</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST"><div id="comment_view_list_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
			<tr><td width="100%" ><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>

                
                    '.$coment_modal.'
                           
        </tbody></table></form></div>  
    </div>
  </div>
</div>';


}
    
   /* else { ?>
        <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;
<?php } */
?>  
<?php $modal .=' <div id="comment_add_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Comment</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST" id="form_comment_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"> Comment: <br>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    <input type="hidden" name="agent_id" value="'.$agent_id.'">
                        
                    <textarea class="comment_box" type="text" maxlength="100" class="task_input" required="required" name="comments"  ></textarea>
                </td>
            </tr>
            <tr><td width="100%" colspan="2">
            <input type="button" class="orange-btn" value="Submit"  onclick="add_comment(\''.$assign_id.'\' ); " name="CommentSubmit"></td></tr>
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
</td>
<td class='center-align large-icons'>
    <a   onclick="changeStatus(<?php echo $assign_id ?>, 1);"  style="cursor: pointer;">
        <i class="fa fa-check-square"></i></a> 
    |  
    
        <a data-toggle="modal" data-target="#denied_<?= $a_client['client_id']?>_" style="cursor: pointer;" >
        <i class="fa fa-times-circle"></i></a> 
    
    |  
    <select style="font-size:12px; border:1px solid #ccc; border-radius: 2px; color:cadetblue; padding:5px;" id="pipe_<?php echo $assign_id; ?>_"  onchange="changePipeline('<?php echo ($assign_id)?>', '<?php echo base64_encode($assign_id)?>');">
            <option value="">--Select--</option>
            <option <?php if($a_client['pipeline']==80) echo 'selected="selected"'; ?>  value="80">Hot</option>
            <option <?php if($a_client['pipeline']==50) echo 'selected="selected"'; ?> value="50">Warm</option>
            <option <?php if($a_client['pipeline']==10) echo 'selected="selected"'; ?>value="10">Cold</option>
        </select>

<?php $modal .=' <div id="denied_'.$a_client['client_id'].'_" class="modal fade left-align" role="dialog" style="color: #666;">
    <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Denied Reason</h4>
      </div>
      <div class="modal-body">
	<form action="" method="POST">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> 
                </td></tr>
            <tr>
                <td width="100%" colspan="2"> <br>
                <span style="display:block; float:left; line-height:30px;">
                    Denied Reason: </span>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" id="den_client_'.$assign_id.'_"  name="client_id" value="'.$a_client['client_id'].'">
                        <select id="den_res_'.$assign_id.'_" class="form-control" name="reason" style="width:auto; height:auto;" required="required">
                                <option value="" >---Select--- </option>';
                        foreach ($DeniedReasons as $drr){
                             $modal .= '<option value="'.$drr['id'].'">'.$drr['reason'] .'</option>';
                        }
                //<option value="" > </option>
                                        
    $modal .='</select>
        <br>
        
                </td>
            </tr>
            <tr><td width="100%" colspan="2"><input type="button" onclick="denyStatus('.$assign_id.');" class="orange-btn" value="Submit" name="deniedReason"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
    
        
</td>

            </tr>
                  
<?php        }
        
    }
 
 
 
 
 foreach($AssignClients as $a_client){
    
        $row_color = '';
        $assign_id = $a_client['assign_id'];
        $assign_CallSMSEmail = $obj_jobs_class->getClientsAssignDetails($a_client['assign_id']);
        if($a_client['status_order'] == 2){$row_color = 'style=""';
?>        
               
<tr id="tr_row_<?=$assign_id ?>" <?=$row_color?>>
    <td style="width:1%;"  ><?= $i++ ?></td>
    
    <td><?php echo $a_client['company_name'] ?>
    <br><span style="color:#F47721" ><?php echo $obj_category_class->getCategoriesName($a_client['categories']);?></span>
     </td>
    
    <td><?php 
            if(isset($a_client['persons']))
            if(count($a_client['persons'])>0){
                foreach($a_client['persons'] as $ac_person){
                        echo $ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') / ';
                }
        ?>
            <a data-toggle="modal" data-target="#persons_<?= $a_client['client_id']?>" style="cursor: pointer;" href="#">
                <i class='fa fa-list-ul'></i>
            </a>
       <?php  } ?>
                                

<div id="persons_<?= $a_client['client_id']?>" class="modal fade left-align" role="dialog" >

  <div class="modal-dialog client-modal">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Contact Persons</h4>
        <span onclick="getEditPersons(<?= $a_client['client_id']?>);" style="float: right; right: 50px; position: relative; bottom: 22px; font-size: 14px;  padding: 1px 10px; border-radius: 5px;    background: #F47721; color: #fff; cursor:pointer;">Edit</span>
      </div>
      <div class="modal-body">
	  
          <table style="table-layout: fixed; width: 100%" class="ttttt">
             <tbody><tr>
                 <td width="50%" style="border-top:none !important; "><small>Company: </small> <strong> <?php echo $a_client['company_name'] ?></strong> </td>
                <td width="50%" style="border-top:none !important; "><small>Owner's Name: </small> <strong> <?php echo $a_client['owner_name'] ?> </strong> </td>
            </tr>
             
            <tr>  <td width="50%"><br></td>
                  <td width="50%"> <br></td>
            </tr>
            
            
<?php if(count($a_client['persons'])>0){$per=1; 
                foreach($a_client['persons'] as $ac_person){ ?> 
              
            <!--<tr>
                <td colspan="2" width="100%" style="background-color: #eee;">  <strong>Contact Persons <?php echo $per++; ?></strong></td>
            </tr>-->
            
        <tr>
            <td width='50%' style="background-color: #eee;" > 
                <small> Name: </small> 
                <strong  ><?php echo $ac_person['f_name'].' '.$ac_person['l_name']; ?></strong>
            </td>
            <td width='50%' style="background-color: #eee;"> 
                <small>Designation: </small> 
                <strong  ><?php echo  $ac_person['designation']; ?></strong>
            </td>
        </tr>
            
            
    <tr>
        <td width='50%' colspan="2"> 
        <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_email');">Email: </small> 
        <strong  id="_<?php  echo $ac_person['person_id'];  ?>_email"><?php echo str_replace(", ", ", ", $ac_person['email']); ?></strong>
        </td>
    </tr>
            
    <tr>
        <td width='50%'>
            <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_mobile');">Mobile: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_mobile"><?php echo str_replace(", ", ", ",$ac_person['mobile']); ?></strong>
        </td>
                
        <td width='50%'> 
            <small class="pointer " onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_phone');">Land Line: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_phone"> <?php echo str_replace(", ", ", ",$ac_person['landline']); ?></strong> 
        </td>
            </tr>
            <tr>
                <td width="50%" colspan="2"><small>Ext: </small> <strong> <?php echo $ac_person['line_ext']; ?> </strong></td>
            </tr>
<?php  }      }   ?>
            
        </tbody></table>
        
      </div>
      
    </div>

  </div>
</div>
	         

       </td>
       <td class='center-align callBoxes'>
           <input type="checkbox" class="all_call" onclick="setStatus_call_sms(<?= $assign_id ?>, 'call')"; name="call[<?= $assign_id ?>]" value="1">
    <span id="row_call_<?= $assign_id ?>"><?php 
       
       if(isset($assign_CallSMSEmail['call']) && !empty($assign_CallSMSEmail['call']) && $assign_CallSMSEmail['call']!='0000-00-00 00:00:00'){ 
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['call']); 
           ?>
       <?php }?></span>
        </td>
        <td class='center-align smsBoxes'>
            
            <input type="checkbox" class="all_sms" onclick="setStatus_call_sms(<?= $assign_id ?>, 'sms')"; name="sms[<?= $assign_id  ?>]" value="1">
            <span id="row_sms_<?= $assign_id ?>">
        <?php if(isset($assign_CallSMSEmail['sms']) && !empty($assign_CallSMSEmail['sms']) && $assign_CallSMSEmail['sms']!='0000-00-00 00:00:00'){
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['sms']); 
         }  ?></span>
        </td>
        <td class='center-align emailBoxes'>
            <input type="checkbox" class="all_email"   onclick="setStatus_call_sms(<?= $assign_id ?>, 'email')";   name="email[<?= $assign_id ?>]" value="1">
                <span id="row_email_<?= $assign_id ?>">
            <?php if(isset($assign_CallSMSEmail['email']) && !empty($assign_CallSMSEmail['email']) && $assign_CallSMSEmail['email']!='0000-00-00 00:00:00'){ 
                        echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['email']); 
                } ?>
                </span>
        </td>
        <td class='center-align'>
            <a data-toggle="modal" data-target="#task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-plus"></i></a> &nbsp;  |   &nbsp;
        
 <?php $modal .= '<div id="task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Task</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
                <tr><td width="100%" colspan="2"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td></tr>
                <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"><span>Task Title: </span> <input type="text" class="task_input" required="required" name="title_task" > 
                <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    
                </td>
            </tr>
        <tr>
            <td width="100%" colspan="2"><span>Start Date: </span> <input type="text" class="task_input start_date"  required="required" name="start_date"> </td>
        </tr>
        <tr>
           <td width="100%" colspan="2"><span>End Date: </span> <input type="text" class="task_input end_date"  required="required" name="end_date"> </td>
            </tr> 
			<tr>
                <td width="100%" colspan="2"><span>Contact Person: </span> 
                    <select class="task_input" name="contact_person">' ;
 
        
 if(isset($a_client['persons']))   
 foreach($a_client['persons'] as $ac_person){
              $modal .=  '<option value="'.$ac_person['person_id'].'">'.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].')</option>';
      }
      
      $modal .='</select>
<input type="hidden" name="agent_id" value="'.$agent_id.'" >           
</td></tr> <tr>
                <td width="100%" colspan="2"><input type="button" onclick="addTask_form('.$assign_id.'); " class="orange-btn" value="Submit" name="AddTaskSubmit"></td>
            </tr> 
        </tbody></table></form>
      </div></div></div></div>';
?>       
        
<?php 
//// GET EVENT_TASKS....
$tasks_events = $obj_jobs_class->getEventTasks($assign_id, $event['event_id']);
//print_r($tasks_events);
?>
    <a data-toggle="modal" data-target="#pending_task_<?= $assign_id ?>_" style="cursor: pointer;"  ><i class="fa fa-eye"></i> 
        (<span id="pend_count_<?php echo $assign_id?>_"> <?php echo  count($tasks_events) ?></span>) <small></small>
        </a>   &nbsp;|   &nbsp;
    <?php 
//if(count($tasks_events)>0)
    {
    
$modal .= '<div id="pending_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Pending Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table>';
 
    foreach($tasks_events as $tee ){
        
$modal .='<div class="listing_outline"  id="task_id_'.$tee['task_id'].'_" >
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>
                <tr id="last_row_task_'.$tee['task_id'].'_">
                    <td width="100%" >
                ';
            if(!empty($ac_person['line_ext'])){
                $modal .='<small>Ext: </small> '.$ac_person['line_ext'];
            }
            break;
        }
    }
    $modal .='</td><td>
        <input type="button" class="orange-btn" value="Task Complete" name="TaskCompleteSubmit" onclick="completeTask(\''.$tee['task_id'].'\', \''.$assign_id.'\' ); ">
        <input type="button" class="orange-btn" value="Delete Task " name="DeleteTaskSubmit" onclick="deleteTask('.$tee['task_id'].' , '.$assign_id.')">
            
            </td>
        </tr>
        </tbody></table>
</div>';        

    }
 
$modal .='</form>
      </div></div></div></div>';
 
    }
    
    $completed_tasks_events = $obj_jobs_class->getEventCompletedTasks($assign_id, $event['event_id']);    
?>
        
<a data-toggle="modal" data-target="#completed_task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-check-circle"></i> 
    (<span id="comp_count_<?php echo $assign_id?>_"><?php echo count($completed_tasks_events); ?></span>)
</a>


<?php 

//print_r($tasks_events);
//if(count($completed_tasks_events)>0)
    {
    
$modal .= '<div id="completed_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Completed Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_1'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table> <div class="task_list_box_all">';
 
    foreach($completed_tasks_events  as $tee ){
        
    $modal .='<div class="listing_outline">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>';
            
            if(!empty($ac_person['line_ext'])){
                $modal .='<tr><td width="100%" > <small>Ext: </small> '.$ac_person['line_ext'].'</td><td></td></tr>';
            }
            break;
        }
    }
        $modal .='</tbody></table> </div>';
    }

    $modal .='</div></form>
      </div></div></div></div>';
}
?>
        
</td>
<td> 
<?php
$comment_events = $obj_jobs_class->getEventComments($assign_id, $event['event_id']);
//print_r($comment_events);

if(count($comment_events)>0){
            echo "<span id='f_comnt_".$assign_id."_'>".$comment_events[0]['comments']."</span>";
}else{
            echo "<span id='f_comnt_".$assign_id."_'></span>";
}
    {
    
    $cinr = 1;
    $coment_modal = '';
    foreach($comment_events as $cmn_eve){ 

        $coment_modal .= '<tr><td width="100%">
            <span class="small-gray" style="width:100%;">'.$obj_jobs_class->change_date($cmn_eve['ts']).'</span><br>
            <i class="fa fa-angle-right"></i> '.$cmn_eve['comments'].'
        </td></tr>';
        
        $cinr++;
    } ?>
    <br>
    <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>_" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;  |  &nbsp;
    <a data-toggle="modal" data-target="#comment_view_<?= $assign_id ?>_" style="cursor: pointer;" >
        <i class="fa fa-eye"></i> (<span id="coment_count_<?= $assign_id ?>_"><?php echo count($comment_events)?></span>)    
    </a>
        
        <?php 

echo  '<div id="comment_view_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Comments</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST"><div id="comment_view_list_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
			<tr><td width="100%" ><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>

                
                    '.$coment_modal.'
                           
        </tbody></table></form></div>  
    </div>
  </div>
</div>';


}
    
   /* else { ?>
        <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;
<?php } */
?>  
<?php $modal .=' <div id="comment_add_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Comment</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST" id="form_comment_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"> Comment: <br>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    <input type="hidden" name="agent_id" value="'.$agent_id.'">
                        
                    <textarea class="comment_box" type="text" maxlength="100" class="task_input" required="required" name="comments"  ></textarea>
                </td>
            </tr>
            <tr><td width="100%" colspan="2">
            <input type="button" class="orange-btn" value="Submit"  onclick="add_comment(\''.$assign_id.'\' ); " name="CommentSubmit"></td></tr>
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
</td>
<td class='center-align large-icons'>
    <a   onclick="changeStatus(<?php echo $assign_id ?>, 1);"  style="cursor: pointer;">
        <i class="fa fa-check-square"></i></a> 
    |  
    
        <a data-toggle="modal" data-target="#denied_<?= $a_client['client_id']?>_" style="cursor: pointer;" >
        <i class="fa fa-times-circle"></i></a> 
    
    |  
    <select style="font-size:12px; border:1px solid #ccc; border-radius: 2px; color:cadetblue; padding:5px;" id="pipe_<?php echo $assign_id; ?>_"  onchange="changePipeline('<?php echo ($assign_id)?>', '<?php echo base64_encode($assign_id)?>');">
            <option value="">--Select--</option>
            <option <?php if($a_client['pipeline']==80) echo 'selected="selected"'; ?>  value="80">Hot</option>
            <option <?php if($a_client['pipeline']==50) echo 'selected="selected"'; ?> value="50">Warm</option>
            <option <?php if($a_client['pipeline']==10) echo 'selected="selected"'; ?>value="10">Cold</option>
        </select>

<?php $modal .=' <div id="denied_'.$a_client['client_id'].'_" class="modal fade left-align" role="dialog" style="color: #666;">
    <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Denied Reason</h4>
      </div>
      <div class="modal-body">
	<form action="" method="POST">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> 
                </td></tr>
            <tr>
                <td width="100%" colspan="2"> <br>
                <span style="display:block; float:left; line-height:30px;">
                    Denied Reason: </span>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" id="den_client_'.$assign_id.'_"  name="client_id" value="'.$a_client['client_id'].'">
                        <select id="den_res_'.$assign_id.'_" class="form-control" name="reason" style="width:auto; height:auto;" required="required">
                                <option value="" >---Select--- </option>';
                        foreach ($DeniedReasons as $drr){
                             $modal .= '<option value="'.$drr['id'].'">'.$drr['reason'] .'</option>';
                        }
                //<option value="" > </option>
                                        
    $modal .='</select>
        <br>
        
                </td>
            </tr>
            <tr><td width="100%" colspan="2"><input type="button" onclick="denyStatus('.$assign_id.');" class="orange-btn" value="Submit" name="deniedReason"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
    
        
</td>

            </tr>
                   
<?php        }
        
    }
 
 
 
 foreach($AssignClients as $a_client){
    
        $row_color = '';
        $assign_id = $a_client['assign_id'];
        $assign_CallSMSEmail = $obj_jobs_class->getClientsAssignDetails($a_client['assign_id']);
        if($a_client['status_order'] == 0){$row_color = 'style="background-color:#FFAAAA;"';
?>        
        
           
<tr id="tr_row_<?=$assign_id ?>" <?=$row_color?>>
    <td style="width:1%;"  ><?= $i++ ?></td>
    
    <td><?php echo $a_client['company_name'] ?>
    <br><span style="color:#F47721" ><?php echo $obj_category_class->getCategoriesName($a_client['categories']);?></span>
     </td>
    
    <td><?php 
            if(isset($a_client['persons']))
            if(count($a_client['persons'])>0){
                foreach($a_client['persons'] as $ac_person){
                        echo $ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') / ';
                }
        ?>
            <a data-toggle="modal" data-target="#persons_<?= $a_client['client_id']?>" style="cursor: pointer;" href="#">
                <i class='fa fa-list-ul'></i>
            </a>
       <?php  } ?>
                                

<div id="persons_<?= $a_client['client_id']?>" class="modal fade left-align" role="dialog" >

  <div class="modal-dialog client-modal">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Contact Persons</h4>
        <span onclick="getEditPersons(<?= $a_client['client_id']?>);" style="float: right; right: 50px; position: relative; bottom: 22px; font-size: 14px;">Edit</span>
      </div>
      <div class="modal-body">
	  
          <table style="table-layout: fixed; width: 100%" class="ttttt">
             <tbody><tr>
                 <td width="50%" style="border-top:none !important; "><small>Company: </small> <strong> <?php echo $a_client['company_name'] ?></strong> </td>
                <td width="50%" style="border-top:none !important; "><small>Owner's Name: </small> <strong> <?php echo $a_client['owner_name'] ?> </strong> </td>
            </tr>
             
            <tr>  <td width="50%"><br></td>
                  <td width="50%"> <br></td>
            </tr>
            
            
<?php if(count($a_client['persons'])>0){$per=1; 
                foreach($a_client['persons'] as $ac_person){ ?> 
              
            <!--<tr>
                <td colspan="2" width="100%" style="background-color: #eee;">  <strong>Contact Persons <?php echo $per++; ?></strong></td>
            </tr>-->
            
        <tr>
            <td width='50%' style="background-color: #eee;" > 
                <small> Name: </small> 
                <strong  ><?php echo $ac_person['f_name'].' '.$ac_person['l_name']; ?></strong>
            </td>
            <td width='50%' style="background-color: #eee;"> 
                <small>Designation: </small> 
                <strong  ><?php echo  $ac_person['designation']; ?></strong>
            </td>
        </tr>
            
            
    <tr>
        <td width='50%' colspan="2"> 
        <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_email');">Email: </small> 
        <strong  id="_<?php  echo $ac_person['person_id'];  ?>_email"><?php echo str_replace(", ", ", ", $ac_person['email']); ?></strong>
        </td>
    </tr>
            
    <tr>
        <td width='50%'>
            <small class="pointer btn btn-default p_button" onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_mobile');">Mobile: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_mobile"><?php echo str_replace(", ", ", ",$ac_person['mobile']); ?></strong>
        </td>
                
        <td width='50%'> 
            <small class="pointer " onclick="copier('_<?php  echo $ac_person['person_id'];  ?>_phone');">Land Line: </small> 
            <strong id="_<?php  echo $ac_person['person_id'];  ?>_phone"> <?php echo str_replace(", ", ", ",$ac_person['landline']); ?></strong> 
        </td>
            </tr>
            <tr>
                <td width="50%" colspan="2"><small>Ext: </small> <strong> <?php echo $ac_person['line_ext']; ?> </strong></td>
            </tr>
<?php  }      }   ?>
            
        </tbody></table>
        
      </div>
      
    </div>

  </div>
</div>
	         

       </td>
       <td class='center-align callBoxes'>
           <input type="checkbox" class="all_call" onclick="setStatus_call_sms(<?= $assign_id ?>, 'call')"; name="call[<?= $assign_id ?>]" value="1">
    <span id="row_call_<?= $assign_id ?>"><?php 
       
       if(isset($assign_CallSMSEmail['call']) && !empty($assign_CallSMSEmail['call']) && $assign_CallSMSEmail['call']!='0000-00-00 00:00:00'){ 
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['call']); 
           ?>
       <?php }?></span>
        </td>
        <td class='center-align smsBoxes'>
            
            <input type="checkbox" class="all_sms" onclick="setStatus_call_sms(<?= $assign_id ?>, 'sms')"; name="sms[<?= $assign_id  ?>]" value="1">
            <span id="row_sms_<?= $assign_id ?>">
        <?php if(isset($assign_CallSMSEmail['sms']) && !empty($assign_CallSMSEmail['sms']) && $assign_CallSMSEmail['sms']!='0000-00-00 00:00:00'){
                echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['sms']); 
         }  ?></span>
        </td>
        <td class='center-align emailBoxes'>
            <input type="checkbox" class="all_email"   onclick="setStatus_call_sms(<?= $assign_id ?>, 'email')";   name="email[<?= $assign_id ?>]" value="1">
                <span id="row_email_<?= $assign_id ?>">
            <?php if(isset($assign_CallSMSEmail['email']) && !empty($assign_CallSMSEmail['email']) && $assign_CallSMSEmail['email']!='0000-00-00 00:00:00'){ 
                        echo $obj_jobs_class->change_date_hours($assign_CallSMSEmail['email']); 
                } ?>
                </span>
        </td>
        <td class='center-align'>
            <a data-toggle="modal" data-target="#task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-plus"></i></a> &nbsp;  |   &nbsp;
        
 <?php $modal .= '<div id="task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Task</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
                <tr><td width="100%" colspan="2"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td></tr>
                <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"><span>Task Title: </span> <input type="text" class="task_input" required="required" name="title_task" > 
                <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    
                </td>
            </tr>
        <tr>
            <td width="100%" colspan="2"><span>Start Date: </span> <input type="text" class="task_input start_date"  required="required" name="start_date"> </td>
        </tr>
        <tr>
           <td width="100%" colspan="2"><span>End Date: </span> <input type="text" class="task_input end_date"  required="required" name="end_date"> </td>
            </tr> 
			<tr>
                <td width="100%" colspan="2"><span>Contact Person: </span> 
                    <select class="task_input" name="contact_person">' ;
 
        
 if(isset($a_client['persons']))   
 foreach($a_client['persons'] as $ac_person){
              $modal .=  '<option value="'.$ac_person['person_id'].'">'.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].')</option>';
      }
      
      $modal .='</select>
<input type="hidden" name="agent_id" value="'.$agent_id.'" >           
</td></tr> <tr>
                <td width="100%" colspan="2"><input type="button" onclick="addTask_form('.$assign_id.'); " class="orange-btn" value="Submit" name="AddTaskSubmit"></td>
            </tr> 
        </tbody></table></form>
      </div></div></div></div>';
?>       
        
<?php 
//// GET EVENT_TASKS....
$tasks_events = $obj_jobs_class->getEventTasks($assign_id, $event['event_id']);
//print_r($tasks_events);
?>
    <a data-toggle="modal" data-target="#pending_task_<?= $assign_id ?>_" style="cursor: pointer;"  ><i class="fa fa-eye"></i> 
        (<span id="pend_count_<?php echo $assign_id?>_"> <?php echo  count($tasks_events) ?></span>) <small></small>
        </a>   &nbsp;|   &nbsp;
    <?php 
//if(count($tasks_events)>0)
    {
    
$modal .= '<div id="pending_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Pending Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table>';
 
    foreach($tasks_events as $tee ){
        
$modal .='<div class="listing_outline"  id="task_id_'.$tee['task_id'].'_" >
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>
                <tr id="last_row_task_'.$tee['task_id'].'_">
                    <td width="100%" >
                ';
            if(!empty($ac_person['line_ext'])){
                $modal .='<small>Ext: </small> '.$ac_person['line_ext'];
            }
            break;
        }
    }
    $modal .='</td><td>
        <input type="button" class="orange-btn" value="Task Complete" name="TaskCompleteSubmit" onclick="completeTask(\''.$tee['task_id'].'\', \''.$assign_id.'\' ); ">
        <input type="button" class="orange-btn" value="Delete Task " name="DeleteTaskSubmit" onclick="deleteTask('.$tee['task_id'].' , '.$assign_id.')">
            
            </td>
        </tr>
        </tbody></table>
</div>';        

    }
 
$modal .='</form>
      </div></div></div></div>';
 
    }
    
    $completed_tasks_events = $obj_jobs_class->getEventCompletedTasks($assign_id, $event['event_id']);    
?>
        
<a data-toggle="modal" data-target="#completed_task_<?= $assign_id ?>_" style="cursor: pointer;" ><i class="fa fa-check-circle"></i> 
    (<span id="comp_count_<?php echo $assign_id?>_"><?php echo count($completed_tasks_events); ?></span>)
</a>


<?php 

//print_r($tasks_events);
//if(count($completed_tasks_events)>0)
    {
    
$modal .= '<div id="completed_task_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal" style="width:800px !important;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Completed Tasks</h4>
      </div>
      <div class="modal-body">
	  <form name="task_form_1'.$assign_id.'_" action="" method="POST" id="task_form_'.$assign_id.'_">
              
        <table style="table-layout: fixed; width: 100%; text-align:left;">
            <tbody>
            <tr><td width="50%" style="font-size:15px;"><small>Exhibition: </small> <strong> '.$event['event_name'].'</strong></td>
                <td width="50%"  style="border-top:none !important; font-size:15px; "><small>Company: </small> <strong>'.$a_client['company_name'].'</strong> </td>
            </tr>
        </table> <div class="task_list_box_all">';
 
    foreach($completed_tasks_events  as $tee ){
        
    $modal .='<div class="listing_outline">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="tasks_listing_box">
            <tr class="task_title_row">
                <td width="100%" class="task_title" colspan="2">'.$tee['title'].' 
                <small class="small-gray">Created on : '.$tee['ts'].'</small>
                </td>
            </tr>
        <tr>
            <td width="50%" ><small>Start Date:</small> '.$obj_jobs_class->change_date3($tee['start_date']).'  </td>
            <td width="50%"><small>End Date: </small> '.$obj_jobs_class->change_date3($tee['end_date']).' </td>
        </tr>';

    foreach($a_client['persons'] as $ac_person){
        
        if($ac_person['person_id'] == $tee['person_id']){
            
            $modal .='<tr>
                    <td width="50%" ><small>Contact Person: </small> '.$ac_person['f_name'].' '.$ac_person['l_name'].'('.$ac_person['designation'].') </td>
                    <td width="50%" ><small>Email: </small> '.$ac_person['email'].'</td>
                </tr>
                <tr>
                    <td width="50%" ><small>Mobile: </small> '.$ac_person['mobile'].' </td>
                    <td width="50%" ><small>Land Line: </small> '.$ac_person['landline'].'</td>
                </tr>';
            
            if(!empty($ac_person['line_ext'])){
                $modal .='<tr><td width="100%" > <small>Ext: </small> '.$ac_person['line_ext'].'</td><td></td></tr>';
            }
            break;
        }
    }
        $modal .='</tbody></table> </div>';
    }

    $modal .='</div></form>
      </div></div></div></div>';
}
?>
        
</td>
<td> 
<?php
$comment_events = $obj_jobs_class->getEventComments($assign_id, $event['event_id']);
//print_r($comment_events);

if(count($comment_events)>0){
            echo "<span id='f_comnt_".$assign_id."_'>".$comment_events[0]['comments']."</span>";
}else{
            echo "<span id='f_comnt_".$assign_id."_'></span>";
}
    {
    
    $cinr = 1;
    $coment_modal = '';
    foreach($comment_events as $cmn_eve){ 

        $coment_modal .= '<tr><td width="100%">
            <span class="small-gray" style="width:100%;">'.$obj_jobs_class->change_date($cmn_eve['ts']).'</span><br>
            <i class="fa fa-angle-right"></i> '.$cmn_eve['comments'].'
        </td></tr>';
        
        $cinr++;
    } ?>
    <br>
    <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>_" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;  |  &nbsp;
    <a data-toggle="modal" data-target="#comment_view_<?= $assign_id ?>_" style="cursor: pointer;" >
        <i class="fa fa-eye"></i> (<span id="coment_count_<?= $assign_id ?>_"><?php echo count($comment_events)?></span>)    
    </a>
        
        <?php 

echo  '<div id="comment_view_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Comments</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST"><div id="comment_view_list_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
			<tr><td width="100%" ><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>

                
                    '.$coment_modal.'
                           
        </tbody></table></form></div>  
    </div>
  </div>
</div>';


}
    
   /* else { ?>
        <a data-toggle="modal" data-target="#comment_add_<?= $assign_id ?>" style="cursor: pointer;" href="#"><i class="fa fa-plus"></i></a> &nbsp;
<?php } */
?>  
<?php $modal .=' <div id="comment_add_'.$assign_id.'_" class="modal fade left-align" role="dialog" >
  <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Add Comment</h4>
      </div>
      <div class="modal-body">
	  <form action="" method="POST" id="form_comment_'.$assign_id.'_">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> </td></tr>
            <tr>
                <td width="100%" colspan="2"> Comment: <br>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" name="client_id" value="'.$a_client['client_id'].'">
                    <input type="hidden" name="agent_id" value="'.$agent_id.'">
                        
                    <textarea class="comment_box" type="text" maxlength="100" class="task_input" required="required" name="comments"  ></textarea>
                </td>
            </tr>
            <tr><td width="100%" colspan="2">
            <input type="button" class="orange-btn" value="Submit"  onclick="add_comment(\''.$assign_id.'\' ); " name="CommentSubmit"></td></tr>
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
</td>
<td class='center-align large-icons'>
    <a   onclick="changeStatus(<?php echo $assign_id ?>, 1);"  style="cursor: pointer;">
        <i class="fa fa-check-square"></i></a> 
    |  
    
        <a data-toggle="modal" data-target="#denied_<?= $a_client['client_id']?>_" style="cursor: pointer;" >
        <i class="fa fa-times-circle"></i></a> 
    
    |  
    <select style="font-size:12px; border:1px solid #ccc; border-radius: 2px; color:cadetblue; padding:5px;" id="pipe_<?php echo $assign_id; ?>_"  onchange="changePipeline('<?php echo ($assign_id)?>', '<?php echo base64_encode($assign_id)?>');">
            <option value="">--Select--</option>
            <option <?php if($a_client['pipeline']==80) echo 'selected="selected"'; ?>  value="80">Hot</option>
            <option <?php if($a_client['pipeline']==50) echo 'selected="selected"'; ?> value="50">Warm</option>
            <option <?php if($a_client['pipeline']==10) echo 'selected="selected"'; ?>value="10">Cold</option>
        </select>

<?php $modal .=' <div id="denied_'.$a_client['client_id'].'_" class="modal fade left-align" role="dialog" style="color: #666;">
    <div class="modal-dialog client-modal">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h4 class="modal-title">Denied Reason</h4>
      </div>
      <div class="modal-body">
	<form action="" method="POST">
        <table style="table-layout: fixed; width: 100%; text-align:left;" class="modal-table">
            <tbody>
            <tr><td width="100%" colspan="2"><small>Exhibition: </small><strong>'.$event['event_name'].' </strong></td></tr>
            <tr><td width="100%" colspan="2" style="border-top:none !important; "><small>Company:</small><strong> '.$a_client['company_name'].'</strong> 
                </td></tr>
            <tr>
                <td width="100%" colspan="2"> <br>
                <span style="display:block; float:left; line-height:30px;">
                    Denied Reason: </span>
                    <input type="hidden" name="assign_id" value="'.$assign_id.'"> 
                    <input type="hidden" name="event_id" value="'.$event['event_id'].'"> 
                    <input type="hidden" id="den_client_'.$assign_id.'_"  name="client_id" value="'.$a_client['client_id'].'">
                        <select id="den_res_'.$assign_id.'_" class="form-control" name="reason" style="width:auto; height:auto;" required="required">
                                <option value="" >---Select--- </option>';
                        foreach ($DeniedReasons as $drr){
                             $modal .= '<option value="'.$drr['id'].'">'.$drr['reason'] .'</option>';
                        }
                //<option value="" > </option>
                                        
    $modal .='</select>
        <br>
        
                </td>
            </tr>
            <tr><td width="100%" colspan="2"><input type="button" onclick="denyStatus('.$assign_id.');" class="orange-btn" value="Submit" name="deniedReason"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
    
        
</td>

            </tr>
                              
<?php        }
    }
 ?>
                        </tbody>
                </table>
              </div>
              
            <div class="col-sm-12">
        <!--	<div class="btn-box">
                    <button type="button" onclick="submit_form();" name="submit_now" class="btn btn-default">Submit Now</button>
            </div -->
        </div>
        </form>  

<?php echo $modal;?>
        </div>
    </div>
</div>
</div>
</div>

<?php include("_includes/footer.php"); ?>
<script src="js/clipboard.js"></script>

<script>

function setStatus_call_sms(key,value){
       
        var url = 'ajax.php?task=add_assign_call_sms&key='+key+'&value='+value;
        /*$.post('ajax.php?task=add_step3Task&event='+event+'&client='+client+'&agent='+agent+'&task_id='+task+'&stat='+stat+'&1=1', function(data){
                console.log(data);
                //if(data=='1'){     location.reload();  }
        })*/
        
           $.ajax({
              type: "POST",
              url: url,
              data: 'id', // serializes the form's elements.
              success: function(data){
                  //console.log(data);
                   {
                    // $("#status_"+client+"_").html('<div class="progress-box-innr" style="width:'+data+'%"> </div><span>'+data+'%</span>')
$("#row_"+value+"_"+key).html(data);
                     
                  }
              }
            });
}  
    function add_comment(id){  
       
       
          var url = 'ajax.php?task=add_comments';
            $.ajax({
              type: "POST",
              url: url,
              data: $("#form_comment_"+id+"_").serialize(), // 'task_form_'+id+'_', // serializes the form's elements.
              success: function(data){
                  
                  if(data!=''){
                      
                    var comment = $("#form_comment_"+id+"_ .comment_box").val();
                    $("#form_comment_"+id+"_ .comment_box").val('');
                    
                    $("#comment_view_list_"+id+"_").html(data);
                    $("#comment_add_"+id+"_ .close").click();
                    old = $("#f_comnt_"+id+"_").html();
                    $("#f_comnt_"+id+"_").html(comment);
                    
                    com_c = $("#coment_count_"+id+"_").html();
                    com_c = parseInt(com_c)+1;
                    $("#coment_count_"+id+"_").html(com_c); 
                }
              }
            });
        }
        

    function addTask_form(id){ 
       
            var url = 'ajax.php?task=add_exiTask';
            $.ajax({
              type: "POST",
              url: url,
              data: $("#task_form_"+id+"_").serialize(), // 'task_form_'+id+'_', // serializes the form's elements.
              success: function(data){
                  if(data!=''){
                    //console.log(data);
                    $("#pending_task_"+id+"_").html(data);
                    $("#task_"+id+"_ .close").click();
                    //$("#pending_task_"+id+"_").modal('toggle');
                    cc = $("#pend_count_"+id+"_").html();
                    cc = parseInt(cc)+1;
                    $("#pend_count_"+id+"_").html(cc);
                    
                    $("#task_form_"+id+"_ .task_input").val(''); 
                }
                    
              }
            });
        }


    function completeTask(id, assg){
        
        $.post('ajax.php?id='+id+'&task=complete_task', function(data){
            
            if(data=='1'){

            cc = $("#pend_count_"+assg+"_").html();
            cc = parseInt(cc);
            if(cc > 0){
                task_html = '';
                task_html = $("#pending_task_"+assg+"_ #task_id_"+id+"_").html();
//console.log(task_html );
                $("#pending_task_"+assg+"_ #task_id_"+id+"_").html();
                $("#pending_task_"+assg+"_ #task_id_"+id+"_").html('');
                $("#pending_task_"+assg+"_ #task_id_"+id+"_").css('display','none');

                comp_html = $("#completed_task_"+assg+"_ .task_list_box_all").html();
                $("#completed_task_"+assg+"_ .task_list_box_all").html(comp_html +'<div class="listing_outline" id="task_id_'+id+'_">'+task_html+'</div>');
                $("#completed_task_"+assg+"_ #last_row_task_"+id+"_").html('');

                cc = parseInt(cc)-1;
                $("#pend_count_"+assg+"_").html(cc);

                com = $("#comp_count_"+assg+"_").html();
                com = parseInt(com)+1;
                $("#comp_count_"+assg+"_").html(com);
                
              
                
                //task_html = $("#pending_task_"+assg+"_ #task_id_"+id+"_").html();
            }
          }
		    $("#pending_task_"+assg+"_").modal('toggle');
        })

    } 

$(document).ready(function() {
//        $('#example').DataTable();
            $('#example').dataTable( {
                  "aoColumnDefs": [
                      { 'bSortable': false, 'aTargets': [ 1 ] }
                   ]
            });

        $('#CallAll').click(function(){
            
            console.log($(this).attr('checked'));
            if($(this).is(':checked')){
                $('input:checkbox.all_call').attr('checked',true);
                $('.all_call').css('display', 'none');
                $('.sellect_call').css('display', 'inline-block');
            }
            else{  
                $('input:checkbox.all_call').attr('checked',false);
                $('.sellect_call').css('display', 'none');    
                $('.all_call').css('display', 'inline-block')
            }
        });
        
        $('#SMSAll').click(function(){
            
            console.log($(this).attr('checked'));
            if($(this).is(':checked')){
                $('input:checkbox.all_sms').attr('checked',true);
                $('.all_sms').css('display', 'none');
                $('.sellect_sms').css('display', 'inline-block');
            }
            else{  
                $('input:checkbox.all_sms').attr('checked',false);
                $('.sellect_sms').css('display', 'none');    
                $('.all_sms').css('display', 'inline-block')
            }
        });

	$('#EmailAll').click(function(){
            
            console.log($(this).attr('checked'));
            if($(this).is(':checked')){
                $('input:checkbox.all_email').attr('checked',true);
                $('.all_email').css('display', 'none');
                $('.sellect_email').css('display', 'inline-block');
            }
            else{  
                $('input:checkbox.all_email').attr('checked',false);
                $('.sellect_email').css('display', 'none');    
                $('.all_email').css('display', 'inline-block')
            }
        });
    });

function redirect(){
        var cat = $('#category').val();
        window.location='assign_client.php?cat='+cat+'&event=<?php  // $_GET['event']?>';
}

function changePipeline(as_id, as_id_code){
    
        var stat = $("#pipe_"+as_id+"_").val();
        
        if(stat !=''){
            var url = 'ajax.php?task=pipline&event=<?php echo $_GET["event"]; ?>&st=<?php echo base64_encode('4')?>&as='+as_id_code+'&st_code='+stat;
          
            $.ajax({
              type: "POST",
              url: url,
              data: 'id', // serializes the form's elements.
              success: function(data){
                console.log(data);
                $("#tr_row_"+as_id).css('background-color','#FDF704');
              }
            });
            
        }
}

function changeStatus(as_id, stat){
    
             
         if(confirm("Are you sure you want to Approve this client ?")){
                if(stat !=''){
                        var url = 'ajax.php?task=changeStatus&asign='+as_id+'&st_code='+stat;
                        $.ajax({
                          type: "POST",
                          url: url,
                          data: 'id', // serializes the form's elements.
                          success: function(data){
                            console.log(data);
                            $("#tr_row_"+as_id).css('background-color','#BBEF7E');
                          }
                        });
                    }
                
            }
            else{
                return false;
            } 
}

function denyStatus(as_id){
        
        var stat = $("#den_res_"+as_id+"_").val();        
        var client = $("#den_client_"+as_id+"_").val();
        
        if(stat != ""){
            var url = 'ajax.php?task=deniedStatus&assign_id='+as_id+'&reason='+stat;
            $.ajax({
              type: "POST",
              url: url,
              data: 'id', //serializes the form's elements.
              success: function(data){
                  
                    $("#tr_row_"+as_id).css('background-color','#FFAAAA');
                    $("#denied_"+client+"_ .close").click();
                    
                    console.log("#denied_"+client+"_");
              }
            });
        }
}


function submit_form(){
    
        var url = "ajax.php?task=add_assign"; 
        $.ajax({
              type: "POST",
              url: url,
              data: $("#assignForm").serialize(), // serializes the form's elements.
              success: function(data){

                    console.log(data);
                  //  location.reload();
                    if(data=='1'){}
              }
            });
        }         
        
        
function addTask_form22(id){
        //alert(id);
        var url = "ajax.php?task=add_task_form"; 
        $.ajax({
              type: "POST",
              url: url,
              data: $("#task_form_"+id+"_").serialize(), // serializes the form's elements.
              success: function(data)
              {
                  alert(data); // show response from the php script.
                  //if(data=='1'){ location.reload();  }
                  
              }
            });
        }
        
        
function deleteTask(id, assg){ 
        var url = "ajax.php?id="+id+"&task=delete_task"; 
        $.ajax({
              type: "POST",
              url: url,
              //data: 'id', // serializes the form's elements.
              success: function(data){ 
                  
                      $("#pending_task_"+assg+"_ #task_id_"+id+"_").html('');
                      $("#pending_task_"+assg+"_ #task_id_"+id+"_").css('display','none');
              }
            });
        }
        
</script>


<script>
$(document).ready(function(){
    
     
        
        
    $(".start_date").datepicker({
        dateFormat: 'yy-mm-dd',
        numberOfMonths: 1,
        onSelect: function(selected) {
          $(".end_date").datepicker("option","minDate", selected)
        }
    });
    $(".end_date").datepicker({
        dateFormat: 'yy-mm-dd',
        numberOfMonths: 1,
        onSelect: function(selected) {
           //$("#start_date").datepicker("option","maxDate", selected)
        }
    });  


$('#exampleNew').dataTable( {
    "ordering": false,
	"pageLength": <?php echo count($AssignClients); ?>,
      "aoColumnDefs": [
          { 'bSortable': false, 'aTargets': [ 1 ]  }
       ]
});


   
});

function copier(tt){
            var vall = $("#"+tt).html();
            clipboard.copy(vall);
        }
function getEditPersons(id){
        
        $.post('ajax.php?getEditClient=1&client_id='+id, function (res){
            $("#persons_edit").html(res);
            $("#persons_"+id).modal('hide');
            $("#persons_edit").modal('show');
        });
}       
        
function delPerson(id){

        var r = confirm('Are you sure you want to delete?'); 
				if (r == true) {
				$.post('ajax.php?delPerson=1&p_id='+id, function (res){
					$("#b_"+id).fadeOut(200);
					$("#b_"+id).html('');
				});
		}
}         

function checkAll(type){
    
    
     if($("#check_"+type).prop("checked") == true){
        $.post('ajax.php?checkSMS=1&event=<?= $exhibition_id ?>&agent=<?= $agent_id ?>&type='+type, function (res){
            $("."+type+"Boxes").html(res);
           ///console.log(res)
        });
    } //else {alert('as')}
}



</script>
 
<div id="persons_edit" class="modal fade left-align" role="dialog" ></div>



	         
