<?php ############################################# Code For Letter Entry #####################################################

include_once('dashboard_desk.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
?>
<html>   
<head>
<script type="text/javascript" src="js/adduser.js"></script> 

<script type="text/javascript">
	
	function disp_sp(val)
	{
		if(val=='shaskiy')
		{
			document.getElementById('ltrtypec').style.display="block";
		}
		else if(val=='sthanik')
		{
			document.getElementById('ltrtypec').style.display="none";
		}
	}
</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><!--pageheader-->   
        <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/letterentrynew2.php?username=<?php echo $username;?>" method="post" name="avakbarnishi">
							<?php
							################################# Generating Panchayat samiti Inward Number #########################################
							$year = date('y');
							/*$r = mysql_query("SELECT MAX(ltr_inword_no)AS id FROM incoming_letters_transaction WHERE ltr_inword_no like '$year%'");
							$row1 = mysql_fetch_array($r);
							$Auto_increment = $row1['id']; //got auto inc in d form of 15-0049     */
							
							$r = mysql_query("SELECT ltr_inword_no FROM incoming_letters_transaction WHERE ltr_inword_no  like '$year%'");
							while($row1 = mysql_fetch_array($r))
							{
							 $Auto_increment =$row1['ltr_inword_no'];
							}
							
							$start='0001';
							if ($Auto_increment != '')
							{
								list($a,$b) = Explode("-",$Auto_increment); // specifies to break d string at '-'
								if ($a==$year)
								{
									$c= str_pad($b + 1, 6, 0, STR_PAD_LEFT);
								
									$n = $year ."-". $c;
								}
								else
								{
									$c= str_pad($b + 1, 6, 0, STR_PAD_LEFT);
									$n =  $year."-". $c;
								}
							}
							else
							{
								$n =$year."-". $start;
							}
							
							
							################################################################################
												// Generating Department Inward No
							################################################################################
							$r1 = mysql_query("select max(t.dpt_inword_no) as id from tapal_to_dpt_transaction t, incoming_letters_transaction i
							where  t.dpt_inword_no like '$year%' 
							AND t.dept_id_from=(SELECT dept_id from login where login_id = '$username')
							AND t.ltr_id=i.ltr_id ") ;
							$row11 = mysql_fetch_array($r1);
							$Auto_increment1 = $row11['id'];
							$start1='0001';
							
							if ($Auto_increment1 != '')
							{	
								list($a1,$b1) = Explode("-",$Auto_increment1);
								if ($a1==$year)
								{
									$c1= str_pad($b1 + 1, 4, 0, STR_PAD_LEFT);
									$n1 = $year ."-". $c1;
								}
								else
								{
									$c1= str_pad($b1 + 1, 4, 0, STR_PAD_LEFT);
									$n1 =  $year."-". $c1;
								}
							}
							else
							{
								$n1 =$year."-". $start1;
							}
							################################# End OF Generating Inward Number ######################################
							
							
							################################## Generating Desk Letter Inward No ##############################
							$r2 = mysql_query("select max(desk_transaction.desk_ltr_inword_no) as id from tapal_to_dpt_transaction,desk_transaction where  desk_transaction.desk_ltr_inword_no like '$year%' and desk_transaction.desk_id_from=(SELECT desk_id from login where login_id = '$username') AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id") ;
							
							$row12 = mysql_fetch_array($r2) or die("<br>fffffff".mysql_error());
							$Auto_increment2 = $row12['id'];
							$start2='0001';
							if ($Auto_increment2 != '')
							{
								list($a2,$b2) = Explode("-",$Auto_increment2);
								if ($a2==$year)
								{
									$c2= str_pad($b2 + 1, 4, 0, STR_PAD_LEFT);
									$n2 = $year ."-". $c2;
								}
								else
								{
									$c2= str_pad($b2 + 1, 4, 0, STR_PAD_LEFT);
									//echo " C is ".$c;
									$n2 =  $year."-". $c2;
								}
							}
							else
							{
								  $n2 =$year."-". $start2;
							}
							################################## Generating Desk Letter Inward No ##############################
							
							?>
							<table width="100%">
								<tr>
									<td><label>आवक क्रमांक : </label></td>
									<td> <input type="text" name="ltrinwardno" class="input-small" value="<?php echo $n;?>" placeholder="" readonly  lang="mr"/></td>	
									<td><label>विभागीय आवक क्रमांक : </label></td>
									<td> <input type="text" name="dptltrinwardno" class="input-small" value="<?php echo $n1;?>" placeholder="" readonly  lang="mr"/></td>
								</tr>
								<tr>
									<td><label>डेस्क आवक क्रमांक : </label></td>
									<td> <input type="text" name="deskltrinwardno" class="input-small" value="<?php echo $n2;?>" placeholder="" readonly  lang="mr"/></td>
									
									<td style=""><label style=""> संदर्भाचा प्रकार :</label></td>
									<td> <input type="radio" name="sp" value="sthanik" onclick="disp_sp(this.value);"> स्थानिक &nbsp;&nbsp;
										 <input type="radio" name="sp" value="shaskiy" onclick="disp_sp(this.value);"> शासकीय
									</td>
								</tr>
								<tr>
									<td><label style="">संदर्भ क्रमांक : </label></td>
									<td><input type="text" name="refno" placeholder="ref no" class="unicode" lang="mr"/></td>
									<td style=""><label style="">संदर्भ दिनांक :</label></td>
									<td> <input type="text" name="refdate" placeholder="dd-mm-yyyy"/></td>
								</tr>
								<tr>
									<td><label style="">संदर्भ प्राप्त दिनांक : </label></td>
									<td><input  type="text" name="recdate" placeholder="dd-mm-yyyy"/></td>
									<td><label style="width:120px;">कोणाकडून प्राप्त झाले : </label></td>
									<td> <input type="text" name="sendernm" class="unicode" placeholder="Sender name" lang="mr"></td>
								</tr>
								<tr>
									<td><label style="">थोडक्यात विषय : </label></td>
									<td><textarea cols="80" rows="2" class="unicode" lang="mr" name="sub"></textarea></td>
									<td><label> संदर्भाचा प्रकार : </label></td>
									<td>  
									<?php
									$query = "SELECT  * FROM sandharbh_master where sandhrbh_id!='27' "; 
							        convert_marathi();
									$result = mysql_query ($query);
									echo "<select name=ltrtypec  id=ltrtypec style='display:none;'>Dropdown</option><option value=>संदर्भाचा प्रकार निवडा </option>";
									while($row = mysql_fetch_array($result))
                                      {
										echo"{
												('<option id='".$row['sandhrbh_id']."' value='".$row['sandhrbh_id']."'>".$row['sandharbh_nm']."</option>')
											}";
                                      }
									echo "</select>";
									?>
									</td>
								</tr>
								<tr>
									<td><label  for="email">ईमेल आय डी :</label></td>
									<td><input type="text" name="email" id="email" /></div></td>
									<td style=""><label>मोबाइल नंबर : </label></td>
									<td> <input type="text" name="mobno" placeholder="Mobile Number"/></td>
								</tr>
								<tr>
									<td><label>पत्ता  : </label></td>
									<td><textarea cols="80" rows="2" class="unicode" lang="mr" name="add"></textarea> </td>
									
									<td><label>प्राथमिकता लावा : </label></td>
									<td><select name="priodays" id="priodays">
											<option value="0">प्राथमिकता लावा</option>
											<option value="1"> 1 day </option>
											<option value="5"> 5 days </option>
											<option value="7"> 7 days </option>
											<option value="15"> 15 days </option>
											<option value="20"> 20 days </option>
										</select>
									</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 validateAvakbarnishi()">जतन करा </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>
