<?php 
//******************************INSERT THE NEW DATA************START HERE************AMIT**********01-11-12**********************

if($_REQUEST['Proceed'])
{
	$images=$_FILES['panel_img']['name'];
	if($_REQUEST['client']=='new')
	{
	$data1['c_name']=$_REQUEST['crm_newclient'];
	$data1['short_name']=$_REQUEST['crm_newclient'];
	$data1['CompanyId']=$_SESSION['ACGCompanyId'];
	$data1['Site']=$_REQUEST['site'];
	//  $data1['Zone']=$_SESSION['ACGCompanyId'];
	$data1['ledger_id']='111';
	$row1= $s->RecordInsert('clientmaster', $data1);
	$lastid1=DB_Last_Insert_ID($db,'clientmaster', 'id');
	$data2['vender_client']=$lastid1;
	$data2['AccountName']=$_REQUEST['crm_newclient'];
	$data2['CompanyId']=$_SESSION['ACGCompanyId'];
	$data2['ledgertype']='client';
	$data2['UnderGroup']='111';
	$row1= $s->RecordInsert('accountledger', $data2);
	}

	$site=$_REQUEST['site'];
	$qry=DB_query("select * from approval_dot_and_panel_entry where site='".$site."'",$db);
$NoRows=DB_num_rows($qry);

if($NoRows>0)
{
	$sel_code=DB_query("select max(form_no) AS max_id from approval_dot_and_panel_entry where site='".$site."'",$db);
	$sel_codeRow=DB_fetch_array($sel_code);
	$sub_code=substr($sel_codeRow['max_id'],-2);
	$maxid=$sub_code+1;
	$finalCode=$site."/".'ADPE'."/".str_pad($maxid,4,"0",STR_PAD_LEFT);
}
else
{
	$finalCode=$site."/".'ADPE'."/".'0001';
}
	if($_REQUEST['client']=='new')
    $datarray['client_id']= $lastid1;
	else
 	$datarray['client_id']=$_REQUEST['client'];
	$datarray['executive']=$_REQUEST['executive'];
	$datarray['site']=$_REQUEST['site'];
	$datarray['form_no']=$finalCode;
	$datarray['document_date']=FormatDateForSQL($_REQUEST['document_date']);
	if($_REQUEST['shade_name']=='new')
	{
	$shade=$_REQUEST['crm_newshade'];
	$item12=$_REQUEST['item_code_new'];
	}
	else
	{
	$shade=$_REQUEST['shade_name'];
	$item12=$_REQUEST['item_code'];
	}
	$datarray['shade_name']=$shade;
	$datarray['item_code']=$item12;
	$datarray['panel']=$_REQUEST['panel'];	
	$datarray['approval_dot']=$_REQUEST['approval_dot'];
	$datarray['status']=$_REQUEST['status'];
	if($_REQUEST['panel']!='')
	{
	$datarray['panel_in_date']=FormatDateForSQL($_REQUEST['panel_in_date']);
	$datarray['panel_out_date']=FormatDateForSQL($_REQUEST['panel_out_date']);
	$datarray['panel_image']=$images;
	$datarray['reamark']=$_REQUEST['reamark'];
	}
	if($_REQUEST['approval_dot']!='')
	{
	$datarray['request_date']=FormatDateForSQL($_REQUEST['request_date']);
	$datarray['in_date']=FormatDateForSQL($_REQUEST['in_date']);
	$datarray['out_date']=FormatDateForSQL($_REQUEST['out_date']);
	$datarray['reamrk_by_executive']=$_REQUEST['reamrk_by_executive'];
	$datarray['reamark_by_cmmercial']=$_REQUEST['reamark_by_cmmercial'];
	}
	$datarray['created_by']=$_SESSION['UserID'];
	$saved= $s->RecordInsert('approval_dot_and_panel_entry', $datarray);
	if($images!='')
	{
		$upload=move_uploaded_file($_FILES['panel_img']['tmp_name'],"CRM/ApprovalDotEntryForm/".$images);
	}
	$s->pageLocation("index.php?route=CRM/view_approval_dot_panel_entry_form".$rurl);
}

