From 56b9c3b186237f5399f51a3d1f677d77fc2b5fcd Mon Sep 17 00:00:00 2001
From: Frank Morgner <morgnerf@ub.uni-leipzig.de>
Date: Fri, 1 Jun 2018 08:49:43 +0200
Subject: [PATCH] refs #12489 * add ILS Libero method payAnyFee.jsp to
 LiberoDingTrait.php * balances all fees of user in one action

---
 .../src/finc/ILS/Driver/LiberoDingTrait.php   | 42 ++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php
index 0e333790b30..e3264e0d4f9 100644
--- a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php
+++ b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php
@@ -111,7 +111,7 @@ trait LiberoDingTrait
      * @return boolean    Returns true if a connection exists
      * @throws \Exception Throws ILSException
      */
-    public function checkLiberoDingConnection ()
+    public function checkLiberoDingConnection()
     {
         $http_header['User-Agent']
             = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
@@ -149,6 +149,46 @@ trait LiberoDingTrait
         return !($details['liberoPing']["soTimeout"] || $details['liberoPing']["connectionTimeout"]);
     }
 
+    /**
+     * Balance (pay all) fines of user at account
+     *
+     * @param array $patron Patron object
+     * @param int   $amount Paid fees in eurocent
+     *
+     * @return boolean True if passed, false if ILS request fails
+     * @access public
+     * @throws ILSException
+     */
+    public function balanceFinesOfUser($patron, $amount)
+    {
+        $params                 = $this->_getLiberoDingRequestParams();
+        $params['memberCode']   = $patron['cat_username'];
+        $params['password']     = $patron['cat_password'];
+        $params['amount']       = $amount;
+
+        try {
+            $result = $this->httpService->get(
+                $this->getWebScraperUrl() .'payAnyFee.jsp',
+                $params,
+                null,
+                $this->_getLiberoDingRequestHeaders()
+            );
+        } catch (\Exception $e) {
+            throw new ILSException($e->getMessage());
+        }
+
+        if (!$result->isSuccess()) {
+            // log error for debugging
+            $this->debug(
+                'HTTP status ' . $result->getStatusCode() .
+                ' received'
+            );
+            return false;
+        }
+
+        return $this->_getLiberoDingResultBool($result);
+    }
+
     /**
      * Get Libero system messages for a given patron
      *
-- 
GitLab