<?php 
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];

$flag=$_REQUEST['flag'];
if($flag=='')
{
$user=$_GET['user'];
$dskltrid=$_GET['dskltrid'];

$dptltrid=$_GET['dptltrid'];// fetch desk_ltr_id
if($user==1)
{
	include_once('dashboard_bdo.php');	
?><html> 
<head>
<script type="text/javascript" src="js/adduser.js"></script> 
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
	 <script type="text/javascript">     
       function PrintDivs() {    
           var divToPrint = document.getElementById('divToPrints');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<style>
td{
height:20px;
width:190px;
}
</style>
</head>
<body>
   <div class="rightpanel">
	<?php
	##################################################### Query ###############################################
		$query11=mysql_query(" SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, di.addressed_to, i.ref_dt, i.ref_no, d.dispatched_dt, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, di.dept_id_to, di.dsk_id_to, d.ltr_category, d.assign_no 
		FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
		LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
		LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
		WHERE d.desk_ltr_id='$dskltrid' ") or die("".mysql_error());
		
		$row=mysql_fetch_array($query11);
		$inwardpath=$row['document'];
		$deptid=$row['dept_id_from'];
		$deskid=$row['desk_id_from'];
		$outwardpath=$row['scan_doc'];
		//fetch inward image
		$str2 = substr($inwardpath, 3);
		//fetch outward image
		$str3 = substr($outwardpath, 3);
		$dptnm=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$deptid'");
		$deptnm=mysql_fetch_array($dptnm);
		$dsknm=mysql_query("SELECT desk_nm from desk_master WHERE desk_id='$deskid'");
		$desknm=mysql_fetch_array($dsknm);
		###################### seperate file name from path for inward file ##########################
		$file1 = basename($inwardpath);      
		##############code to retrive extension of file for outward file #########################	
		$filename=$file1;
		$ext = end(explode('.', $filename));	
		$ext = substr(strrchr($filename, '.'), 1);
		$ext = substr($filename, strrpos($filename, '.') + 1);
		$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
		$exts = split("[/\\.]", $filename);
		$n    = count($exts)-1;
		$inext  = $exts[$n];	

		###################### seperate file name from path for outward file ##########################
		$file2 = basename($outwardpath);       

		##############code to retrive extension of file for outward file #########################	
		$filename1=$file2;
		$ext1 = end(explode('.', $filename1));	
		$ext1 = substr(strrchr($filename1, '.'), 1);
		$ext1 = substr($filename1, strrpos($filename1, '.') + 1);
		$ext1 = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename1);
		$exts1 = split("[/\\.]", $filename1);
		$n1    = count($exts1)-1;
		$outext  = $exts1[$n1];
			
		?>
		<ul class="breadcrumbs">
            <li><a href="dashboard_bdo.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="dashboard_bdo.php"></a> <span class="separator"></span></li>
            <li>आवक बारनिशी व जावक बारनिशी</li>
        </ul>
        
        <div class="pageheader"> 
            <div class="pageicon"><span class="iconfa-pencil"></span></div>
				<div class="pagetitle">
					<h5>Forms</h5>
					<h1>आवक बारनिशी व जावक बारनिशी</h1>
				</div>
		</div><!--pageheader-->
        
			<div class="maincontent">
				<div class="maincontentinner">
				<!------------------------------- Tab Desigining -------------------------------------->
					<div class="tabbedwidget tab-primary"><ul></ul></div>
						<div class="tabbedwidget tab-primary ui-tabs ui-widget ui-widget-content ui-corner-all">
                            <ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                                <li aria-selected="true" aria-labelledby="ui-id-4" aria-controls="a-1" tabindex="0" role="tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a id="ui-id-4" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-1" style="font-size:14px;">आवक बारनिशी</a></li>
                                <li aria-selected="false" aria-labelledby="ui-id-5" aria-controls="a-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-5" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-2" style="font-size:14px;">जावक बारनिशी</a></li>
                            </ul>
							
							<!------------------------- avak Barnishi ------------------------------------------>
                            <div aria-hidden="false" aria-expanded="true" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-4" id="a-1">
								<div id="divToPrint">
									<h4 class="widgettitle1">आवक बारनिशी</h4><br>
										<table>
											<tr>
												<td>आ_क्र : </td>
												<td>आ_दि : </td>
												<td>विषय : </td>
												<td>कोणाकडून प्राप्त : </td>
											</tr>
											
											<tr>
												<td><?php echo $row['ltr_inword_no']; ?></td>
												<td><?php echo $row['receive_dt']; ?></td>
												<td><?php echo $row['subject']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>विभाग आ_क्र : </td>
												<td>विभाग प्राप्त दि : </td>
												<td>डेस्क आ_क्र : </td>
												<td>डेस्क प्राप्त दि : </td>
												<td>केलेली कार्यवाही : </td>
											</tr>
											<tr>
												<td><?php echo $row['dpt_inword_no']; ?></td>
												<td><?php echo $row['dpt_ltr_rec_dt']; ?></td>
												<td><?php echo $row['desk_ltr_inword_no']; ?></td>
												<td><?php echo $row['desk_ltr_rec_dt']; ?></td>
												<?php
												if( $row['ltr_status']!='')
												{
													echo "<td> ".$row['action_taken']."</td>";
												}
												else
												{
													echo "<td>  </td>";
												}
												?>
											</tr>
											
										</table><br>
									
												<?php 
												
												if($inext=='bmp' || $inext=='gif'|| $inext== 'jpg'|| $inext== 'png' ||$inext=='BMP' ||$inext=='GIF' ||$inext=='JPG' ||$inext=='PNG' ||$inext=='JPEG' || $inext=='jpeg')
												{
												?>
												<!------------------- image fetching ------------------------->
												<img src="<?php echo $str2; ?>" height="400px" width="100%" align='centre' border="2" style="border-color: #ff0000;">
													</div>	<!--print div-->
													<p>	
													<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"	/>
													</p>
										
												<!------------------- pdf fetching ------------------------->
												<?php }
												else if($inext=='pdf' || $inext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str2; ?>"></iframe>
												<?php
												}
												?>
								
							</div>
							<!--------------------------- End Of Javak Barnishi ---------------->
							<!------------------------- Javak Barnishi ------------------------------------------>
                            <div aria-hidden="true" aria-expanded="false" style="display:none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-5" id="a-2">
							
									<div id="divToPrints">
										<h4 class="widgettitle1">जावक बारनिशी</h4><br>
										
										<table>
											<tr>
												<td>जावक_क्र. : </td>
												<td>जावक_दि. : </td>
												<td>कोणाकडून प्राप्त : </td>
												<td>विषय : </td>
											</tr>
											<tr>
												<td><?php echo $row['outword_no']; ?></td>
												<td><?php echo $row['dispatched_dt']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
												<td><?php echo $row['subject']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>कोणास पाठवले : </td>
												<td>केलेली कार्यवाही : </td>
												<td>विभाग जा_क्र : </td>
											</tr>
											<tr>
											
												<td>
													<?php
														if($row['dispatched_to']=='permanent')
														{
															echo $row['addressed_to'];
														}
														else if($row['dispatched_to']=='department')
														{
															$todept=$row['dept_id_to'];
															$q=mysql_query("SELECT dept_nm from department_master where dept_id='$todept' ");
															$r=mysql_fetch_array($q);
															echo $r['dept_nm'];
														}
														else if($row['dispatched_to']=='desk')
														{
															$todesk=$row['dsk_id_to'];
															$q=mysql_query("SELECT desk_nm from desk_master where desk_id='$todesk' ");
															$r=mysql_fetch_array($q);
															echo $r['desk_nm'];
														}
													?>
												</td>
												<td><?php echo $row['action_taken']; ?></td>
												<td><?php echo $deptnm['dept_nm']."-".$row['dpt_inword_no'] ?>/<?php echo "<br>".$desknm['desk_nm']."-".$row['desk_ltr_inword_no']; ?></td>
											</tr>
											</table><br>
								
											<?php if($outext=='bmp' || $outext=='gif'|| $outext== 'jpg'|| $outext== 'png' ||$outext=='BMP' ||$outext=='GIF' ||$outext=='JPG' ||$outext=='PNG' ||$outext=='JPEG' || $outext=='jpeg')
												{
												?>
												<img src="<?php echo $str3;?>" height="400px" width="100%" align='centre'>
											</div>	<!--print div-->
												
											
												<?php }
												else if($outext=='pdf' || $outext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str3;?>?#zoom=100"></iframe>
												<?php
												}
											
												?>
												<p>	
												<center><input type="submit" value=" Print Page " onclick="PrintDivs();" class="btn btn-primary"/>
												</p>
                        </div>
             </div>
			<?php include_once('footer.php'); ?>
        </div><!--maincontentinner-->
    </div><!--rightpanel-->
</body>
</html>
			 <!----------------------------------------------------- End Of Javak Barnishi ----------------------------------->
 <?php 
 }
 
else if($user==2)
{
	include_once('dashboard_tapal.php');
?><html> 
<head>
<script type="text/javascript" src="js/adduser.js"></script> 
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
	 <script type="text/javascript">     
       function PrintDivs() {    
           var divToPrint = document.getElementById('divToPrints');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<style>
td{
height:20px;
width:190px;
}
</style>
</head>
<body>
   <div class="rightpanel">
	<?php
	##################################################### Query ###############################################
		$query11=mysql_query(" SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, di.addressed_to, i.ref_dt, i.ref_no, d.dispatched_dt, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.assign_no 
		FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
		LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
		LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
		WHERE d.desk_ltr_id='$dskltrid'") or die("".mysql_error());
		$row=mysql_fetch_array($query11);
		$inwardpath=$row['document'];
		$deptid=$row['dept_id_from'];
		$deskid=$row['desk_id_from'];
		$outwardpath=$row['scan_doc'];
		//fetch inward image
		$str2 = substr($inwardpath, 3);
		//fetch outward image
		$str3 = substr($outwardpath, 3);
		$dptnm=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$deptid'");
		$deptnm=mysql_fetch_array($dptnm);
		$dsknm=mysql_query("SELECT desk_nm from desk_master WHERE desk_id='$deskid'");
		$desknm=mysql_fetch_array($dsknm);
		###################### seperate file name from path for inward file ##########################
		$file1 = basename($inwardpath);      
		##############code to retrive extension of file for outward file #########################	
		$filename=$file1;
		$ext = end(explode('.', $filename));	
		$ext = substr(strrchr($filename, '.'), 1);
		$ext = substr($filename, strrpos($filename, '.') + 1);
		$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
		$exts = split("[/\\.]", $filename);
		$n    = count($exts)-1;
		$inext  = $exts[$n];	

		###################### seperate file name from path for outward file ##########################
		$file2 = basename($outwardpath);       

		##############code to retrive extension of file for outward file #########################	
		$filename1=$file2;
		$ext1 = end(explode('.', $filename1));	
		$ext1 = substr(strrchr($filename1, '.'), 1);
		$ext1 = substr($filename1, strrpos($filename1, '.') + 1);
		$ext1 = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename1);
		$exts1 = split("[/\\.]", $filename1);
		$n1    = count($exts1)-1;
		$outext  = $exts1[$n1];
			
		?>
		<ul class="breadcrumbs">
            <li><a href="dashboard_bdo.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="dashboard_bdo.php"></a> <span class="separator"></span></li>
            <li>आवक बारनिशी व जावक बारनिशी</li>
        </ul>
        
        <div class="pageheader"> 
            <div class="pageicon"><span class="iconfa-pencil"></span></div>
				<div class="pagetitle">
					<h5>Forms</h5>
					<h1>आवक बारनिशी व जावक बारनिशी</h1>
				</div>
		</div><!--pageheader-->
        
			<div class="maincontent">
				<div class="maincontentinner">
				<!------------------------------- Tab Desigining -------------------------------------->
					<div class="tabbedwidget tab-primary"><ul></ul></div>
						<div class="tabbedwidget tab-primary ui-tabs ui-widget ui-widget-content ui-corner-all">
                            <ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                                <li aria-selected="true" aria-labelledby="ui-id-4" aria-controls="a-1" tabindex="0" role="tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a id="ui-id-4" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-1" style="font-size:14px;">आवक बारनिशी</a></li>
                                <li aria-selected="false" aria-labelledby="ui-id-5" aria-controls="a-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-5" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-2" style="font-size:14px;">जावक बारनिशी</a></li>
                            </ul>
							
							<!------------------------- avak Barnishi ------------------------------------------>
                            <div aria-hidden="false" aria-expanded="true" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-4" id="a-1">
								<div id="divToPrint">
									<h4 class="widgettitle1">आवक बारनिशी</h4><br>
										<table>
											<tr>
												<td>आ_क्र : </td>
												<td>आ_दि : </td>
												<td>विषय : </td>
												<td>कोणाकडून प्राप्त : </td>
											</tr>
											<tr>
												<td><?php echo $row['ltr_inword_no']; ?></td>
												<td><?php echo $row['receive_dt']; ?></td>
												<td><?php echo $row['subject']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>विभाग आ_क्र : </td>
												<td>विभाग प्राप्त दि : </td>
												<td>डेस्क आ_क्र : </td>
												<td>डेस्क प्राप्त दि : </td>
												<td>केलेली कार्यवाही : </td>
											</tr>
											<tr>
												<td><?php echo $row['dpt_inword_no']; ?></td>
												<td><?php echo $row['dpt_ltr_rec_dt']; ?></td>
												<td><?php echo $row['desk_ltr_inword_no']; ?></td>
												<td><?php echo $row['desk_ltr_rec_dt']; ?></td>
												<?php	
												if( $row['ltr_status']!='')
												{
													echo "<td>केलेली कार्यवाही : </td><td> ".$row['action_taken']."</td>";
												}
												else
												{
													echo "<td>केलेली कार्यवाही : </td><td>  </td>";
												}
												?>
											</tr>
											
										</table><br>
									
												<?php if($inext=='bmp' || $inext=='gif'|| $inext== 'jpg'|| $inext== 'png' ||$inext=='BMP' ||$inext=='GIF' ||$inext=='JPG' ||$inext=='PNG' ||$inext=='JPEG' || $inext=='jpeg')
												{
												?>
												<!------------------- image fetching ------------------------->
												<img src="<?php echo $str2;?>" height="400px" width="100%" align='centre' border="2" style="border-color: #ff0000;">
													</div>	<!--print div-->
													<p>	
													<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"	/>
													</p>
										
												<!------------------- pdf fetching ------------------------->
												<?php }
												else if($inext=='pdf' || $inext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str2;?>"></iframe>
												<?php
												}
												?>
								
							</div>
							<!--------------------------- End Of Javak Barnishi ---------------->
							<!------------------------- Javak Barnishi ------------------------------------------>
                            <div aria-hidden="true" aria-expanded="false" style="display:none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-5" id="a-2">
							
									<div id="divToPrints">
										<h4 class="widgettitle1">जावक बारनिशी</h4><br>
										
										<table>
											<tr>
												<td>जावक_क्र. : </td>
												<td>जावक_दि. : </td>
												<td>कोणाकडून प्राप्त : </td>
												<td>विषय : </td>
											</tr>
											<tr>
												<td><?php echo $row['outword_no']; ?></td>
												<td><?php echo $row['dispatched_dt']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
												<td><?php echo $row['subject']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>कोणास पाठवले : </td>
												<td>केलेली कार्यवाही : </td>
												<td>विभाग जा_क्र : </td>
											</tr>
											<tr>
												<td>
													<?php 
														if($row['dispatched_to']=='permanent')
														{
															echo $row['addressed_to'];
														}
														else if($row['dispatched_to']=='department')
														{
															$todept=$row['dept_id_to'];
															$q=mysql_query("SELECT dept_nm from department_master where dept_id='$todept' ");
															$r=mysql_fetch_array($q);
															echo $r['dept_nm'];
														}
														else if($row['dispatched_to']=='desk')
														{
															$todesk=$row['dsk_id_to'];
															$q=mysql_query("SELECT desk_nm from desk_master where desk_id='$todesk' ");
															$r=mysql_fetch_array($q);
															echo $r['desk_nm'];
														} 
													?>
												</td>
												<td><?php echo $row['action_taken']; ?></td>
												<td><?php echo $deptnm['dept_nm']."-".$row['dpt_inword_no'] ?>/<?php echo "<br>".$desknm['desk_nm']."-".$row['desk_ltr_inword_no']; ?></td>
											</tr>
											<tr>
											
											<tr>
											</table><br>
								
											<?php if($outext=='bmp' || $outext=='gif'|| $outext== 'jpg'|| $outext== 'png' ||$outext=='BMP' ||$outext=='GIF' ||$outext=='JPG' ||$outext=='PNG' ||$outext=='JPEG' || $outext=='jpeg')
												{
												?>
												<img src="<?php echo $str3;?>" height="400px" width="100%" align='centre'>
											</div>	<!--print div-->
												
											
												<?php }
												else if($outext=='pdf' || $outext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str3;?>?#zoom=100"></iframe>
												<?php
												}
												?>
												<p>	
												<center><input type="submit" value=" Print Page " onclick="PrintDivs();" class="btn btn-primary"/>
												</p>
                        </div>
             </div>
			<?php include_once('footer.php'); ?>
        </div><!--maincontentinner-->
    </div><!--rightpanel-->
</body>
</html>
			 <!----------------------------------------------------- End Of Javak Barnishi ----------------------------------->
 <?php 
 }
 

 } //if($flag='n')
 
 ////////////////////////////////////////////////////////////////////////
 
else if($flag=='n')
{
$user=$_GET['user'];
//$dskltrid=$_GET['dskltrid'];

$dptltrid=$_GET['dptltrid'];// fetch desk_ltr_id
if($user==1)
{
	include_once('dashboard_bdo.php');
?><html> 
<head>
<script type="text/javascript" src="js/adduser.js"></script> 
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
	 <script type="text/javascript">     
       function PrintDivs() {    
           var divToPrint = document.getElementById('divToPrints');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<style>
td{
height:20px;
width:190px;
}
</style>
</head>
<body>
   <div class="rightpanel">
	<?php
	##################################################### Query ###############################################
		/*$query11=mysql_query(" SELECT desk_transaction.desk_ltr_id, desk_transaction.desk_id_from, desk_transaction.action_taken, desk_transaction.desk_ltr_rec_dt, desk_transaction.desk_ltr_inword_no, tapal_to_dpt_transaction.dpt_inword_no, tapal_to_dpt_transaction.dpt_ltr_id, tapal_to_dpt_transaction.dpt_ltr_rec_dt, tapal_to_dpt_transaction.dpt_inword_no, tapal_to_dpt_transaction.desk_id, tapal_to_dpt_transaction.dept_id_from, incoming_letters_transaction.subject, desk_transaction.ltr_approval, dispatched_transaction.addressed_to, desk_transaction.ltr_status, incoming_letters_transaction.sender_name, incoming_letters_transaction.ltr_id, incoming_letters_transaction.ltr_inword_no, incoming_letters_transaction.receive_dt, dispatched_transaction.addressed_to, incoming_letters_transaction.ref_dt, incoming_letters_transaction.ref_no, desk_transaction.dispatched_dt, incoming_letters_transaction.dept_id, incoming_letters_transaction.document, desk_transaction.scan_doc, dispatched_transaction.outword_no, dispatched_transaction.dispatched_to, desk_transaction.ltr_category, desk_transaction.assign_no FROM tapal_to_dpt_transaction LEFT OUTER JOIN incoming_letters_transaction ON incoming_letters_transaction.ltr_id = tapal_to_dpt_transaction.ltr_id LEFT OUTER JOIN desk_transaction ON desk_transaction.dpt_ltr_id = tapal_to_dpt_transaction.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction ON dispatched_transaction.desk_ltr_id = desk_transaction.desk_ltr_id WHERE tapal_to_dpt_transaction.dpt_ltr_id='$dptltrid'") or die("".mysql_error());*/
		$query11=mysql_query("SELECT t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, di.addressed_to, i.ref_dt, i.ref_no, t.dispatched_date, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, t.ltr_category, t.assign_no 
		FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
		LEFT OUTER JOIN dispatched_transaction di ON di.ltr_id = t.ltr_id 
		WHERE t.dpt_ltr_id='$dptltrid' ") or die("".mysql_error());
		$row=mysql_fetch_array($query11);
		$inwardpath=$row['document'];
		$deptid=$row['dept_id_from'];
		//$deskid=$row['desk_id_from'];
		$outwardpath=$row['scan_doc'];
		//fetch inward image
		$str2 = substr($inwardpath, 3);
		//fetch outward image
		$str3 = substr($outwardpath, 3);
		$dptnm=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$deptid'");
		$deptnm=mysql_fetch_array($dptnm);
		//$dsknm=mysql_query("SELECT desk_nm from desk_master WHERE desk_id='$deskid'");
		//$desknm=mysql_fetch_array($dsknm);
		###################### seperate file name from path for inward file ##########################
		$file1 = basename($inwardpath);      
		##############code to retrive extension of file for outward file #########################	
		$filename=$file1;
		$ext = end(explode('.', $filename));	
		$ext = substr(strrchr($filename, '.'), 1);
		$ext = substr($filename, strrpos($filename, '.') + 1);
		$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
		$exts = split("[/\\.]", $filename);
		$n    = count($exts)-1;
		$inext  = $exts[$n];	

		###################### seperate file name from path for outward file ##########################
		$file2 = basename($outwardpath);       

		##############code to retrive extension of file for outward file #########################	
		$filename1=$file2;
		$ext1 = end(explode('.', $filename1));	
		$ext1 = substr(strrchr($filename1, '.'), 1);
		$ext1 = substr($filename1, strrpos($filename1, '.') + 1);
		$ext1 = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename1);
		$exts1 = split("[/\\.]", $filename1);
		$n1    = count($exts1)-1;
		$outext  = $exts1[$n1];
			
		?>
		<ul class="breadcrumbs">
            <li><a href="new_dashboard_department.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="new_dashboard_department.php"></a> <span class="separator"></span></li>
            <li>आवक बारनिशी व जावक बारनिशी</li>
        </ul>
        
        <div class="pageheader"> 
            <div class="pageicon"><span class="iconfa-pencil"></span></div>
				<div class="pagetitle">
					<h5>Forms</h5>
					<h1>आवक बारनिशी व जावक बारनिशी</h1>
				</div>
		</div><!--pageheader-->
        
			<div class="maincontent">
				<div class="maincontentinner">
				<!------------------------------- Tab Desigining -------------------------------------->
					<div class="tabbedwidget tab-primary"><ul></ul></div>
						<div class="tabbedwidget tab-primary ui-tabs ui-widget ui-widget-content ui-corner-all">
                            <ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                                <li aria-selected="true" aria-labelledby="ui-id-4" aria-controls="a-1" tabindex="0" role="tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a id="ui-id-4" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-1" style="font-size:14px;">आवक बारनिशी</a></li>
                                <li aria-selected="false" aria-labelledby="ui-id-5" aria-controls="a-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-5" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-2" style="font-size:14px;">जावक बारनिशी</a></li>
                            </ul>
							
							<!------------------------- avak Barnishi ------------------------------------------>
                            <div aria-hidden="false" aria-expanded="true" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-4" id="a-1">
								<div id="divToPrint">
									<h4 class="widgettitle1">आवक बारनिशी</h4><br>
										<table>
											<tr>
												<td>आ_क्र : </td>
												<td>आ_दि : </td>
												<td>विषय : </td>
												<td>कोणाकडून प्राप्त : </td>
											</tr>
											<tr>
												<td><?php echo $row['ltr_inword_no']; ?></td>
												<td><?php echo $row['receive_dt']; ?></td>
												<td><?php echo $row['subject']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>विभाग आ_क्र : </td><td><?php echo $row['dpt_inword_no']; ?></td>
												<td>विभाग प्राप्त दि : </td><td><?php echo $row['dpt_ltr_rec_dt']; ?></td>
												<td>केलेली कार्यवाही : </td>
											</tr>
											<tr>
												<td><?php echo $row['dpt_inword_no']; ?></td>
												<td><?php echo $row['dpt_ltr_rec_dt']; ?></td>
												<?php	
												if( $row['ltr_status']!='')
												{
													echo "<td> ".$row['action_taken']."</td>";
												}
												else
												{
													echo "<td>  </td>";
												}
											?>
											</tr>
											
											
										</table><br>
									
												<?php if($inext=='bmp' || $inext=='gif'|| $inext== 'jpg'|| $inext== 'png' ||$inext=='BMP' ||$inext=='GIF' ||$inext=='JPG' ||$inext=='PNG' ||$inext=='JPEG' || $inext=='jpeg')
												{
												?>
												<!------------------- image fetching ------------------------->
												<img src="<?php echo $str2;?>" height="400px" width="100%" align='centre' border="2" style="border-color: #ff0000;">
													</div>	<!--print div-->
													<p>	
													<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"	/>
													</p>
										
												<!------------------- pdf fetching ------------------------->
												<?php }
												else if($inext=='pdf' || $inext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str2;?>"></iframe>
												<?php
												}
												?>
								
							</div>
							<!--------------------------- End Of Avak Barnishi ---------------->
							<!------------------------- Javak Barnishi ------------------------------------------>
                            <div aria-hidden="true" aria-expanded="false" style="display:none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-5" id="a-2">
							
									<div id="divToPrints">
										<h4 class="widgettitle1">जावक बारनिशी</h4><br>
										
										<table>
											<tr>
												<td>जावक_क्र. : </td>
												<td>जावक_दि. : </td>
												<td>कोणाकडून प्राप्त : </td>
												<td>विषय : </td>
											</tr>
											<tr>
												<td><?php echo $row['outword_no']; ?></td>
												<td><?php echo $row['dispatched_date']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
												<td><?php echo $row['subject']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>कोणास पाठवले : </td>
												<td>केलेली कार्यवाही : </td>
												<td>विभाग जा_क्र : </td>
											</tr>
											<tr>
												<td>
													<?php 
														if($row['dispatched_to']=='permanent')
														{
															echo $row['addressed_to'];
														}
														else if($row['dispatched_to']=='department')
														{
															$todept=$row['dept_id_to'];
															$q=mysql_query("SELECT dept_nm from department_master where dept_id='$todept' ");
															$r=mysql_fetch_array($q);
															echo $r['dept_nm'];
														}
													?>
												</td>
												<td><?php echo $row['action_taken']; ?></td>
												<td><?php echo $deptnm['dept_nm']."-".$row['dpt_inword_no'] ?></td>
											</tr>
											</table><br>
								
											<?php if($outext=='bmp' || $outext=='gif'|| $outext== 'jpg'|| $outext== 'png' ||$outext=='BMP' ||$outext=='GIF' ||$outext=='JPG' ||$outext=='PNG' ||$outext=='JPEG' || $outext=='jpeg')
												{
												?>
												<img src="<?php echo $str3;?>" height="400px" width="100%" align='centre'>
											</div>	<!--print div-->
												
												<?php }
												else if($outext=='pdf' || $outext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str3;?>?#zoom=100"></iframe>
												<?php
												}
												?>
												<p>	
												<center><input type="submit" value=" Print Page " onclick="PrintDivs();" class="btn btn-primary"/>
												</p>
                        </div>
             </div>
			<?php include_once('footer.php'); ?>
        </div><!--maincontentinner-->
    </div><!--rightpanel-->
</body>
</html>
			 <!----------------------------------------------------- End Of Javak Barnishi ----------------------------------->
 <?php 
}
	
else if($user==2)
{
	include_once('dashboard_tapal.php');
?><html> 
<head>
<script type="text/javascript" src="js/adduser.js"></script> 
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
	 <script type="text/javascript">     
       function PrintDivs() {    
           var divToPrint = document.getElementById('divToPrints');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<style>
td{
height:20px;
width:190px;
}
</style>
</head>
<body>
   <div class="rightpanel">
	<?php
	##################################################### Query ###############################################
		/*$query11=mysql_query(" SELECT desk_transaction.desk_ltr_id, desk_transaction.desk_id_from, desk_transaction.action_taken, desk_transaction.desk_ltr_rec_dt, desk_transaction.desk_ltr_inword_no, tapal_to_dpt_transaction.dpt_inword_no, tapal_to_dpt_transaction.dpt_ltr_id, tapal_to_dpt_transaction.dpt_ltr_rec_dt, tapal_to_dpt_transaction.dpt_inword_no, tapal_to_dpt_transaction.desk_id, tapal_to_dpt_transaction.dept_id_from, incoming_letters_transaction.subject, desk_transaction.ltr_approval, dispatched_transaction.addressed_to, desk_transaction.ltr_status, incoming_letters_transaction.sender_name, incoming_letters_transaction.ltr_id, incoming_letters_transaction.ltr_inword_no, incoming_letters_transaction.receive_dt, dispatched_transaction.addressed_to, incoming_letters_transaction.ref_dt, incoming_letters_transaction.ref_no, desk_transaction.dispatched_dt, incoming_letters_transaction.dept_id, incoming_letters_transaction.document, desk_transaction.scan_doc, dispatched_transaction.outword_no, dispatched_transaction.dispatched_to, desk_transaction.ltr_category, desk_transaction.assign_no FROM tapal_to_dpt_transaction LEFT OUTER JOIN incoming_letters_transaction ON incoming_letters_transaction.ltr_id = tapal_to_dpt_transaction.ltr_id LEFT OUTER JOIN desk_transaction ON desk_transaction.dpt_ltr_id = tapal_to_dpt_transaction.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction ON dispatched_transaction.desk_ltr_id = desk_transaction.desk_ltr_id WHERE tapal_to_dpt_transaction.dpt_ltr_id='$dptltrid'") or die("".mysql_error());*/
		$query11=mysql_query("SELECT t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, di.addressed_to, i.ref_dt, i.ref_no, t.dispatched_date, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, t.ltr_category, t.assign_no 
		FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
		LEFT OUTER JOIN dispatched_transaction di ON di.ltr_id = t.ltr_id 
		WHERE t.dpt_ltr_id='$dptltrid' ") or die("".mysql_error());
		$row=mysql_fetch_array($query11);
		$inwardpath=$row['document'];
		$deptid=$row['dept_id_from'];
		//$deskid=$row['desk_id_from'];
		$outwardpath=$row['scan_doc'];
		//fetch inward image
		$str2 = substr($inwardpath, 3);
		//fetch outward image
		$str3 = substr($outwardpath, 3);
		$dptnm=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$deptid'");
		$deptnm=mysql_fetch_array($dptnm);
		//$dsknm=mysql_query("SELECT desk_nm from desk_master WHERE desk_id='$deskid'");
		//$desknm=mysql_fetch_array($dsknm);
		###################### seperate file name from path for inward file ##########################
		$file1 = basename($inwardpath);      
		##############code to retrive extension of file for outward file #########################	
		$filename=$file1;
		$ext = end(explode('.', $filename));	
		$ext = substr(strrchr($filename, '.'), 1);
		$ext = substr($filename, strrpos($filename, '.') + 1);
		$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
		$exts = split("[/\\.]", $filename);
		$n    = count($exts)-1;
		$inext  = $exts[$n];	

		###################### seperate file name from path for outward file ##########################
		$file2 = basename($outwardpath);       

		##############code to retrive extension of file for outward file #########################	
		$filename1=$file2;
		$ext1 = end(explode('.', $filename1));	
		$ext1 = substr(strrchr($filename1, '.'), 1);
		$ext1 = substr($filename1, strrpos($filename1, '.') + 1);
		$ext1 = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename1);
		$exts1 = split("[/\\.]", $filename1);
		$n1    = count($exts1)-1;
		$outext  = $exts1[$n1];
			
		?>
		<ul class="breadcrumbs">
            <li><a href="dashboard_tapal.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="dashboard_tapal.php"></a> <span class="separator"></span></li>
            <li>आवक बारनिशी व जावक बारनिशी</li>
        </ul>
        
        <div class="pageheader"> 
            <div class="pageicon"><span class="iconfa-pencil"></span></div>
				<div class="pagetitle">
					<h5>Forms</h5>
					<h1>आवक बारनिशी व जावक बारनिशी</h1>
				</div>
		</div><!--pageheader-->
        
			<div class="maincontent">
				<div class="maincontentinner">
				<!------------------------------- Tab Desigining -------------------------------------->
					<div class="tabbedwidget tab-primary"><ul></ul></div>
						<div class="tabbedwidget tab-primary ui-tabs ui-widget ui-widget-content ui-corner-all">
                            <ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                                <li aria-selected="true" aria-labelledby="ui-id-4" aria-controls="a-1" tabindex="0" role="tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a id="ui-id-4" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-1" style="font-size:14px;">आवक बारनिशी</a></li>
                                <li aria-selected="false" aria-labelledby="ui-id-5" aria-controls="a-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-5" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#a-2" style="font-size:14px;">जावक बारनिशी</a></li>
                            </ul>
							
							<!------------------------- avak Barnishi ------------------------------------------>
                            <div aria-hidden="false" aria-expanded="true" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-4" id="a-1">
								<div id="divToPrint">
									<h4 class="widgettitle1">आवक बारनिशी</h4><br>
										<table>
											<tr>
												<td>आ_क्र : </td>
												<td>आ_दि : </td>
												<td>विषय : </td>
												<td>कोणाकडून प्राप्त : </td>
											</tr>
											<tr>
												<td><?php echo $row['ltr_inword_no']; ?></td>
												<td><?php echo $row['receive_dt']; ?></td>
												<td><?php echo $row['subject']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
											</tr>
											<tr> <td colspan=4></td><tr>
											<tr>
												<td>विभाग आ_क्र : </td>
												<td>विभाग प्राप्त दि : </td>
												<td>केलेली कार्यवाही : </td>
											</tr>
											<tr>
												<td><?php echo $row['dpt_inword_no']; ?></td>
												<td><?php echo $row['dpt_ltr_rec_dt']; ?></td>
												<?php	
												if( $row['ltr_status']!='')
												{
													echo "<td> ".$row['action_taken']."</td>";
												}
												else
												{
													echo "<td>  </td>";
												}
												?>
											</tr>
										</table><br>
									
												<?php if($inext=='bmp' || $inext=='gif'|| $inext== 'jpg'|| $inext== 'png' ||$inext=='BMP' ||$inext=='GIF' ||$inext=='JPG' ||$inext=='PNG' ||$inext=='JPEG' || $inext=='jpeg')
												{
												?>
												<!------------------- image fetching ------------------------->
												<img src="<?php echo $str2;?>" height="400px" width="100%" align='centre' border="2" style="border-color: #ff0000;">
													</div>	<!--print div-->
													<p>	
													<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"	/>
													</p>
										
												<!------------------- pdf fetching ------------------------->
												<?php }
												else if($inext=='pdf' || $inext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str2;?>"></iframe>
												<?php
												}
												?>
								
							</div>
							<!--------------------------- End Of Javak Barnishi ---------------->
							<!------------------------- Javak Barnishi ------------------------------------------>
                            <div aria-hidden="true" aria-expanded="false" style="display:none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-5" id="a-2">
							
									<div id="divToPrints">
										<h4 class="widgettitle1">जावक बारनिशी</h4><br>
										
										<table>
											<tr>
												<td>जावक_क्र. : </td>
												<td>जावक_दि. : </td>
												<td>कोणाकडून प्राप्त : </td>
												<td>विषय : </td>
											</tr>
											<tr>
												<td><?php echo $row['outword_no']; ?></td>
												<td><?php echo $row['dispatched_date']; ?></td>
												<td><?php echo $row ['sender_name']; ?></td>
												<td><?php echo $row['subject']; ?></td>
											</tr>
											<tr>
												<td>कोणास पाठवले : </td>
												<td>केलेली कार्यवाही : </td>
												<td>विभाग आ_क्र : </td>
											</tr>
											<tr>
												<td>
													<?php 
														if($row['dispatched_to']=='permanent')
														{
															echo $row['addressed_to'];
														}
														else if($row['dispatched_to']=='department')
														{
															$todept=$row['dept_id_to'];
															$q=mysql_query("SELECT dept_nm from department_master where dept_id='$todept' ");
															$r=mysql_fetch_array($q);
															echo $r['dept_nm'];
														}
													?>
												</td>
												<td><?php echo $row['action_taken']; ?></td>
												<td><?php echo $deptnm['dept_nm']."-".$row['dpt_inword_no'] ?></td>
											</tr>
											</table><br>
								
											<?php if($outext=='bmp' || $outext=='gif'|| $outext== 'jpg'|| $outext== 'png' ||$outext=='BMP' ||$outext=='GIF' ||$outext=='JPG' ||$outext=='PNG' ||$outext=='JPEG' || $outext=='jpeg')
												{
												?>
												<img src="<?php echo $str3;?>" height="400px" width="100%" align='centre'>
											</div>	<!--print div-->
												<p>	
												<center><input type="submit" value=" Print Page " onclick="PrintDivs();" class="btn btn-primary"/>
												</p>
											
												<?php }
												else if($outext=='pdf' || $outext=='PDF')
												{?>
												<iframe  name="myiframe" id="myiframe"  width="100%" height="500px;" src="<?php echo $str3;?>?#zoom=100"></iframe>
												<?php
												}
												?>
												<p>	
												<center><input type="submit" value=" Print Page " onclick="PrintDivs();" class="btn btn-primary"/>
												</p>
											
                        </div>
             </div>
			<?php include_once('footer.php'); ?>
        </div><!--maincontentinner-->
    </div><!--rightpanel-->
</body>
</html>
			 <!----------------------------------------------------- End Of Javak Barnishi ----------------------------------->
 <?php 
	}
 } //else if($flag='n')
 ?>