From 4864a774b19004283390d7ea3734a21c8a080586 Mon Sep 17 00:00:00 2001
From: VESSILLER <lvessiller@open-dsi.fr>
Date: Tue, 19 May 2020 10:17:52 +0200
Subject: [PATCH] NEW remise en place du decoupage des champs PDF pour
 extraction standard des BP depuis CIRIL

---
 lib/Controller/PageController.php | 70 +++++++++++++++----------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 9d318c1..8206947 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -37,18 +37,18 @@ class PageController extends Controller {
     /**
      * @var array Payslip PDF search field list
      */
-//    private $_payslipPDFSearchFieldList = array(
-//        'siret'     => array(3),
-//        'matricule' => array(10),
-//        'fullname'  => array(9),
-//        'zip_city'  => array(19, 20),
-//    );
     private $_payslipPDFSearchFieldList = array(
-        'siret'     => array(4, 5),
-        'matricule' => array(20, 21),
-        'fullname'  => array(19, 20),
-        'zip_city'  => array(34, 35, 36, 37),
+        'siret'     => array(3),
+        'matricule' => array(10),
+        'fullname'  => array(9),
+        'zip_city'  => array(19, 20),
     );
+//    private $_payslipPDFSearchFieldList = array(
+//        'siret'     => array(4, 5),
+//        'matricule' => array(20, 21),
+//        'fullname'  => array(19, 20),
+//        'zip_city'  => array(34, 35, 36, 37),
+//    );
 
     /**
      * @var string CSV delimiter
@@ -1102,20 +1102,20 @@ class PageController extends Controller {
                                 // pour chaque champ CSV a controler
                                 foreach ($checkCurrentValues as $checkField => $checkCurrentValue) {
                                     // verifier d'abord aux emplacements previsibles du PDF
-                                    //if ($checkField == 'siret') {
-                                    //    // siret
-                                    //    if (isset($this->_payslipPDFSearchFieldList[$checkField]) && !empty($this->_payslipPDFSearchFieldList[$checkField])) {
-                                    //        foreach ($this->_payslipPDFSearchFieldList[$checkField] as $payslipPDFSearchFieldIndex) {
-                                    //            $matchList = array();
-                                    //            if (preg_match('#SIRET:\s(\d+)\s\d+$#', $pdfPageTextList[$payslipPDFSearchFieldIndex], $matchList)) {
-                                    //               if ($matchList[1] == $checkCurrentValue) {
-                                    //                    $pdfPageValues[$checkField] = $checkCurrentValue;
-                                    //                    continue;
-                                    //                }
-                                    //            }
-                                    //        }
-                                    //    }
-                                    //} else {
+                                    if ($checkField == 'siret') {
+                                        // siret
+                                        if (isset($this->_payslipPDFSearchFieldList[$checkField]) && !empty($this->_payslipPDFSearchFieldList[$checkField])) {
+                                            foreach ($this->_payslipPDFSearchFieldList[$checkField] as $payslipPDFSearchFieldIndex) {
+                                                $matchList = array();
+                                                if (preg_match('#SIRET:\s(\d+)\s\d+$#', $pdfPageTextList[$payslipPDFSearchFieldIndex], $matchList)) {
+                                                   if ($matchList[1] == $checkCurrentValue) {
+                                                        $pdfPageValues[$checkField] = $checkCurrentValue;
+                                                        continue;
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    } else {
                                         // siret, matricule, fullname, zip_city
                                         if (isset($this->_payslipPDFSearchFieldList[$checkField]) && !empty($this->_payslipPDFSearchFieldList[$checkField])) {
                                             foreach ($this->_payslipPDFSearchFieldList[$checkField] as $payslipPDFSearchFieldIndex) {
@@ -1125,7 +1125,7 @@ class PageController extends Controller {
                                                 }
                                             }
                                         }
-                                    //}
+                                    }
 
                                     if (!isset($pdfPageValues[$checkField])) {
                                         // si on a pas trouve aux emplacement previsibles du PDF
@@ -1134,21 +1134,21 @@ class PageController extends Controller {
                                             // formater les champs textes du PDF (enlever les espaces)
                                             $pdfPageTextValue = trim($pdfPageText);
 
-                                            //if ($checkField == 'siret') {
-                                            //    $matchList = array();
-                                            //    if (preg_match('#SIRET:\s(\d+)\s\d+$#', $pdfPageTextValue, $matchList)) {
-                                            //        if ($matchList[1] == $checkCurrentValue) {
-                                            //            $pdfPageValues[$checkField] = $checkCurrentValue;
-                                            //            break;
-                                            //        }
-                                            //    }
-                                            //} else {
+                                            if ($checkField == 'siret') {
+                                                $matchList = array();
+                                                if (preg_match('#SIRET:\s(\d+)\s\d+$#', $pdfPageTextValue, $matchList)) {
+                                                    if ($matchList[1] == $checkCurrentValue) {
+                                                        $pdfPageValues[$checkField] = $checkCurrentValue;
+                                                        break;
+                                                    }
+                                                }
+                                            } else {
                                                 // siret, matricule, fullname, zip_city
                                                 if ($pdfPageTextValue == $checkCurrentValue) {
                                                     $pdfPageValues[$checkField] = $checkCurrentValue;
                                                     break;
                                                 }
-                                            //}
+                                            }
                                         }
                                     }
                                 }
-- 
GitLab