//******************************INSERT THE NEW DATA************END HERE************AMIT************10-10-12********************




//******************************EDIT PART************START HERE************AMIT************10-10-12********************

if($_REQUEST['action']=='Edit')
{
	$condition="id='".$_REQUEST['id']."'";
	$GetRec=$s->GetRecordById('approval_dot_and_panel_entry',  $condition);
	$GetRec1=DB_fetch_array($GetRec);
	extract($GetRec1);
}

if($_REQUEST['Update'] && $_REQUEST['action']=='Edit')
{
	if($_FILES['panel_img']['name']=='')
	{
		$images=$_REQUEST['panel_img1'];
	}
	else
	{
		$image=DB_query("select panel_image from approval_dot_and_panel_entry where id='".$_REQUEST['id']."'",$db);
		$ImageName=DB_fetch_array($image);
		@unlink("CRM/ApprovalDotEntryForm/".$ImageName['panel_image']);
		$images=$_FILES['panel_img']['name'];
		$upload=move_uploaded_file($_FILES['panel_img']['tmp_name'],"CRM/ApprovalDotEntryForm/".$images);
	}
	if($_REQUEST['client']=='new')
	{
	$data1['c_name']=$_REQUEST['crm_newclient'];
	$data1['short_name']=$_REQUEST['crm_newclient'];
	$data1['CompanyId']=$_SESSION['ACGCompanyId'];
	$data1['Site']=$_REQUEST['site'];
	//  $data1['Zone']=$_SESSION['ACGCompanyId'];
	$data1['ledger_id']='111';
	$row1= $s->RecordInsert('clientmaster', $data1);
	$lastid1=DB_Last_Insert_ID($db,'clientmaster', 'id');
	$data2['vender_client']=$lastid1;
	$data2['AccountName']=$_REQUEST['crm_newclient'];
	$data2['CompanyId']=$_SESSION['ACGCompanyId'];
	$data2['ledgertype']='client';
	$data2['UnderGroup']='111';
	$row1= $s->RecordInsert('accountledger', $data2);
	}
	if($_REQUEST['client']=='new')
    $datarray['client']= $lastid1;
	else
 	$datarray['client_id']=$_REQUEST['client'];
	$datarray['executive']=$_REQUEST['executive'];
	$datarray['site']=$_REQUEST['site'];
	$datarray['document_date']=FormatDateForSQL($_REQUEST['document_date']);
	
	
	if($_REQUEST['shade_name']=='new')
	{
	$shade=$_REQUEST['crm_newshade'];
	$item12=$_REQUEST['item_code_new'];
	}
	else
	{
	$shade=$_REQUEST['shade_name'];
	$item12=$_REQUEST['item_code'];
	}
	$datarray['shade_name']=$shade;
	$datarray['item_code']=$item12;
	$datarray['panel']=$_REQUEST['panel'];	
	$datarray['panel_image']=$images;
	$datarray['approval_dot']=$_REQUEST['approval_dot'];	
	if($_REQUEST['panel']!='')
	{
	$datarray['panel_in_date']=FormatDateForSQL($_REQUEST['panel_in_date']);
	$datarray['panel_out_date']=FormatDateForSQL($_REQUEST['panel_out_date']);
	$datarray['panel_image']=$images;
	$datarray['reamark']=$_REQUEST['reamark'];
	}
	if($_REQUEST['approval_dot']!='')
	{
	$datarray['request_date']=FormatDateForSQL($_REQUEST['request_date']);
	$datarray['in_date']=FormatDateForSQL($_REQUEST['in_date']);
	$datarray['out_date']=FormatDateForSQL($_REQUEST['out_date']);
	$datarray['status']=$_REQUEST['status'];
	$datarray['reamrk_by_executive']=$_REQUEST['reamrk_by_executive'];
	$datarray['reamark_by_cmmercial']=$_REQUEST['reamark_by_cmmercial'];
	}
	$datarray['modify_by']=$_SESSION['UserID'];
	$cond="id='".$_REQUEST['id']."'";
	

	
	
	$saved= $s->RecordEdit('approval_dot_and_panel_entry', $datarray, $cond);
	$s->pageLocation("index.php?route=CRM/view_approval_dot_panel_entry_form".$rurl);
}




