<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
    <script src="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.min.js"></script>
	
	
 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script>

         <script type="text/javascript">
  
	  $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });

		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		$(document).on("click", "#editbtn", function()
        {
     	     var dealid = $(this).data('id');
		  $("#dealid").val(dealid);  	
          var owner = $(this).data('owner');
		  $("#owner").val(owner); 
		  
		    var dealowner = $(this).data('dealowner');
		   $("#dealowner").val(dealowner); 
		   
		     var title = $(this).data('title');
		   $("#title").val(title); 
		 
		     var type = $(this).data('type');
		   $("#type").val(type);


		     var nextstep = $(this).data('type');
		   $("#nextstep").val(nextstep); 

		     var contactname = $(this).data('contactname');
		   $("#contactname").val(contactname); 		
	
		   
 var 	todate = $(this).data('todate');
		   $("#todate").val(todate); 		
 var contact = $(this).data('contact');
		   $("#contact").val(contact); 		
 var probability = $(this).data('probability');
		   $("#probability").val(probability); 		
 var expectedrevenue = $(this).data('expectedrevenue');
		   $("#expectedrevenue").val(expectedrevenue); 	

 var amount = $(this).data('amount');
		   $("#amount").val(amount);
		   
		    var comments = $(this).data('comments');
		   $("#comments").val(comments);
		   
		       var stage = $(this).data('stage');
		   $("#stage").val(stage);
		   
		       var fromdate = $(this).data('fromdate');
		   $("#fromdate").val(fromdate);
		   
		      var allsteps = $(this).data('allsteps');
		   $("#allsteps").val(allsteps);
		  
        });
		
		
		
		
		
		
		
			
		
		
		
		
		
		
    </script>  

 
    <script type="text/javascript">  
 
    $(this).ready( function() {  
            $("#newdeals").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/newdealslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
 
     </script>  
	 
	 
	  
    <script type="text/javascript">  
 
    $(this).ready( function() {  
            $("#newdeals").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/newdealslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
 
     </script>  
	 
	 
	 
    <script type="text/javascript">  
 
    $(this).ready( function() {  
            $("#firstfeedback").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/newdealsfeedbacklookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
 
     </script>  
	 
	 
	 
	 
	 
	 
	 
	 
	 
   <script type="text/javascript">  
 
    $(this).ready( function() {  
            $("#routes").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/newcategories",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
 
     </script>  
 
 <div class="row">
  
   	

   	<div class="col-md-12">
<?PHP
				$session_data = $this->session->userdata('logged_in');

    $session_data = $this->session->userdata('logged_in');
 $finalendate=date("Y-m-d H:59:59");
  $finalstartdate=date("Y-m-d 00:00:00");
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];


				 $mydate=date("Y-m-d");
				
				$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 
	 
	 
	 
	 	   $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 			    $viewcontact=$this->usermodel->populatuserpermissionsdataarray('deals','viewcontact',$userid);
			    $addpossiblefeedback=$this->usermodel->populatuserpermissionsdataarray('deals','addpossiblefeedback',$userid);
			    $transferdeals=$this->usermodel->populatuserpermissionsdataarray('deals','transferdeals',$userid);
			    $AddAgents=$this->usermodel->populatuserpermissionsdataarray('deals','AddAgents',$userid);
			    $downloaddeals=$this->usermodel->populatuserpermissionsdataarray('deals','downloaddeals',$userid);
	   $viewallaction=$this->usermodel->populatuserpermissionsdataarray('deals','viewall',$userid);

			    $viewalldeals=$this->usermodel->populatuserpermissionsdataarray('deals','viewall',$userid);
					$smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
	  $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
 echo $this->session->flashdata('deletemsg'); 

								?>	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> View deals</span>
				    <a data-toggle='modal' data-target='#addModal' class="btn btn-default">Add New Deal/Customer </a>

	 				    <a data-toggle='modal' data-target='#addfollowupModal' class="btn btn-default">Add Follow-Up </a>
<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/allquatation"> Quotation </a>

<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viedeals"> View my deals </a>
				<?php
		
		 if($viewalldeals==true){

			 ?> 
			  <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/viewotherdeals"> View other  deals </a>
			
	<?php

 }else{
 }
  ?>
  <a  id="more" target="blank" class="btn btn-warning" href="<?php echo base_url();?>user/viewmoredealstoday"> Deals due today </a>

<a  id="more" target="blank" class="btn btn-warning" href="<?php echo base_url();?>user/viewmoredeals"> Pending Deals </a>
<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewallfollowups"> Deals follow-ups </a>
 
 <a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/salesfollowups"> Deptors follow-ups </a>
  <a  id="more" target="blank" class="btn btn-warning" href="<?php echo base_url();?>user/salesdue"> Deptors Due </a>

<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewallcustomer"> Customers follow-ups </a>
<a  id="more" target="blank" class="btn btn-warning" href="<?php echo base_url();?>user/viewallcustomerdue"> Customers Due </a>

 	 <?php
	 if($downloaddeals==true){											
				?>
 <a data-toggle='modal' data-target='#colectionModal' class="btn btn-default"> Download	Daily deals</a>
 		<a href="<?php echo base_url();?>user/downloaddeals" class="btn btn-info">download    Deals </a>	 

  <?php
	 }										
				?>
 
 <a data-toggle='modal' data-target='#uploaddealModal' class="btn btn-info"> Upload 	Daily deals</a>
<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewallpostedsales"> All Posted sales </a>

				 <?php
	 if($viewalldeals==true){											
											?>

<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewagentscustomers">View online customers </a>

										<?php
										}
										
											?>
											
											
			<?php
		
		 if($addpossiblefeedback==true){

			 ?> 
			<a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewdealsfeedback">View/add Deals Feedback </a>
 
			 
				<?php
				}
										
			?>	

			<a  id="more" target="blank" class="btn btn-info" href="<?php echo base_url();?>user/viewrecordings">View / Listen to Recordings </a>

			
				<?php
		
		 if($transferdeals==true){

			 ?> 
			  <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/transferdeals"> Transfer deals </a>
			
	<?php

 }else{
 }
  ?>
  
				
				<?php
		
		 if($AddAgents==true){

			 ?> 
			  <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/allresellers"> Resellers  </a>
			
	<?php

 }else{
 }
  ?>
  	
			
			
			
			
			
			
            	</div>
					<br>


<?php 
			 				echo $this->session->flashdata('deletemsg'); 

		 echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallmydeals", $attr);?>
	

            <div class="form-group">
			
                <div class="col-md-9">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for deals, by name,conatct etc.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                 <div class="col-md-3">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/viedeals"; ?>" class="btn btn-default">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP
 $mydate=date("Y-m-d");
 echo $this->session->flashdata('deletemsg'); 
								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
								<div class="col-md-12">
        <?php 
		
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchalldeals", $attr);?>
            <div class="form-group">
			
                <div class="col-md-3">
				
				

     <div class="form-group">
    <label for="inputsearchterm" class="col-sm-2 control-label">Staff?</label>
    <div class="col-sm-10">
	<select class="chzn-select" name="searchterm" required>
	
	<option value=""  >---Select user---</option>

						<?php
		 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $myuserid = $data['id'];
			 if($viewalldeals==true){
			//$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'status',1);
			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

			
			?>
						<option value="all"  >All 	users</option>
<?php


 }else{
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$myuserid,'status',1);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected"  value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('searchterm'); ?>

	</div>
  </div>
				
                </div>
				
				
				
				
					 <div class="col-md-2">



   
	    <div class="col-md-12">
				<div class="col-sm-7">
					<div class="form-group">

                     		  		<input type="date" name="startdate" value="<?php echo set_value('fromdate',date("Y-m-d", strtotime($finalstartdate))); ?>" class="form-control2" required placeholder="Enter start date">

					</div>
				</div>
				<div class="col-sm-5">
					<div class="form-group">
					

							  		<input type="time"  name="frotime" value="<?php echo set_value('frotime',$starttime.":00"); ?>" class="form-control2" required placeholder="Enter start time">

					</div>
				</div>
			
</div>







					</div>
				
				
				
				  <div class="col-md-2">
				
				
				
			

				<div class="col-sm-6">
					<div class="form-group">

		  		<input type="date" name="closedate" value="<?php echo set_value('closedate',date("Y-m-d", strtotime($finalendate))); ?>" class="form-control2" required placeholder="Enter End date">

					</div>
				</div>
				<div class="col-sm-4">
					<div class="form-group">
					

							  		<input type="time"  name="totime" value="<?php echo set_value('totime',$duetime.":00"); ?>" class="form-control2" required placeholder="Enter stop time">

					</div>
				</div>
  
				
				
				
					</div>
				
				
				
				
				
				
				
				
				
				
				
				
				
				
			
					  <div class="col-md-2">
<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"  >All branches/Counters</option>
								

	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>













					</div>
				
				
				
				
				
                <div class="col-md-3">
				
<select class="form-control2" name="dealtype"  id="dealtype" required>
	
	
	<option value=""  >---Select Deal type--</option>

									
					<option value="Normal" selected >Normal Deals</option>
												<option value="Overdue"  >Overdue Deals</option>
	

</select>



		
		Action :<select class="form-control2" name="action" id="action" >

	<option value="" >---Select Action --</option>
	
		<option value="all" selected="selected" >---All --</option>

	
	
	
	
	
	<?php 
					 
			$groups =  $this->usermodel->populateall('dealstatus','companyid',$companyid);
	

	
if(is_array($groups)) {

   foreach($groups as $grouprowdeals){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $grouprowdeals->name;   ?>"><?=  $grouprowdeals->name; ?></option>



	<?php

}} else {
    echo 'No supplier available.';
}
	
?>
	
	

	</select>








                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/viedeals"; ?>" class="btn btn-default">Refresh</a>
					
					
                </div>
				 
            </div>
        <?php echo form_close(); ?>

        </div>	
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
		 	     <th>Followup</th>
		 <th>Due Date</th>

		  
	
		
     <th>Business Name</th>
     <th>Deal Title</th>
	  <th>Route</th>
	   <th>Contact </th>	

	     <th>Type</th>
<th>Feedback</th>	
<th>Comments</th>	
		  
		 <th>Amount</th>
	  <th>Start Date</th> 
	  <th>Status</th>
	    <th>User</th>

	    <th>Started by</th>
	<th>Branch</th>

	<th>More</th>


                 </tr>
             </thead>
<?php

 if(!is_array($viedeals)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='10'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($viedeals as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>
<td>

											   <a  id="more" target="_blank" class="btn btn-default" href="<?php echo base_url();?>user/viewfollowups?randomitemidentifier=<?php   {echo  $id;}  ?>&type=Deal&currentid=na">Follow-Up </a>

</td>
 	
		
		
		      	  

		    <td><?php 
echo $c->todate ;
$endate=$c->todate;
    		  $newDate = date('Y-m-d H:i:s');

	  //$newDate = date("Y-m-d");


		$mycurrentdate = strtotime(date($newDate));

	




$finaldate = strtotime(date($c->todate));
$exactdate = strtotime(date($c->todate));

									$secs = $mycurrentdate-$finaldate;// == <seconds between the two times>
									$days = $secs / 86400;
							 $finaldays=round($days,0);

if((trim($c->status)!="Interested") && (trim($c->status)!="Green")&& (trim($c->status)!="Call Later")&& (trim($c->status)!="Not Picking") ){

		?>
			<div class="btn-success">


			</div>
			<?php
	
	
}else{

			 ?>
			 
			 
			<?php 
			
			if($finaldays <= 0){
			
			
						if(($finaldays == -0) ||($finaldays == -1)) {

	$hours = (($secs / 3600)* -1);
															 $finalhrs=round($hours,0);

					?>
			<div class="btn-success">
			<?php  echo $finalhrs." Hr(s) Due" ; 	?>
			</div>
			<?php
	
						}else{
							?>
			<div class="btn-success">
			<?php  echo $finaldays." Due" ; 	?>
			</div>
			<?php
						}
			
			
			
			}else if(($finaldays > 0) && ($finaldays <3)) {
		?>
			<div class="btn-warning">
			<?php  echo $finaldays." Overdue"  ; 	?>
			</div>
			<?php
			
			}else if($finaldays >=3){
			?>
			<div class="btn-danger">
			<?php  echo $finaldays." Overdue" ; 	?>
			</div>
			<?php
			}else{
				
			?>
			<div class="btn-danger">
			<?php  echo $success." Overdue" ; 	?>
			</div>
			<?php	
				
			}
}
			?>	
			 
			 
			 
			 
			 
			 
			 
			 </td>

      <td><?php echo $c->owner ; ?></td>     	  
  <td><?php echo $c->title ; ?></td>
    	  <td><?php echo $c->probability ; ?></td>

   <td><?php 
   $dealowner=$c->dealowner;

if($userid ==  $c->userid){
	echo $c->contact ;
}else{
		
		 if($viewcontact==true){
			 	echo $c->contact ;
		 }else{
			 
		 }
	
}

   ?></td>
    <td><?php echo $c->type ; ?></td>
	  <td><?php echo $c->allsteps ; ?></td>
	  <td><?php echo $c->comments ; ?></td>


	<td><?php echo $c->amount ; ?></td>
      <td><?php echo $c->fromdate ; ?></td>      

	<td><?php echo $c->status ; ?></td>



	 <td><?php ; 
	 
   if($c->userid!=""){
	  
      $myname = $this->usermodel->geteuser($c->userid);
  
     $fname=$myname[0]['firstname']; 
echo $names= $fname; 
	
   }else{
	    echo "No Sender";  
   }
   ?>
            	 	 </td> 





	 <td><?php ; 
	 
   if($dealowner!=""){
	  
      $myname = $this->usermodel->geteuser($dealowner);
  
     $fname=$myname[0]['firstname']; 
echo $names= $fname; 
	
   }else{
	    echo "No Sender";  
   }
   ?>
            	 	 </td> 
					 
					<td>

<?php
	 $Branchdetails = $this->usermodel->populateallarray('branch','id',$c->branchid);

   echo $Branchdetails[0]['name'];

?>







</td>					
					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
<td>
 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        

											  <li>
											 <a  id="more" target="_blank" class="btn btn-default" href="<?php echo base_url();?>user/viewfollowups?randomitemidentifier=<?php   {echo  $id;}  ?>&type=Deal&currentid=na">Follow-Up </a>

												</li>
												                                  <li class="divider"></li>	

										<?php
	 if($viewalldeals==true){											
											?>
											<!---
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
														
														-->
									<?php
										}
										?>
									
                                        <li class="divider"></li>	
										  <li> 

 <a class="btn btn-default editbtn" id="editbtn" data-owner='<?php echo  $c->owner;?>' data-dealowner='<?php echo  $c->dealowner;?>'  data-stage='<?php echo  $c->stage;?>'data-title='<?php echo  $c->title;?>' data-type='<?php echo  $c->type;?>'	data-nextstep='<?php echo  $c->nextstep;?>'  data-contactname='<?php echo  $c->contactname;?>' data-amount='<?php echo  $c->amount;?>'data-contact='<?php echo  $c->contact;?>' data-todate='<?php echo  $c->todate;?>' data-probability='<?php echo  $c->probability;?>' data-allsteps='<?php echo  $c->allsteps;?>'data-comments='<?php echo  $c->comments;?>' data-expectedrevenue='<?php echo  $c->expectedrevenue;?>'	data-fromdate='<?php echo  $c->fromdate;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editModel'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																View/ Edit 
                                                </a>
											</li> 
											                                      </ul>                                      
    
										
                                </div>
</td>
     		  
             </tr>

	<?php endforeach;} ?>

       

        </table>
		<div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Deal/Lead (s) in the system. " ;?>    </span>

        
        </div>
	</div>
	
	
	
	
	
	
	<div id="uploaddealModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Please Upload daily deals</h4>
		 <a href="<?php echo base_url();?>downloads/deals.xlsx" class="btn btn-primary">Download   deals template </a>	 

      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploaddeals' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
<input type="hidden" name="type" value="child"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viedeals"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="deals" name="btn_uploaddeals" class="btn btn-default">Upload deals  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>
	
	
	
	
	
	
	
	
	
	
	
	
		<div id="deleteModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="deals">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viedeals">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>			
	<div id="addModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new Customer</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');

		 $myuserid = $data['id'];
		 $userid = $data['id'];

 	 			 	$finalsalesid = $myuserid.time();

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/adddeals' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
		  		<input type="hidden" name="finalsalesid" value="<?php echo set_value('finalsalesid',$finalsalesid); ?>" class="form-control"  placeholder="Enter  finalsalesid">

				
				


				  
  
  
  <div class="form-group">
    <label for="inputcontact" class="col-sm-2 control-label">Phone Number</label>
    <div class="col-sm-10">
	
		  		<input type="text" id="newdeals" name="contact" value="<?php echo set_value('contact'); ?>" class="form-control"  placeholder="Enter contact eg 2547XXXXX ">
		 
				
		<span class="text-danger"> <?php echo form_error('contact'); ?>
		
		</span>
	</div>
  </div>

				
				
				
				
				
				
				
	<div class="form-group">
    <label for="inputowner" class="col-sm-2 control-label">	Business Name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="owner" value="<?php echo set_value('owner'); ?>" class="form-control"  placeholder="Enter Business and  customer Name">
		 
				
		<span class="text-danger">Business Name - Customer Name <?php echo form_error('owner'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
				<div class="form-group" style="display:none">
    <label for="inputcontactname" class="col-sm-2 control-label">	 Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contactname"  value="<?php echo set_value('contactname'); ?>" class="form-control"  placeholder="Enter contact name ">
		 
				
		<span class="text-danger"> <?php echo form_error('contactname'); ?>
		
		</span>
	</div>
  </div>
  
  
				
  
  
  
  
  


  <div class="form-group">
    <label for="inputtitle" class="col-sm-2 control-label">Deal title </label>
    <div class="col-sm-10">
	<select class="form-control" name="title" required>
	
	<option value=""  >---Select Deal title ---</option>

	<?php 
					 
			$group =  $this->usermodel->populateall('mainservices','companyid',$companyid);
	

	
if(is_array($group)) {

   foreach($group as $grouprow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $grouprow->name;   ?>"><?=  $grouprow->name; ?></option>



	<?php

}} else {
    echo 'No supplier available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('title'); ?>

	</div>
  </div>
  
  
	
  
  <div class="form-group"  >
    <label for="inputtype" class="col-sm-2 control-label">Customer Source ?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	
	<option value=""  >---select deal type--</option>

		
	<option value=""  >---select deal type--</option>
			<option value="Event"  >Event/Expo</option>

		<option value="Tv advert"  >Tv advert</option>
		<option value="Billboard advert"  >Billboard advert</option>
		<option value="Banner advert"  >Banner advert</option>
		<option value="SMS advert"  >SMS advert</option>
		<option value="Physical Marketing"  >Physical Marketing</option>

	<option value="cold call"  selected >Cold call</option>
		<option value="Employement Referral"  >Employement Referral</option>
		<option value="External Referral"  >External Referral</option>
		<option value="Online source"  >Online source</option>
		<option value="Partner">Partner</option>
		<option value="Public Relations">Public Relations</option>
		<option value="Sales email allas">Sales email allas</option>
		<option value="Analog sales">Analog sales</option>
				<option value="other">Other</option>

</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
   
   


  	
  
  
  
  <div class="form-group"  style="display:none">
    <label for="inputprobability" class="col-sm-2 control-label">Route	?</label>
    <div class="col-sm-10">
	
			  		<input type="text" id="routes" name="probability" value="<?php echo set_value('probability'); ?>" class="form-control"  placeholder="Enter Route Name ">

	
	
	
	
	
		
						<span class="text-danger"><?php echo form_error('priority'); ?>

	</div>
  </div>
  <div class="form-group" style="display:none">
    <label for="inputexpectedrevenue" class="col-sm-2 control-label">	Expected revenue Paid  </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="expectedrevenue" value="0.00" class="form-control"  placeholder="Enter expected revenue  ">
		 
				
		<span class="text-danger"> <?php echo form_error('expectedrevenue'); ?>
		
		</span>
	</div>
  </div>
  
  
  <div class="form-group" style="display:none" >
    <label for="inputamount" class="col-sm-2 control-label">	Amount Paid  </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="amount" value="0.00" readonly class="form-control"  placeholder="Enter Amount paid ">
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
     <div class="form-group" style="display:none">
    <label for="inputstage" class="col-sm-2 control-label">Stage?</label>
    <div class="col-sm-10">
	<select class="form-control" name="stage" required>
	
	<option value="new" selected="selected" >---new--</option>
	<option value="old"  >---old--</option>
		<option value="attended"  >---attended--</option>
		<option value="pending"  >---pending--</option>
		<option value="attended"  >---attended--</option>
		<option value="other">---other--</option>
</select>
		
						<span class="text-danger"><?php echo form_error('stage'); ?>

	</div>
  </div>
   
  

		
	<div class="form-group">
    <label for="inputallsteps" class="col-sm-2 control-label">First Feedback</label>
    <div class="col-sm-10">

				<textarea name="allsteps" id="firstfeedback" value="<?php echo set_value('allsteps'); ?>"  class="form-control"  placeholder="Enter  the first Feedback E.G 1. Call, 2.Send us proposal"></textarea>
			
		<span class="text-danger">First Feedback-  Recommendation<?php echo form_error('allsteps'); ?>
		
		</span>
	</div>
  </div>
	
	
  
	<div class="form-group" >
    <label for="inputcomments" class="col-sm-2 control-label">	Other Details</label>
    <div class="col-sm-10">

				<textarea name="comments" value="<?php echo set_value('comments'); ?>"  class="form-control"  placeholder="Enter Your recommendations or comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
      <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="fromdate" value="<?php echo set_value('fromdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  
   
	
	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	Next step Date  </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="todate" value="<?php echo set_value('todate', $mydate); ?>" class="form-control2" required placeholder="Enter date of next action/closed date">
		 	Time :<select class="form-control2" name="starttime" id="starttime" >

	<option value=""  >-time </option>
	
			<option value="06:00">06:00</option>
		<option value="06:15">06:15</option>
		<option value="06:30">06:30</option>
		<option value="06:45">06:45</option>
			<option value="07:00">07:00</option>
		<option value="07:15">07:15</option>
		<option value="07:30">07:30</option>
		<option value="07:45">07:45</option>
			<option value="08:00">08:00</option>
		<option value="08:15">08:15</option>
		<option value="08:30">08:30</option>
		<option value="08:45">08:45</option>
			<option value="09:00">09:00</option>
		<option value="09:15">09:15</option>
		<option value="09:30">09:30</option>
		<option value="09:45">09:45</option>
			<option value="10:00">10:00</option>
		<option value="10:15">10:15</option>
		<option value="10:30">10:30</option>
		<option value="10:45">10:45</option>
			<option value="11:00">11:00</option>
		<option value="11:15">11:15</option>
		<option value="11:30">11:30</option>
		<option value="11:45">11:45</option>
					<option selected="selected" value="12:00">12:00</option>

		<option value="12:15">12:15</option>
		<option value="12:30">12:30</option>
		<option value="12:30">12:45</option>
		
			<option value="13:00">13:00</option>
		<option value="13:15">13:15</option>
		<option value="13:30">13:30</option>
		<option value="13:45">13:45</option>
			<option value="14:00">14:00</option>
		<option value="14:15">14:15</option>
		<option value="14:30">14:30</option>
		<option value="14:45">14:45</option>
			
			<option value="15:00">15:00</option>
		<option value="15:15">15:15</option>
		<option value="15:30">15:30</option>
		<option value="15:45">15:45</option>
			<option value="16:00">16:00</option>
		<option value="16:15">16:15</option>
		<option value="16:30">16:30</option>
		<option value="16:45">16:45</option>
		
			<option value="17:00">17:00</option>
		<option value="17:15">17:15</option>
		<option value="17:30">17:30</option>
		<option value="17:45">17:45</option>
			<option value="18:00">18:00</option>
		<option value="18:15">18:15</option>
		<option value="18:30">18:30</option>
		<option value="18:45">18:45</option>
			
			<option value="19:00">19:00</option>
		<option value="19:15">19:15</option>
		<option value="19:30">19:30</option>
		<option value="19:45">19:45</option>
		
		
		
			<option value="20:00">20:00</option>
		<option value="20:15">20:15</option>
		<option value="20:30">20:30</option>
		<option value="20:45">20:45</option>
		<option value="21:00">21:00</option>
		<option value="21:15">21:15</option>
		<option value="21:30">21:30</option>
		<option value="21:45">21:45</option>
		<option value="22:00">22:00</option>
		<option value="22:15">22:15</option>
		<option value="22:30">22:30</option>
		<option value="22:45">22:45</option>
		<option value="23:00">23:00</option>
		<option value="23:15">23:15</option>
		<option value="23:30">23:30</option>
		<option value="23:45">23:45</option>
<option value="23:59">23:59</option>
<option value="00:00"  >00:00</option>
		<option value="00:15">00:15</option>
		<option value="00:30">00:30</option>
		<option value="00:45">00:45</option>
		<option value="01:00">01:00</option>
		<option value="01:15">01:15</option>
		<option value="01:30">01:30</option>
		<option value="01:45">01:45</option>
		<option value="02:00">02:00</option>
		<option value="02:15">02:15</option>
		<option value="02:30">02:30</option>
		<option value="02:45">02:45</option>
		
		
		
			<option value="03:00">03:00</option>
		<option value="03:15">03:15</option>
		<option value="03:30">03:30</option>
		<option value="03:45">03:45</option>
			<option value="04:00">04:00</option>
		<option value="04:15">04:15</option>
		<option value="04:30">04:30</option>
		<option value="04:45">04:45</option>
			<option value="05:00">05:00</option>
		<option value="05:15">05:15</option>
		<option value="05:30">05:30</option>
		<option value="05:45">05:45</option>
	</select>	
				
		Action :<select class="form-control2" name="action" id="action" required >

	<option value="" selected="selected" >---Select Action --</option>
	
	
	
	
	
	
	
	<?php 
					 
			$groups =  $this->usermodel->populateall('dealstatus','companyid',$companyid);
	

	
if(is_array($groups)) {

   foreach($groups as $grouprowdeals){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $grouprowdeals->name;   ?>"><?=  $grouprowdeals->name; ?></option>



	<?php

}} else {
    echo 'No supplier available.';
}
	
?>
	
	

	</select>	
	</div>
  </div>
      <div class="form-group" >
    <label for="inputsendsms" class="col-sm-2 control-label">Send Thank you sms?</label>
    <div class="col-sm-10">
	<select class="form-control" name="sendsms" required>
	

		<option value="yes"  >---Yes--</option>
		<option value="no" selected="selected" >---No--</option>
		
</select>
		
						<span class="text-danger"><?php echo form_error('stage'); ?>

	</div>
  </div>
    
				<div class="form-group" >
    <label for="inputcontactname" class="col-sm-2 control-label">Email </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contactname"  value="<?php echo set_value('contactname'); ?>" class="form-control"  placeholder="Enter Email if any ">
		 
				
		<span class="text-danger"> <?php echo form_error('contactname'); ?>
		
		</span>
	</div>
  </div>
  
  
     <div class="form-group">
    <label for="inputdealowner" class="col-sm-2 control-label">Started by?</label>
    <div class="col-sm-10">
	<select class="form-control" name="dealowner" style ="width: 100%"  required>
	<option value=""  >---Select Deal/Lead Owner---</option>

				
	
	
	
	<?php 
				
				
	
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
   // echo 'No user available.';
}
	
?>

	<?php 
				
				
	 if($viewalldeals==true){			//$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'id >',0);
			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
		}
?>








</select>
		
						<span class="text-danger">Select the employee/person who started the deal/lead?<?php echo form_error('taskowner'); ?>

	</div>
  </div>







					  <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Posting Branch</label>
    <div class="col-sm-10">
				
	
		
		
		
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallaction==true){
										 ?>
									<?php
									
							
				 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
 }
?>
</select>
		
				
		</div>
  </div>
					
			









  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="deal" name="btn_adddeal" class="btn btn-default"> Add Deal/Lead  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>			
									
									
		






















<div id="addfollowupModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new follow-ups</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');

		 $myuserid = $data['id'];
		 $userid = $data['id'];

 	 			 	$finalsalesid = $myuserid.time();

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/adddealsfollowups' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
		  		<input type="hidden" name="finalsalesid" value="<?php echo set_value('finalsalesid',$finalsalesid); ?>" class="form-control"  placeholder="Enter  finalsalesid">

				
				

				  
  
  
  <div class="form-group">
    <label for="inputcontact" class="col-sm-2 control-label">Phone Number</label>
    <div class="col-sm-10">
	
		  		<input type="text" id="newfollowup" name="contact" value="<?php echo set_value('contact'); ?>" class="form-control"  placeholder="Enter contact eg 2547XXXXX ">
		 
				
		<span class="text-danger">Search woth Phone Number or Business Name <?php echo form_error('contact'); ?>
		
		</span>
	</div>
  </div>

				
				
				
				
				
				

  
  
				
  
  
  
  
  

  
	


  	
  
  
  
		
	<div class="form-group">
    <label for="inputallsteps" class="col-sm-2 control-label">Current Feedback</label>
    <div class="col-sm-10">

				<textarea name="feedback" value="<?php echo set_value('feedback'); ?>"  class="form-control"  placeholder="Enter  the first Feedback E.G 1. Call, 2.Send us proposal"></textarea>
			
		<span class="text-danger">Enter oCurrent Feedback from the customer <?php echo form_error('feedback'); ?>
		
		</span>
	</div>
  </div>
	
	
  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label"> Remarks</label>
    <div class="col-sm-10">

				<textarea name="recommendation" value="<?php echo set_value('recommendation'); ?>"  class="form-control"  placeholder="Enter Your recommendations or comments"></textarea>
			
		<span class="text-danger"> Enter (Remarks/recommendation - Any challange)<?php echo form_error('recommendation'); ?>
		
		</span>
	</div>
  </div>
    
   
   

   
   
   
   
   
   
   
   
   
	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	Next step Date  </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="dateposted" value="<?php echo set_value('todate', $mydate); ?>" class="form-control2" required placeholder="Enter date of next action/closed date">
		 	Time :<select class="form-control2" name="starttime" id="starttime" >

	<option value=""  >-time </option>
	
			<option value="06:00">06:00</option>
		<option value="06:15">06:15</option>
		<option value="06:30">06:30</option>
		<option value="06:45">06:45</option>
			<option value="07:00">07:00</option>
		<option value="07:15">07:15</option>
		<option value="07:30">07:30</option>
		<option value="07:45">07:45</option>
			<option value="08:00">08:00</option>
		<option value="08:15">08:15</option>
		<option value="08:30">08:30</option>
		<option value="08:45">08:45</option>
			<option value="09:00">09:00</option>
		<option value="09:15">09:15</option>
		<option value="09:30">09:30</option>
		<option value="09:45">09:45</option>
			<option value="10:00">10:00</option>
		<option value="10:15">10:15</option>
		<option value="10:30">10:30</option>
		<option value="10:45">10:45</option>
			<option value="11:00">11:00</option>
		<option value="11:15">11:15</option>
		<option value="11:30">11:30</option>
		<option value="11:45">11:45</option>
		
			<option selected="selected" value="12:00">12:00</option>
		<option value="12:15">12:15</option>
		<option value="12:30">12:30</option>
		<option value="12:30">12:45</option>
		
			<option value="13:00">13:00</option>
		<option value="13:15">13:15</option>
		<option value="13:30">13:30</option>
		<option value="13:45">13:45</option>
			<option value="14:00">14:00</option>
		<option value="14:15">14:15</option>
		<option value="14:30">14:30</option>
		<option value="14:45">14:45</option>
			
			<option value="15:00">15:00</option>
		<option value="15:15">15:15</option>
		<option value="15:30">15:30</option>
		<option value="15:45">15:45</option>
			<option value="16:00">16:00</option>
		<option value="16:15">16:15</option>
		<option value="16:30">16:30</option>
		<option value="16:45">16:45</option>
		
			<option value="17:00">17:00</option>
		<option value="17:15">17:15</option>
		<option value="17:30">17:30</option>
		<option value="17:45">17:45</option>
			<option value="18:00">18:00</option>
		<option value="18:15">18:15</option>
		<option value="18:30">18:30</option>
		<option value="18:45">18:45</option>
			
			<option value="19:00">19:00</option>
		<option value="19:15">19:15</option>
		<option value="19:30">19:30</option>
		<option value="19:45">19:45</option>
		
		
		
			<option value="20:00">20:00</option>
		<option value="20:15">20:15</option>
		<option value="20:30">20:30</option>
		<option value="20:45">20:45</option>
		<option value="21:00">21:00</option>
		<option value="21:15">21:15</option>
		<option value="21:30">21:30</option>
		<option value="21:45">21:45</option>
		<option value="22:00">22:00</option>
		<option value="22:15">22:15</option>
		<option value="22:30">22:30</option>
		<option value="22:45">22:45</option>
		<option value="23:00">23:00</option>
		<option value="23:15">23:15</option>
		<option value="23:30">23:30</option>
		<option value="23:45">23:45</option>
<option value="23:59">23:59</option>
<option value="00:00"  >00:00</option>
		<option value="00:15">00:15</option>
		<option value="00:30">00:30</option>
		<option value="00:45">00:45</option>
		<option value="01:00">01:00</option>
		<option value="01:15">01:15</option>
		<option value="01:30">01:30</option>
		<option value="01:45">01:45</option>
		<option value="02:00">02:00</option>
		<option value="02:15">02:15</option>
		<option value="02:30">02:30</option>
		<option value="02:45">02:45</option>
		
		
		
			<option value="03:00">03:00</option>
		<option value="03:15">03:15</option>
		<option value="03:30">03:30</option>
		<option value="03:45">03:45</option>
			<option value="04:00">04:00</option>
		<option value="04:15">04:15</option>
		<option value="04:30">04:30</option>
		<option value="04:45">04:45</option>
			<option value="05:00">05:00</option>
		<option value="05:15">05:15</option>
		<option value="05:30">05:30</option>
		<option value="05:45">05:45</option>
	</select>	
				
		Action :<select class="form-control2" name="action" id="action" >

	<option value=""  >---Select Action --</option>
	
			<option value="Intrested" selected="selected">Intrested</option>
		<option value="Not Intrested">Not Intrested</option>
		<option value="Closed">Closed</option>
		<option value="Dont Call">Don't Call me again</option>
			
		
	</select>	
	</div>
  </div>
  
     <div class="form-group">
    <label for="inputdealowner" class="col-sm-2 control-label">Started by?</label>
    <div class="col-sm-10">
	<select class="form-control" name="dealowner" style ="width: 100%"  required>
	<option value=""  >---Select Deal/Lead Owner---</option>

				
	
	
	
	<?php 
				
				
	
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
   // echo 'No user available.';
}
	
?>

	<?php 
				
				
	 if($viewalldeals==true){			//$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'id >',0);
			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
		}
?>








</select>
		
						<span class="text-danger">Select the employee/person who started the deal/lead?<?php echo form_error('taskowner'); ?>

	</div>
  </div>
  
  
	 <div class="form-group">
			 <input type="hidden" id="type"name="type" class="type" placeholder="type" value="Deal">
			 <input type="hidden" id="followupid"name="followupid" class="followupid" placeholder="followupid" value="">
			 <input type="hidden" id="level"name="level" class="level" placeholder="level" value="">

    <div class="col-sm-offset-2 col-sm-10">
     	<button type="submit" name="btn_followups" class="btn btn-primary" value="followup">Add New Follow-up </button>


    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>			
									
									
		


















	<div id="colectionModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Download Daily deals Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
 //$mydate=date("Y-m-d");
 					 // $mydate=date("Y-m-d H:i:s");



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/downloaddailydeals' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	
	
	 <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewalldeals==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?php
									 }
							
	?>
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		

		
	</div>
  </div>
	
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$finalstartdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputclosedate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="closedate" value="<?php echo set_value('closedate',$finalendate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('closedate'); ?>
		
		</span>
	</div>
  </div>
  
  
      <div class="form-group">
    <label for="inputdealowner" class="col-sm-2 control-label">Started by?</label>
    <div class="col-sm-10">
	<select class="form-control" name="userid" id="userid" style ="width: 100%"  required>
		<option value=""  selected="selected"></option>

	<option value=""  >---Select Deal/Lead Owner---</option>

						<?php
		 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $myuserid = $data['id'];
	 if($viewalldeals==true){
		 //$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'status',0);
						$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

			?>
						<option value="all"  >All 	users</option>
<?php


 }else{
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$myuserid,'status',0);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option  selected value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
	
?>
</select>
		
						<span class="text-danger">Select the employee/person who started the deal/lead?<?php echo form_error('taskowner'); ?>

	</div>
  </div>
  
  
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="deal" name="btn_downloaddeals" class="btn btn-default"> Download DealS</button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>	

	
	
	

<div id="editModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update my new Lead/deal</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatetdeals' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	<div class="form-group">
    <label for="inputowner" class="col-sm-2 control-label">	Business Name</label>
    <div class="col-sm-10">
			  		<input type="hidden" name="dealid" id="dealid" value="" class="form-control"  placeholder="Enter dealid">

		  		<input type="text" name="owner" id="owner" value="<?php echo set_value('owner'); ?>" class="form-control"  placeholder="Enter Business Name">
		 
				
		<span class="text-danger"> <?php echo form_error('owner'); ?>
		
		</span>
	</div>
  </div>
 
  
    
    <div class="form-group">
    <label for="inputdealowner" class="col-sm-2 control-label">Started by?</label>
    <div class="col-sm-10">
	<select class="form-control" name="dealowner" id="dealowner" style ="width: 100%"  required>
		<option value=""  selected="selected"></option>

	<option value=""  >---Select Deal/Lead Owner---</option>

						<?php
		 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $myuserid = $data['id'];
	 if($viewalldeals==true){			//$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'status',0);
						$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

			?>
						<option value="all"  >All 	users</option>
<?php


 }else{
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$myuserid,'status',0);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
	
?>
</select>
		
						<span class="text-danger">Select the employee/person who started the deal/lead?<?php echo form_error('taskowner'); ?>

	</div>
  </div>
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputtitle" class="col-sm-2 control-label">Deal title </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="title" id="title" value="<?php echo set_value('title'); ?>" class="form-control" required placeholder="Enter title">
		 
				
		<span class="text-danger"> <?php echo form_error('title'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Lead Source ?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type"  id="type" required>
	
	<option value="" selected="selected" ></option>

	<option value=""  >---select deal type--</option>
		<option value="Tv advert"  >Tv advert</option>
		<option value="Billboard advert"  >Billboard advert</option>
		<option value="Banner advert"  >Banner advert</option>
		<option value="SMS advert"  >SMS advert</option>
		<option value="Physical Marketing"  >Physical Marketing</option>

	<option value="cold call"  >cold call</option>
		<option value="Employement Referral"  >Employement Referral</option>
		<option value="External Referral"  >External Referral</option>
		<option value="Online source"  >Online source</option>
		<option value="Partner">Partner</option>
		<option value="Public Relations">Public Relations</option>
		<option value="Sales email allas">Sales email allas</option>
		<option value="Analog sales">Analog sales</option>
				<option value="other">Other</option>


</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
   
   

	<div class="form-group">
    <label for="inputnextstep" class="col-sm-2 control-label">	Nextstep</label>
    <div class="col-sm-10">

				<textarea name="nextstep" id="nextstep" value="<?php echo set_value('nextstep'); ?>"  class="form-control"  placeholder="Enter next step/Customer feedback"></textarea>
			
		<span class="text-danger"> <?php echo form_error('nextstep'); ?>
		
		</span>
	</div>
  </div>
  
  	
  
  <div class="form-group">
    <label for="inputcontactname" class="col-sm-2 control-label">	Contact name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contactname"id="contactname" value="<?php echo set_value('contactname'); ?>" class="form-control"  placeholder="Enter contact name ">
		 
				
		<span class="text-danger"> <?php echo form_error('contactname'); ?>
		
		</span>
	</div>
  </div>
   <div class="form-group">
    <label for="inputcontact" class="col-sm-2 control-label">	Contact  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contact" id="contact" value="<?php echo set_value('contact'); ?>" class="form-control"  placeholder="Enter contact  ">
		 
				
		<span class="text-danger"> <?php echo form_error('contact'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputprobability" class="col-sm-2 control-label">Probability	?</label>
    <div class="col-sm-10">
	<select class="form-control" name="probability" id="probability" required>
	
	<option value="High"  >---High--</option>
	<option value="Low"  >---Low--</option>
		<option value="Medium"  >---Medium--</option>
</select>
		
						<span class="text-danger"><?php echo form_error('priority'); ?>

	</div>
  </div>
  <div class="form-group">
    <label for="inputexpectedrevenue" class="col-sm-2 control-label">	Expected revenue Paid  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="expectedrevenue" id="expectedrevenue" value="<?php echo set_value('expectedrevenue'); ?>" class="form-control"  placeholder="Enter expected revenue  ">
		 
				
		<span class="text-danger"> <?php echo form_error('expectedrevenue'); ?>
		
		</span>
	</div>
  </div>
  
  
  <div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">	Amount Paid  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="amount" id="amount" value="<?php echo set_value('amount'); ?>" class="form-control"  placeholder="Enter Amount paid ">
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="fromdate" id="fromdate" value="<?php echo set_value('fromdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	Next step Date  </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="todate" id="todate" value="<?php echo set_value('todate', $mydate); ?>" class="form-control" required placeholder="Enter date of next action/closed date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    
     <div class="form-group">
    <label for="inputstage" class="col-sm-2 control-label">Stage?</label>
    <div class="col-sm-10">
	<select class="form-control" name="stage" id="stage" required>
	
	<option value="new"  >---new--</option>
	<option value="old"  >---old--</option>
		<option value="attended"  >---attended--</option>
		<option value="pending"  >---pending--</option>
		<option value="attended"  >---attended--</option>
		<option value="other">---other--</option>
</select>
		
						<span class="text-danger"><?php echo form_error('stage'); ?>

	</div>
  </div>
   
  

  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	Comments</label>
    <div class="col-sm-10">

				<textarea name="comments" value="<?php echo set_value('comments'); ?>" id="comments" class="form-control"  placeholder="Enter Description/comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		
		<div class="form-group">
    <label for="inputallsteps" class="col-sm-2 control-label">First Feedback</label>
    <div class="col-sm-10">

				<textarea name="allsteps" value="<?php echo set_value('allsteps'); ?>"  id="allsteps"  class="form-control"  placeholder="Enter  the first Feedback E.G 1. Call, 2.Send us proposal"></textarea>
			
		<span class="text-danger">Enter only the first feedback from the customer <?php echo form_error('allsteps'); ?>
		
		</span>
	</div>
  </div>
	
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="deal" name="btn_updatedeal" class="btn btn-default"> Update Deal   </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>	


		
									
							</div>
						</div>
				
								
									
									
									
							</div>
						</div>
				

			
			</div>
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>


















