<?php
ob_start();
$PageSecurity = 2;
include('includes/SQL_CommonFunctions.inc');
global $db; 

  if(isset($_REQUEST['Save']))
  {
 $prefix=$s->getField('companies','CompanyId',$_SESSION['ACGCompanyId'],'company_code');
  $prefix_sql=DB_query("Select * from prefix_tbl where prefix_name='".$_REQUEST['frmid']."'",$db);
  $prefix_row=DB_fetch_array($prefix_sql);
  $prefix1=$prefix_row['prefix_code'];
  
  $financial=substr($_SESSION['YearStart'],-2)."-".substr($_SESSION['YearEnd1'],-2);
    $sql="Select work_indent_no from tpl_work_indent where site='".$_REQUEST['site']."' 
  and INSTR(`work_indent_no`, '$financial') > 0 order by work_indent_no desc limit 0,1";

  $result=DB_query($sql,$db);
  $myrow=DB_fetch_array($result);
  //echo DB_num_rows($result);
  if(DB_num_rows($result)>0)
  {
  //$Reqno=$myrow['Reqno'];
  //$req_part1=substr($Reqno,-4);
         if($prefix!='')
      {
      $ExplBill=explode("/",$myrow['work_indent_no']);
      $maxval = $ExplBill[4];
        }
        else
        {
        $ExplBill=explode("/",$myrow['work_indent_no']);
      $maxval = $ExplBill[3];
        }     
  //$ExplBill=explode("/",$myrow['Reqno']);
  //$maxval = $ExplBill[3];
  //echo $req_part1;
  $req_final=$maxval+1;
  }else
  {
  $req_final="1";
  }
          if($prefix!='')
       $string=$prefix."/".$_REQUEST['site']."/".$financial."/".$prefix1."/";
         else
         $string=$_REQUEST['site']."/".$financial."/".$prefix1."/";

  //$string=$prefix."/".$_REQUEST['site']."/".$financial."/";
    $final_string=$string.str_pad($req_final,4,"0",STR_PAD_LEFT);

                     
             $sql_workindent="insert into tpl_work_indent set 
                                           site='".$_REQUEST['site']."',
                                 work_indent_no='".$final_string."',
                                 work_indent_date='".FormatDateForSQL($_REQUEST['work_indent_date'])."',
                                 department      ='".$_REQUEST['department']."',
                                 division       = '".$_REQUEST['division']."',
                                 prepared_by    ='".$_REQUEST['prepairedBy']."',
                                 CompanyID      ='".$_SESSION['ACGCompanyId']."',
                                 remak          ='".$_REQUEST['remarks1']."',
                                 status         ='N',
                                 order_status   ='0'

                                            ";
                    $insertResult1=DB_query($sql_workindent,$db); 
                   $LastId=DB_Last_Insert_ID($db,'tpl_work_indent','id');
                   if(isset($LastId))
                   {


                     for($str=0;$str<count($_REQUEST['itemID']);$str++)
                     {  
                        $inserSql="insert into tpl_work_indent_asset set 
                                              work_indent_id='".$LastId."', 
                                              asset_id      ='".$_REQUEST['itemID'][$str]."',
                                              junction_file ='".$_REQUEST['junctionfile'][$str]."',
                                              group_id      ='".$_REQUEST['groupType'][$str]."'  ";

                                     if($_REQUEST['activity_defId'][$_REQUEST['itemID'][$str]][0]!='') 
                                    {                
                         $insertResult2=DB_query($inserSql,$db); 
                        $Last_detail_Id=DB_Last_Insert_ID($db,'tpl_work_indent_asset','id');
                       saveDataServiceItem($Last_detail_Id,$_REQUEST['itemID'][$str],$LastId);
                                     }          
                     } // for($str=0;$str<count($_REQUEST['itemID']);$str++)

                   }//if(isset($LastId))
   
     
prnMsg( _('Record Saved Successfully'),'success');

echo "<script>location.href='index.php?route=work_indent_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";

  }// if(isset($_REQUEST['Save']))
 function saveDataServiceItem($inser_id,$itemIds,$lastId1)
     {global $db;
      $queryService='';
     $queryService="insert into tpl_work_indent_asset_details( work_indent_id,work_indent_asset_id,activity_id,activity_qty,work_completion_date,remark) values ";
      $subQueryService='';$j=0;

          for($i=0;$i<count($_REQUEST['activity_defId'][$itemIds]);$i++)
            {

            if($_REQUEST['activity_defId'][$itemIds][$i]!='')
            {  
     
          $subQueryService.=($j==0)?"(":",(";
          $subQueryService.="'".$lastId1."','".$inser_id."','".$_REQUEST['activity_defId'][$itemIds][$i]."','".$_REQUEST['activityQty'][$itemIds][$i]."','".FormatDateForSQL($_REQUEST['complitionDate'][$itemIds][$i])."','".$_REQUEST['remarks'][$itemIds][$i]."')";
             $j++;
           //echo $_REQUEST['activity_defId'][$itemIds][$i];  
           }

           }
          
            if($subQueryService!='')
            DB_query($queryService.$subQueryService,$db); 
           

     }//function saveDataServiceItem()