//******************************EDIT PART************END HERE************AMIT************10-10-12********************




//*******************************VIEW PART***************START HERE****************AMIT*********10-10-12*************

if($_REQUEST['action']=='View')
{
	$condition="id='".$_REQUEST['id']."'";
	$Rec_For_View=$s->GetRecordById('approval_dot_and_panel_entry', $condition);
	$Rec12=DB_fetch_array($Rec_For_View);
	extract($Rec12);
}

//*******************************VIEW PART***************END HERE****************AMIT*********10-10-12*************





?>

<!-----------------------AJAX FILES----------------------------START HERE------AMITSINGH--------------------------------->

<script type="text/javascript" language="javascript">
function autogeneratecode(str)
{
	//alert(str);
	if(str.length==0)
	{
	document.getElementById("autono").innerHTML="";
	return;
	}
	if(window.XMLHttpRequest)
	{
	xmlhttp=new XMLHttpRequest();
	}
	else
	{
	xmlhttp=new ActiveXobject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	document.getElementById("autono").innerHTML=xmlhttp.responseText;
	}
	xmlhttp.open("GET","auto_generate_no.php?AUTO_NO="+str,true);
	xmlhttp.send();
}


function getitemcode(str)
{
//alert(str);
	
	if(str.length==0)
	{
	document.getElementById("ITEMCODE").innerHTML="";
	return;
	}
	if(str=='new')
	{
	document.getElementById("hid-newclient1").style.display='block';	
	}
	else
	{
	document.getElementById("hid-newclient1").style.display='none';	
	}
	if(window.XMLHttpRequest)
	{
	xmlhttp=new XMLHttpRequest();
	}
	else
	{
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	document.getElementById("ITEMCODE").innerHTML=xmlhttp.responseText;
	}
	xmlhttp.open("GET","getitemcodeforDRF.php?shadecode="+str,true);
	xmlhttp.send();
 
}



function dispanel()
{
	var a=document.getElementById("panel").checked;
	if(a==true)
	{
	var1=document.getElementById("panel_in_date").removeAttribute("disabled",false);
	var2=document.getElementById("panel_out_date").removeAttribute("disabled",false);
	var3=document.getElementById("panel_img").removeAttribute("disabled",false);
	var3=document.getElementById("remarks").removeAttribute("disabled",false);
	}
	else
	{
	var1=document.getElementById("panel_in_date").setAttribute("disabled",true);
	var2=document.getElementById("panel_out_date").setAttribute("disabled",true);
	var3=document.getElementById("panel_img").setAttribute("disabled",true);
	var3=document.getElementById("remarks").setAttribute("disabled",true);
	}
}
	
	
	
function ApprovalDot()
{
	var a=document.getElementById("approval_dot").checked;
	if(a==true)
	{
	var1=document.getElementById("request_date").removeAttribute("disabled",false);
	var2=document.getElementById("in_date").removeAttribute("disabled",false);
	var3=document.getElementById("out_date").removeAttribute("disabled",false);
	var4=document.getElementById("reamrk_by_executive").removeAttribute("disabled",false);
	var5=document.getElementById("reamark_by_cmmercial").removeAttribute("disabled",false);
	}
	else
	{
	var1=document.getElementById("request_date").setAttribute("disabled",true);
	var2=document.getElementById("in_date").setAttribute("disabled",true);
	var3=document.getElementById("out_date").setAttribute("disabled",true);
	var4=document.getElementById("reamrk_by_executive").setAttribute("disabled",true);
	var5=document.getElementById("reamark_by_cmmercial").setAttribute("disabled",true);
	}
}	




