<?php 
   session_start(); 
   ob_start();
   include("../leadsnew/branch_connection.php");
   $sujpath="./";
   ?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Projects</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/skins/_all-skins.min.css">
    <link rel="stylesheet" type="text/css" href="tcal.css" />    
    <script type="text/javascript" src="tcal.js"></script>
    
  <script>
    function add_new_customer(){
             var vcompany = $('#vcompany').val();
             var vcontact = $('#vcontact').val();
             var vmob = $('#vmob').val();
             var vemail = $('#vemail').val();
             var vcountry = $('#vcountry').val();
             var vstate = $('#vstate').val();
             var vdistrict = $('#vdistrict').val();
             var vstatus = $('#vstatus').val();
             if(vcompany == ''){
                alert("Enter Company");   	
             } else if(vmob == ''){
             	alert("Enter Mobile");
             } else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          add_new_customer: 1,
                          vcompany     : vcompany,
                          vcontact     : vcontact,
                          vmob         : vmob,
                          vemail       : vemail,
                          vcountry     : vcountry,
                          vstate       : vstate,
                          vdistrict    : vdistrict,
                          vstatus      : vstatus
                     },
                     cache: true,
                     success: function(res23)
                     {
                     	   	$('#vcompany').val('');
                           	$('#vcontact').val('');
                           	$('#vmob').val('');
                           	$('#vemail').val('');
                           	$('#vcountry').val('');
                           	$('#vstate').val('');
                           	$('#vdistrict').val('');
                           	$("#marketingdiv123").load("customer.php #marketingdiv123");   
                            datat2();                    
                      }
                   }); 
    	    }
    }


    	
     function edit_new_customer()
       {
             var vcompany = $('#vcompany').val();
             var vcontact = $('#vcontact').val();
             var vmob = $('#vmob').val();
             var vemail = $('#vemail').val();
             var vcountry = $('#vcountry').val();
             var vstate = $('#vstate').val();
             var vdistrict = $('#vdistrict').val();
             var vstatus = $('#vstatus').val();
             var hidvall = $('#hidvall').val();
             
             if(vcompany == ''){
                alert("Enter Company");   	
             } else if(vmob == ''){
             	alert("Enter Mobile");
             } else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          edit_new_customer: 1,
                          vcompany     : vcompany,
                          vcontact     : vcontact,
                          vmob         : vmob,
                          vemail       : vemail,
                          vcountry     : vcountry,
                          vstate       : vstate,
                          vdistrict    : vdistrict,
                          vstatus      : vstatus,
                          hidvall      : hidvall
                     },
                     cache: true,
                     success: function(res23)
                     {
                     	   	$('#vcompany').val('');
                           	$('#vcontact').val('');
                           	$('#vmob').val('');
                           	$('#vemail').val('');
                           	$('#vcountry').val('');
                           	$('#vstate').val('');
                           	$('#vdistrict').val('');
                           	$("#marketingdiv123").load("customer.php #marketingdiv123");   
                            datat2();                    
                      }
                   }); 
    	    }

        }
        
        
    	
    	    	
    	
    	
    	
    	function edit_assignment(id)
    	{
    		$.ajax({
			type: "POST",
			url:  "ajaxmarket.php",
			data: {
			btn_edit_market: 1,
			id:id
			},
			cache: true,
			success: function(res)
			{
	         	$("#marketingdiv22").load("assignment.php?idd2="+id+" #marketingdiv22"); 	
			}  
			});
    	}
    	
    	
function state_change(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("vdistrict").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajaxmarket.php?state_idd="+str,true);
xmlhttp.send();
}
    </script>
    
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
     <div class="wrapper">
  <?php include("head.php");
    include("left.php"); ?> 
	 
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1 style=" font-size: 22px;"> Project Assignment
          	<small>- Control panel</small>
          	</h1>
          <ol class="breadcrumb">
            <li><a href="dash_board.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active">Project Assignment</li> 
          </ol>
        </section>
  <!-- Main content -->
        <section class="content" >
          <div class="row" >
            <div class="col-xs-12" >


  
  
  
  