?>
<style type="text/css">
.body_lightbox {
width:100%;
background-color:#e7e7e7;
position:absolute;
left:280px;
top:95px;
padding-left:5px;
padding-right:5px;
border:#666666 solid 3px;
}
</style>
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({ dateFormat: 'dd/mm/yy', 
    minDate:'0'});
});
</script>
<script type="text/javascript">
var jobSelectType='';
//$.noConflict();
$(document).ready(function(){ 
    //var cnt=document.getElementById("count").value;
    $('input[name=profile_popup]').click(function(){
    var tt=this.id;
    var tt1=tt.split("_");
    var tt2=tt1[1];
    var site=$('#site').val();
          if($('#site').val()==0)
          {
            alert("Please select site.");
            return false;
          }

       if($('#jobtype').val()==0)
       {
        alert('Please select job type.');
        return false;
       }

        //alert($('#dataTable').find('tr').eq(0).html());
         /*if(jobSelectType!=$('#jobtype').val())
         {
        $('#dataTable').html('<tr>'+$('#dataTable').find('tr').eq(0).html()+'</tr>');
        $('#dataTable').find('#itemid').val('');
        $('#hiditemcount').val();
        $('#edit_cnt').val(0);
        $('#rowcount1').val(0);
        }*/

    //var LeaveType=document.getElementById("LeaveType_"+tt2).value;
    $("#PickedItems").dialog({
        title:'Item List',
        modal: true,
        resizable: false,
        width:900,
        height:400,
        closeText: 'fechar',
        draggable: true,
        show: 'fade',
        hide: 'fade',
        dialogClass: 'main-dialog-class',
        buttons: {
          Exit: function()
          {
            $(this).dialog("close");
          }
        }
        
      });

        if($('#jobtype').val()=='J')
    GetitemListForDirectPO(site);
     else
       GetitemListForDirectPOAsset(site);
      
        // GetitemListForDirectPOAsset(str)

    });
  });

