<?php include 'header1f.php';
date_default_timezone_set('Asia/Calcutta');
$today = date("Y-m-d");
$current_month=date("m");
$query2job = "select * from check_month";
$resultjob = mysql_query($query2job,$conn);
while($rowmonth=mysql_fetch_array($resultjob))
{
$check_month = $rowmonth['check_month'];
}


$month1=date("m");
if($month1>$check_month)
  {
  $currentyear = date("Y");
 $curr_full_year=date("Y");
$curr_short_year=date("y");
$future=$curr_short_year+1;
} else {
$currentyear1 = date("Y");
$currentyear = $currentyear1-1;
$curr_full_year1=date("Y");
 $curr_full_year=$curr_full_year1-1;
 $curr_short_year1=date("y");

$curr_short_year=$curr_short_year1-1;
$future=$curr_short_year+1;
}

 $curr_fy=$currentyear .'-'. $future;
 
 $query = "select * from users where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
//echo $query;
		                 $result = mysql_query($query,$conn);
						 while($row=mysql_fetch_array($result))
	                                              	{
													  $staff_name = $row['full_name'];
													  $full_name = $row['full_name'];
													   $full_name11 = $row['full_name'];
													  $avatar = $row['avatar'];
													  $department_name = $row['department_name'];
													  $staff_id  = $row['id'];
													  $username = $row['username'];
													  $our_company = $row['our_company'];
													  $designation = $row['designation'];
													  $sales_group = $row['sales_group'];
													  $head = $row['head'];
													  $region = $row['region'];
													  $district = $row['district'];
													  $email = $row['email'];
													  $mobile_no = $row['mobile_no'];
													  $staff_id_self  = $row['id'];
													  //echo $Branch;
													  }	


?> <div class="content-page">
    <div class="content">
      <div class="container">
	  <div class="row">
          <div class="col-sm-12">
            <div class="page-header-title">
            <button type="button" class="btn btn-dark waves-effect waves-light" onclick="location.href='make_challan_master.php'">BACK </button>
              <div class="clearfix"></div>
            </div>
          </div>
        </div>
	  <?php include('sahavas_dropdown_function.php');?>
 
 <?php depat_check($department_name,$designation);?>

<?php $short_form = $_REQUEST['short_form']; ?>
<?php
$query2t = "select * from transport_master where trans_inv_no = '".$_REQUEST['trans_inv_no']."'";
$result2t = mysql_query($query2t,$conn);	
$rowcount=mysql_num_rows($result);				
if($rowcount!='0'){
while($row = mysql_fetch_array($result2t))
{
$short_form = $row['short_form'];
}
}else {
$str = $_REQUEST['trans_inv_no'];
				$resultset = explode("/",$str);
				
			$short_form = current($resultset);
				
		}		
				

	$query2t = "select * from tax_transtax where trans_inv_no = '".$_REQUEST['trans_inv_no']."'";
$result2t = mysql_query($query2t,$conn);	
$rowcount=mysql_num_rows($result);				

while($row = mysql_fetch_array($result2t))
{
$challan_id = $row['challan_id'];
$inv_type=$row['inv_type'];
$challan_no_book= $row['challan_no_book'];
$delivery_date= $row['delivery_date'];

}	
	
		

		?>	
<?php
$query2c = "select * from main_job_details where main_id='".$_REQUEST['main_id']."'";
		                 				$result2c = mysql_query($query2c,$conn);	
										while($row = mysql_fetch_array($result2c)){
													 $main_job_no = $row['main_job_no'];
													 $main_id = $row['main_id'];
													 $customer_id=$row['customer_id'];
													  $customer_name=$row['customer_name'];
													  $inv_type=$row['inv_type'];
													  $account_of=$row['account_of'];
												}
												
											

$query2 = "select * from customer_master where customer_id = '".$_REQUEST['customer_id']."'";
				//echo $query2;
		                 $result2 = mysql_query($query2,$conn);	
