PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/cashdesk/facturation_dhtml.php

https://bitbucket.org/speedealing/speedealing
PHP | 110 lines | 68 code | 14 blank | 28 comment | 16 complexity | 37dcf70a338b1416bb63353b4c3039be MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
  3. * Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
  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. * This page is called each time we press a key in the code
  20. * search form to show product combo list.
  21. */
  22. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
  23. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
  24. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  25. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  26. if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
  27. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
  28. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  29. if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  30. if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  31. //if (! defined("NOLOGIN")) define("NOLOGIN",'1');
  32. // Change this following line to use the correct relative path (../, ../../, etc)
  33. require '../main.inc.php';
  34. require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
  35. //header("Content-type: text/html; charset=UTF-8");
  36. header("Content-type: text/html; charset=".$conf->file->character_set_client);
  37. // Search from criteria
  38. if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at least
  39. {
  40. $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
  41. if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
  42. $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
  43. if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
  44. $sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
  45. $sql.= " AND p.tosell = 1";
  46. $sql.= " AND p.fk_product_type = 0";
  47. // Add criteria on ref/label
  48. if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
  49. {
  50. $sql.= " AND (p.ref LIKE '".$_GET['code']."%' OR p.label LIKE '".$_GET['code']."%')";
  51. }
  52. else
  53. {
  54. $sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
  55. }
  56. $sql.= " ORDER BY label";
  57. dol_syslog("facturation_dhtml.php sql=".$sql);
  58. $result = $db->query($sql);
  59. if ($result)
  60. {
  61. if ( $nbr = $db->num_rows($result) )
  62. {
  63. $resultat = '<ul class="dhtml_bloc">';
  64. $ret=array(); $i=0;
  65. while ( $tab = $db->fetch_array($result) )
  66. {
  67. foreach ( $tab as $cle => $valeur )
  68. {
  69. $ret[$i][$cle] = $valeur;
  70. }
  71. $i++;
  72. }
  73. $tab=$ret;
  74. $tab_size=count($tab);
  75. for($i=0;$i < $tab_size;$i++)
  76. {
  77. $resultat .= '
  78. <li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
  79. onMouseOver="javascript: this.className = \'dhtml_selection\';"
  80. onMouseOut="javascript: this.className = \'dhtml_defaut\';"
  81. >'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</li>
  82. ';
  83. }
  84. $resultat .= '</ul>';
  85. print $resultat;
  86. }
  87. else
  88. {
  89. $langs->load("cashdesk");
  90. print '<ul class="dhtml_bloc">';
  91. print '<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li>';
  92. print '</ul>';
  93. }
  94. }
  95. }
  96. ?>