Example #1
0
File: txn.php Project: jacques/scat
function txn_load_full($db, $id)
{
    $txn = txn_load($db, $id);
    $items = txn_load_items($db, $id);
    $payments = txn_load_payments($db, $id);
    $notes = txn_load_notes($db, $id);
    if ($txn['person']) {
        $person = person_load($db, $txn['person']);
    }
    return array('txn' => $txn, 'items' => $items, 'payments' => $payments, 'person' => $person, 'notes' => $notes);
}
Example #2
0
  </tr>
 </thead>
 <tbody data-bind="foreach: { data: people, as: 'item' }">
  <tr>
   <td><a data-bind="text: $index() + 1,
                     attr: { href: '?id=' + item[1] }"></a></td>
   <td><a data-bind="text: item[2], attr: { href: '?id=' + item[1] }"></a></td>
   <td><a data-bind="text: item[3], attr: { href: '?id=' + item[1] }"></a></td>
  </tr>
 </tbody>
</table>
<?php 
if (!$id) {
    goto end;
}
$person = person_load($db, $id);
?>
<form class="form-horizontal" role="form"
      data-bind="submit: savePerson">
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-8">
      <input type="text" class="form-control" id="name" placeholder="Name"
             data-bind="value: person.name">
    </div>
  </div>
  <div class="form-group">
    <label for="role" class="col-sm-2 control-label">Role</label>
    <div class="col-sm-8">
      <label class="checkbox-inline">
        <input type="radio" value="customer"
Example #3
0
<?php

include '../scat.php';
include '../lib/txn.php';
$txn_id = (int) $_REQUEST['txn'];
if (!$txn_id) {
    die_jsonp("No transaction specified.");
}
$txn = txn_load($db, $txn_id);
$person = (int) $_REQUEST['person'];
if (!$person) {
    die_jsonp("No person specified.");
}
$q = "SELECT id FROM person WHERE id = {$person}";
$r = $db->query($q) or die_query($db, $q);
if (!$r->num_rows) {
    die_jsonp("No such person.");
}
$q = "UPDATE txn SET person = {$person} WHERE id = {$txn_id}";
$r = $db->query($q) or die_query($db, $q);
$txn = txn_load($db, $txn_id);
$person = person_load($db, $person);
echo jsonp(array("success" => "Updated person.", "txn" => $txn, "person" => $person));
Example #4
0
<?php

include '../scat.php';
include '../lib/txn.php';
include '../lib/eps-express.php';
$id = (int) $_REQUEST['id'];
$amount = $_REQUEST['amount'];
if (!$id || !$amount) {
    die_jsonp("Either transaction or amount was not specified.");
}
$person_id = (int) $_REQUEST['person'];
$person = $person_id ? person_load($db, $person_id) : false;
$account = $person['payment_account_id'];
if (!$person_id || !$person || !$account) {
    die_jsonp("No person specified or no card stored for person.");
}
$eps = new EPS_Express();
$response = $eps->CreditCardSalePaymentAccount($id, $amount, $account);
$xml = new SimpleXMLElement($response);
if ($xml->Response->ExpressResponseCode != 0) {
    die_jsonp((string) $xml->Response->ExpressResponseMessage);
}
$method = 'credit';
$cc = array();
$cc['cc_txn'] = $xml->Response->Transaction->TransactionID;
$cc['cc_approval'] = $xml->Response->Transaction->ApprovalNumber;
$cc['cc_type'] = $xml->Response->Card->CardLogo;
$txn = new Transaction($db, $id);
try {
    $payment = $txn->addPayment($method, $amount, $cc);
} catch (Exception $e) {
Example #5
0
    echo "<script>parent.finishAttachPayment();</script>";
    exit;
}
if ($_REQUEST['HostedPaymentStatus'] == 'Complete') {
    $payment_account_id = $db->escape($_REQUEST['PaymentAccountID']);
    $setup_id = $db->escape($_REQUEST['TransactionSetupID']);
    $valid = $db->escape($_REQUEST['ValidationCode']);
    $id = $db->get_one("SELECT txn FROM hostedpayment_txn\n                      WHERE hostedpayment = '{$setup_id}'\n                        AND validationcode = '{$valid}'");
    if ($id) {
        $person = person_load($db, $id);
        $q = "UPDATE person\n            SET payment_account_id = '" . addslashes($payment_account_id) . "'\n          WHERE id = {$id}";
        $r = $db->query($q) or die_query($db, $q);
        ?>
<script>
var person= <?php 
        echo json_encode(person_load($db, $id));
        ?>
;
parent.finishAttachPayment();
parent.loadPerson(person);
</script>
<?php 
        exit;
    } else {
        echo 'Completion information not valid.';
    }
}
?>
<button onclick="javascript:parent.finishAttachPayment()">Close</button>
<?php 
echo '<pre>';
Example #6
0
<?php

include '../scat.php';
include '../lib/person.php';
include '../lib/eps-express.php';
$person_id = (int) $_REQUEST['person'];
$person = $person_id ? person_load($db, $person_id) : false;
if (!$person_id || !$person || !$person['payment_account_id']) {
    die_jsonp("No person specified or no card stored for person.");
}
$eps = new EPS_Express();
$response = $eps->PaymentAccountDelete($person['payment_account_id']);
if ($response->ExpressResponseCode != 0) {
    die_jsonp((string) $response->ExpressResponseMessage);
}
// remove payment account info from person
$q = "UPDATE person\n        SET payment_account_id = NULL\n      WHERE id = {$person_id}";
$r = $db->query($q) or die_query($db, $q);
echo jsonp(array('person' => person_load($db, $person_id), 'response' => $response));