while($row = mysql_fetch_array($result2))
{
$address_exp = $row['billing_address'];
$city_exp = $row['bcity'];
$customer_name = $row['customer_name'];
}	?>
				
	 

	<form name="deptdetail" id="deptdetail" action="insert_direct_tranexp.php" method="post" enctype="multipart/form-data">
			<input  type="hidden" name="customer_id" value="<?php echo $_REQUEST['customer_id'];?>" />
			<input  type="hidden" name="trans_inv_date" value="<?php echo $_REQUEST['trans_inv_date'];?>" />
			<input  type="hidden" name="trans_inv_no" value="<?php echo $_REQUEST['trans_inv_no'];?>" />
			<input  type="hidden" name="inv_type" value="<?php echo $_REQUEST['inv_type'];?>" />
			


			<input  type="hidden" name="main_id" value="<?php echo $_REQUEST['main_id'];?>" />


                    <div class="row">
                        <div class="col-sm-12">
                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    <h3 class="panel-title">Make Bill for Job: <?php echo $final_job_no?> </h3></div>
                                <div class="panel-body">
                                    <div class="row">
                                                    <?php if($inv_type=='EXP'){?> <div class="col-sm-3 col-xs-12"><div class="form-group">
                                                        <label>Consignor Name</label>
                                                          <input type="text" name="consignor"  value="<? echo $customer_name?>" readonly="readonly" class="form-control">
												<? if($sub_party_name!='') { ?>
												<b style="font-weight:bold; padding-top:5px;">3 Party Name </b>: <? echo $sub_party_name;?>
												<? } ?> 
                                                    </div>
													</div>
													
												
													<div class="col-sm-4 col-xs-12"><div class="form-group">
                                                        <label>Address</label>
                                                         <textarea name="consignor_address" class="form-control" required><? echo $address_exp?></textarea>
                                                    </div>
													</div>  <?php } ?>
													
													
													<?php if($inv_type=='IMP'){?> <div class="col-sm-4 col-xs-12"><div class="form-group">
                                                        <label>Consignor Name</label>
                                                          <input type="text" name="consignor"  value="<? echo $customer_name?>" readonly="readonly" class="form-control">
												<? if($sub_party_name!='') { ?>
												<b style="font-weight:bold; padding-top:5px;">3 Party Name </b>: <? echo $sub_party_name;?>
												<? } ?> 
                                                    </div>
													</div>
													
												
													<div class="col-sm-8 col-xs-12"><div class="form-group">
                                                        <label>Address</label>
                                                         <textarea name="consignor_address" class="form-control" required><? echo $address_exp?></textarea>
                                                    </div>
													</div>  <?php } ?>
													<div class="clearfix"></div>
													<div class="col-sm-4 col-xs-12"><div class="form-group">
                                                        <label>Bill No.</label>
                                                        <input class="form-control" id="trans_inv_no" name="trans_inv_no" value="<?php echo $_REQUEST['trans_inv_no']?>" readonly="readonly" type="text">
                                                    </div>
													</div>
													
													<div class="col-sm-4 col-xs-12"><div class="form-group">
                                                        <label>Bill Date</label>
                                                   <input type="text" class="datepicker1 form-control"  name="trans_inv_date" value="<?php echo $_REQUEST['trans_inv_date']?>"  readonly="readonly" >
                                                    </div>
													</div>
													
													
													<div class="col-sm-3 col-xs-12"><div class="form-group">
                                                        <label>Challan No</label>
														<input type="text" name="challan_no_book"  class="form-control" value="<?php echo $challan_no_book?>" />
														
                                                    </div></div>
												
													<div class="col-sm-3 col-xs-12"><div class="form-group">
                                                        <label>Delivery  Date</label>
                                                        <input type="text" class="form-control"  name="delivery_date" value="<?php echo $delivery_date?>"  >
                                                    </div>
													</div>
													
													<div class="col-sm-4 col-xs-12"><div class="form-group">
                                                        <label> A/C of </label>
                                                       <input type="text" class="form-control"  name="an_ac_of"  <?php if($account_of==''){?>value="Shigmoda Carriers and Lifters Pvt Ltd" <?php } else {?> value="<?php echo $account_of?>"<?php }?>>
                                                    </div>
													</div>
													
													
													
													
													
													
													
													
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
					
					
					
					
					
					
					
					
					<div class="row">
                        <div class="col-sm-12">
                            <div class="panel panel-primary">
                                
                                <div class="panel-body">
                                    <div class="row">
                                                   <div class="col-sm-12 col-xs-12"><div class="form-group">
                                                    
                                                          
														  <table  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">  
														  <tr><th>Sr.No.</th>
														  <th>From </th>
														  <th>To </th>
														  <th>Actual Weight </th>
														  <th>Charged Weight</th>
														  <th>Fright</th>
														  <th>Services </th>
														  <th>Vechicle No.</th>
														  <th>Amt.</th></tr>

      			  <? $i=1;
	//$sql = mysql_query("select * from job_register_import where job_imp_reg_id = '".$_REQUEST['job_imp_reg_id']."' "); 

