<div id="client_info"> <?php if ($details['person']) { $q = "SELECT * FROM person WHERE id = {$details['person']}"; $r = $db->query($q) or die($db->error); $person = $r->fetch_assoc(); echo '<small>To:</small><br>'; echo '<b>', ashtml($person['company']), $person['company'] && $person['name'] ? '<br>' : '', ashtml($person['name']), '</b><br>'; 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>' : '';
<?php $q = "SELECT meta, Number\$txn, Created\$date,\n Ordered, Allocated,\n CAST(ROUND_TO_EVEN(taxed * (1 + tax_rate / 100), 2) + untaxed\n AS DECIMAL(9,2))\n Total\$dollar,\n Paid\$dollar\n FROM (SELECT\n txn.type AS meta,\n CONCAT(txn.id, '|', type, '|', txn.number) AS Number\$txn,\n txn.created AS Created\$date,\n CONCAT(txn.person, '|', IFNULL(person.company,''),\n '|', IFNULL(person.name,''))\n AS Person\$person,\n SUM(ordered) * IF(txn.type = 'customer', -1, 1) AS Ordered,\n SUM(allocated) * IF(txn.type = 'customer', -1, 1) AS Allocated,\n CAST(ROUND_TO_EVEN(\n SUM(IF(txn_line.taxfree, 1, 0) *\n IF(type = 'customer', -1, 1) * allocated *\n CASE discount_type\n WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)\n WHEN 'relative' THEN (retail_price - discount) \n WHEN 'fixed' THEN (discount)\n ELSE retail_price\n END),\n 2) AS DECIMAL(9,2))\n untaxed,\n CAST(ROUND_TO_EVEN(\n SUM(IF(txn_line.taxfree, 0, 1) *\n IF(type = 'customer', -1, 1) * allocated *\n CASE discount_type\n WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)\n WHEN 'relative' THEN (retail_price - discount) \n WHEN 'fixed' THEN (discount)\n ELSE retail_price\n END),\n 2) AS DECIMAL(9,2))\n taxed,\n tax_rate,\n CAST((SELECT SUM(amount) FROM payment WHERE txn.id = payment.txn)\n AS DECIMAL(9,2)) AS Paid\$dollar\n FROM txn\n LEFT JOIN txn_line ON (txn.id = txn_line.txn)\n LEFT JOIN person ON (txn.person = person.id)\n WHERE person = {$id}\n GROUP BY txn.id\n ORDER BY created DESC\n LIMIT 50) t"; $r = $db->query($q); if ($r->num_rows) { while ($row = $r->fetch_row()) { $activity[] = $row; } } end: foot(); ?> <script> var model= { search: '<?php echo ashtml($search); ?> ', all: <?php echo (int) $all; ?> , person: <?php echo json_encode($person); ?> , activity: <?php echo json_encode($activity); ?> , people: <?php
?> </td></tr> <tr><th>Amount</th><td><?php echo amount($payment['amount']); ?> </td></tr> </table> <div id="signature"> <br> <div style="font-size: 2em; padding-top: 2em; padding-bottom: 0.25em; margin-bottom: 0.25em; border-bottom: 4px solid black; text-align: left; page-break-before: always;">×</div> Cardmember agrees to pay total in accordance with agreement governing use of such card. </div> <div id="doc_info"> MERCHANT COPY <br> Invoice <?php echo ashtml($payment['invoice']); ?> <br> <?php echo ashtml($payment['processed']); ?> </div> <div id="store_footer"> Items purchased from stock may be returned in original condition and packaging within 30 days with receipt. No returns without original receipt. <br><br> http://RawMaterialsLA.com/ </div>
$criteria = join(' AND ', $criteria); } $page = (int) $_REQUEST['page']; ?> <form class="form-inline" method="get" action="txns.php"> <input type="submit" class="btn btn-primary" value="Show"> <select name="type" class="form-control"> <option value="">Any <option value="customer">Invoice <option value="vendor">Purchase Order <option value="correction">Correction <option value="drawer">Till Count </select> that includes <input type="text" name="q" value="<?php echo ashtml($q); ?> "> <div class="checkbox"> <label><input type="checkbox" name="unfilled" value="1"> Unfilled</label> </div> <div class="checkbox"> <label><input type="checkbox" name="unpaid" value="1"> Unpaid</label> </div> </form> <br> <?php $per_page = 50; $start = $page * $per_page; $q = "SELECT meta, Number\$txn,\n Created\$date, Filled\$date,\n Person\$person,\n Ordered, Allocated,\n CAST(ROUND_TO_EVEN(taxed * (1 + tax_rate / 100), 2) + untaxed\n AS DECIMAL(9,2))\n Total\$dollar,\n Paid\$dollar, Paid\$date\n FROM (SELECT\n txn.type AS meta,\n CONCAT(txn.id, '|', type, '|', txn.number) AS Number\$txn,\n txn.created AS Created\$date,\n txn.filled AS Filled\$date,\n CONCAT(txn.person, '|', IFNULL(person.company,''),\n '|', IFNULL(person.name,''))\n AS Person\$person,\n SUM(ordered) * IF(txn.type = 'customer', -1, 1) AS Ordered,\n SUM(allocated) * IF(txn.type = 'customer', -1, 1) AS Allocated,\n CAST(ROUND_TO_EVEN(\n SUM(IF(txn_line.taxfree, 1, 0) *\n IF(type = 'customer', -1, 1) * allocated *\n CASE discount_type\n WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)\n WHEN 'relative' THEN (retail_price - discount) \n WHEN 'fixed' THEN (discount)\n ELSE retail_price\n END),\n 2) AS DECIMAL(9,2))\n untaxed,\n CAST(ROUND_TO_EVEN(\n SUM(IF(txn_line.taxfree, 0, 1) *\n IF(type = 'customer', -1, 1) * allocated *\n CASE discount_type\n WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)\n WHEN 'relative' THEN (retail_price - discount) \n WHEN 'fixed' THEN (discount)\n ELSE retail_price\n END),\n 2) AS DECIMAL(9,2))\n taxed,\n tax_rate,\n CAST((SELECT SUM(amount) FROM payment WHERE txn.id = payment.txn)\n AS DECIMAL(9,2)) AS Paid\$dollar,\n txn.paid AS Paid\$date\n FROM txn\n LEFT JOIN txn_line ON (txn.id = txn_line.txn)\n LEFT JOIN person ON (txn.person = person.id)\n WHERE {$criteria}\n GROUP BY txn.id\n ORDER BY created DESC\n LIMIT {$start}, {$per_page}) t"; dump_table($db->query($q));
value="<?php echo ashtml($end); ?> " /> </div> </div> </div> <div class="form-group"> <label for="items" class="col-sm-2 control-label"> Items </label> <div class="col-sm-10"> <input id="items" name="items" type="text" class="form-control" style="width: 20em" value="<?php echo ashtml($items); ?> "> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" class="btn btn-primary" value="Show"> </div> </div> </form> <div id="results"> <?php $q = "SELECT\n item.id AS meta,\n item.code Code\$item,\n item.name Name\$name,\n SUM(-1 * allocated) Sold,\n AVG(sale_price(txn_line.retail_price, txn_line.discount_type,\n txn_line.discount)) AvgPrice\$dollar,\n SUM(-1 * allocated * sale_price(txn_line.retail_price,\n txn_line.discount_type,\n txn_line.discount)) Total\$dollar\n FROM txn\n LEFT JOIN txn_line ON txn.id = txn_line.txn\n LEFT JOIN item ON txn_line.item = item.id\n LEFT JOIN brand ON item.brand = brand.id\n LEFT JOIN barcode ON (item.id = barcode.item)\n WHERE type = 'customer'\n AND ({$sql_criteria})\n AND paid BETWEEN '{$begin}' AND '{$end}' + INTERVAL 1 DAY\n GROUP BY 1\n ORDER BY 2"; dump_table($db->query($q)); dump_query($q);
} ?> <div id="doc_info"> <?php if ($credit) { ?> CUSTOMER COPY <br> <?php } ?> Invoice <?php echo ashtml($txn['formatted_number']); ?> <br> <?php echo date('F j, Y g:i A', strtotime($txn['created'])); ?> <br><br> <span style="font-family: Aatrix3of9Reg; font-size: 2em">*@INV-<?php echo ashtml($txn['id']); ?> *</span> </div> <div id="store_footer"> Items purchased from stock may be returned in original condition and packaging within 30 days with receipt. Assembled easels are subject to a 20% restocking fee. No returns without original receipt. <br><br> http://RawMaterialsLA.com/ </div>
function dump_query($q) { static $num; $num += 1; if (!$GLOBALS['DEBUG']) { return; } ?> <button onclick="$('#query_<?php echo $num; ?> ').toggle('drop')" class="btn btn-default">Show Query</button> <pre id="query_<?php echo $num; ?> " class="debug" style="display: none"><?php echo ashtml($q); ?> </pre> <?php }
<form role="form" method="get" action="items.php"> <div class="input-group"> <span class="input-group-btn"> <input type="submit" class="btn btn-primary" value="Search"> </span> <input id="autofocus" type="text" class="form-control" size="60" name="search" data-bind="value: search" placeholder="Enter keywords or scan barcode" autocorrect="off" autocapitalize="off" value="<?php echo ashtml($_REQUEST['search']); ?> "> <span class="input-group-addon"> <label> <input type="checkbox" value="1" name="all" data-bind="checked: all" <?php echo (int) $_REQUEST['all'] ? 'checked' : ''; ?> > Include inactive? </label> </span> </div> </form> <br> <br>
head("Daily Flow @ Scat", true); $q = "SELECT DATE_FORMAT(processed, '%Y-%m-%d %a') AS date,\n method, cc_type, SUM(amount) amount\n FROM payment\n WHERE processed > DATE(NOW() - INTERVAL 8 DAY)\n GROUP BY date, method, cc_type\n ORDER BY date DESC"; $r = $db->query($q) or die($db->error); bcscale(2); ?> <table class="table table-striped sortable" style="width: auto"> <thead> <tr><th>Date</th><th>Cash</th><th>Credit</th><th>Amex</th><th>Other</th></tr> </thead> <tbody> <?php $day = null; $cash = $credit = $amex = $other = 0.0; while ($row = $r->fetch_assoc()) { if ($row['date'] != $day && $day) { echo '<tr><td>', ashtml($day), '</td><td align="right">', amount($cash), '</td><td align="right">', amount($credit), '</td><td align="right">', amount($amex), '</td><td align="right">', amount($other), "</td></tr>\n"; $cash = $credit = $amex = $other = 0.0; } switch ($row['method']) { case 'cash': case 'change': $cash = bcadd($cash, $row['amount']); break; case 'credit': if ($row['cc_type'] == 'AmericanExpress') { $amex = bcadd($amex, $row['amount']); } else { $credit = bcadd($credit, $row['amount']); } break; case 'withdrawal':