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

// filter forms..
/*
$filtersessionname=$_POST['sessionname'];
$filteruserpkey=$_POST['userpkey'];
$filterstartdate=$_POST['startdate'];
$filterstopdate=$_POST['stopdate'];
$realstartdate=converttounix($filterstartdate);
$realstopdate=converttounix($filterstopdate)+86399;
*/
?>

<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 mbl_button_viewmro(mrotype) {
  document.location='index.php?module=mro&task=list&type='+mrotype;
}

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

function mbl_button_add() {
  document.location='index.php?module=mbl&task=add';
}

function mbl_button_edit(itempkey) {
  document.location='index.php?module=mbl&task=edit&itemid='+itempkey;
}

function mbl_button_delete(itempkey) {
  document.location='index.php?module=mbl&task=delete&itemid='+itempkey;
}

function mbl_button_save() {
  if (validateForm()==true) {
    document.mblform.job.value='mbl_add'; document.mblform.submit();
  }
}

function mbl_button_update() {
  if (validateForm()==true) {
    document.mblform.job.value='mbl_edit'; document.mblform.submit();
  }
}

function mbl_button_submit() {
  if (confirm('Are you sure to submit the MBL?')) {
    document.mblform.job.value='mbl_submit'; document.mblform.submit();
  }
}

function mbl_button_approve() {
  if (confirm('Are you sure to approve the MBL? Note: Approved MBL may no longer be edited')) {
    document.mblform.job.value='mbl_approve'; document.mblform.submit();
  }
}

function mbl_button_purge() {
  document.mblform.job.value='mbl_remove'; document.mblform.submit();
}

function mbl_button_backtolist() {
  document.location='index.php?module=mbl&task=view';
}

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

</script>

<?

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

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

?>

<?

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


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


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

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

$pagetitle="Project";
if (($pubtask=="main")||($pubtask=="submenu")) {
  $subtitle="MBL Menu";
} else if ($pubtask=="view") {
  $subtitle="Material Budget List";
} else if ($pubtask=="list") {
  $subtitle="Edit Material Budget List";
} else if ($pubtask=="add") {
  $subtitle="Add MBL Item";
} else if ($pubtask=="edit") {
  $subtitle="Edit MBL Item";
} else if ($pubtask=="delete") {
  $subtitle="Delete MBL Item";

} else if ($pubtask=="byclass") {
  $subtitle="Browse By Classification";
} else if ($pubtask=="byclasstree") {
  $subtitle="Browse By Classification Tree";
} else if ($pubtask=="bystatus") {
  $subtitle="Browse By Status";
} else if ($pubtask=="processed") {
  $subtitle="Processed Pages";
} else if ($pubtask=="unprocessed") {
  $subtitle="Pages Pending for Action";
} else if ($pubtask=="unrated") {
  $subtitle="Unrated Pages";
} else if ($pubtask=="unclassified") {
  $subtitle="Unclassified Pages";
} else if ($pubtask=="ignored") {
  $subtitle="Ignored Pages";
} else if ($pubtask=="unignore") {
  $subtitle="Unignore Page";
} else if ($pubtask=="unprocess") {
  $subtitle="Unprocess Page";
} else if ($pubtask=="actiontaken") {
  $subtitle="Action Taken";
} else if ($pubtask=="bylist") {
  $subtitle="Browse By List";
} else if ($pubtask=="list") {
  $subtitle="Browse By List";
} else if ($pubtask=="search") {
  $subtitle="Search Repository";
} else if ($pubtask=="found") {
  $subtitle="Search Results";
} else if ($pubtask=="view") {
  $subtitle="View Page";
} 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/browser-submenu.tpl');