//$challan_id_p=$_POST['challan_id'];
    $person_to_contact2 = explode(",", $challan_id);
foreach ($person_to_contact2 as $challan_id)
{

$query2 = "select * from  challan_master where challan_id='$challan_id'";
			//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
	                                              	{
$consignor= $row['consignor'];
$consignee= $row['consignee'];
$consignee_gst_no= $row['consignee_gst_no'];
$from_consignor= $row['from_consignor'];
$to_consignor= $row['to_consignor'];
$vehicle_no = $row['vehicle_no'];
$articles_no= $row['articles_no'];
$challan_to= $row['challan_to'];
$weight= $row['weight'];
$freight= $row['freight'];
$transportations_service= $row['transportations_service'];
$description= $row['description'];
$loaded_export_import= $row['loaded_export_import'];
$container_no= $row['container_no'];
$paid= $row['paid'];
$transportation= $row['transportation'];
$loaded= $row['loaded'];
$container_no= $row['container_no'];
$seal_no= $row['seal_no'];
$destinations= $row['destinations'];
$shipping_agent= $row['shipping_agent'];
$booking_no= $row['booking_no'];
$in_time= $row['in_time'];
$out_time= $row['out_time'];
$receiver_signature_with_seal= $row['receiver_signature_with_seal'];
$delivery_at= $row['delivery_at'];
$description= $row['description'];	
	$date= $row['date'];
  $consignor_address= $row['consignor_address'];
  $consignee_addess= $row['consignee_addess'];
  $actual_weight=$row['actual_weight'];
$charged_weight=$row['charged_weight'];
$topay_freight=$row['topay_freight'];
$no_of_pkgs=$row['no_of_pkgs'];
$paid_freight=$row['paid_freight'];		
$challan_no=$row['challan_no'];	

  		$b_e_no=$row['b_e_no'];
$b_e_date=$row['b_e_date'];
$sb_no=$row['sb_no'];
$sb_date=$row['sb_date'];
$seal_no=$row['seal_no'];
$container_type=$row['container_type'];
$consignee_gst_no=$row['consignee_gst_no'];
					}		
		
?>
<input type="hidden" name="challan_id<? echo $i?>" value="<?php echo $challan_id?>">
<tr><td><?php echo $i;?> </td><td>From <?php echo $from_consignor;?><br>
To <?php echo $to_consignor;?> </td><td><?php echo $no_of_pkgs;?> <br>
Container No : <?php $container_no?> </td> <td><? echo $actual_weight;?> </td><td><?php echo $charged_weight;?></td><td><?php echo $paid_freight;?> </td><td><textarea name="particular<?php echo $i?>" class="form-control"></textarea> </td>
<td><textarea name="vehicle_no<?php echo $i?>" class="form-control"><? echo $vehicle_no;?></textarea> </td><td><input type="text" name="chargable_amount<?php echo $i?>" class="form-control"></td></tr><? $i++;?>

<?  }?></table>
														  
														  
														  
                                                    </div>
													</div>
													
												
													
													
													
													
													
													
													
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
					
					
					<input type="hidden" name="count2" value="<?php echo $i?>">

					
					
					<div class="row">
                        <div class="col-sm-12">
                            <div class="panel panel-primary">
                                
                                <div class="panel-body">
                                    <div class="row">
                                                   <div class="col-sm-12 col-xs-12"><div class="form-group">
                                                    
                                                         <table class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">