//var table = document.getElementById('TABLE1');
//var inputs = table.getElementsByTagName('input');
//var links = table.getElementsByTagName('A');
//for (var i = 0; i < inputs.length; i++) {
//    inputs[i].disabled = true;
//}
//
//for (var i = 0; i < links.length; i++) {
//    // There are better ways to disable links, but 
//    // this is the shortest code to do it
//    links[i].onclick = 'return false;';
//}



<!-----------------------AJAX FILES----------------------------END HERE------AMITSINGH--------------------------------->



<!-----------------------VALIDATION----------------------------START HERE------AMITSINGH--------------------------------->

function validate_field()
{

	if(document.getElementById("site").value=='0')
	{
		alert("Please Select The Site First");
		return false;
	}
	if(document.getElementById("document_date").value=='')
	{
		alert("Please Enter The Document Date First");
		return false;
	}
	if(document.getElementById("client").value=='new' && document.getElementById("crm_newclient").value=='')
	{
		alert("Please Enter The Name Of New Client First");
		return false;
	}
	
	if(document.getElementById("client").value=='0')
	{
		alert("Please Select The client First");
		return false;
	}
	
	if(document.getElementById("executive").value=='0')
	{
		alert("Please Select The Executive First");
		return false;
	}
	if(document.getElementById("shade_name").value=='0')
	{
		alert("Please Select The Item Shade Name First");
		return false;
	}
	

	if(document.getElementById("shade_name").value=='new' && document.getElementById("crm_newshade").value=='')
	{
		alert("Please Enter The Shade Name First");
		return false;
	}
	
	
	if(document.getElementById("item_code").value=='0')
	{
		alert("Please Select The Item Code First");
		return false;
	}
	
	/*if(document.getElementById("item_code_new").value=='')
	{
		alert("Please Enter The New Item Code First");
		return false;
	}*/
	
	if(document.getElementById("panel").checked==false && document.getElementById("approval_dot").checked==false)
	{
		alert("Please Chech At Least One");
		return false;
	}
	
	
	if(document.getElementById("status").value=='0')
	{
		alert("Please Select Status First");
		return false;
	}
	
	if(document.getElementById("panel").checked==true)
	{
		if(document.getElementById("panel_in_date").value=='')
		{
			alert("Please Enter The Panel In Date");
			return false;
		}
		if(document.getElementById("panel_out_date").value=='')
		{
			alert("Please Enter The Panel Out Date");
			return false;
		}

	}
	
	if(document.getElementById("approval_dot").checked==true)
	{
		if(document.getElementById("request_date").value=='')
		{
			alert("Please Enter The Request Date First");
			return false;
		}
		if(document.getElementById("in_date").value=='')
		{
			alert("Please Enter The In Date First");
			return false;
		}
		if(document.getElementById("out_date").value=='')
		{
			alert("Please Enter The Out Date First");
			return false;
		}
	}

}

<!-----------------------VALIDATION----------------------------END HERE------AMITSINGH--------------------------------->


</script>



