<?php include '../scat.php'; include '../lib/txn.php'; $id = (int) $_REQUEST['id']; $type = $_REQUEST['type']; $number = (int) $_REQUEST['number']; if (!$id && $type) { $q = "SELECT id FROM txn\n WHERE type = '" . $db->real_escape_string($type) . "'\n AND number = {$number}"; $r = $db->query($q); if (!$r->num_rows) { die_jsonp("No such transaction."); } $row = $r->fetch_row(); $id = $row[0]; } if (!$id) { die_jsonp("No transaction specified."); } echo jsonp(txn_load_full($db, $id));
}}); return false; }); $("#sidebar a[id='unpaid']").click(); <?php $id = (int) $_REQUEST['id']; $number = (int) $_REQUEST['number']; if ($number) { $q = "SELECT id FROM txn WHERE type = 'customer' AND number = {$number}"; $id = $db->get_one($q); } if ($id) { $data = txn_load_full($db, $id); echo 'loadOrder(', json_encode($data), ");\n"; } ?> }); </script> <div class="row"> <div class="col-md-3 col-md-push-9 well" id="sidebar"> <ul class="nav nav-pills nav-justified"> <li class="active"><a id="unpaid">Unpaid</a></li> <li><a id="recent">Recent</a></li> </ul> <script> $("#sidebar .nav a").click(function() { var params= { open: { type: 'customer', unfilled: true },
$id = (int) $_REQUEST['id']; $type = $_REQUEST['type']; $number = (int) $_REQUEST['number']; if (!$id && $type) { $q = "SELECT id FROM txn\n WHERE type = '" . $db->real_escape_string($type) . "'\n AND number = {$number}"; $r = $db->query($q); if (!$r->num_rows) { die("<h2>No such transaction found.</h2>"); } $row = $r->fetch_row(); $id = $row[0]; } if (!$id) { die("no transaction specified."); } $txn = txn_load_full($db, $id); if ($txn['txn']['type'] == 'customer') { header("Location: ./?id=" . $id); exit; } head("Transaction @ Scat", true); ?> <form class="form-horizontal" role="form"> <div class="form-group"> <label for="number" class="col-sm-2 control-label">Number</label> <div class="col-sm-8"> <p class="form-control-static" id="number" data-bind="text: txn.formatted_number"></p> </div> </div> <div class="form-group">
public function __construct($db, $id = null) { $this->db = $db; $this->id = $id; if ($id) { $this->data = txn_load_full($db, $this->id); } }