var objInner='';
var currentItemId='';
  function showpopUpAssetGroup(obj)
  {assetServiceCount=1;
         objInner=obj;
    if($(obj).attr('groupid')=='')
    {
      alert('Please first select item.')
      return false;
    }
    $("#PickedItems").dialog({
        title:'Item List',
        modal: true,
        resizable: false,
        width:900,
        height:400,
        closeText: 'fechar',
        draggable: true,
        show: 'fade',
        hide: 'fade',
        dialogClass: 'main-dialog-class',
        buttons: {
          Exit: function()
          {
            $(this).dialog("close");
          }
        }
        
      });
        currentGrpId=$(obj).attr('groupid');
        currentItemId=$(obj).closest('tr').find('input[type=hidden]').val();
        showServicePopup($(obj).attr('groupid'),$(obj).closest('tr').find('input[type=hidden]').val());


  }

  function GetitemListForDirectPO(str)
    { $('#PickedItems').html('<center><span style="font-size:20px;"><strong>Loading...</strong></span></center>');
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
    document.getElementById("PickedItems").innerHTML=xmlhttp.responseText;
  }
  }
  xmlhttp.open("GET","popup_item_list.php?site="+str,true);
  xmlhttp.send();
    }


    function GetitemListForDirectPOAsset(str)
    {
       $('#PickedItems').html('<center><span style="font-size:20px;"><strong>Loading...</strong></span></center>');
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
    document.getElementById("PickedItems").innerHTML=xmlhttp.responseText;
  }
  }
  xmlhttp.open("GET","popup_asset_item-list.php?site="+str,true);
  xmlhttp.send();
    }

      function getdataforSearch()
      { 
            // $('#PickedItems').html('<center><span style="font-size:20px;"><strong>Loading...</strong></span></center>');
                     $.ajax({
            url : "popup_asset_item-list.php",
            type : "POST",
            data : {
            site:$('#site').val(),
            itemCode:$('#PickedItems').find('input[id=srch_code]').val(),
            itemName:$('#PickedItems').find('input[id=srch_name]').val()
            },
            success : function(data) {//alert(data);
             $('#PickedItems').html(data);  
                          }
                 });
    
      } 
var currentGrpId='';
      function showServicePopup(grpId,crItem)
      {   
              var sendGrpId=(grpId!='')?grpId:currentGrpId;
              
            // $('#PickedItems').html('<center><span style="font-size:20px;"><strong>Loading...</strong></span></center>');
                     $.ajax({
            url : "ajax_asset_group_activity.php",
            type : "POST",
            data : {
            groupId:sendGrpId,
            itemId1:(crItem!='')?crItem:currentItemId,
            ActivityCode:$('#PickedItems').find('input[id=act_code]').val(),
            ActivityName:$('#PickedItems').find('input[id=act_name]').val()
            },
            success : function(data) { //alert(data);
             $('#PickedItems').html(data);  
                          }
                 });
    
      } 