<tr>
    <td colspan="2"> <a class="btn btn-success waves-effect waves-light" onClick="callAddContact2();" title="Click to add Contacts">
									<span class="glyphicon glyphicon-plus"></span>&nbsp;Add Services
								</a>	<a class="btn btn-danger waves-effect waves-light"  onClick="delRow();" title="Click to remove">
								  <span class="glyphicon glyphicon-minus"></span>&nbsp;Del							</a></td>
  </tr>
  
  
  
  
  
  </table>
  
  <table class="table table-striped table-bordered dt-responsive nowrap" id="cntTable2">
							
								<tr bgcolor="#C5DFFA" >
								
								
									<td width="100px" height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Sr.No.</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Particular</strong></div></td>

									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Amount</strong></div> </td>

									
									
							</tr>
							</thead>
							<tbody> <input id="allcontypes" name="allcontypes" value="Decision Maker~^~Influencer~^~Recommender~^~User~^~Purchase Officer" type="hidden">
						<input name="cntlnos" id="cntlnos" value="" type="hidden">
						<input name="cntcount2" id="cntcount2" value="" type="hidden">
						<input name="cntdelids" id="cntdelids" value="" type="hidden">

							</tbody>
						</table>
   
														 						  
														  
                                                    </div>
													</div>
													
												
													
												<div class="col-sm-12 col-xs-12">
                                           
                                            <div class="m-t-20">
                                                    <div class="form-group">
                                                        <div>
                                                          <input class="btn btn-primary " type="submit" name="Submit" value="NEXT" >
						
															
                                                           
                                                        </div>
                                                    </div>
                                               
                                            </div>
                                        </div>	
													
													
													
													
													
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
					
					
					
					
					</form>
        
         <script type="text/Javascript">
	function callAddContact2()
	{
	
   var tbl = document.getElementById('cntTable2');
	 var lastRow = tbl.rows.length;
	 // if there's no header row in the table, then iteration = lastRow + 1
	 var iteration = lastRow;
	 var row = tbl.insertRow(lastRow);
	 var node1;
	 var lineno = lastRow;
	 // cell 0
	 var cellLeft = row.insertCell(0);
	 cellLeft.className = "center";
		var node = document.createElement('span');
		node.className = "glyphicon glyphicon-remove";
		node.title="Delete line";
		var link = document.createElement("a");
		link.className = "btn bg-btn-delete";
		link.style.padding = "0px 2px";
		link.href="javascript:callRemoveContact("+lineno+");";
		link.appendChild(node);
		//cellLeft.appendChild(link);
	 
	 node = document.createElement("input");
	 node.type = 'hidden';
	 node.name = 'cid'+lineno;
	 node.value = '';
	 node.id = 'cid'+lineno;
	 cellLeft.appendChild(node);
	 node = document.createElement("input");
	 node.type = 'text';
	 node.style.width = "50px";
	
	 node.name = 'clinenum'+lineno;
	 node.value = lineno;
	 node.readOnly = true;
	 node.id = 'clinenum'+lineno;
	 cellLeft.appendChild(node);
	 
	 
	 
	  var cell1 = row.insertCell(1);
	  
	 node = document.createElement("textarea");
	 node.className = 'form-control';
	 node.type = 'text';	
	 node.name = 'particular_a'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell1.appendChild(node);
	 
	
	 

	 
	 
		  var cell2 = row.insertCell(2);
	  
	 node = document.createElement("input");
	 node.className = 'form-control';
	 node.type = 'text';	
	 node.name = 'chargable_amount_a'+lineno;
	 node.placeholder='Amount';
	 node.value = "";
	 node.id = '';
	 cell2.appendChild(node);
	
		
		
	document.getElementById('cntcount2').value = lineno;
	document.getElementById('sigthseeing').style.visibility='visible';
	
}
function delRow()
{

    var tableName = document.getElementById('cntTable2');

    var prev = tableName.rows.length;

    if(prev > 1)

{
    

/////////////////////////////////////////////////////////////////////////////////////
   
	 // if there's no header row in the table, then iteration = lastRow + 1
	
	 var row = document.getElementById('cntTable2').deleteRow(prev-1);
	 
	 }
	 var node1;
	  var iteration = lastRow;
	 var lastRow = tableName.rows.length;
	 var lineno = lastRow;
document.getElementById('cntcount2').value = lineno-1;




}
</script>


      </div>
    </div>
   	<?php include 'footer1a.php';?>
