An easy point of sale system with automatic inventory tracking. https://netsyms.biz/apps/nickelbox/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

action.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. * Make things happen when buttons are pressed and forms submitted.
  7. */
  8. require_once __DIR__ . "/required.php";
  9. if ($VARS['action'] !== "signout") {
  10. dieifnotloggedin();
  11. }
  12. /**
  13. * Redirects back to the page ID in $_POST/$_GET['source'] with the given message ID.
  14. * The message will be displayed by the app.
  15. * @param string $msg message ID (see lang/messages.php)
  16. * @param string $arg If set, replaces "{arg}" in the message string when displayed to the user.
  17. */
  18. function returnToSender($msg, $arg = "") {
  19. global $VARS;
  20. if ($arg == "") {
  21. header("Location: app.php?page=" . urlencode($VARS['source']) . "&msg=" . $msg);
  22. } else {
  23. header("Location: app.php?page=" . urlencode($VARS['source']) . "&msg=$msg&arg=$arg");
  24. }
  25. die();
  26. }
  27. switch ($VARS['action']) {
  28. case "itemsearch":
  29. header("Content-Type: application/json");
  30. if (!is_empty($VARS['q'])) {
  31. $where["AND"]["OR"] = [
  32. "name[~]" => $VARS['q'],
  33. "code1[~]" => $VARS['q'],
  34. "code2[~]" => $VARS['q']
  35. ];
  36. } else {
  37. exit(json_encode(["status" => "ERROR", "items" => false]));
  38. }
  39. $items = $binstack->select('items', [
  40. 'itemid (id)',
  41. 'name',
  42. 'code1',
  43. 'code2',
  44. 'cost',
  45. 'price'
  46. ], $where);
  47. $items = (count($items) > 0 ? $items : false);
  48. exit(json_encode(["status" => "OK", "items" => $items]));
  49. case "signout":
  50. session_destroy();
  51. header('Location: index.php');
  52. die("Logged out.");
  53. }