Guest User

paton_info.php

a guest
Jul 28th, 2017
116
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. # ---------------------------------------------------------------
  3. # Copyright (C) 2017 C/W MARS, INC.
  4. # Jason Stephenson <jstephenson@cwmars.org>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. # ---------------------------------------------------------------
  16.  
  17. # edit me for your environment:
  18. include "/home/opensrf/PHPSIP2/sip2client.class.php";
  19.  
  20. $sip_params = parse_ini_file("sip.ini");
  21. $db_params = parse_ini_file("db.ini");
  22.  
  23.  
  24. $client = new SIP2Client();
  25. $client->recvTimeO = 60;
  26. $client->doChecksum = false;
  27.  
  28. $query = <<<EOQ
  29. select card.barcode
  30. from actor.card
  31. join actor.usr on usr.card = card.id
  32. and not usr.deleted
  33. join money.open_usr_summary
  34. on usr.id = open_usr_summary.usr
  35. and open_usr_summary.balance_owed > 0
  36. EOQ;
  37.  
  38. $dsn = "pgsql:host=$db_params[host];port=$db_params[port];dbname=$db_params[database]";
  39. $dbh = new PDO($dsn, $db_params['user'], $db_params['password']);
  40.  
  41. if ($client->connect($sip_params['host'], $sip_params['port'], $sip_params['user'], $sip_params['password'])) {
  42.   foreach ($dbh->query($query) as $row) {
  43.         $info = $client->patronInformation($row['barcode']);
  44.     $fines = intval($info['FineItems']);
  45.     if ($fines > 0) {
  46.       $info = $client->patronInformation($row['barcode'], null, 'Fine', 1, $fines);
  47.       var_dump($info);
  48.     }
  49.   }
  50. }
RAW Paste Data