HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /www/exchange2/exchange/custom_actions/TT2299.php
<?php
  class TT2299
  {
      private $query;
        
      function __construct()
      {
          include_once('../Bin/constants.php');
          include_once('../Bin/init.php');
          require_once(ROOT_FOLDER.'Bin/Security.php');
          
          $this->query = new Bin_Query();
          include_once(ROOT_FOLDER.'admin/classes/Model/MHelpers.php');
          include_once(ROOT_FOLDER.'admin/classes/Model/statement_actions.php');
          include_once(ROOT_FOLDER.'admin/classes/Model/MDebtor.php');
      }
      
      function fixTB()
      {
          $this->query->executeQuery('SELECT manual_transactions.manual_transaction_id as tb_id, manual_transactions.reconcile_ref, owner.manual_transaction_id, owner.transaction_type, owner.reconcile_payment, owner.reconcile_ref
                                       FROM manual_transactions
                                       LEFT JOIN manual_transactions as owner ON owner.manual_transaction_id = manual_transactions.reconcile_ref
                                       WHERE manual_transactions.transaction_type='.TRAILING_BALANCE);
          
          $TBs=$this->query->records;
          
          foreach($TBs as $TB)
          {
              if (in_array($TB['transaction_type'],array(INBOUND_DEBTOR_PAYMENT,PAID_DIRECTLY_TO_ORIGINATOR,TRANSFER_OF_PAYMENT_BY_ORIGINATOR)))
              {
                  continue;
              }
              
              if (empty($TB['reconcile_payment']))
              {
                  var_dump($TB['tb_id']);
                  continue;
              }
                            
              $this->query->updateQuery('UPDATE manual_transactions SET reconcile_ref='.$TB['reconcile_payment'].' WHERE manual_transaction_id='.$TB['tb_id']);
          }
      }
  }
  
  $TT2299 = new TT2299();
  $TT2299->fixTB();
?>