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); }
if ($person['address']) { echo nl2br(ashtml($person['address'])), '<br>'; } if ($person['phone']) { echo 'Phone: ', ashtml($person['phone']), '<br>'; } if ($person['email']) { echo 'Email: ', ashtml($person['email']), '<br>'; } } ?> </div> <div style="clear:both;"></div> </div> <?php $items = txn_load_items($db, $id); ?> <table id="products" cellspacing="0" cellpadding="0"> <thead> <tr> <th class="right">#</th> <?php echo $details['type'] == 'vendor' ? '<th class="left">Code</th>' : ''; ?> <th class="left">Name</th> <th class="right">Price</th> <th class="right">Total</th> </tr> </thead> <tbody> <?php
include '../scat.php'; include '../lib/txn.php'; include '../lib/pole.php'; $id = (int) $_REQUEST['txn']; if (!$id) { die_jsonp("no transaction specified."); } $txn = txn_load($db, $id); if ($txn['paid']) { die_jsonp("This order is already paid!"); } $line = (int) $_REQUEST['line']; if ($line) { $q = "UPDATE txn_line SET allocated = ordered WHERE txn = {$id} AND id = {$line}"; $r = $db->query($q) or die_jsonp($db->error); $lines = $db->affected_rows; } else { $q = "UPDATE txn_line SET allocated = ordered WHERE txn = {$id}"; $r = $db->query($q) or die_jsonp($db->error); $lines = $db->affected_rows; if ($lines || !$txn['filled']) { $q = "UPDATE txn SET filled = NOW() WHERE id = {$id}"; $r = $db->query($q) or die_jsonp($db->error); } } $txn = txn_load($db, $id); if ($txn['total']) { pole_display_price('Total Due', $txn['total']); } echo jsonp(array("success" => "Allocated all lines.", "txn" => $txn, "lines" => $lines, "items" => txn_load_items($db, $id)));
<?php include '../scat.php'; include '../lib/txn.php'; $txn_id = (int) $_REQUEST['txn']; $txn = txn_load($db, $txn_id); if (!$txn['paid']) { die_jsonp("Can't return an order that hasn't been paid for!"); } $q = "SELECT 1 + MAX(number) AS number FROM txn WHERE type = 'customer'"; $r = $db->query($q); if (!$r) { die_query($db, $q); } $row = $r->fetch_assoc(); $q = "INSERT INTO txn\n SET created= NOW(),\n type = 'customer',\n number = {$row['number']},\n returned_from = {$txn_id},\n tax_rate = " . DEFAULT_TAX_RATE; $r = $db->query($q); if (!$r) { die_query($db, $q); } $new_txn_id = $db->insert_id; $q = "INSERT INTO txn_line (txn, item, ordered, allocated, override_name,\n retail_price, discount_type, discount, taxfree)\n SELECT {$new_txn_id} AS txn,\n item,\n -ordered AS ordered,\n -allocated AS allocated,\n override_name,\n retail_price, discount_type, discount,\n taxfree\n FROM txn_line WHERE txn = {$txn_id}"; $r = $db->query($q); if (!$r) { die_query($db, $q); } echo jsonp(array('txn' => txn_load($db, $new_txn_id), 'items' => txn_load_items($db, $new_txn_id), 'payments' => array(), 'notes' => array()));