<?
/* index.php: $pubmodule, $pubtask, $pubitemid */
/*
$pubsubjectid = $_REQUEST["subjectid"];
$pubtypeid = $_REQUEST["typeid"];
$pubgroupid = $_REQUEST["groupid"];
*/
$pubprojectid = $_REQUEST["pid"];
$pubtype = $_REQUEST["type"];

// filter forms..
$filterrfqno=$_POST['rfqno'];
$filtermrono=$_POST['mrono'];
$filtervendorname=$_POST['vendorname'];
/*
$filtersessionname=$_POST['sessionname'];
$filteruserpkey=$_POST['userpkey'];
$filterstartdate=$_POST['startdate'];
$filterstopdate=$_POST['stopdate'];
$realstartdate=converttounix($filterstartdate);
$realstopdate=converttounix($filterstopdate)+86399;
*/

$pubpageno1 = $_REQUEST['pageno1'];
if ($pubpageno1=="") $pubpageno1=1;
$pubpageno2 = $_REQUEST['pageno2'];
if ($pubpageno2=="") $pubpageno2=1;

?>

<script type="text/javascript">

// ................................................................................
// user-interaction handlers..
// ................................................................................

/*
function browse_tree_open(catnode,nodeno) {
  document.getElementById(catnode).style.cssText="display: block;";
  document.getElementById('open'+nodeno).style.cssText="display: none; cursor: hand;";
  document.getElementById('close'+nodeno).style.cssText="display: block; cursor: hand;";
  document.getElementById('spanopen'+nodeno).style.cssText="display: none; cursor: hand;";
  document.getElementById('spanclose'+nodeno).style.cssText="display: inline; cursor: hand;";
}

function browse_tree_close(catnode,nodeno) {
  document.getElementById(catnode).style.cssText="display: none;";
  document.getElementById('open'+nodeno).style.cssText="display: block; cursor: hand;";
  document.getElementById('close'+nodeno).style.cssText="display: none; cursor: hand;";
  document.getElementById('spanopen'+nodeno).style.cssText="display: inline; cursor: hand;";
  document.getElementById('spanclose'+nodeno).style.cssText="display: none; cursor: hand;";
}

function browse_tree_select(categorypkey,categoryname,subjectpkey,subjectname) {
  document.getElementById('newclass').innerHTML=categoryname+' -> '+subjectname;
  document.getElementById('page_subjectpkey').value=subjectpkey;
}

function browse_button_search() {
  var keywords=document.getElementById('searchkeywords');
  var searchtitle=document.getElementById('searchsearchtitle');
  var searchheaders=document.getElementById('searchsearchheaders');
  var searchcontent=document.getElementById('searchsearchcontent');
  if (keywords.value=="") {
    alert('Error: No Keywords specified!');
  } else if ((searchtitle.checked==false)&&(searchheaders.checked==false)&&(searchcontent.checked==false)) {
    alert('Error: At least one search option (Title/Headers/Content) must be selected!');
  } else {
    document.browseform.job.value='browser_search'; document.browseform.submit();
  }
}

function browse_button_treeview() {
  document.location='index.php?module=browser&task=byclasstree';
}

function browse_button_normalview() {
  document.location='index.php?module=browser&task=byclass';
}

function browse_button_updateratings() {
  // go thru rows and compile strings..
  var mypkey = "";
  var myrate = "";
  // get values..
  for(var i=0;i<20;i++){
    var pkeyfield = document.getElementById('pkey'+i);
    if (pkeyfield!=null) mypkey += "|"+pkeyfield.getAttribute('value');
    for(var j=1;j<=10;j++) {
      var ratefield = document.getElementById('rate'+i+j);
      if (ratefield!=null) {
        if (ratefield.checked) {
          myrate += "|"+j;
        }
      }
    }
  }
  document.rateform.fullpkey.value=mypkey.substr(1);
  document.rateform.fullratings.value=myrate.substr(1);
  document.rateform.submit();
}

function browse_button_updatetags() {
  document.tagform.submit();
}

function browse_button_updateclass() {
  document.classificationform.submit();
}

function browse_button_showheadings() {
  document.getElementById('divheadings').style.cssText="display: block;";
  document.getElementById('showheadings').style.cssText="display: none;";
  document.getElementById('hideheadings').style.cssText="display: inline;";
}

function browse_button_hideheadings() {
  document.getElementById('divheadings').style.cssText="display: none;";
  document.getElementById('hideheadings').style.cssText="display: none;";
  document.getElementById('showheadings').style.cssText="display: inline;";
}

function browse_button_showothersratings() {
  document.getElementById('divothersrating').style.cssText="display: block;";
  document.getElementById('showotherrating').style.cssText="display: none;";
  document.getElementById('hideotherrating').style.cssText="display: inline;";
}

function browse_button_hideothersratings() {
  document.getElementById('divothersrating').style.cssText="display: none;";
  document.getElementById('hideotherrating').style.cssText="display: none;";
  document.getElementById('showotherrating').style.cssText="display: inline;";
}

function browse_button_addsubject(subjectname) {
  // add subject with no category specified (different behaviour in add page - i.e. has dropdown list of cats)
  document.location='index.php?module=classifier&task=subjectadd&subjectname='+escape(subjectname);
}

function browse_button_addnclassify(pagepkey,subjectname) {
  document.location='index.php?module=classifier&task=subjectadd&subjectname='+escape(subjectname)+'&assignto='+pagepkey;
}

function browse_button_discardheading(pagepkey,subjectname) {
  document.location='index.php?module=classifier&task=discardheading&itemid='+pagepkey+'&subjectname='+escape(subjectname);
}

function browse_button_formatpage() {
  document.formatform.submit();
}

function browse_button_exportpage() {
  document.exportform.submit();
}

function browse_button_refreshpage() {
  document.otherform.job.value='browser_refresh';
  document.otherform.submit();
}

function browse_button_purgepage() {
  if (confirm('Are you sure to purge this Web page?')) {
    document.otherform.job.value='browser_purge';
    document.otherform.submit();
  }
}

function browse_button_shortlist() {
  document.otherform.job.value='browser_shortlist';
  document.otherform.submit();
}

function browse_button_actiontaken(pagepkey) {
  if (confirm('Are you sure to mark this page as completed?')) {
    document.location='index.php?module=browser&task=actiontaken&itemid='+pagepkey;
  }
}

function browse_button_viewpage(pagepkey) {
  document.location='index.php?module=browser&task=view&itemid='+pagepkey;
}

function browse_button_unignorepage(pagepkey) {
  document.location='index.php?module=browser&task=unignore&itemid='+pagepkey;
}

function browse_button_unprocesspage(pagepkey) {
  document.location='index.php?module=browser&task=unprocess&itemid='+pagepkey;
}

function browse_button_printlist() {
  document.browseform.job.value='browser_listprint'; document.browseform.submit();
}

function browse_button_printsession(itemid) {
  window.open('views/report-crawlsession.php?itemid='+itemid, 'reportwindow');
}

function browse_button_printwebpage(itemid) {
  window.open('views/report-pagedetails.php?itemid='+itemid, 'reportwindow');
}
*/