//} else if (($pubtask=="view")&&(($pubuseraccess['access_mbl_view']==1)||($pubuserrole>=2))) {
} else if ($pubtask=="view") {

  // NOTE: BM and BME appear in MBL straightaway, VO and SUBCON appear only after approval

  include_once('models/tradeModel.php');
  $mytradeModel=new tradeModel;

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

  $mbl_list = $mymblModel->getlist_mblitems($pubprojectpkey);
  $bm_list = $mymroModel->getlist_mro_bm($pubprojectpkey);
  $bme_list = $mymroModel->getlist_mro_bme($pubprojectpkey,"3");
  $nbmvo_list = $mymroModel->getlist_mro_nbmvo($pubprojectpkey,"3");
  $nbmsc_list = $mymroModel->getlist_mro_nbmsc($pubprojectpkey,"3");

  $last_approval = $mymblModel->getdata_lastapproval();

  include_once('views/mbl-view.tpl');

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

  $mbl_list = $mymblModel->getlist_mblitems($pubprojectpkey);
  $last_approval = $mymblModel->getdata_lastapproval();

  include_once('views/mbl-list.tpl');

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

  $item_data = $mymblModel->getdata_mblitem($pubitemid);
  include_once('views/mbl-edit.tpl');

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

  $item_data = $mymblModel->getdata_mblitem($pubitemid);
  include_once('views/mbl-delete.tpl');

} else if (($pubtask=="byclass")&&(($pubuseraccess['access_browse_byclass']==1)||($pubuserrole>=2))) {

  if ($pubitemid!="") {
    $category_data = $myclassifierModel->getdata_category($pubitemid);
    $subjects_list = $myclassifierModel->getlist_subjects($pubitemid);
    if ($pubsubjectid!="") {
      $subject_data = $myclassifierModel->getdata_subject($pubsubjectid);
      $result_data = $mycrawlerModel->getlist_pagesbyclass($pubsubjectid);
      include_once('views/browser-traverse.tpl');
    } else {
      include_once('views/browser-subjects.tpl');
    }
  } else {
    if ($pubuserrole>=2) {
      $categories_list = $myclassifierModel->getlist_categories("");
    } else {
      $categories_list = $myclassifierModel->getlist_categories($pubusergrouppkey);
    }
    include_once('views/browser-categories.tpl');
  }

} else if (($pubtask=="byclasstree")&&(($pubuseraccess['access_browse_byclass']==1)||($pubuserrole>=2))) {

  $cindex=0;
  //$page_data = $mybrowserModel->getdata_page($pubitemid);
  if ($pubuserrole>=2) {
    $categories_list = $myclassifierModel->getlist_categories();
  } else {
    $categories_list = $myclassifierModel->getlist_categories($pubusergrouppkey);
  }
  foreach ($categories_list as $mycategory) {
    $subjects_list[$cindex] = $myclassifierModel->getlist_subjects($mycategory['category_pkey']);
    $cindex++;
  }  
  include_once('views/browser-tree.tpl');

} else if (($pubtask=="bystatus")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  include_once('views/browser-statusmenu.tpl');

} else if (($pubtask=="processed")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  $page_list = $mybrowserModel->getlist_processedpages($pubuserpkey);
  include_once('views/browser-processed.tpl');

} else if (($pubtask=="unprocessed")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  $page_list = $mybrowserModel->getlist_unprocessedpages($pubuserpkey);
  include_once('views/browser-unprocessed.tpl');

} else if (($pubtask=="unrated")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  $page_list = $mybrowserModel->getlist_unratedpages($pubuserpkey);
  include_once('views/browser-unrated.tpl');

} else if (($pubtask=="unclassified")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  $page_list = $mybrowserModel->getlist_unclassifiedpages($pubuserpkey);
  include_once('views/browser-unclassified.tpl');

} else if (($pubtask=="ignored")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  $page_list = $mybrowserModel->getlist_ignoredpages($pubuserpkey);
  include_once('views/browser-ignored.tpl');

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

  $opresult = $mybrowserModel->updatedata_unignorepage($pubitemid,$pubuserpkey);

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

  $opresult = $mybrowserModel->updatedata_actiontaken($pubitemid,0,$pubuserpkey);

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

  $opresult = $mybrowserModel->updatedata_actiontaken($pubitemid,1,$pubuserpkey);

} else if (($pubtask=="bylist")&&(($pubuseraccess['access_browse_bylists']==1)||($pubuserrole>=2))) {

  if ($pubuserrole>=2) {
    if ($pubgroupid!="") {
      $list_list = $mytemplateModel->getlist_lists($pubgroupid);
    } else {
      $list_list = $mytemplateModel->getlist_lists();
    }
  } else {
    $list_list = $mytemplateModel->getlist_lists($pubusergrouppkey);
  }
  include_once('views/browser-list.tpl');

} else if (($pubtask=="list")&&(($pubuseraccess['access_browse_bylists']==1)||($pubuserrole>=2))) {

  $list_data = $mytemplateModel->getdata_list($pubitemid);
  $item_list = $mytemplateModel->getlist_listitems($pubitemid);
  include_once('views/browser-listview.tpl');

} else if (($pubtask=="search")&&(($pubuseraccess['access_browse_bysearch']==1)||($pubuserrole>=2))) {

  include_once('views/browser-search.tpl');

} else if (($pubtask=="found")&&(($pubuseraccess['access_browse_bysearch']==1)||($pubuserrole>=2))) {

  include_once('views/browser-found.tpl');

} else if (($pubtask=="view")&&(($pubuseraccess['access_browse_viewpage']==1)||($pubuserrole>=2))) {

  $page_data = $mybrowserModel->getdata_page($pubitemid);
  $ratings_list = $mybrowserModel->getlist_ratings();
  $cindex=0;
  foreach ($ratings_list as $myratings) {
    $page_rating[$cindex] = $mybrowserModel->getdata_pageratingbyuser($pubitemid,$myratings['rating_pkey'],$pubuserpkey);
    $page_rating_others[$cindex] = $mybrowserModel->getlist_pageratingbyothers($pubitemid,$myratings['rating_pkey'],$pubuserpkey);
    $cindex++;
  }
  $page_tags = $mybrowserModel->getdata_pagetagsbyuser($pubitemid,$pubuserpkey);
  $page_class = $mybrowserModel->getdata_pageclass($pubitemid);
  $page_headings = $mybrowserModel->getlist_pageheadings($pubitemid);
  if ($page_class['category_name']=="") $page_class['category_name']="None";
  if ($page_class['subject_name']=="") $page_class['subject_name']="None";
  //$page_content = $mybrowserModel->getdata_pagecontent($pubitemid);
  $page_history = $mybrowserModel->getlist_pagehistory($pubitemid);
  $page_links = $mybrowserModel->getlist_pagelinks($pubitemid);
  if ($pubuserrole>=2) {
    $categories_list = $myclassifierModel->getlist_categories();
  } else {
    $categories_list = $myclassifierModel->getlist_categories($pubusergrouppkey);
  }
  $cindex=0;
  foreach ($categories_list as $mycategory) {
    $subjects_list[$cindex] = $myclassifierModel->getlist_subjects($mycategory['category_pkey']);
    $cindex++;
  }  
  $list_data = $mytemplateModel->getlist_listsassigned($pubitemid);
  include_once('views/browser-view.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=\"mbl_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=="view") {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"mbl_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>";
  if ($last_approval['approval_type']=="") {
    if (($pubuseraccess['access_mbl_edit']==1)||($pubuserrole>=2)) {
      echo "<button name=\"add\" id=\"add\" onClick=\"mbl_button_add();\"><img src='gfx/options/b_add.png' class='actionbutton'>&nbsp;&nbsp;Add MBL Item</button>&nbsp;";
    }
  }
  if ($last_approval['approval_type']!="3") {
    if (($pubuseraccess['access_mbl_edit']==1)||($pubuserrole>=2)) {
      echo "<button name=\"submitmbl\" id=\"submitmbl\" onClick=\"mbl_button_submit();\"><img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Submit MBL</button>&nbsp;";
    }
  }
  if (($last_approval['approval_type']=="1")&&($last_approval['approval_status']=="1")) {
    if (($pubuseraccess['access_mbl_approve']==1)||($pubuserrole>=2)) {
      echo "<button name=\"approve\" id=\"approve\" onClick=\"mbl_button_approve();\"><img src='gfx/options/b_approve.png' class='actionbutton'>&nbsp;&nbsp;Approve MBL</button>&nbsp;";
    }
  }
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"mbl_button_backtolist();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back to MBL&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

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

  echo "<br><hr size=1>";
  if (($pubuseraccess['access_mbl_edit']==1)||($pubuserrole>=2)) {
    echo "<button name=\"save\" id=\"save\" onClick=\"mbl_button_save();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Save MBL Item</button>&nbsp;";
  }
  echo "<button name=\"cancel\" id=\"cancel\" ".$backstatus." onClick=\"mbl_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>";
  if (($pubuseraccess['access_mbl_edit']==1)||($pubuserrole>=2)) {
    echo "<button name=\"update\" id=\"update\" onClick=\"mbl_button_update();\"><img src='gfx/options/b_save.png' class='actionbutton'>&nbsp;&nbsp;Update MBL Item</button>&nbsp;";
  }
  echo "<button name=\"cancel\" id=\"cancel\" ".$backstatus." onClick=\"mbl_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=="delete") {

  echo "<br><hr size=1>";
  if (($pubuseraccess['access_mbl_edit']==1)||($pubuserrole>=2)) {
    echo "<font color='#ff0000'><b>ARE YOU SURE TO PERMANENTLY DELETE THIS MBL Item?</b></font><br><br>";
    echo "<button name=\"delete\" id=\"delete\" onClick=\"mbl_button_purge();\">&nbsp;Yes, Delete MBL Item&nbsp;</button>&nbsp;";
  }
  echo "<button name=\"cancel\" id=\"cancel\" ".$backstatus." onClick=\"mbl_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=="newsearch")||($pubtask=="initsearch")) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="bysession")&&(($pubuseraccess['access_browse_bysession']==1)||($pubuserrole>=2))) {

  if ($pubitemid!="") {

    echo "<br><hr size=1>";
    echo "<button name=\"print\" id=\"print\" onClick=\"javascript:browse_button_printsession('".$pubitemid."');\">&nbsp;<img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print&nbsp;</button>&nbsp;";
    echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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 {

    echo "<br><hr size=1>";
    echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="byclass")&&(($pubuseraccess['access_browse_byclass']==1)||($pubuserrole>=2))) {

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

} else if (($pubtask=="byclasstree")&&(($pubuseraccess['access_browse_byclass']==1)||($pubuserrole>=2))) {

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

} else if (($pubtask=="bystatus")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="processed")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="unprocessed")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="unrated")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="unclassified")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="ignored")&&(($pubuseraccess['access_browse_bystatus']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="unignore") {

  $g = goto('index.php?module=browser&task=ignored');
  echo $g;

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

  $g = goto('index.php?module=browser&task=view&itemid='.$pubitemid);
  echo $g;

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

  $g = goto('index.php?module=browser&task=view&itemid='.$pubitemid);
  echo $g;

} else if (($pubtask=="bylist")&&(($pubuseraccess['access_browse_bylists']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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")&&(($pubuseraccess['access_browse_bylists']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"javascript:browse_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back&nbsp;</button>&nbsp;";
  echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Template ";
  echo "<select name='template_pkey' id='template_pkey' style='width: 200px;'>";
  include_once("views/object-selecttemplatelist.tpl");
  echo "</select>&nbsp;";
  echo "<button name=\"print\" id=\"print\" onClick=\"javascript:browse_button_printlist();\">&nbsp;<img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";
  echo "</form>";

} else if (($pubtask=="search")&&(($pubuseraccess['access_browse_bysearch']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"search\" id=\"search\" onClick=\"browse_button_search();\"><img src='gfx/options/b_find.png' class='actionbutton'>&nbsp;&nbsp;Search</button>&nbsp;";
  echo "<button name=\"reset\" id=\"reset\" type=\"reset\">&nbsp;<img src='gfx/options/b_reset.png' class='actionbutton'>&nbsp;&nbsp;Reset&nbsp;</button>&nbsp;";
  echo "<button name=\"cancel\" id=\"cancel\" onClick=\"browse_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=="found")&&(($pubuseraccess['access_browse_bysearch']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"browse_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=="view")&&(($pubuseraccess['access_browse_viewpage']==1)||($pubuserrole>=2))) {

  echo "<br><hr size=1>";
  echo "<button name=\"print\" id=\"print\" onClick=\"javascript:browse_button_printwebpage('".$pubitemid."');\">&nbsp;<img src='gfx/options/b_print1.png' class='actionbutton'>&nbsp;&nbsp;Print&nbsp;</button>&nbsp;";
  echo "<button name=\"back\" id=\"back\" ".$backstatus." onClick=\"javascript:browse_button_back();\">&nbsp;<img src='gfx/options/b_back.png' class='actionbutton'>&nbsp;&nbsp;Back&nbsp;</button>&nbsp;";
  echo "<br><hr size=1><br>";

}

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

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

?>