<?php

namespace RxConnexionBundle\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr;


class PurchaseInvoicePaymentRepository extends EntityRepository
{
    public function validate($purchaseInvoicePayment_form) {

        $errors = array();

        if($purchaseInvoicePayment_form['action'] != 'd'){

            if(empty($purchaseInvoicePayment_form['purchaseInvoice'])){
                $errors[] = 'Invalid transaction. Please try again or contact the administrator.';
            }

            if(empty($purchaseInvoicePayment_form['amount'])){
                $errors[] = 'Amount should not be blank.';
            }

            if(empty($purchaseInvoicePayment_form['payment_date'])){
                $errors[] = 'Payment date should not be blank.';
            }

            if(empty($purchaseInvoicePayment_form['payment_method'])){
                $errors[] = 'Payment method should not be blank';
            }

//            if($purchaseInvoicePayment_form['payment_method'] == 'Check' && (empty($purchaseInvoicePayment_form['checkDate']) || empty($purchaseInvoicePayment_form['bank']))){
//                $errors[] = 'There are error on check detail.';
//            }
        }

        return $errors;
    }


}