function itq_button_add(projectpkey,itqtype) {
  document.location='index.php?module=itq&task=add&pid='+projectpkey+'&type='+itqtype;
}

function itq_button_edit(itqpkey) {
  document.location='index.php?module=itq&task=edit&itemid='+itqpkey;
}

function itq_button_view(itqpkey) {
  document.location='index.php?module=itq&task=view&itemid='+itqpkey;
}

function itq_button_delete(itqpkey) {
  document.location='index.php?module=itq&task=delete&itemid='+itqpkey;
}

function itq_button_generate(itqpkey) {
  if (validateForm()==true) {
    if (itqpkey!="") {
      if (confirm("ITQ already exists for this MRO. Are you sure to overwrite the existing ITQ?")) {
        document.itqform.job.value='itq_add'; document.itqform.submit();
      }
    } else {
      document.itqform.job.value='itq_add'; document.itqform.submit();
    }
  }
}

function itq_button_save() {
  if (validateForm()==true) {
    document.itqform.job.value='itq_add'; document.itqform.submit();
  }
}

function itq_button_update() {
  if (validateForm()==true) {
    document.itqform.job.value='itq_edit'; document.itqform.submit();
  }
}

function itq_button_purge() {
  document.itqform.job.value='itq_remove'; document.itqform.submit();
}

