<?php 

                echo "outer echo  ";
				if(isset($_POST['save']))
				{
					  echo "save  echo  ";
					$res = "";
					$iid = $_POST['txtiid'];
					$res = $_POST['txt'.$iid];
					 echo "AAAAAAAAA : ".$iid." : ".$res;

					/*convert_marathi();
					$qrye=("SELECT * FROM incoming_letters_transaction WHERE dept_id = (SELECT dept_id FROM login WHERE login_id ='$username') AND dept_id='0' AND status!='approve' AND incoming_letters_transaction.ltr_id='$iid'");
					$rsult=mysql_query($qrye) or die("".mysql_error());
					while($rw=mysql_fetch_array($rsult))
					{	
						$ltr_id = $rw['ltr_id'];
						$refno  = $rw['ref_no'];
						$refdt  = $rw['ref_dt'];
						$recdt  = $rw['receive_dt'];
						$sendernm=$rw['sender_name'];
						$mobno  = $rw['mobile_no'];
						$email  = $rw['email_id'];
						$add    = $rw['address'];
						$sandh  = $rw['ltr_type'];
						$sub    = $rw['subject'];
						$prio   = $rw['	priority_days'];
						$path   = $rw['document'];

						########################################################## if Assgin To all Department #########################################################
						if($res=='222' and $res!='')
						{	
							$qryrs=mysql_query("Select * from department_master");
							$cnt=1;
							while($dept=mysql_fetch_array($qryrs))
							{	
								$deptid=$dept['dept_id'];
									
								if($cnt==1)
								{
									$sql1 = mysql_query("UPDATE incoming_letters_transaction SET dept_id = '$deptid', sent_dt=curdate(),status='pending' WHERE ltr_inword_no = '$rw[ltr_inword_no]'");
															
									$cnt=$cnt+1;
								}
								else if($cnt!=1)
								{
									############################################################# Generating Inward no and adding record no of times that is equal to no of departments available in dept_master #############################################################
									$year = date('y');
									//echo $year;
									$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'];
									$start='0001';
									if ($Auto_increment != '')
									{
										list($a,$b) = Explode("-",$Auto_increment);
										if ($a==$year)
										{
											$c= str_pad($b + 1, 4, 0, STR_PAD_LEFT);
											$n = $year ."-". $c;
										}
										else
										{
											$c= str_pad($b + 1, 4, 0, STR_PAD_LEFT);
											$n =  $year."-". $c;
										}
									}
									else
									{
										$n =$year."-". $start;
									}
														
									$padtalni=mt_rand();
														
									$qry13=mysql_query("insert into incoming_letters_transaction(ltr_inword_no, ref_no, ref_dt, receive_dt, sender_name, mobile_no, email_id, address, ltr_type, subject,priority_days, document,status,sent_dt,dept_id,padtalni_no,first_flag) values('$n','$refno','$refdt' ,'$recdt','$sendernm','$mobno','$email','$add','$sandh','$sub','$prio','$path', 'pending',curdate(),'$deptid','$padtalni','Y')") or die("<br>Error".mysql_error());
								}//if cnt
							}//while
							
						}//if select dept==222
						################## End Of If Assign To All Department Coding #########################
										
						######################################################################################## if assigned to single department ########################################################################################
						else if($res!='222' and $res!='')	
						{
							$arr = explode(",", $res);
							$cnt = count($arr);
							$cnt11 = 1;
							for($i=0;$i<$cnt;$i++)
							{
								$deptid=$arr[$i];
									
								if($cnt11==1)
								{
									$sql1 = mysql_query("UPDATE incoming_letters_transaction SET dept_id = '$deptid', sent_dt=curdate(),status='pending' WHERE ltr_inword_no = '$rw[ltr_inword_no]'");
															
									$cnt11=$cnt11+1;
								}
								else if($cnt11!=1)
								{
									############################################################# Generating Inward no and adding record no of times that is equal to no of departments available in dept_master #############################################################
									$year = date('y');
									//echo $year;
									$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'];
									$start='0001';
									if ($Auto_increment != '')
									{
										list($a,$b) = Explode("-",$Auto_increment);
										if ($a==$year)
										{
											$c= str_pad($b + 1, 4, 0, STR_PAD_LEFT);
											$n = $year ."-". $c;
										}
										else
										{
											$c= str_pad($b + 1, 4, 0, STR_PAD_LEFT);
											$n =  $year."-". $c;
										}
									}
									else
									{
										$n =$year."-". $start;
									}
														
									$padtalni=mt_rand();
														
									$qry13=mysql_query("insert into incoming_letters_transaction(ltr_inword_no, ref_no, ref_dt, receive_dt, sender_name, mobile_no, email_id, address, ltr_type, subject,priority_days, document,status,sent_dt,dept_id,padtalni_no,first_flag) values('$n','$refno','$refdt' ,'$recdt','$sendernm','$mobno','$email','$add','$sandh','$sub','$prio','$path', 'pending',curdate(),'$deptid','$padtalni','Y')") or die("<br>Error".mysql_error());
								}//if cnt
							}
						}//else if($selectedDepertmentNumber!='222')
					}//while

					if($sql1)
					{
						// echo "---------------------------------";
						echo "<script type='text/javascript'>alert('Assigned Department Successfully!')</script>";
						echo '<script language="JavaScript"> window.location.href ="assign_dept.php" </script>';	
					}*/
				}	
				else if(isset($_POST['demo2']))
				
				{
					 echo "else  demo2  ";
					$res = "";
					$iid = $_POST['txtiid'];
					$res = $_POST['txt'.$iid];
					// echo "AAAAAAAAA : ".$iid." : ".$res;
				}
				

					
							
				?>