<?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;
    }
</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';
            }
            
            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 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 " >
                    <thead>
                            <tr>
                            	<th>Sr. </th>
                                <th>Company Name </th>
				<th style="width:300px;">Contact Persons </th>
                                <th class='center-align' >Call 
                                    <!--<br> <input id="CallAll" type="checkbox" name="CallAll" value="all"> -->
                                </th>
                                <th class='center-align' >SMS 
                                    <!--<br> <input id="SMSAll" type="checkbox" name="SMSAll" value="all">-->
                                </th>
                                <th class='center-align'>Email
                                    <!--<br> <input id="EmailAll" type="checkbox" name="EmailAll" value="all">-->
                                </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){$row_color = 'style="background-color:#FDF704"';}
    ?>
                            
<tr <?=$row_color?>>
    <td><?= $i++ ?></td>
    
    <td><?php echo $a_client['company_name'] ?> </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>
      </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 width="100%" style="background-color: #eee;">
                <td width="50%"> <small>Name: </small> <strong> <?php echo $ac_person['f_name'].' '.$ac_person['l_name']; ?> </strong> </td>
                <td width="50%"><small>Designation: </small> <strong> <?php echo $ac_person['designation']; ?> </strong></td>
            </tr>
            <tr>
                <td width="50%" colspan="2"> <small>Email: </small> <strong>  <?php echo $ac_person['email']; ?> </strong> </td>
            </tr>
            
            <tr>
                <td width="50%"><small>Mobile: </small> <strong>  <?php echo $ac_person['mobile']; ?> </strong></td>
                <td width="50%"> <small>Land Line: </small> <strong>  <?php echo $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'>
        <input type="checkbox" class="all_call" name="call[<?= $assign_id ?>]" value="1">
       <?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 } ?>
        
        </td>
        <td class='center-align'>
        <?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']); 
         } else {?>
            <input type="checkbox" class="all_sms" name="sms[<?= $assign_id  ?>]" value="1">
         <?php } ?>
        </td>
        <td class='center-align'>

        <?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']); 
              }else { ?>
            <input type="checkbox" class="all_email" name="email[<?= $assign_id ?>]" value="1">
        <?php } ?>

        </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></td></tr> <tr>
                <td width="100%" colspan="2"><input type="submit" onclick="ad1dTask_form('.$assign_id.'); " class="orange-btn" value="Save" 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> 
            (<?php echo  count($tasks_events) ?>)<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">
        <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>
                    <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'].'\'); ">
                <input type="button" class="orange-btn" value="Delete Task " name="DeleteTaskSubmit" onclick="deleteTask('.$tee['task_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> 
(<?php echo count($completed_tasks_events); ?>)
</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>';
 
    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 .='</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){$cinr = 1;
    $coment_modal = '';
    foreach($comment_events as $cmn_eve){
        if($cinr == 1){
            echo $cmn_eve['comments'];
        }
        
            $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> (<?php echo count($comment_events)?>)</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">
        <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>';


}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">
        <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'].'">
                        <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="submit" class="orange-btn" value="Save" name="CommentSubmit"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
        
</td>
<td class='center-align large-icons'>
    <a href="assign_client_step2.php?event=<?php echo $_GET['event']; ?>&st=<?php echo base64_encode('1')?>&as=<?php echo base64_encode($assign_id)?>" onclick="return window.confirm('Are you sure you want to Done this Client?');" >
        <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" name="client_id" value="'.$a_client['client_id'].'">
                        <select 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="submit" class="orange-btn" value="Save" name="deniedReason"></td></tr> 
            </tbody>
        </table></form>
      </div> </div> </div></div></div>';
?>
    
        
</td>

            </tr>
                        <?php } ?>
                	</tbody>
                </table>
              </div>
              
        </form>  

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


<?php include("_includes/footer.php"); ?>
<script>
    
    function completeTask(id){
        $.post('ajax.php?id='+id+'&task=complete_task', function(data){
            console.log(data);
             if(data=='1'){
                     location.reload();
                  }
        })
    }




$(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 = 'assign_client_step2.php?event=<?php echo $_GET["event"]; ?>&st=<?php echo base64_encode('4')?>&as='+as_id_code+'&st_code='+stat;
            //alert(url);
            window.location=url;
            
        }
}



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_form(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){
        //alert(id);
        var url = "ajax.php?id="+id+"&task=delete_task"; 
        $.ajax({
              type: "POST",
              url: url,
              data: 'id', // serializes the form's elements.
              success: function(data){
                   if(data=='1'){
                       
                     location.reload();
                  }
              }
            });
        }
        
</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)
        }
    });  
});
</script>
 