function itq_button_cancel(itqpkey) {
  if (confirm("Are you sure to Cancel this ITQ?")) {
    document.location='index.php?module=itq&task=cancel&itemid='+itqpkey;
  }
}

function itq_button_saveevaluation() {
  if (validateForm()==true) {
    if (submitForm()==true) {
      document.itqform.job.value='itq_saveeval'; document.itqform.submit();
	  //edit 22-08-2010
	  //document.location='index.php?module=itq&task=evaluate&itemid='+itqpkey;
    }
  } else {
    alert("Please enter Awarded Quantities!");
  }
}

function itq_button_submit(itqpkey) {
  if (validateForm()==true) {
    if (confirm("Are you sure to submit this Quotation Evaluation?")) {
      document.location='index.php?module=itq&task=submit&itemid='+itqpkey;
    }
  } else {
    alert("Please enter Awarded Quantities!");
  }
}

function itq_button_recommend() {
  if (submitForm()==true) {
    document.itqform.job.value='itq_saveeval'; document.itqform.submit();
  }
}

function itq_button_approve() {
  if (submitForm()==true) {
    document.itqform.job.value='itq_saveeval'; document.itqform.submit();
  }
}

function itq_button_print(itqpkey) {
  // get suppliers
  var mysupplist="";
  for (i=1;i<=100;i++) {
    var objsupp = document.getElementById('supplier-'+i);
    if (objsupp!=null) {
      if (objsupp.checked) {
        //mysupplist += ";"+objsupp.value;
        window.open('views/rpt_itq.php?itemid='+itqpkey+'&supplier='+objsupp.value,'printwindow'+i, 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=800,height=600');
      }
    }
  }
  //mysupplist = mysupplist.substr(1);
  //window.open('views/rpt_itq.php?itemid='+itqpkey+'&suppliers='+mysupplist,'printwindow', 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=800,height=600');
}

function itq_button_printall(itqpkey,supplierpkeys) {
  // get suppliers
  var mysupplist=supplierpkeys.split(";");
  var mysupp;
  var i=0;
  for (mysupp in mysupplist) {
    i++;
    window.open('views/rpt_itq.php?itemid='+itqpkey+'&supplier='+mysupplist[mysupp],'printwindow'+i, 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=800,height=600');
  }
  document.location='index.php?module=itq&task=list';
}

function itq_button_printeval(mropkey) {
  window.open('views/rpt_evaluation.php?itemid='+mropkey,'printwindow', 'menubar=0,toolbar=0,scrollbars=1,resizable=0,location=0,width=1024,height=760');
}

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

function itq_button_back() {
  history.go(-1);
}

</script>

<?

// ................................................................................
// model..
// ................................................................................

include_once('models/itqModel.php');
include_once('models/mroModel.php');
$myitqModel=new itqModel;
$mymroModel=new mroModel;

?>

<?

// ................................................................................
// data retrieval functions..
// ................................................................................


// ................................................................................
// data modifications functions..
// ................................................................................


// ................................................................................
// default to list view if none specified..
// ................................................................................
if ($pubtask=="") $pubtask="main";

// ................................................................................
// display page header..
// ................................................................................

$pagetitle="Quotation";
if (($pubtask=="main")||($pubtask=="submenu")) {
  $subtitle="List";
} else if ($pubtask=="list") {
  $subtitle="ITQ List";

} else if ($pubtask=="add") {
  $subtitle="Add ITQ";
} else if ($pubtask=="edit") {
  $subtitle="Edit ITQ";

} else if ($pubtask=="view") {
  $subtitle="View ITQ";

} else if ($pubtask=="delete") {
  $subtitle="Delete ITQ";
} else if ($pubtask=="additem") {
  $subtitle="Add ITQ Item";
} else if ($pubtask=="edititem") {
  $subtitle="Edit ITQ Item";
} else if ($pubtask=="viewitem") {
  $subtitle="View ITQ Item";
} else if ($pubtask=="deleteitem") {
  $subtitle="Delete ITQ Item";

} else if ($pubtask=="generate") {
  $subtitle="Create ITQ";
} else if ($pubtask=="print") {
  $subtitle="Print ITQ";
} else if ($pubtask=="eval") {
  $subtitle="ITQ/Evaluation List";
} else if ($pubtask=="evaluate") {
  $subtitle="Evaluation";
} else if ($pubtask=="submit") {
  $subtitle="Submit Evaluation";
} else if ($pubtask=="review") {
  $subtitle="Review Quotation Evaluation";
} else if ($pubtask=="approve") {
  $subtitle="Approve Quotation Evaluation";
} else if ($pubtask=="cancel") {
  $subtitle="Cancel ITQ";

} else {
  $subtitle="Error: Invalid Option";
}

$headercaption=$pagetitle." ··» ".$subtitle;
include_once('header.php');

include_once('views/general-header.tpl');


// TODO: Later to show list of available variables here if in DEBUG mode!!

// ................................................................................
// display main area..
// ................................................................................

if (($pubtask=="main")||($pubtask=="submenu")) {

  //include_once('views/mro-menu.tpl');
  include_once('views/general-invalidtask.php');

} else if ($pubtask=="list") {

  //$mro_list = $mymroModel->getlist_mrobystatus($pubprojectpkey,3);
  //include_once('views/itq-mros.tpl');

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  $itq_list = $myitqModel->getlist_itqbyproject($pubprojectpkey, $filterrfqno, $filtermrono, $filtervendorname);
  $mro_list = $mymroModel->getlist_mrobystage($pubprojectpkey, "3", "4");
  $itq_hist = $myitqModel->getlist_itqhistory($pubprojectpkey);
  include_once('views/itq-list.tpl');

  // if itemid specified, print ITQ!
  //if ($pubitemid!="") {
  //  echo "<script type='text/javascript'>itq_button_print('".$pubitemid."');</script>";
  //}

} else if (($pubtask=="add")||($pubtask=="edit")) {

  $itq_data = $myitqModel->getdata_itq($pubitemid);
  if ($itq_data['itq_type']=="") $itq_data['itq_type']=$pubtype;
  if ($itq_data['itq_projectpkey']=="") $itq_data['itq_projectpkey']=$pubprojectpkey;
  include_once('views/itq-edit.tpl');

} else if ($pubtask=="view") {

  //$itq_data = $myitqModel->getdata_itq($pubitemid);
  //$item_list = $myitqModel->getlist_itqitems($pubitemid);
  //include_once('views/itq-view.tpl');

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  include_once('models/mblModel.php');
  $mymblModel=new mblModel;

  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mroitem_list = $mymroModel->getlist_mroitems($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);
  include_once('views/itq-evaluate.tpl');

} else if ($pubtask=="delete") {

  $itq_data = $myitqModel->getdata_itq($pubitemid);
  $item_list = $myitqModel->getlist_itqitems($pubitemid);
  include_once('views/itq-view.tpl');

} else if (($pubtask=="additem")||($pubtask=="edititem")) {

  $item_data = $myitqModel->getdata_itqitem($pubitemid);
  include_once('views/itq-edititem.tpl');

} else if ($pubtask=="viewitem") {

  $item_data = $myitqModel->getdata_itqitem($pubitemid);
  include_once('views/itq-viewitem.tpl');

} else if ($pubtask=="deleteitem") {

  $item_data = $myitqModel->getdata_itqitem($pubitemid);
  include_once('views/itq-viewitem.tpl');

} else if ($pubtask=="generate") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;
  
  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  if ($itq_data['itq_pkey']=="") {
    $itq_data['itq_date']=getdatestamp();	// dulu gettimestamp
    $itq_data['itq_returndate']=getdatestamp()+604800;	// 1209600; 7 days now, dulu 30?
    $itq_data['itq_from']=$_SESSION['Xstaffname'];
    $itq_data['itq_type']="1";
  }
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);
  include_once('views/itq-generate.tpl');

} else if ($pubtask=="print") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  $itq_data = $myitqModel->getdata_itq($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($pubitemid);
  include_once('views/itq-print.tpl');

} else if ($pubtask=="printall") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  $itq_data = $myitqModel->getdata_itq($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($pubitemid);
  foreach ($supplier_list as $mysupp) {
    $supplist .= ";".$mysupp['itq_supplierpkey'];
  }
  $supplist = substr($supplist,1);

  echo "<script type='text/javascript'>";
  echo "itq_button_printall('".$itq_data['itq_pkey']."','".$supplist."');";
  echo "</script>";
  
  //$g=goto('index.php?module=itq&task=list');
  //echo $g;
  //exit;

} else if ($pubtask=="submit") {

  $itq_data = $myitqModel->getdata_itq($pubitemid);

  $opresult = $myitqModel->updatestatus_rfq($pubitemid,"1");
  $g=goto('index.php?module=itq&task=list');
  echo $g;
  exit;

} else if ($pubtask=="cancel") {

  $itq_data = $myitqModel->getdata_itq($pubitemid);

  $opresult = $myitqModel->updatestatus_itq($pubitemid,"4");
  $g=goto('index.php?module=itq&task=list');
  echo $g;
  exit;

} else if ($pubtask=="eval") {

  $mro_list = $mymroModel->getlist_mrobystatus($pubprojectpkey,3);
  include_once('views/itq-list.tpl');

} else if ($pubtask=="evaluate") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  include_once('models/mblModel.php');
  $mymblModel=new mblModel;

  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mroitem_list = $mymroModel->getlist_mroitems($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);
  include_once('views/itq-evaluate.tpl');
  //include_once('views/itq-quotation.tpl');

} else if ($pubtask=="review") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  include_once('models/mblModel.php');
  $mymblModel=new mblModel;

  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mymroamount = floatval($mymroModel->gettotal_mroitems($pubitemid));
  $mroitem_list = $mymroModel->getlist_mroitems($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);
  //include_once('views/itq-evaluate.tpl');

  $pubtype="2";
  include_once('views/itq-approval.tpl');

} else if ($pubtask=="approve") {

  include_once('models/supplierModel.php');
  $mysupplierModel=new supplierModel;

  include_once('models/mblModel.php');
  $mymblModel=new mblModel;

  $itq_data = $myitqModel->getdata_itqbymro($pubitemid);
  $mro_data = $mymroModel->getdata_mro($pubitemid);
  $mymroamount = floatval($mymroModel->gettotal_mroitems($pubitemid));
  $mroitem_list = $mymroModel->getlist_mroitems($pubitemid);
  $supplier_list = $myitqModel->getlist_itqsuppliers($itq_data['itq_pkey']);
  //include_once('views/itq-evaluate.tpl');

  $pubtype="3";
  include_once('views/itq-approval.tpl');

} else {
  include_once('views/general-invalidtask.php');
}

