You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mypage.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /* <one line to give the program's name and a brief idea of what it does.>
  3. * Copyright (C) <year> <name of author>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file mypage.php
  20. * \ingroup photocopies
  21. * \brief This file is an example php page
  22. * Put some comments here
  23. */
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
  25. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
  26. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  27. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  28. //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
  29. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
  30. // If there is no menu to show
  31. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  32. // If we don't need to load the html.form.class.php
  33. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  34. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  35. // If this page is public (can be called outside logged session)
  36. //if (! defined("NOLOGIN")) define("NOLOGIN",'1');
  37. // Choose the following lines to use the correct relative path
  38. // (../, ../../, etc)
  39. $res = 0;
  40. if (! $res && file_exists("../main.inc.php")) {
  41. $res = @include("../main.inc.php");
  42. }
  43. if (! $res && file_exists("../../main.inc.php")) {
  44. $res = @include("../../main.inc.php");
  45. }
  46. if (! $res && file_exists("../../../main.inc.php")) {
  47. $res = @include("../../../main.inc.php");
  48. }
  49. // The following should only be used in development environments
  50. if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) {
  51. $res = @include("../../../dolibarr/htdocs/main.inc.php");
  52. }
  53. if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) {
  54. $res = @include("../../../../dolibarr/htdocs/main.inc.php");
  55. }
  56. if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) {
  57. $res = @include("../../../../../dolibarr/htdocs/main.inc.php");
  58. }
  59. if (! $res) {
  60. die("Main include failed");
  61. }
  62. // Change this following line to use the correct relative path from htdocs
  63. // (do not remove DOL_DOCUMENT_ROOT)
  64. require_once DOL_DOCUMENT_ROOT . "/photocopies/class/myclass.class.php";
  65. // Load translation files required by the page
  66. $langs->load("photocopies@photocopies");
  67. // Get parameters
  68. $id = GETPOST('id', 'int');
  69. $action = GETPOST('action', 'alpha');
  70. $myparam = GETPOST('myparam', 'alpha');
  71. // Access control
  72. if ($user->societe_id > 0) {
  73. // External user
  74. accessforbidden();
  75. }
  76. /*
  77. * ACTIONS
  78. *
  79. * Put here all code to do according to value of "action" parameter
  80. */
  81. if ($action == 'add') {
  82. $myobject = new SkeletonClass($db);
  83. $myobject->prop1 = $_POST["field1"];
  84. $myobject->prop2 = $_POST["field2"];
  85. $result = $myobject->create($user);
  86. if ($result > 0) {
  87. // Creation OK
  88. } {
  89. // Creation KO
  90. $mesg = $myobject->error;
  91. }
  92. }
  93. /*
  94. * VIEW
  95. *
  96. * Put here all code to build page
  97. */
  98. llxHeader('', 'Photocopies', '');
  99. $form = new Form($db);
  100. // Put here content of your page
  101. // Example 1 : Adding jquery code
  102. echo '<script type="text/javascript" language="javascript">
  103. jQuery(document).ready(function() {
  104. function init_myfunc()
  105. {
  106. jQuery("#myid").removeAttr(\'disabled\');
  107. jQuery("#myid").attr(\'disabled\',\'disabled\');
  108. }
  109. init_myfunc();
  110. jQuery("#mybutton").click(function() {
  111. init_needroot();
  112. });
  113. });
  114. </script>';
  115. // Example 2 : Adding jquery code
  116. $somethingshown = $myobject->showLinkedObjectBlock();
  117. // End of page
  118. llxFooter();
  119. $db->close();