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.

societephcpproduct_page.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) ---Put here your own copyright and developer email---
  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 dev/Societephcpproducts/Societephcpproduct_page.php
  20. * \ingroup mymodule othermodule1 othermodule2
  21. * \brief This file is an example of a php page
  22. * Initialy built by build_class_from_table on 2013-09-12 16:47
  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'); // Do not check anti CSRF attack test
  29. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
  30. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
  31. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
  32. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
  33. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  34. //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
  35. // Change this following line to use the correct relative path (../, ../../, etc)
  36. $res=0;
  37. if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
  38. if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
  39. if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
  40. if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  41. if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  42. if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  43. if (! $res) die("Include of main fails");
  44. // Change this following line to use the correct relative path from htdocs
  45. dol_include_once('/module/class/societephcpproduct.class.php');
  46. // Load traductions files requiredby by page
  47. $langs->load("companies");
  48. $langs->load("other");
  49. // Get parameters
  50. $id = GETPOST('id','int');
  51. $action = GETPOST('action','alpha');
  52. $myparam = GETPOST('myparam','alpha');
  53. // Protection if external user
  54. if ($user->societe_id > 0)
  55. {
  56. //accessforbidden();
  57. }
  58. /*******************************************************************
  59. * ACTIONS
  60. *
  61. * Put here all code to do according to value of "action" parameter
  62. ********************************************************************/
  63. if ($action == 'add')
  64. {
  65. $object=new Societephcpproduct($db);
  66. $object->prop1=$_POST["field1"];
  67. $object->prop2=$_POST["field2"];
  68. $result=$object->create($user);
  69. if ($result > 0)
  70. {
  71. // Creation OK
  72. }
  73. {
  74. // Creation KO
  75. $mesg=$object->error;
  76. }
  77. }
  78. /***************************************************
  79. * VIEW
  80. *
  81. * Put here all code to build page
  82. ****************************************************/
  83. llxHeader('','MyPageName','');
  84. $form=new Form($db);
  85. // Put here content of your page
  86. // Example 1 : Adding jquery code
  87. print '<script type="text/javascript" language="javascript">
  88. jQuery(document).ready(function() {
  89. function init_myfunc()
  90. {
  91. jQuery("#myid").removeAttr(\'disabled\');
  92. jQuery("#myid").attr(\'disabled\',\'disabled\');
  93. }
  94. init_myfunc();
  95. jQuery("#mybutton").click(function() {
  96. init_needroot();
  97. });
  98. });
  99. </script>';
  100. // Example 2 : Adding links to objects
  101. // The class must extends CommonObject class to have this method available
  102. //$somethingshown=$object->showLinkedObjectBlock();
  103. // Example 3 : List of data
  104. if ($action == 'list')
  105. {
  106. $sql = "SELECT";
  107. $sql.= " t.rowid,";
  108. $sql.= " t.societe_phcp_product_number,";
  109. $sql.= " t.entity,";
  110. $sql.= " t.ref_ext,";
  111. $sql.= " t.ref_int,";
  112. $sql.= " t.fk_phcp,";
  113. $sql.= " t.fk_societe,";
  114. $sql.= " t.fk_product";
  115. $sql.= " FROM ".MAIN_DB_PREFIX."societe_phcp_product as t";
  116. $sql.= " WHERE field3 = 'xxx'";
  117. $sql.= " ORDER BY field1 ASC";
  118. print '<table class="noborder">'."\n";
  119. print '<tr class="liste_titre">';
  120. print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
  121. print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
  122. print '</tr>';
  123. dol_syslog($script_file." sql=".$sql, LOG_DEBUG);
  124. $resql=$db->query($sql);
  125. if ($resql)
  126. {
  127. $num = $db->num_rows($resql);
  128. $i = 0;
  129. if ($num)
  130. {
  131. while ($i < $num)
  132. {
  133. $obj = $db->fetch_object($resql);
  134. if ($obj)
  135. {
  136. // You can use here results
  137. print '<tr><td>';
  138. print $obj->field1;
  139. print $obj->field2;
  140. print '</td></tr>';
  141. }
  142. $i++;
  143. }
  144. }
  145. }
  146. else
  147. {
  148. $error++;
  149. dol_print_error($db);
  150. }
  151. print '</table>'."\n";
  152. }
  153. // End of page
  154. llxFooter();
  155. $db->close();
  156. ?>