var assetRowCount=1;
   function getItemsListjQuery(obj)
   { 
     // assetRowCount=$("input:checkbox[name='delitem[]']").length;
    var flag=true;
       $("input:checkbox[name='delitem[]']").each(function(){
                      
          if(!$(obj).is(':checked'))
          {
            if($("input:checkbox[name='delitem[]']").length > 1)
            {
           $("input:checkbox[id="+$(obj).val()+"]").closest('tr').remove();
            flag=false;
            return false;
           }
           else
            alert("You can'nt delete it.");
           }
         if($(this).attr('id')==$(obj).val())
         {alert('You have already added !');
         flag=false;
          }
         });

      if(flag)
      {
      if(assetRowCount!=1)
      $('#divShowStructure').find('#dataTable').prepend('<tr bgcolor="#FFFFFF"><td valign="top"><input name="delitem[]" type="checkbox"  id="delitem" /></td><td valign="top"><input type="hidden" name="itemID[]" id="itemid" value="" /></td><td valign="top"><input type="text" name="assetCode[]" style="width:100%" readonly /></td><td valign="top"><input type="text" name="itemdesc[]" id="itemdesc" style="width:100%" readonly /></td><td valign="top"><textarea  name="junctionfile[]" id="junctionfile" style="width:100%; height:40px;"></textarea></td><td valign="top"><!--<input type="text" name="itemunit[]" id="itemunit" style="width:100%" readonly />--></td><td valign="top"><input type="button" groupid="" value="Add Activity" onclick="showpopUpAssetGroup(this)" class="search"><input type="hidden" name="groupType[]" value="" /></td><td colspan="7" style="padding:0px;"><table class="tableAssetService" cellpadding="3" cellspacing="0" border="0" width="100%"><tr><td style="border-right:#808080 1px solid;" width="69" valign="top"><input type="text"  name="activityCode[][]"  qty="qty" readonly   onkeypress="return isNumberKey(event)"  autocomplete="off"  style="width:100%" /><input type="hidden" name="activity_defId[][]"></td><td style="border-right:#808080 1px solid;" width="180" valign="top"><input type="text" autocomplete="off" name="activityName[][]"  readonly onkeypress="return isNumberKey(event)" style="width:100%" /></td><td style="border-right:#808080 1px solid;" width="70" valign="top"><input type="text" readonly name="activityUnit[][]"  style="width:100%"/></td><td width="90" style="border-right:#808080 1px solid;" valign="top"><input type="text" onkeyup="set_color_text_box(this);" qty="qtyName" style="width:100%;" name="activityQty[][]"   onkeypress="return isNumberKey(event)"  autocomplete="off"  /></td><td style="border-right:#808080 1px solid;" width="70" valign="top"><input type="text" style="width:100%;" class="datepicker" cpdate="autoComp" onmouseup="set_color_text_box(this);" onchange="javascript:checkitemdate(this)"  name="complitionDate[][]"  /></td><td style="border-right:#808080 1px solid;" width="130" valign="top"><textarea name="remarks[][]" id="remarks" style="width:100%; height:40px;" ></textarea></td><td valign="top"><img src="images/Icon_Delete3.gif" onclick="delserviceAssets(this)" style="cursor:pointer;"></td></tr></table></td></tr>');      
              var chkObj=$('#divShowStructure').find('#dataTable').find('tr').eq(0);
              $(chkObj).find('td:eq(0)').find('input[type=checkbox]').attr('id',$(obj).val());
              $(chkObj).find('td:eq(1)').find('input[type=hidden]').val($(obj).val());
              $(chkObj).find('td:eq(2)').find('input[type=text]').val($(obj).attr('assetCode'));
              $(chkObj).find('td:eq(3)').find('input[type=text]').val($(obj).attr('assetName'));
              $(chkObj).find('td:eq(5)').find('input[type=text]').val($(obj).attr('assetUnit'));
              $(chkObj).find('td:eq(6)').find('input[type=button]').attr('groupid',$(obj).attr('groupId'));
              $(chkObj).find('td:eq(6)').find('input[type=hidden]').val($(obj).attr('groupId'));
      assetRowCount++;
  callDate();
     }

   }//getItemsListjQuery()
function deleteRowOrder(tableID) 
{ 
    if($('#'+tableID).find('input[type="checkbox"]:checked').length == 0)
    { alert('Please select at least one row to delete.');
      return false;
    }
  try 
  {
  var table = document.getElementById(tableID);
  // /alert(table);
  var rowCount = table.rows.length;
  //alert(rowCount);
  for(var i=0; i<rowCount; i++) 
  {
  var row = table.rows[i];
  var chkbox = row.cells[0].childNodes[0];
  if(null != chkbox && true == chkbox.checked) 
  {
  if(rowCount <= 1) 
  {
  alert("Cannot delete all the rows.");
  break;
  }
  table.deleteRow(i);
  rowCount--;
  i--;
  }
  }
  document.getElementById("hiditemcount").value=(rowCount);   }
  catch(e) 
  {
  alert(e);
  }
  //caltotalAmnt();
} 

