Increase Speed of Invoice Handling - IMPLEMENTED IN V2.9

Details of modifications which users can incorporate within Enuuk Auction Platform free of charge
Locked
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Increase Speed of Invoice Handling - IMPLEMENTED IN V2.9

Post by RWAP » Fri Jul 01, 2011 1:30 pm

When the admin is dealing with invoices - sending and updating status, it can take an extremely long time to update the status from notpaid to paid (for example)

To overcome this, in class\Invoice.php, find

Code: Select all

    public function updateInvoiceStatus(MyPDO $DB,$status=self::SENT)
    {
        $this->_status = $status;
        //update fee rows
        if($this->_invoiceLines){
            foreach($this->_invoiceLines as $v){
                $rowStatus = '';
                if(in_array($status,array(self::SENT,self::PENDING,self::PAYMENT_PENDING,self::PAYMENT_VERIFIED ))){
                    $rowStatus = Fee::FEE_PAYMENT_IN_PROCESS;
                }
                if($status == self::NOT_PAID){
                    $rowStatus = Fee::FEE_NOTPAID;
                }
                if($status == self::PAID){
                    $rowStatus = Fee::FEE_PAID;
                }
                Fee::updateFeeStatus($DB,$v['userFeesId'],$rowStatus);
            }
        }
        return $this->saveToDB($DB);
    }
Change the whole of this function to read:

Code: Select all

    public function updateInvoiceStatus(MyPDO $DB,$status=self::SENT)
    {
        $this->_status = $status;
        //update fee rows
        $rowStatus = '';
        if(in_array($status,array(self::SENT,self::PENDING,self::PAYMENT_PENDING,self::PAYMENT_VERIFIED ))){
            $rowStatus = Fee::FEE_PAYMENT_IN_PROCESS;
        }
        elseif($status == self::NOT_PAID){
            $rowStatus = Fee::FEE_NOTPAID;
        }
        elseif($status == self::PAID){
            $rowStatus = Fee::FEE_PAID;
        }
        if($this->_invoiceLines){
            $feeIds=array();
            foreach($this->_invoiceLines as $v){
				$feeIds[]=$v['userFeesId'];
            }
            Fee::updateMultipleFeeStatus($DB,$feeIds,$rowStatus);
        }
        $sql = 'update '.self::DB_TABLE.' set status=:status where id=:id limit 1';
        $query = $DB->prepare($sql);
        $result = $query->execute(array(':status'=>$status, ':id'=>$this->_id));
        unset($query);
        return $result;
    }

Then, in class\Fee.php

Find:

Code: Select all

    static public function updateFeeStatus(MyPDO $DB,$feeId,$status = self::FEE_NOTPAID)
    {
        $sql = 'update '.self::FEES_USERS_TABLE. ' set status=:status where id=:id limit 1';
        $query = $DB->prepare($sql);
        $result = $query->execute(array(':status'=>$status, ':id'=>$feeId));
        unset($query);
        return $result;
    }
Add below this:

Code: Select all

    static public function updateMultipleFeeStatus(MyPDO $DB,$feeIds,$status = self::FEE_NOTPAID)
    {
		if (is_array($feeIds))
        {
	        $fees=implode(',',$feeIds);
            $sql = 'update '.self::FEES_USERS_TABLE. ' set status=:status where id in ('.$fees.')';
	        $query = $DB->prepare($sql);
	        $result = $query->execute(array(':status'=>$status));
	        unset($query);
	        return $result;
        }
        else
        {
        	return self::updateFeeStatus($DB,$feeIds,$status);
        }
    }

Locked

Who is online

Users browsing this forum: No registered users and 1 guest