<?php

require "../settings.php";
cFramework::run("view");
cFramework::quickLinks(ql("order_approve.php", "Approve Customer Sales Orders"), ql("../customers-view.php", "View Customers"), ql("../supp-view.php", "View Suppliers"), ql("configuration.php", "Transheks Configuration"));
cFramework::parse();
function view(&$frm, $err = "")
{
    $OUT = "\n\t<h3>Unknown Transactioning Requests</h3>\n\t{$err}\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th colspan='5'>Customers</th>\n\t</tr>\n\t<tr>\n\t\t<th>Name</th>\n\t\t<th>Telephone</th>\n\t\t<th colspan='2'>Options</th>\n\t</tr>";
    $qry = new dbSelect("keys", "trh", grp(m("where", "custid='-1'")));
    $qry->run();
    if ($qry->num_rows() <= 0) {
        $OUT .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='4'>No unknown requests.</td>\n\t\t</tr>";
    }
    while ($row = $qry->fetch_array()) {
        $OUT .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$row['compname']}</td>\n\t\t\t<td>{$row['bustel']}</td>\n\t\t\t<td><a href='" . SELF . "?id={$row['id']}&key=approve'>Approve</a></td>\n\t\t\t<td><a href='" . SELF . "?id={$row['id']}&key=deny'>Deny</a></td>\n\t\t</tr>";
    }
    $OUT .= TBL_BR . "\n\t<tr>\n\t\t<th colspan='5'>Suppliers</th>\n\t</tr>\n\t<tr>\n\t\t<th>Name</th>\n\t\t<th>Telephone</th>\n\t\t<th colspan='2'>Options</th>\n\t</tr>";
    $qry = new dbSelect("keys", "trh", grp(m("where", "suppid='-1'")));
    $qry->run();
    if ($qry->num_rows() <= 0) {
        $OUT .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='4'>No unknown requests.</td>\n\t\t</tr>";
    }
    while ($row = $qry->fetch_array()) {
        $OUT .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$row['compname']}</td>\n\t\t\t<td>{$row['bustel']}</td>\n\t\t\t<td><a href='" . SELF . "?id={$row['id']}&key=approve'>Approve</a></td>\n\t\t\t<td><a href='" . SELF . "?id={$row['id']}&key=deny'>Deny</a></td>\n\t\t</tr>";
    }
    $OUT .= "\n\t</table>";
    return $OUT;
}
function approve(&$frm)
{
 /**
  * parses the output and includes template.php
  *
  */
 static function parse()
 {
     global $FRAMEWORK;
     if (!isset($FRAMEWORK->o["result"])) {
         $FRAMEWORK->o["result"] = "";
     }
     if (!isset($FRAMEWORK->o["quicklinks"])) {
         cFramework::quickLinks();
     }
     $OUTPUT = "" . $FRAMEWORK->o["result"] . "<br />" . $FRAMEWORK->o["quicklinks"];
     parse($OUTPUT);
 }