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

$q=mysql_query("SELECT * from login where login_id='$username' ");
$r=mysql_fetch_array($q);
$deptid=$r['dept_id'];
?>
<html>   
<head>

<script>
	
	function disp_sp(val)
	{
		if(val=='other')
		{
			
			 $("#ltrtypec2").show();
			  $("#ltrtypec1").hide();
		}
		else if(val=='dpt')
		{
			$("#ltrtypec1").show();
			 $("#ltrtypec2").hide();
		}
	}
function valicatioon()
{

	var x=document.forms["directjavak"]["javak"];
	if (x.value=="")
	{
		alert("जावक क्रमांक  टाका !!!");
		x.focus();
		return false;
	}
	
	
	//validate ref dt
	var date = /^(0[1-9]|[12][0-9]|3[01])[-](0[1-9]|1[012])[-](19|20)\d\d$/
	var x=document.forms["directjavak"]["jdate"];
	if (x.value=="")
	{
		alert("कृपया जावक दिनांक टाका !!!");
		x.focus();
		return false;
	}
	else if ((!date.test(x.value)))
	{
		alert("दिनांक 25-03-2014 या पद्धतीने टाका");
		x.value="";
		x.focus();
		return false;
	}
	var x=document.forms["directjavak"]["sp"];
	if (x.value=="")
	{
		alert("संदर्भाचा प्रकार निवडा !!!");
		return false;
	}	
	else if (x.value!="")
	{
		var y=document.forms["directjavak"]["sp"].value;
		
		if(y=='sthanik')
		{
			//ltrtype
			var x=document.forms["directjavak"]["vibhag"];
			if (x.value=="")
			{
				alert("विभाग निवडा!!!");
				x.focus();
				return false;
			}
		}
		else if(y=='shaskiy')
		{
			//ltrtype
			var x=document.forms["directjavak"]["othern"];
			if (x.value=="")
			{
				alert("नाव टाका  !!!");
				x.focus();
				return false;
			}
		}
	}
	var x=document.forms["directjavak"]["sakalan"];
	if (x.value=="")
	{
		alert("संक्लन क्रंमाक व नाव  टाका !!!");
		x.focus();
		return false;
	}
	var x=document.forms["directjavak"]["sub"];
	if (x.value=="")
	{
		alert("थोडक्यात विषय  टाका !!!");
		x.focus();
		return false;
	}
	
	//file upload
	var x=document.forms["directjavak"]["uploadedimage"];
	var _validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png", ".pdf"];    
	if(x.value!='')
    { 
		var sFileName = x.value;
        if (sFileName.length > 0) 
		 {
            var blnValid = false;
            for (var j = 0; j < _validFileExtensions.length; j++) 
			{
                var sCurExtension = _validFileExtensions[j];
                if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) 
				{
                    blnValid = true;
                    break;
                }
            }
             
            if (!blnValid)
			{
                alert("Sorry, " + sFileName + " is invalid, allowed extensions are: " + _validFileExtensions.join(", "));
                x.value = "";
                return false;
            }
		}
     return true;
	}

}
</script>

</head>
<div class="rightpanel">
    <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">Forms</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>

        <div class="maincontent">
            <div class="maincontentinner">
				<div class="widget">
					<h4 class="widgettitle">विभागीय  थेट जावक बारनिशी</h4>
					<div class="widgetcontent">
						<form enctype="multipart/form-data" class="stdform" action="./connection/letterentry_javak_dpt.php?username=<?php echo $username;?>" method="post" name="directjavak">
							
							<table width="40%" >
								<tr>
									<td><label>जावक क्रमांक : </label></td>
									<td> <input type="text" name="javak" class="input-small" placeholder=""   lang="mr" /></td>	
								</tr>
								<tr>
									<td style=""> &nbsp;&nbsp; </td>
								</tr>
								<tr>
									<td style=""><label style="">जावक दिनांक :</label></td>
									<td> <input type="text" name="jdate" placeholder="dd-mm-yyyy"/></td>
								</tr>
								<tr>
									<td style=""> &nbsp;&nbsp; </td>
								</tr>
								<tr>
									<td style=""><label style="">कोणास पाठवले :</label></td>
									<td> <input type="radio" name="sp" value="dpt" onclick="disp_sp(this.value);"> स्व-विभाग&nbsp;&nbsp;
									<input type="radio" name="sp" value="other" onclick="disp_sp(this.value);"> इतर
									</td>
								</tr>
								<tr>
									<td style=""> &nbsp;&nbsp; </td>
								</tr>
								</table >
				               <table id="ltrtypec1"  hidden>
				        		<tr>
				        			
				        <?php 

				        	$i = 2;
							$result = mysql_query("SELECT * FROM department_master");
							while($row = mysql_fetch_array($result))
							{	
								if($i==1)
								{
									echo '<tr>';
								}
								echo "<td><input type='checkbox' name='chkk[]' id='".$row['dept_id']."' value='".$row['dept_id']."' />&nbsp;&nbsp;".$row['dept_nm']."&nbsp;&nbsp;</td>";
								$i = $i + 1;
								if($i==5)
								{
									echo '</tr>';
									$i = 1;
								}
							}
				        ?>
				        </table>	
				       
				     
								</tr>	
								 <table>
								<tr id="ltrtypec2" hidden>
									<td><label style="">नाव टाका </label></td>
									<td ><input type="text" name="othern" class="unicode" /></td>
									
								</tr>
								<tr>
									<td><label style="">संक्लन क्रंमाक व नाव</label></td>
									<td><textarea cols="80" rows="2" class="unicode" lang="mr" name="sakalan"></textarea></td>
									
								</tr>
								<tr>
									<td><label style="">थोडक्यात विषय : </label></td>
									<td><textarea cols="80" rows="2" class="unicode" lang="mr" name="sub"></textarea></td>
									
								</tr>
								
							</table>
						<div class="par" >
							<label for="upload" style="">कागदपत्र जोडा : </label>
							<div class="fileupload fileupload-new" data-provides="fileupload">
								<div class="input-append">
									<div class="uneditable-input" style="margin-Left:135px;">
										<i class="iconfa-file fileupload-exists"></i>
										<span class="fileupload-preview"></span></td>
									</div>
									<span class="btn btn-file"><span class="fileupload-new">कागदपत्र निवडा </span>
									<span class="fileupload-exists">बदल करा</span>
									<input id="upload" type="file" name="uploadedimage" accept="image/jpeg,image/gif,image/png"/></span>
									<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">रद्द करा </a>
								</div>
							</div>
						</div>
						<div>  				 
							<p class="stdformbutton">
								<center> <button class="btn btn-primary" onclick="return valicatioon()">जतन करा </button>
								<button type="reset" class="btn">रद्द करा  </button> </center>
							</p>
						</div>
						
                    </form>
				</div><!--widgetcontent-->
            </div><!--widget-->
            <?php include_once('footer.php');?>  
       </div><!--maincontentinner-->
    </div><!--maincontent-->   
</div><!--rightpanel-->   
</div><!--mainwrapper-->
</body>
</html>