  <?
  include_once('models/tradeModel.php');
  include_once('models/poModel.php');
 error_reporting(0);
  
  $mypoModel=new poModel;
  $mytradeModel=new tradeModel;

  // get project info
  // get mro details and items

  //$project_data = $myprojectModel->getdata_project

  $myprojectname = $_SESSION['Xprojectname'];
  $myprojectdesc = $_SESSION['Xprojectdesc'];

  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mro_items = $mymroModel->getlist_mroitems($pubitemid);

  $trade_data = $mytradeModel->getdata_trade($mro_data['mro_subtradepkey']);
  $po_list = $mypoModel->getlist_pobyitq($itq_data['itq_pkey']);

  $suppliercount=0;
  $tablewidth=700;
  foreach ($supplier_list as $supplier_data) {
    $suppliercount++;
    $tablewidth += 200;
  }

  $ponos="";
  foreach ($po_list as $po_data) {
    $ponos .= ", ".poidstr($po_list['po_no']);
  }
  $ponos = substr($ponos,2);

  $prep_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],1);
  $rev_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],2);
  $app_data = $myitqModel->getdata_lastapprovalbytype($itq_data['itq_pkey'],3);
  //$prep_data = $myuserModel->getdata_user($);

  $awarded="";
  $awardedno=0;
  $award_list = $myitqModel->getlist_itqawardedsuppliers($itq_data['itq_pkey']);
  foreach ($award_list as $award_data) {
    $supplier = $mysupplierModel->getdata_supplier($award_data['eval_supplierpkey']);
    $awarded .= ", ".$supplier['supplier_name'];
  }
  $awarded = substr($awarded,2);
  ?>

  <div style="background: #ffffff;">

  <table border=0 cellspacing=2 cellpadding=0 width=<?=$tablewidth;?>>
  <tr valign=top>
  <td valign=top width=100>&nbsp;</td>
  <!--<td valign=top width=400 class=rptzikayheader style="text-decoration: none; text-align: right;"><img src="gfx/zikay.png" width=45px height=56px align=left><br><span style="font-size: 18px;"><u>KEMBANG SERANTAU SDN. BHD.</u></span><br><span style="font-size: 10px; font-family: times new roman;">(224505-W)</span></td>-->
  <td valign=top width=<?=$tablewidth-200;?> class=rptzikayheader style="text-decoration: none; text-align: center;"><img src="gfx/zikayheader.png" style="width: 311px; height: 69px;"><!-- 259/58 390/87 416/93 519/116 --><!--<br><span style="font-size: 14px;"><u>KEMBANG SERANTAU SDN. BHD.</u></span>--></td>
  <!--<td valign=top width=<?=$tablewidth-700;?>>&nbsp;</td>-->
  <td valign=top width=100>
    <table border=0 cellspacing=0 cellpadding=2 width=100>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: right;">PU-SP-01-F3</td></tr>
    <tr valign=top><td valign=top width=100 class=rptzikayconfidential style="font-size: 10px; text-align: right; border-top: 0px;">Rev : 2</td></tr>
    </table>
  </td>
  </tr>
  </table>
  <br>

  <table border=0 cellspacing=2 cellpadding=0 width=<?=$tablewidth;?>>
  <tr valign=top>
  <td valign=top width=100% class=rptzikayheader colspan=5 style="text-align: center;"><b><u>QUOTATION EVALUATION APPROVAL</u></b></td>
  </td>
  </tr>
  <tr valign=top><td valign=top width=100% colspan=5 class=rptlistcontent><img src="pixel.gif" width=1 height=5></td></tr>
  <tr valign=top>
  <td valign=top width=140 class=rptzikayheader style="text-decoration: none;"><b>Project Title</b></td>
  <td valign=top width=10 class=rptzikayheader style="text-decoration: none;">:</td>
  <td valign=top width=<?=$tablewidth-350;?> class=rptzikayheader style="font-weight: normal;"><u><?=$myprojectdesc;?></u></td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>Date :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?=unconverttounixslash($itq_data['itq_date']);?></td>
  </tr>
  <tr valign=top>
  <td valign=top width=140 class=rptzikayheader style="text-decoration: none;"><b>Trade</b></td>
  <td valign=top width=10 class=rptzikayheader style="text-decoration: none;">:</td>
  <td valign=top width=<?=$tablewidth-350;?> class=rptzikayheader style="font-weight: normal;"><u><?=$trade_data['tradedescription'];?>&nbsp;</u></td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>RFQ No :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?=itqidstr($itq_data['itq_rfqno'],$itq_data['itq_revno']);?></td>
  </tr>
  <tr valign=top>
  <td valign=top width=<?=$tablewidth-200;?> colspan=3 class=rptzikayheader style="text-decoration: none;">&nbsp;</td>
  <td valign=top width=100 class=rptzikayheader style="text-align: right; text-decoration: none;"><b>PO No :</b></td>
  <td valign=top width=100 class=rptzikayheader style="text-decoration: none; font-weight: normal;">&nbsp;&nbsp;<?=$ponos;?></td>
  </tr>
  </table>
  <br>

  <table border=1 cellspacing=1 cellpadding=2 width=<?=$tablewidth;?> style="border: 1px solid black; border-collapse: collapse;">
  <tr valign=top>
  <td valign=top width=40 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Item</td>
  <td valign=top width=260 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Description</td>
  <td valign=top width=100 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Unit</td>
  <td valign=top width=100 rowspan=2 class=rptlistcontent-special style="background: #f0f0f0;">Qty</td>

  <td valign=top width=200 colspan=2 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">
  ZIKAY GROUP S/B
  </td>

  <? reset($supplier_list); ?>
  <? $scount=0; ?>
  <? foreach ($supplier_list as $supplier_data) { ?>
    <? $scount++; ?>
    <td valign=top width=200 colspan=2 class=rptlistcontent-special style="background: #f0f0f0;">
    <? $mysupplier = $mysupplierModel->getdata_supplier($supplier_data['itq_supplierpkey']); ?>
    <?=$mysupplier['supplier_name'];?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <? for ($i=1;$i<=$suppliercount+1;$i++) { ?>
    <td valign=top width=100 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">Rate (RM)</td>
    <td valign=top width=100 class=rptlistcontent-special style="text-align: center; background: #f0f0f0;">Amt (RM)</td>
  <? } ?>
  </tr>

  <? $total[0]=0; ?>
  <? $total[1]=0; ?>
  <? $total[2]=0; ?>
  <? $total[3]=0; ?>
  <? $total[4]=0; ?>
  <? $total[5]=0; ?>
  <? $total[6]=0; ?>
  <? $total[7]=0; ?>
  <? $total[8]=0; ?>
  <? $total[9]=0; ?>
  <? $total[10]=0; ?>

  <? $icount=0; ?>

  <? foreach($mroitem_list as $myitem) { ?>

    <? $icount++; ?>

    <? $itqitem_list = $myitqModel->getlist_itqevaluationbyitem($myitem['item_mropkey'], $myitem['item_pkey']); ?>

    <tr valign=top>
    <td valign=top width=40 class=rptlistnumber-leftrightbottom><?=$myitem['item_no'];?></td>
    <td valign=top width=260 class=rptlistcontent-leftrightbottom><?=unescape($myitem['item_code']);?> : <?=unescape($myitem['item_description']);?></td>
    <td valign=top width=100 class=rptlistcontent-leftrightbottom style="text-align: center;"><?=$myitem['item_unit'];?></td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom><?=number_format($myitem['item_quantity'],4);?>
    </td>

    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <?=number_format($myitem['item_rate'],2);?>
    </td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? $total[0]=$total[0]+($myitem['item_rate']*$myitem['item_quantity']); ?>
    <?=number_format(($myitem['item_rate']*$myitem['item_quantity']),2);?>
    </td>

    <? //reset($itqitem_list); ?>
    <? $scount=0; ?>
    <? foreach ($itqitem_list as $itqitem_data) { ?>
      <? $scount++; ?>
      <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
      <?=number_format($itqitem_data['eval_supplierrate'],2);?>
      </td>
      <? $mysubtotal=($myitem['item_quantity']*$itqitem_data['eval_supplierrate']); ?>
      <? $total[$scount]=$total[$scount]+$mysubtotal; ?>
      <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
      <?=number_format($mysubtotal,2);?>
      </td>
    <? } ?>

    </tr>

  <? } ?>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>TOTAL</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
  <?=number_format($total[0],2);?>
  </td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <?=number_format($total[$scount],2);?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>ESTIMATED PROFIT</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? if ($total[$scount]!=0) { ?>
      <?=number_format($total[0]-$total[$scount],2);?>
    <? } else { ?>
      NA
    <? } ?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>% DIFFERENCE</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>

  <? reset($itqitem_list); ?>
  <? $scount=0; ?>
  <? foreach ($itqitem_list as $itqitem_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <? if ($total[$scount]!=0) { ?>
      <?=number_format((($total[0]-$total[$scount])/$total[0])*100,0)."%";// or round function? ?>
    <? } else { ?>
      NA
    <? } ?>
    </td>
  <? } ?>


  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom style="text-align: center;"><b>TRANSPORT CHARGES</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
  <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>

  <? reset($supplier_list); ?>
  <? $scount=0; ?>
  <? foreach ($supplier_list as $supplier_data) { ?>
    <? $scount++; ?>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>&nbsp;</td>
    <td valign=top width=100 class=rptlistcontentnumeric-leftrightbottom>
    <?=number_format($supplier_data['itq_transportrate'],2);?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=300 colspan=2 class=rptlistcontent-leftrightbottom>
  Prepared By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=250>
    <tr valign=top>
    <td valign=top width=250 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
     <?php  
	$sql1 = "SELECT * FROM `zikay_pmsv5`.`itq_details` WHERE itq_mropkey = '".$_GET['itemid']."'";
	$sql2 = mysql_query($sql1);
	while($data = mysql_fetch_array($sql2)) {
	echo $data['itq_requestor'];
	
	}
	 
	 //echo "&nbsp;". $prep_data['approval_officername'];
	 //echo "" .dottedstr($pubuserfullname,30). "";
	 ?>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=120 class=rptlistcontent style="text-align: center;">
    QS/PE
    </td>
    <td valign=top width=130 class=rptlistcontent style="text-align: center;">
    Date: <?=unconverttounixslash($prep_data['approval_date']);?>
    </td>
    </tr>
    </table>
  </td>
  <td valign=top width=200 colspan=2 class=rptlistcontent-leftrightbottom>
  Recommend/Approved By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=200>
    <tr valign=top>
    <td valign=top width=180 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
    <?php
	$aa1 = "SELECT * FROM zikay_pmsv5.itq_details WHERE itq_mropkey ='".$_GET['itemid']."'";
	$aa2 = mysql_query($aa1);
	$aa3 = mysql_fetch_assoc($aa2);
	echo $aa3['itq_approval1'];
	//echo $aa3['itq_approver'];
	
	?>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=70 class=rptlistcontent style="text-align: center;">
	
    CM/PMG
    </td>
    <td valign=top width=110 class=rptlistcontent style="text-align: center;">
    Date: <?=unconverttounixslash($rev_data['approval_date']);?>
    </td>
    </tr>
    </table>
  </td>

  <td valign=top width=200 colspan=2 rowspan=2 class=rptlistcontent-leftrightbottom>
  Remarks :&nbsp;<br />
  <?php
  // remark for zikay
  //$sqlz = mysql_query("select remarks_zikay from zikay_pmsv5.itq_details where itq_mropkey ='".$itq_data['itq_mropkey']."'");
  //$sqlzData = mysql_fetch 
  echo $itq_data['remarks_zikay'];
  ?>
  </td>

  <? reset($supplier_list); ?>
  <? $scount=0; ?>
  <? foreach ($supplier_list as $supplier_data) { ?>
    <? $scount++; ?>
    <? if ($supplier_data['itq_remarks']=="") { ?>
      <? $mysupplier = $mysupplierModel->getdata_supplier($supplier_data['itq_supplierpkey']); ?>
      <? $myremarks = "TERMS: ".$mysupplier['supplier_ct']; ?>
    <? } else { ?>
      <? $myremarks = $supplier_data['itq_remarks']; ?>
    <? } ?>
    <?
    reset($mroitem_list);
    foreach($mroitem_list as $myitem) {
      $myapproval = $myitqModel->getdata_lastitqapprovalsbysupplier($itq_data['itq_pkey'],$myitem['item_pkey'],$supplier_data['itq_supplierpkey']);
      if ($myapproval['approval_pkey']!="") {
        if ($myapproval['approval_quantity']>0) {
          $mymroitem = $mymroModel->getdata_mroitem($myapproval['approval_itempkey']);
          //$myremarks .= "<br>Item ".$mymroitem['item_no']." : ".$myapproval['approval_quantity']." ".$mymroitem['item_unit'];
        }
      }
      //reset($app_data);
    }
    ?>
    <td valign=top width=200 colspan=2 rowspan=2 class=rptlistcontent-leftrightbottom>Remarks:<br>
    <?=$myremarks;?>
    </td>
  <? } ?>

  </tr>

  <tr valign=top>
  <td valign=top width=500 colspan=4 class=rptlistcontent-leftrightbottom>
    <table border=0 cellspacing=0 cellpadding=0 width=480>
    <tr valign=top>
    <td valign=top width=100 class=rptlistcontent>
    AWARDED TO:
    </td>
    <td valign=top width=380 class=rptlistcontent style="line-height: 18px;"><!-- style="border-bottom: 3px double black;"-->
    <span style="border-bottom: 3px double black;"><?=$awarded;?></span>&nbsp;
    </td>
    </tr>
    </table>
    Approved By:<br><br><br>
    <table border=0 cellspacing=0 cellpadding=0 width=230 style="display: inline;">
    <tr valign=top>
    <td valign=top width=230 colspan=2 class=rptlistcontent style="border-bottom: 1px solid black;">
	<?php if($app_data['approval_officername'] == ""){ ?>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<?php } else ?>
    <?=$app_data['approval_officername'];?>
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=100 class=rptlistcontent style="text-align: center;">
    CEO
    </td>
    <td valign=top width=130 class=rptlistcontent style="text-align: center;">
    Date: <?=unconverttounixslash($app_data['approval_date']);?>
    </td>
    </tr>
    </table>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <table border=0 cellspacing=0 cellpadding=0 width=230 style="display: inline;">
    <tr valign=top>
    <td valign=top width=230 class=rptlistcontent style="border-bottom: 1px solid black;">
    <? //  how to get md/ed name??; ?>&nbsp;
    </td>
    </tr>
    <tr valign=top>
    <td valign=top width=230 class=rptlistcontent style="text-align: center;">
    MD/ED
    </td>
    </tr>
    </table>
  </td>
  </tr>

  </table>

  </div>

  <div style="background: #f0f0f0; width: <?=$tablewidth;?>;">

  <form action="controllers/inputController.php" method="post" name="itqform" id="itqform">

  <table border=1 cellspacing=2 cellpadding=0 width=760<?//=$tablewidth;?> style="background: #f0f0f0;">
  <tr valign=top>
  <td valign=top width=100 class=formlabel>Date *</td>
  <td valign=top width=510 class=cboxcontent><input name="date" id="date" type="text" value="<?=unconverttounixslash(gettimestamp());?>" style="width: 90px;">
  
  <!-- tooltips -->
  <a rel="htmltooltip" style="color:red">
  PM REMARKS</a>
  <div class="htmltooltip">
  <?php echo $aa3['rekemen_remark']; ?>
  </div>
  
  
  
  </td>
  <td valign=top width=150 class=formlabel>Action</td>
  </tr>
  <tr valign=top>
  <td valign=top width=100 class=formlabel>Remarks *</td>
  <td valign=top width=510 class=cboxcontent><textarea name="remarks" id="remarks" rows=6 style="width: 500px;">&nbsp;</textarea></td>
  <td valign=top width=150 class=cboxcontent>
  <? $mymroamount = $total[0];//$mymroamount = number_format($total[0],2);  ?>
  <?php $compx = 100000; ?>
  <? if ($itq_data['itq_cancel']=="0") { ?>
    <? if ($pubtype>="2") { ?>
      <? if ($mymroamount > $compx ) { ?>
        <? if (($pubuseraccess['access_itq_review']==1)||($pubuserrole>=2)) { ?>
		 
		
          <button name="accept" id="accept" onClick="approveDocument('Recommend');" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Recommend</button>&nbsp;<br>
        <!-- 
		 <?php // echo "test : ". $mymroamount; ?>
		 
		 <?php if(($_SESSION['Xuseraccess']['access_itq_review_approved'] == 1)||  ($pubuserrole>=2)){ ?> 
		 <button name="accept" id="accept" onClick="approveDocument('Approve');" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Approve</button>&nbsp;<br>
         -->
		 <?php }else{}?>
		       
		 
		  <button name="reject" id="reject" onClick="rejectDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Reject Item</button>&nbsp;<br>
          
	   <? } ?>
      <? } ?>
    <? } else if ($pubtype=="3") { ?>
      <? // TODO: different approval maxes.. ?>
      <? if (($pubuseraccess['access_itq_approve50k']==1)||($pubuseraccess['access_itq_approve100k'])||($pubuseraccess['access_itq_approve1m']==1)||($pubuseraccess['access_itq_approveall'])||($pubuserrole>=2)) { ?>
        
		
			 <button name="accept" id="accept" onClick="window.location.href='http://www.zikaysystem.com/sispms/index.php?module=itq&task=evaluate&yus=1&&itemid=<?php echo $_GET['itemid'];?>'" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Edit</button>&nbsp;<br>
		
		     <?php if($itq_data['itq_evalstatus']=="1" AND $mymroamount > $compx  AND $itq_data['itq_approval1'] == ""){ ?>
			<!--
			<button name="accept" id="accept" onClick="window.location='<?php echo $_SERVER['PHP_SELF'];?>?module=itq&task=approve&itemid=<?php echo $_GET['itemid'];?>&rekemen=1'" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Recommend</button>&nbsp;<br>
			-->
			<button name="accept" id="accept" onClick="rekemen();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Recommend</button>&nbsp;<br>
			
		
		
		
		<?php } else { ?>
		
	   <?php if(($_SESSION['Xuseraccess']['access_itq_approve50k'] == 1)||($pubuserrole>=2)){ ?> 
	   <button name="accept" id="accept" onClick="approveDocument('Approve');" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Approved</button>&nbsp;<br>
       <?php }else{}?>
	   
		<?php } ?>
		
		<button name="reject" id="reject" onClick="rejectDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Reject Item</button>&nbsp;<br>
		<button name="cancel" id="cancel" onClick="cancelDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel RFQ</button>&nbsp;<br>
      <? } ?>
    <? } ?>
    <? //if (($pubtask=="approve")||($pubtask=="review")) { ?>
      <!--<button name="reject" id="reject" onClick="rejectDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Reject Item</button>&nbsp;<br>-->
    <? //} ?>
    <? if (($pubuseraccess['access_itq_cancel']==1)||($pubuserrole>=2)) { ?>
      <!--
	  <button name="cancel" id="cancel" onClick="cancelDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel RFQ</button>&nbsp;<br>
      -->
	<? } ?>
  <? } ?>
  <button name="print" id="print" onClick="itq_button_printeval('<?=$itq_data['itq_mropkey'];?>');" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print</button>&nbsp;<br>
  
  <!-- celaru -->
  <?php if ($_SESSION['Xuseraccess']['access_itq_approve50k']== 1 AND ($mymroamount <= $compx )){ ?>
  
   <button name="accept" id="accept" onClick="approveDocument('Approve');" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Approved</button>&nbsp;<br>
   
   
   
  <?php }else{}?>
  <?php if ($_SESSION['Xuseraccess']['access_itq_edit']== 1){ ?>
     <button name="reject" id="reject" onClick="rejectDocument();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Reject Item</button>&nbsp;<br>
	 <button name="accept" id="accept" onClick="window.location.href='http://www.zikaysystem.com/sispms/index.php?module=itq&task=evaluate&yus=1&&itemid=<?php echo $_GET['itemid'];?>'" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Edit</button>&nbsp;<br>
  <?php }else{}?>
  <!--celaru end -->
  
  <button name="back" id="back" onClick="cancelAction();" style="width: 130px; text-align: left;">&nbsp;&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back</button>&nbsp;
  </td>
  </tr>
  <input name="itqpkey" id="itqpkey" type="hidden" value="<?=$itq_data['itq_pkey'];?>">
  <input name="mropkey" id="mropkey" type="hidden" value="<?=$itq_data['itq_mropkey'];?>">
  <input name="type" id="type" type="hidden" value="<?=$pubtype;?>">
  <input name="userpkey" id="userpkey" type="hidden" value="<?=$_SESSION['Xuserpkey'];?>">
  <input name="officername" id="officername" type="hidden" value="<?=$_SESSION['Xstaffname'];?>">
  <input name="status" id="status" type="hidden" value="">
  <input name="job" id="job" type="hidden" value="itq_approve">

  </table>

  </form>

  </div>
  
<?php
switch($_GET['rekemen']) 
	{
		case "1":
		//$rek = "UPDATE zikay_pmsv5.itq_details SET itq_approval1 ='".$_SESSION['Xstaffname']."', rekemen_remark ='".$_POST['remarks']."' WHERE itq_mropkey ='".$_GET['itemid']."'";
		//mysql_query($rek);
		//echo $rek;
		/*
		echo "
		<script type=\"text/javascript\">

		window.location = \"".$_SERVER['PHP_SELF']."?module=itq&task=list\"

		</script>

		";
		*/
		break;
		default:
		
		break;
	}
	
	
?>

<script type="text/javascript">

function validDateOnly() {
  var isvalid = true;
  var objdate = document.getElementById('date');
  if (objdate.value=="") isvalid = false;
  return isvalid;
}

function validRemarks() {
  var isvalid = true;
  var objremarks = document.getElementById('remarks');
  var objdate = document.getElementById('date');
  if ((objremarks.value=="")||(objdate.value=="")) isvalid = false;
  return isvalid;
}

function approveDocument(actiontype) {
  if (validDateOnly()) {
    if (confirm('Are you sure to ' + actiontype + ' this RFQ?')) {
      document.itqform.status.value='1'; document.itqform.submit();
    }
  } else {
    alert('Approval Date is a mandatory field!');
  }
}

function rekemen() {
document.itqform.status.value ='4'; document.itqform.submit();

}

function rejectDocument() {
  if (validRemarks()) {
    if (confirm('Are you sure to Reject this RFQ?')) {
      document.itqform.status.value='3'; document.itqform.submit();
    }
  } else {
    alert('Date and Remarks are mandatory fields!');
  }
}

function cancelDocument() {
  if (validRemarks()) {
    if (confirm('Are you sure to Cancel this RFQ?')) {
      document.itqform.status.value='2'; document.itqform.submit();
    }
  } else {
    alert('Date and Remarks are mandatory fields!');
  }
}

function cancelAction() {
  document.location='index.php?module=itq&task=list';
}

</script>
<pre>
<?php 
//print_r($_SESSION);
//echo $pubtype;
?>
</pre>