<div id="marketingdiv123" style=" margin-top: 20px;">


<div class="box" >
   <div class="box-body" >
        <div class="box-body table-responsive no-padding" >
   
  	                 	
                  <table id="example1" class="table table-bordered table-striped" >
                    <thead >
                    <tr >
<th>#</th>                    	
<th>Company</th>
<th>Location</th>
<th>Customer</th>
<th>Order Type</th>
<th>Order Date</th>
<th>Completion Date</th>
<th>Status</th>
<th></th>
</tr>
                    </thead>
                    <tbody>

<?php 
$sqq = mysqli_query($conn, "
    SELECT mo.*, c.name AS category_name
    FROM marketing_order mo
    LEFT JOIN categories c 
           ON mo.product_category = c.id
    WHERE mo.status IN ('Completed', 'Order Confirmed')
    ORDER BY mo.id DESC
");

if(!$sqq){
    die(mysqli_error($conn));
}


 $p=1;
 while($res = mysqli_fetch_array($sqq)){
  $company = $res['company_name'];
  $sq1 = mysqli_query($con,"SELECT c_comp FROM `p_company` WHERE `cid`='$comid' ");
  $rs1 = mysqli_fetch_array($sq1);  
  
 $customer = $res['customer_name'];
  $sq5 = mysqli_query($con, "SELECT cname FROM `p_customers` WHERE `cid`='$ocustm'");
  $rs5 = mysqli_fetch_array($sq5);
?>
<tr>
	<td><?php echo $p; ?></td>
<td><?php echo $company; ?></td>
<td><?php echo $res['location']; ?></td>
<td><?php echo $res['customer_name']; ?></td>
	<td><?php echo $res['category_name']; ?></td>
<td><?php echo $res['order_date']; ?></td>
<td><?php echo $res['delivery_date']; ?></td>
<td><?php echo $res['status']; ?></td>

	<td>
	&nbsp;&nbsp;  <a href="" data-toggle="modal" data-target="#myModal<?php echo $res['id']; ?>" style=" cursor: pointer;"><span class="glyphicon glyphicon-eye-open" style="font-size:14px;"></span></a> &nbsp; &nbsp;                	
  </td>
</tr>



<div class="modal fade" id="myModal<?php echo $res['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Project Details</h4>
      </div>
      <div class="modal-body" id="myModal2">
  <form method="post" action="ptd_save.php"> 
<div style="width:550px;">

  <div style="float:left;width:150px;color:#0000FF;">Company Name</div>
  <div style="width:375px;">: <?php echo $res['company_name']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Location</div>
  <div style="width:375px;">: <?php echo $res['location']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Order Type</div>
  <div style="width:375px;">: <?php echo $res['category_name']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Customer</div>
  <div style="width:375px;">: <?php echo $res['customer_name']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Order Date</div>
  <div style="width:375px;">: <?php echo $res['order_date']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Completion Date</div>
  <div style="width:375px;">: <?php echo $res['delivery_date']; ?></div>

  <div style="float:left;width:150px;color:#0000FF;">Status</div>
  <div style="width:375px;">: <?php echo $res['status']; ?></div>

</div>

 <br>
 <h4 class="modal-title" id="myModalLabel"  style=" background-color: #E8E8E8;">Project Assignment</h4>
 <br>
   <div class="row" >
        <div class="col-xs-12" >
       
      <div class="col-md-5"  style=" padding-left: 2px; padding-right: 0px; ">					
      <div class="form-group">
    <select name="assigned_to" id="assigned_to" class="form-control">
        <option value="">Select Employee</option>
        <?php
        $emp_q = mysqli_query($conn, "SELECT id, name FROM users ORDER BY name ASC");
        while ($emp = mysqli_fetch_assoc($emp_q)) {
        ?>
            <option value="<?php echo $emp['id']; ?>">
                <?php echo $emp['name']; ?>
            </option>
        <?php } ?>
    </select>
</div>
</div>

     	 <div class="col-md-5"  style=" padding-left: 2px; padding-right: 0px; ">					
      <div class="form-group">
	        <input type="text" name="man_hours" id="man_hours" class="form-control" placeholder="Man Hours"/>
      </div></div>
      
      <!-- Segment -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <select name="segment" id="segment" class="form-control">
      <option value="">Segment</option>
      <option value="Billable">Billable</option>
      <option value="Non Billable">Non Billable</option>
    </select>
  </div>
</div>
<!-- Work Type -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <select name="work_type" class="form-control">
      <option value="">Work Type</option>
      <option value="New">New</option>
      <option value="Updation">Updation</option>
    </select>
  </div>
</div>
<!-- SO No -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <input type="text" name="so_no" class="form-control" placeholder="SO No">
  </div>
</div>

<!-- SR No -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <input type="text" name="sr_no" class="form-control" placeholder="SR No">
  </div>
</div>

<!-- SRS No -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <input type="text" name="srs_no" class="form-control" placeholder="SRS No">
  </div>
</div>

<!-- BDO -->
<div class="col-md-5" style="padding-left:2px;padding-right:0px;">
  <div class="form-group">
    <input type="text" name="bdo" class="form-control" placeholder="BDO">
  </div>
</div>

      
  <!--<form method="post" action="ptd_save.php">-->
  <input type="hidden" name="marketing_order_id" value="<?php echo $res['id']; ?>">
  <input type="hidden" name="company_name" value="<?php echo $res['company_name']; ?>">
  <input type="hidden" name="customer_name" value="<?php echo $res['customer_name']; ?>">
  <input type="hidden" name="category_id" value="<?php echo $res['product_category']; ?>">
  <input type="hidden" name="order_date" value="<?php echo $res['order_date']; ?>">
  <input type="hidden" name="delivery_date" value="<?php echo $res['delivery_date']; ?>">
  <input type="hidden" name="status" value="<?php echo $res['status']; ?>">
<input type="hidden" name="ptd_id" value="">

  <input type="submit"
         class="btn btn-primary"
         name="ptd_submit"
         value="Submit"
         style="float:right;margin-right:20px;">
</form>

      
            	
     </div></div>       	
            	
  
      </div>
    </div>
  </div>
</div>   
<?php $p=$p+1; } ?>


                    </tbody>
                    </table>
  
         		  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
	
	
</div>
	
		
			
			
			








                           
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
  </div><!-- /.content-wrapper -->
  </div>
	<!-- <?php include("footer.php"); ?> -->
 <!-- jQuery 2.1.4 -->
    <script src="<?php echo $sujpath; ?>plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="<?php echo $sujpath; ?>bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
	<script src="<?php echo $sujpath; ?>plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="<?php echo $sujpath; ?>plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo $sujpath; ?>plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo $sujpath; ?>dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo $sujpath; ?>dist/js/demo.js"></script>
    <!-- page script -->
    
  <script type="text/javascript">
    function PreviewImage(no) {
    	var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById("uploadImage"+no).files[0]);
        oFReader.onload = function (oFREvent) {
            document.getElementById("uploadPreview"+no).src = oFREvent.target.result;
        };
    }
</script>

<style>
label.filebutton {
    width:120px;
    height:80px;
    overflow:hidden;
    position:relative;
}
label span input {
    z-index: 999;
    line-height: 0;
    font-size: 50px;
    position: absolute;
    top: -2px;
    left: -700px;
    opacity: 0;
    filter: alpha(opacity = 0);
    -ms-filter: "alpha(opacity=0)";
    cursor: pointer;
    _cursor: hand;
    margin: 0;
    padding:0;
}
</style>



    <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      
	function datat(){
	  alert("Data Deleted Successfully.");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat2(){
	  alert("Data Added Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat3(){
	  alert("Updated Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
   </script>  
   
   
   
  </body>
</html>
