invoice_item_delete.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /* $Id$ */
  3. /*
  4. Copyright (C) 2008-2013 Mark J Crane
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without
  7. modification, are permitted provided that the following conditions are met:
  8. 1. Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  14. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  15. AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  16. AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  18. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  19. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  20. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  21. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  22. POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. //includes files
  25. require_once dirname(__DIR__, 2) . "/resources/require.php";
  26. require_once "resources/check_auth.php";
  27. //get permissions
  28. if (permission_exists('invoice_item_delete')) {
  29. //access granted
  30. }
  31. else {
  32. echo "access denied";
  33. exit;
  34. }
  35. //get the http variables
  36. if (count($_GET) > 0) {
  37. $id = check_str($_GET["id"]);
  38. $invoice_uuid = check_str($_GET["invoice_uuid"]);
  39. $contact_uuid = check_str($_GET["contact_uuid"]);
  40. $back = check_str($_GET["back"]);
  41. }
  42. //add multi-lingual support
  43. $language = new text;
  44. $text = $language->get();
  45. //delete invoice_item
  46. if (strlen($id) > 0) {
  47. $sql = "delete from v_invoice_items ";
  48. $sql .= "where domain_uuid = '$domain_uuid' ";
  49. $sql .= "and invoice_item_uuid = '$id' ";
  50. $prep_statement = $db->prepare(check_sql($sql));
  51. $prep_statement->execute();
  52. unset($sql);
  53. }
  54. //redirect the user
  55. $_SESSION['message'] = $text['message-delete'];
  56. $back = ($back != '') ? "&back=".$back : null;
  57. header("Location: invoice_edit.php?id=".$invoice_uuid."&contact_uuid=".$contact_uuid.$back);
  58. exit;
  59. ?>