gridphp

Concurrent user notification

May 15th, 2014
565
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * PHP Grid Component
  4.  *
  5.  * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  6.  * @version 1.5.2
  7.  * @license: see license.txt included in package
  8.  */
  9.  
  10. // include db config
  11. include_once("../../config.php");
  12.  
  13. // set up DB
  14. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  15. mysql_select_db(PHPGRID_DBNAME);
  16.  
  17. // include and create object
  18. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  19.  
  20. $grid = new jqgrid();
  21.  
  22. $opt["caption"] = "Data";
  23. $grid->set_options($opt);
  24.  
  25. $e["on_update"] = array("update_client", null, true);
  26. $grid->set_events($e);
  27.  
  28. function update_client($data)
  29. {
  30.     $str = "SELECT * FROM invheader WHERE id = {$data["id"]}";
  31.     $rs = mysql_fetch_assoc(mysql_query($str));
  32.     if ( strtotime($rs["invdate"]) > strtotime($data["params"]["invdate"]) )
  33.         phpgrid_error('Already Edited, Kindly refresh grid!');
  34.    
  35.     // update new timestamp
  36.     $data["params"]["invdate"] = date("Y-m-d H:i:s");
  37.    
  38.     // continue normal grid update ... by grid lib
  39. }
  40.  
  41. $grid->table = "invheader";
  42. $out = $grid->render("list1");
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  45. <html>
  46. <head>
  47.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>  
  48.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link> 
  49.    
  50.     <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  51.     <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  52.     <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script> 
  53.     <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  54. </head>
  55. <body>
  56.     <div style="margin:10px">
  57.     <?php echo $out?>
  58.     </div>
  59. </body>
  60. </html>
RAW Paste Data