var assetServiceCount=1;
   function getinnerItemlist(obj)
   { var innnerflag=true;
            var innertableobject=$(objInner).closest('td').next().find('table');
            assetServiceCount=($(innertableobject).find('tr').find('td:eq(0)').find('input[type=hidden]').val()=='')?1:2;
         $(innertableobject).find('input[qty="qty"]').each(function(){
               if(!$(obj).is(':checked'))
                 {
              if($(innertableobject).find('input[qty="qty"]').length > 1)
                  {
                   $(innertableobject).find('input[id='+$(obj).val()+']').closest('tr').remove();
                      innnerflag=false;
                    return false;
                     }
            else
            alert("You can'nt delete it.");
                   }
       /* if($(this).attr('id')==$(obj).attr('activity_def_id'))
        {
          alert('You have already added !');
         innnerflag=false;
        }*/
       });
      if(innnerflag)
      {
   
       if(assetServiceCount!=1)
         $(objInner).closest('td').next().find('table').prepend('<tr>'+$(objInner).closest('td').next().find('table').find('tr').eq(0).html()+'</tr>');
           var innertblobj=$(objInner).closest('td').next().find('table').find('tr').eq(0);
           $(innertblobj).find('td:eq(0)').find('input[type=text]').val($(obj).attr('activityCode'));
            $(innertblobj).find('td:eq(0)').find('input[type=text]').attr('name','activityCode['+$(obj).attr('id')+'][]');
           $(innertblobj).find('td:eq(0)').find('input[type=hidden]').attr('name','activity_defId['+$(obj).attr('id')+'][]');
           $(innertblobj).find('td:eq(0)').find('input[type=hidden]').val($(obj).attr('activity_def_id'));
           $(innertblobj).find('td:eq(0)').find('input[type=text]').attr('id',$(obj).attr('activity_def_id'));
           $(innertblobj).find('td:eq(1)').find('input[type=text]').attr('name','activityName['+$(obj).attr('id')+'][]');
            $(innertblobj).find('td:eq(1)').find('input[type=text]').val($(obj).attr('activityName'));
          $(innertblobj).find('td:eq(1)').find('input[type=hidden]').attr('name','serviceId['+$(obj).attr('id')+'][]');
           $(innertblobj).find('td:eq(1)').find('input[type=hidden]').val($(obj).val());
            $(innertblobj).find('td:eq(2)').find('input[type=text]').val($(obj).attr('activityUnit'));
            $(innertblobj).find('td:eq(2)').find('input[type=text]').attr('name','activityUnit['+$(obj).attr('id')+'][]');
             $(innertblobj).find('td:eq(3)').find('input[type=text]').val('');
              $(innertblobj).find('td:eq(3)').find('input[type=text]').attr('name','activityQty['+$(obj).attr('id')+'][]');
              $(innertblobj).find('td:eq(4)').find('input[type=text]').attr('name','complitionDate['+$(obj).attr('id')+'][]');
              $(innertblobj).find('td:eq(4)').find('input[type=text]').attr('id','');
              $(innertblobj).find('td:eq(5)').find('textarea').attr('name','remarks['+$(obj).attr('id')+'][]');
    assetServiceCount++;
      callDate();
       }
     
   }

   function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       } 

   function delserviceAssets(obj)
   {
    var r=confirm("Do you want to delete ?"); 
     if (r==true)
      {
       if($(obj).closest('table').find('input[qty="qty"]').length > 1)
       {
        $(obj).closest('tr').remove();
        caltotalAmnt();
       }
    else
      alert("You can'nt delete it.");
      }
   }

  function get_division()
  {
        $('#division').html('<option>Loading...</option>');  
        $.ajax({
            url : "ajax_get_breakDown_type.php",
            type : "POST",
            data : {
            branchCode:$('#site').val()
            },
            success : function(data) {//alert(data);
             $('#division').html(data);  
                          }
                 });

  }
  function callDate()
  {
    $('.datepicker').removeClass('hasDatepicker').datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true, changeYear: true,yearRange: '-80:+20'});
    $('.datepicker').datepicker();
  } 