// ...............................................................................
// display button options area..
// ...............................................................................

$prevurl = explode('/',$_SESSION['Xpreviousurl']);
$prevfile = $prevurl[count($prevurl)-1];
if ($prevfile=='inputController.php') $backstatus="style='display: none;'";

echo "<br>";

if (($pubtask=="main")||($pubtask=="submenu")) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"itq_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="list") {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"itq_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="add") {

  echo "<br><hr size=1>";
  echo "<button name=\"save\" id=\"save\" onClick=\"itq_button_save();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save ITQ</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_backtolist();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ List</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="edit") {

  echo "<br><hr size=1>";
  echo "<button name=\"update\" id=\"update\" onClick=\"itq_button_update();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Update ITQ</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_backtolist();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ List</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="view") {

  echo "<br><hr size=1>";
  echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print Tabulation</button>&nbsp;";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"itq_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ List&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="delete") {

  echo "<br><hr size=1>";
  echo "<font color='#ff0000'><b>ARE YOU SURE TO PERMANENTLY DELETE THIS itq?</b></font><br><br>";
  echo "<button name=\"delete\" id=\"delete\" onClick=\"itq_button_purge();\">&nbsp;Yes, Delete itq&nbsp;</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<brp><hr size=1><br>";

} else if ($pubtask=="additem") {

  echo "<br><hr size=1>";
  echo "<button name=\"save\" id=\"save\" onClick=\"itq_button_saveitem();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save ITQ Item</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ Details</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="edititem") {

  echo "<br><hr size=1>";
  echo "<button name=\"update\" id=\"update\" onClick=\"itq_button_updateitem();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Update ITQ Item</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ Details</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="viewitem") {

  echo "<br><hr size=1>";
  echo "<button name=\"edit\" id=\"edit\" onClick=\"itq_button_edititem('".$pubitemid."');\">&nbsp;<img src='gfx/options/b_edit.png' class='actionbutton'>&nbsp;&nbsp;Edit&nbsp;</button>&nbsp;";
  echo "<button name=\"delete\" id=\"delete\" onClick=\"itq_button_deleteitem('".$pubitemid."');\"><img src='gfx/options/b_drop.png' class='actionbutton'>&nbsp;&nbsp;Delete</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ Details</button>&nbsp;";
  //echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"itq_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="deleteitem") {

  echo "<br><hr size=1>";
  echo "<font color='#ff0000'><b>ARE YOU SURE TO PERMANENTLY DELETE THIS itq ITEM?</b></font><br><br>";
  echo "<button name=\"delete\" id=\"delete\" onClick=\"itq_button_purgeitem();\">&nbsp;Yes, Delete ITQ Item&nbsp;</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<brp><hr size=1><br>";

} else if ($pubtask=="generate") {

  echo "<br><hr size=1>";
  if (($pubuseraccess['access_itq_edit']==1)||($pubuseraccess['access_itq_invite']==1)||($pubuserrole>=2)) {
    echo "<button name=\"generate\" id=\"generate\" onClick=\"itq_button_generate('".$itq_data['itq_pkey']."');\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save ITQ</button>&nbsp;";
  }
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="print") {

  echo "<br><hr size=1>";
  if (($pubuseraccess['access_itq_edit']==1)||($pubuseraccess['access_itq_invite']==1)||($pubuserrole>=2)) {
    echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_print('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print ITQ</button>&nbsp;";
  }
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";

} else if ($pubtask=="evaluate") {

  echo "<br><hr size=1>";
  echo "<table border=0 cellspacing=0 cellpadding=0 width=928>";
  echo "<tr valign=top>";
  echo "<td valign=top width=700>";
  if (($pubuseraccess['access_itq_evaluate']==1)||($pubuserrole>=2)) {
    echo "<button name=\"save\" id=\"save\" onClick=\"itq_button_saveevaluation();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save Evaluation</button>&nbsp;";
    echo "<button name=\"send\" id=\"send\" onClick=\"itq_button_submit('".$itq_data['itq_pkey']."');\"><img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Submit Evaluation</button>&nbsp;";
  }
  echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_backtolist();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ List</button>&nbsp;";
  echo "</td>";
  echo "<td valign=top width=228 style='text-align: right;'>";
  //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
  //  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_cancel('".$pubitemid."');\"><img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Cancel ITQ</button>&nbsp;";
  //}
  echo "</td>";
  echo "</tr>";
  echo "</table>";
  echo "<hr size=1><br>";

  //echo "<br><hr size=1>";
  //if (($pubuseraccess['access_itq_evaluate']==1)||($pubuserrole>=2)) {
  //  echo "<button name=\"save\" id=\"save\" onClick=\"itq_button_saveevaluation();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save Evaluation Data</button>&nbsp;";
  //  echo "<button name=\"send\" id=\"send\" onClick=\"itq_button_submit('".$itq_data['itq_pkey']."');\"><img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Submit Evaluation</button>&nbsp;";
  //}
  //echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print Tabulation</button>&nbsp;";
  //echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  //echo "<br><hr size=1><br>";
  
  
 // testtt ##############################
 else if ($pubtask=="edit") {

  echo "<br><hr size=1>";
  echo "<table border=0 cellspacing=0 cellpadding=0 width=928>";
  echo "<tr valign=top>";
  echo "<td valign=top width=700>";
  if (($pubuseraccess['access_itq_evaluate']==1)||($pubuserrole>=2)) {
    echo "<button name=\"save\" id=\"save\" onClick=\"itq_button_saveevaluation();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save Evaluation</button>&nbsp;";
    echo "<button name=\"send\" id=\"send\" onClick=\"itq_button_submit('".$itq_data['itq_pkey']."');\"><img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Submit Evaluation</button>&nbsp;";
  }
  echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_backtolist();\"><img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to ITQ List</button>&nbsp;";
  echo "</td>";
  echo "<td valign=top width=228 style='text-align: right;'>";
  //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
  //  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_cancel('".$pubitemid."');\"><img src='gfx/options/b_stop.png' class='actionbutton'>&nbsp;&nbsp;Cancel ITQ</button>&nbsp;";
  //}
  echo "</td>";
  echo "</tr>";
  echo "</table>";
  echo "<hr size=1><br>";


}
 
 
 // #######################################

} else if ($pubtask=="review") {

  /*
  // TO CHECK: can anyone other then requestor cancel itq?
  echo "<br><hr size=1>";
  if ($mymroamount>100000) {
    if (($pubuseraccess['access_itq_review']==1)||($pubuserrole>=2)) {
      echo "<button name=\"recommend\" id=\"recommend\" onClick=\"itq_button_recommend();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Recommend Evaluation</button>&nbsp;";
    }
  }
  echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print Tabulation</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";
  */

} else if ($pubtask=="approve") {

  /*
  echo "<br><hr size=1>";
  if (($pubuseraccess['access_itq_approve50k']==1)||($pubuseraccess['access_itq_approve100k'])||($pubuseraccess['access_itq_approve1m']==1)||($pubuseraccess['access_itq_approveall'])||($pubuserrole>=2)) {
    echo "<button name=\"approve\" id=\"approve\" onClick=\"itq_button_approve();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Approve Evaluation</button>&nbsp;";
  }
  echo "<button name=\"print\" id=\"print\" onClick=\"itq_button_printeval('".$pubitemid."');\"><img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print Tabulation</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"itq_button_back();\"><img src='gfx/options/b_cancel.png' class='actionbutton'>&nbsp;&nbsp;Cancel</button>&nbsp;";
  echo "<br><hr size=1><br>";
  */

}

// ................................................................................
// display page footer..
// ................................................................................

include_once('views/general-footer.tpl');

?>