<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<?php if($_REQUEST['action']=='View') {?>
<h1>View Approval Dot and Panel Entry Form</h1>
  	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Branch</td>
  	    <td><? echo $s->GetFieldValue('locations',"loccode='".$site."'",'locationname'); ?></td>
  	    <td class="tabledata1">&nbsp;</td>
  	    <td>&nbsp;</td>
	  </tr>
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Form No.</td>
  	    <td id="autono"><? echo $form_no ?></td>
  	    <td class="tabledata1">Document Date</td>
  	    <td><? echo ConvertSQLDate($document_date);?></td>
	  </tr>
	  <tr class="row1">
  	    <td class="tabledata1" align="left">Client Name</td>
  	    <td><?php echo $s->GetFieldValue('clientmaster',"id='".$client_id."'",'c_name'); ?></td>
  	    <td class="tabledata1">Executive Name</td>
  	    <td><?php echo $s->GetFieldValue('www_users',"id='".$executive."'",'userid'); ?></td>
	  </tr>
  	  <tr class="row1">
	  <td class="tabledata1">Shade Name</td>
  	    <td><? if(is_numeric($shade_name)){ echo $s->GetFieldValue('item_master',"id='".$shade_name."'",'item_name');} else { echo $shade_name; } ?></td>
  	    <td class="tabledata1" align="left">Item Code</td>
  	    <td><? if(is_numeric($item_code)){echo $s->GetFieldValue('item_master',"id='".$item_code."'",'StockID');}else{echo $item_code;} ?></td>
	  </tr>
	   <tr class="row1">
	   <td class="tabledata1">Status</td>
	   <td><?php if($status=='approved'){echo 'Approved';}if($status=='unapproved'){echo 'UnApproved';}if($status=='requesttoad'){echo 'Request To AD';}if($status=='forfutureReference'){echo 'For Future Reference';}if($status=='dispatchtoad'){echo 'Dispatch To AD';}if($status=='underdevelopment'){echo 'Under Development';}if($status=='sentforapproval'){echo 'Sent For Approval';}if($status=='2ndtimerequest'){echo '2nd Time Request';}if($status=='resend'){echo 'Resend';} ?></td>
	   </tr>
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Panel</td>
	    <td><input type="checkbox" name="panel" id="panel" value="panel"<?php echo($panel=='panel'?'checked':''); ?>></td>
  	    <td class="tabledata1">Approve Dot</td>
	    <td><input type="checkbox" name="approval_dot" id="approval_dot" value="approval_dot"<?php echo($approval_dot=='approvalDot'?'checked':''); ?>></td>
	  </tr>
	<?php if($panel_in_date!=''){ ?>
	 <tr class="row1">
  	   <td colspan="4">
	   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	   	<tr class="row1">
			<td class="tabledata1" colspan="4"><strong>Panel Details</strong></td>
			</tr>
		<tr class="row1">
			<td class="tabledata1">Panel In Date</td>
			<td><?php if($panel_in_date!=''){echo ConvertSQLDate($panel_in_date);} ?></td>
			<td class="tabledata1">Panel Out Date</td>
			<td><?php if($panel_out_date!=''){echo ConvertSQLDate($panel_out_date);} ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Panel Images</td>
			<td><?php if($panel_image!=''){echo '<img src="CRM/ApprovalDotEntryForm/'.$panel_image.'" style=" border:2px solid grey;width:100px;"/>';} ?></td>
		</tr>
		
		
		<tr class="row1">
			<td class="tabledata1">Remark</td>
			<td><?php if($reamark!=''){echo $reamark;} ?></td>
		</tr>
	   </table>
	   </td>
	  </tr>	
	 <?php } ?>
	 <?php if($request_date!=''){ ?>
	  <tr class="row1">
  	   <td colspan="4">
	   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	   	<tr class="row1">
			<td class="tabledata1" colspan="4"><strong>Approval Dot Details</strong></td>
			</tr>
		<tr class="row1">
			<td class="tabledata1">Request Date</td>
			<td><?php if($request_date!=''){echo ConvertSQLDate($request_date);} ?></td>
			<td class="tabledata1">In Date</td>
			<td><?php if($in_date!=''){echo ConvertSQLDate($in_date);} ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Out Date</td>
			<td><?php if($out_date!=''){echo ConvertSQLDate($out_date);} ?></td>
			<!--<td class="tabledata1">Status</td>
			<td><?php if($status!=''){echo $status;} ?></td>-->
		</tr>
		
		  <tr class="row1">
  	    <td class="tabledata1" align="left">Remark by Executive</td>
  	    <td colspan="3">
			<?php if($reamrk_by_executive!=''){echo $reamrk_by_executive;} ?>
		</td>
	  </tr>
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Remark By Commericial</td>
  	    <td colspan="3">
			<?php if($reamark_by_cmmercial!=''){echo $reamark_by_cmmercial;} ?>
		</td>
	  </tr>
		
		
	   </table>
	   </td>
	  </tr>
	 <?php } ?>
    </table>
<?php }else {?>
<h1>Approval Dot and Panel Entry Form</h1>
<form name="" method="post" action="" enctype="multipart/form-data">
  	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Branch<font color="#FF0000">*</font></td>
  	    <td><select name="site" id="site" style="width: 180px;" >
	<option value="0">Select</option>
	<?php     
	$site_sql=DB_query("Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')",$db);
	while($site_row=DB_fetch_array($site_sql))
	{?>
	<option value="<?php echo $site_row['loccode']?>"<?php echo($site==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname']?></option>
	<?php 	
	}
	?>
	</select></td>
  	    <td class="tabledata1">&nbsp;</td>
  	    <td>&nbsp;</td>
		</tr>
  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Form No.<font color="#FF0000">*</font></td>
  	    <td id="autono"><input type="text" name="form_no" id="form_no" value="<? if($_REQUEST['action']=='Edit'){echo $form_no; }else{echo 'Auto Generated';}?>" readonly="" style="width:180px;" /></td>
  	    <td class="tabledata1">Document Date<font color="#FF0000">*</font></td>
  	    <td><input type="text" name="document_date" id="document_date" value="<? if($_REQUEST['action']=='Edit'){ echo ConvertSQLDate($document_date);}else{echo date('d/m/Y');}?>" class="datepicker" style="width:180px;" /></td>
		</tr>
  	
	  <tr class="row1">
  	    <td class="tabledata1" align="left">Client Name<font color="#FF0000">*</font></td>
  	    <td><select style="width:180px;"  name="client" id="client"  onchange="ShowDiv(this.value,'hid-newclient','CRM_leadclient.php')" >
		<option value="0">---</option>
		<option value="new" <?php echo  $_SESSION['crm_company_name']=='new' ?'selected':''?>>--New Client--</option>
		<?php
		  $ClientSQL="Select * from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site in('".$_SESSION['AssignedBranch']."') 
		and Zone in(".$_SESSION['AssignedSites'].")";
		$ClientRes=DB_query($ClientSQL,$db);
		while($ClientRow=DB_fetch_array($ClientRes))
		{
 		?>
		<option value="<?php echo $ClientRow['id']?>" <?php echo ($client_id==$ClientRow['id']?'selected':'');?>><?php echo $ClientRow['c_name']?></option>
		<?php  } ?>
 	</select>
	<div id='hid-newclient'><input style="width:180px;" name="crm_newclient" id="crm_newclient" type="text" value="<?php  echo $_SESSION['crm_newclient']?>"/> </div></td>
  	    <td class="tabledata1">Executive Name<font color="#FF0000">*</font></td>
  	    <td><?php 
						$Dept=DB_query("SELECT id FROM deptmaster WHERE deptcode='MKT' OR deptcode='sal'",$db);
						if(DB_num_rows($Dept)>0)
						{
	while($DeptRow=DB_fetch_array($Dept))
	{
		$DCode[]=$DeptRow['id'];
	}
	 $Dept_id=implode(',',$DCode);
							$Sale_key_Exe=DB_query("select * from www_users where companyid='".$_SESSION['ACGCompanyId']."' and department in($Dept_id)",$db);
							
						?>
						<select name="executive" id="executive" style="width:180px;;">
						<option value="0">Select</option>
						<?php while($Sale_keyRow=DB_fetch_array($Sale_key_Exe))
						{
						 ?>
						 <option value="<?php echo $Sale_keyRow['id'] ?>"<?php echo ($executive==$Sale_keyRow['id']?'selected':'')?>><?php echo $Sale_keyRow['userid']; ?></option>
						 <?php } }?>
						</select></td>
		</tr>
  	  <tr class="row1">
	  <td class="tabledata1">Shade Name<font color="#FF0000">*</font></td>
  	    <td><select name="shade_name" id="shade_name" style="width:180px;" onchange="getitemcode(this.value)">
  	      		<option value="0">Select</option>
				<?php $sel='';
					if(!is_numeric($shade_name) && $shade_name!='')
					{
					$sel='selected';
					}
				 ?>
  	      		<option value="new" <?php echo $sel;?>>--New Shade--</option>
  	      					<?php $itemname=DB_query("Select id,StockID,item_name from item_master order by item_name",$db); 
					  while($itemnameRow=DB_fetch_array($itemname)){
					  $selc='';
					  if($shade_name==$itemnameRow['id'])
					  $selc='selected';
					  ?>
				<option value="<? echo $itemnameRow['id']; ?>"<?php echo $selc; ?>><? echo $itemnameRow['item_name']; ?></option>
				<?php } ?>
	      </select>
		<?php   
		if(!is_numeric($shade_name) && $shade_name!='') {?>
		 <div id='hid-newclient1'><input style="width:180px;" name="crm_newshade" id="crm_newshade" type="text" value="<?php  echo $shade_name;?>"/></div>
		
		<?php } else { ?>
	      <div id='hid-newclient1' style="display: none;"><input style="width:180px;" name="crm_newshade" id="crm_newshade" type="text" value=""/></div>
		  
		  <?php } ?>
	      </td>
  	    <td class="tabledata1" align="left">Item Code<font color="#FF0000">*</font></td>
  	    <td id="ITEMCODE">
		<?php   if(!is_numeric($shade_name) && $shade_name!='') {?>
		<input type="text" name="item_code_new" id="item_code_new" value="<?php echo $item_code ?>" style="width:180px;" />
		<?php }else { ?>
		
		<select name="item_code" id="item_code" style="width:180px;">
  	      		<option value="0">Select</option>
				<?php $itemcode=DB_query("Select id,StockID,item_name from item_master ",$db); 
					  while($itemcodeRow=DB_fetch_array($itemcode)){
					  $sel='';
					  if($item_code==$itemcodeRow['id'])
					  $sel='selected';
					  ?>
				<option value="<? echo $itemcodeRow['id']; ?>"<?php echo $sel; ?>><? echo $itemcodeRow['StockID']; ?></option>
				<?php } ?>
	      </select>
		  
		  <?php } ?>
		  </td>
		</tr>

  	  <tr class="row1">
  	    <td class="tabledata1" align="left">Panel<font color="#FF0000">*</font></td>
	    <td><input type="checkbox" name="panel" id="panel" value="panel" <?php echo($panel=='panel'?'checked':''); ?> onclick="dispanel();"></td>
  	    <td class="tabledata1">Approval Dot<font color="#FF0000">*</font></td>
	    <td><input type="checkbox" name="approval_dot" id="approval_dot" value="approvalDot"<?php echo($approval_dot=='approvalDot'?'checked':''); ?> onclick="ApprovalDot();"></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1">Status</td>
			<td><select name="status" id="status" style="width:180px;">
					<option value="0">Select Staus</option>
					<option value="approved"<?php echo($status=='approved'?'selected':''); ?>>approved</option>
					<option value="unapproved"<?php echo($status=='unapproved'?'selected':''); ?>>Unapproved</option>
					<option value="requesttoad"<?php echo($status=='requesttoad'?'selected':''); ?>>Request To AD</option>
					<option value="forfutureReference"<?php echo($status=='forfutureReference'?'selected':''); ?>>For Future Reference</option>
					<option value="dispatchtoad"<?php echo($status=='dispatchtoad'?'selected':''); ?>>Dispatch To HO</option>
					<option value="underdevelopment"<?php echo($status=='underdevelopment'?'selected':''); ?>>Under Development</option>
					<option value="sentforapproval"<?php echo($status=='sentforapproval'?'selected':''); ?>>Sent For Approval</option>
					<option value="2ndtimerequest"<?php echo($status=='2ndtimerequest'?'selected':''); ?>>2nd Time Request</option>
					<option value="resend"<?php echo($status=='resend'?'selected':''); ?>>Resend</option>
				</select>
			</td>
		</tr>
	 <tr class="row1">
	 <td colspan="4">
  	    <table id="TABLE1" width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr class="row1">
			<td class="tabledata1" colspan="4"><strong>Panel In Details</strong></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1" width="19%">Panel In Date</td>
			<td  width="31%"><input type="text" name="panel_in_date" id="panel_in_date" class="datepicker" <?php echo($panel=='panel' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> value="<?php if($_REQUEST['action']=='Edit'){echo ConvertSQLDate($panel_in_date);} ?>" style="width:180px;"></td>
			<td class="tabledata1" width="17%">Panel Out Date</td>
			<td width="33%"><input type="text" name="panel_out_date" id="panel_out_date" <?php echo($panel=='panel' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> class="datepicker" value="<?php if($_REQUEST['action']=='Edit'){echo ConvertSQLDate($panel_out_date);} ?>" style="width:180px;"></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1">Panel Image</td>
			<td><input type="file" <?php echo($panel=='panel' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> name="panel_img" id="panel_img" style="width:180px;" >
			<input type="hidden" name="panel_img1" value="<?php echo $panel_image; ?>">
			</td>
			</tr>
			 <tr class="row1">
  	    <td class="tabledata1">Remark</td>
  	    <td colspan="3">
			<textarea name="reamark" id="remarks" <?php echo($panel=='panel' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> style="width:83%"><? echo $reamark; ?></textarea>
		</td>
		</tr>
		</table>
		</td>
		</tr>
		
		
		
		
		 <tr class="row1">
	 <td colspan="4">
  	    <table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr class="row1">
			<td class="tabledata1" colspan="4"><strong>Approval Dot Details</strong></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1" width="19%">Request Date</td>
			<td  width="31%"><input type="text" name="request_date" id="request_date" class="datepicker" value="<?php if($_REQUEST['action']=='Edit'){echo ConvertSQLDate($request_date);} ?>" style="width:180px;" <?php echo($approval_dot=='approvalDot' && $_REQUEST['action']=='Edit'?'':'disabled'); ?>></td>
			<td class="tabledata1" width="17%">In Date</td>
			<td width="33%"><input type="text" name="in_date" id="in_date" class="datepicker" <?php echo($approval_dot=='approvalDot' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> value="<?php if($_REQUEST['action']=='Edit'){echo ConvertSQLDate($in_date);} ?>" style="width:180px;"></td>
			</tr>
			<tr class="row1">
			<td class="tabledata1">Out Date</td>
			<td><input type="text" name="out_date" id="out_date" <?php echo($approval_dot=='approvalDot' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> class="datepicker" value="<?php if($_REQUEST['action']=='Edit'){echo ConvertSQLDate($out_date);} ?>" style="width:180px;"></td>
			</tr>
			 <tr class="row1">
  	    <td class="tabledata1">Remark by Executive</td>
  	    <td colspan="3">
			<textarea name="reamrk_by_executive" id="reamrk_by_executive" <?php echo($approval_dot=='approvalDot' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> style="width:83%"><? echo $reamrk_by_executive; ?></textarea>
		</td>
		</tr>
		<tr class="row1">
  	    <td class="tabledata1" align="left">Remark By Commercial </td>
  	    <td colspan="3">
			<textarea name="reamark_by_cmmercial" id="reamark_by_cmmercial" <?php echo($approval_dot=='approvalDot' && $_REQUEST['action']=='Edit'?'':'disabled'); ?> style="width:83%"><? echo $reamark_by_cmmercial; ?></textarea>
		</td>
		</tr>
		</table>
		</td>
		</tr>	
    </table>
<p align="center"><input type="submit" name="<? if($_REQUEST['action']=='Edit'){echo 'Update'; }else{echo 'Proceed';}?>" id="button" value="<? if($_REQUEST['action']=='Edit'){echo 'Update'; }else{echo 'Save';}?>" onclick="return validate_field();" /></p>
</form>
<?php } ?>
</div></div>