function chkComp_date()
{
  alert(1);
}

  function validate()
  {
       

    if(document.getElementById("site").value=='0')
        {
            alert('Select Branch');
            document.getElementById("site").focus();
            return false;
        }
    
      if($('#work_indent_date').val()=='')
      {
        alert('Please select work indent date.');
       return false;
      }

      if($('#department').val()=='')
      {
     alert('Please select department.');
     return false;
      }
      if($('#division').val()=='')
      {
        alert('Please select division.');
        return false;
      }
       //if($('input[name=activityCode[]]'))
       var activityChk=$('#divShowStructure').find('#dataTable').find('tr').eq(0).find('.tableAssetService').find('tr').eq(0).find('td').eq(0).find('input[type="text"]').attr('id');

        if(activityChk=='')
        {
          alert('Please pick at least one activity.');
          return false;
        }
        var chkFlag=false;
         $('input[type=text][qty="qtyName"]').each(function(){
           if($(this).val()=='')
           {chkFlag=true;
             $(this).css("background-color","red");
           }
        
         });
           if(chkFlag)
           {
            alert('Please Enter Quantity.');
            return false;
           }//cpdate="autoComp"

           var chkDateFlag=false;
            $('input[type=text][cpdate="autoComp"]').each(function(){
            if($(this).val()=='')
            {chkDateFlag=true;
               $(this).css("background-color","red");
            }
            });
             if(chkDateFlag)
           {
            alert('Please Enter Completion Date.');
            return false;
           }//cpdate="autoComp"

        return true;
 }
 
   function set_color_text_box(obj)
   {
     $(obj).css("background-color","#FDF6EB");
   }


   function checkitemdate(obj)
   {
  var secondDate=new Date($('input[name="work_indent_date"]').val());
  var firstDate=new Date($(obj).val());
   if(secondDate <= firstDate)
    return true;
   else
    {
    alert('Work Completion date should be greater work indent date.');
      $(obj).val('');
      document.getElementById(obj).focus();
    }
 }
</script>
<div id="PickedItems" style="display:none"></div>
<div id="div_id" style="display:none"></div>
<div id="div_idEcess" style="display:none"></div>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name"); ?></h1>		
<form name="RequisitionDetailsform" action="" method="post" onsubmit="return validate();">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
    <td width="13%" height="33"><strong>Branch</strong><font style="color:red;">*</font></td>
    <td width="20%">
   <?php
  if($_SESSION['AssignedBranch']!='')
    {     
  $ss="Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
 $site_sql=DB_query($ss,$db);
  }
 else
 {
$ss="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."'";
$site_sql=DB_query($ss,$db);
 }

?>

<select name="site" id="site" style="width:100%" onchange="get_division()">
    <option value="0">Select Branch</option>
<?php 
while($Row=DB_fetch_array($site_sql)){?>
<option value="<?php echo $Row['loccode']?>"<?php echo($_SESSION['Site']==$Row['loccode'] ? 'selected':'');?> ><?php echo $Row['locationname']?></option>
<?php  } ?>
</select>
    </td>
    <td width="13%"><strong>Work Indent No.</strong></td>
    <td width="20%"><input type="text" placeholder="Auto Generated" readonly style="width:100%;"/></td>
    <td width="13%"><strong>W/O Indent Date </strong></td>
    <td><input type="text" id="datepicker" value="<?php echo date('d/m/Y'); ?>" name="work_indent_date"   style="width:100%;"/></td>
  </tr>
  <tr class="row1">
    <td><strong>Department</strong></td>
    <td><select style="width:100%;" name="department" id="department">
      <option value="">Select</option>
     <?php
     $resultDept=DB_query("select * from deptmaster where CompanyId='".$_SESSION['ACGCompanyId']."'" ,$db);
     while($rowDept=DB_fetch_array($resultDept))
     {?>
     <option value="<?php echo $rowDept['id']; ?>"><?php echo $rowDept['deptname']; ?></option>
     <?php
     }

     ?>
    </select></td>
    <td><strong>Division</strong></td>
    <td><select style="width:100%;" id="division" name="division">
   <option value="">Select</option>
    </select></td>
    <td><strong>Prepared By</strong></td>
    <td><input type="text" name="prepairedBy" value="<?php echo $s->getField('www_users','id',$_SESSION['UserID'],'realname') ?>" style="width:100%;" readonly/></td>
  </tr>
  <tr class="row1">
    <td colspan="6"><input type="button" name="profile_popup" value="Pick Assets" id="profile_popup" class="search" />
  
    <input type="button" class="search"   onclick="deleteRowOrder('dataTable')" value="Delete" /> </td>
    </tr>  
</table>

<div id="divShowStructure">

<table border="1" width="100%" cellpadding="3" style="border:#999999 solid 1px; border-collapse:collapse" align="center">

<tr bgcolor="#ccc">
    <td width="3%"><strong>Select</strong></td>
    <td width="1%">&nbsp;</td>
    <td width="6%"><strong>Asset Code</strong></td>
    <td width="10%"><strong>Asset Name</strong></td>
    <td width="13%"><strong>Justification </strong></td>
    <td width="1%"></td>
    <td width="7%"></td>
    <td width="70"><strong>Activity Code</strong></td>
    <td width="180"><strong>Activity Name</strong></td>
    <td width="70"> <strong>Unit</strong></td>
    <td width="90"><strong>Activity Qty.</strong></td>
    <td  width="70"><strong>Work Completion Date </strong></td>  
    <td width="130"><strong>Remark</strong></td>
    <td><strong>Delete</strong></td>
</tr>
<tbody id="dataTable">
<tr bgcolor="#FFFFFF">  
<td valign="top"><input name="delitem[]" type="checkbox"  id="delitem" /></td>
<td valign="top"><input type="hidden" name="itemID[]" id="itemid" value="" /></td>
<td valign="top"><input type="text" name="assetCode[]" style="width:100%" readonly /></td>
<td valign="top"><input type="text" name="itemdesc[]" id="itemdesc" style="width:100%" readonly /></td>
<td valign="top"><textarea name="junctionfile[]" id="junctionfile" style="width:100%; height:40px;" rows="2"></textarea></td>
<td valign="top"><!--<input type="text" name="itemunit[]" id="itemunit" style="width:100%" readonly />--></td>
<td valign="top"><input type="button" groupid="" value="Add Activity" onclick="showpopUpAssetGroup(this)" class="search"><input type="hidden" name="groupType[]" value="" /></td>
<td colspan="7" style="padding:0px;">
<table class="tableAssetService" cellpadding="3" cellspacing="0" border="0" width="100%" style="border:none;">
<tr>   
  <td width="70" valign="top" style="border-right:#808080 1px solid;"><input type="text" id="" name="activityCode[][]" qty="qty"    readonly  onkeypress="return isNumberKey(event)"  autocomplete="off"  style="width:100%" /><input type="hidden" name="serviceId[][]"></td>
<td width="180" valign="top" style="border-right:#808080 1px solid;"><input type="text" autocomplete="off" name="activityName[][]"  readonly onkeypress="return isNumberKey(event)"    style="width:100%" /></td>
<td width="70" valign="top" style="border-right:#808080 1px solid;"><input type="text" readonly name="activityUnit[][]"  style="width:100%"/></td>
<td width="90" valign="top" nowrap="nowrap" style="border-right:#808080 1px solid;"><input type="text" onkeyup="set_color_text_box(this);" qty="qtyName" style="width:100%;" name="activityQty[][]"   onkeypress="return isNumberKey(event)"  autocomplete="off"  />
      </td>
        
 <td  width="70" valign="top" style="border-right:#808080 1px solid;"><input type="text" style="width:100%;" onchange="javascript:checkitemdate(this)" class="datepicker" cpdate="autoComp" onmouseup="set_color_text_box(this);"   name="complitionDate[][]"  /></td>
 
<td valign="top" width="130" style="border-right:#808080 1px solid;" nowrap><textarea name="remarks[][]" id="remarks" style="width:100%; height:40px;" rows="2" ></textarea></td>
<td valign="top"><img src="images/Icon_Delete3.gif" onclick="delserviceAssets(this)" style="cursor:pointer;"></td>
</tr>
</table><!--tableAssetService-->  
</td>
</tr>

</tbody>
</table>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
    <td align="left" valign="middle" width="7%"><strong>Remarks :</strong></td>
    <td align="left" valign="middle"><textarea name="remarks1" id="remarks1" style="width:100%; height:50px;" ></textarea></td>
  </tr>
</table>
</div>
<input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
<input type="hidden" name="" value="0" id="edit_cnt" />
<input type="hidden" name="" value="0" id="rowcount1" />
    </table>
<p align="center"><input type="submit" name="Save" value="Save" class='search' /></p>
</form>
</div>
</div>
<noscript>Your browser does not support java script</noscript>
