<?php

/**
 * Subclass for performing query and update operations on the 'katao_member_deposit' table.
 *
 * @package lib.model
 */
class KataoMemberDepositPeer extends BaseKataoMemberDepositPeer {
    public static function getAllCurrencies() {
        return array(KataoMemberDeposit::CURRENCY_EURO => self::getCurrencyStr(KataoMemberDeposit::CURRENCY_EURO), KataoMemberDeposit::CURRENCY_SOL => self::getCurrencyStr(KataoMemberDeposit::CURRENCY_SOL));
    }

    public static function getCurrencyStr($currency) {
        switch ($currency) {
            case KataoMemberDeposit::CURRENCY_EURO:
                return 'Euro';
            case KataoMemberDeposit::CURRENCY_SOL:
                return wpConfig::getAdditionalCurrencyName();
        }
        return '';
    }

    public static function getAllPaymentModes($include_transfer_sol = false) {
        $return = array(KataoMemberDeposit::PAYMENT_MODE_OTHER => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_OTHER), KataoMemberDeposit::PAYMENT_MODE_CASH => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_CASH), KataoMemberDeposit::PAYMENT_MODE_CHECK => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_CHECK), KataoMemberDeposit::PAYMENT_MODE_BANK_TRANSFER => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_BANK_TRANSFER), KataoMemberDeposit::PAYMENT_MODE_CREDIT => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_CREDIT), KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL => self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL));
        if ($include_transfer_sol) {
            $return[KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL] = self::getPaymentModeStr(KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL);
        }
        return $return;
    }

    public static function getPaymentModeStr($status) {
        switch ($status) {
            case KataoMemberDeposit::PAYMENT_MODE_OTHER:
                return 'Autre';
            case KataoMemberDeposit::PAYMENT_MODE_CASH:
                return 'Espèces';
            case KataoMemberDeposit::PAYMENT_MODE_CHECK:
                return 'Chèque';
            case KataoMemberDeposit::PAYMENT_MODE_BANK_TRANSFER:
                return 'Virement';
            case KataoMemberDeposit::PAYMENT_MODE_CREDIT:
                return 'Avoir';
            case KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL:
                return 'Retrait';
            case KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL:
                return 'Transfert en ' . wpConfig::getAdditionalCurrencyName();
        }
        return '';
    }

    public static function getAllStatuses() {
        return array(KataoMemberDeposit::STATUS_VALIDATED => self::getStatusStr(KataoMemberDeposit::STATUS_VALIDATED), KataoMemberDeposit::STATUS_PENDING => self::getStatusStr(KataoMemberDeposit::STATUS_PENDING), KataoMemberDeposit::STATUS_EXPIRED => self::getStatusStr(KataoMemberDeposit::STATUS_EXPIRED));
    }

    public static function getStatusStr($status) {
        switch ($status) {
            case KataoMemberDeposit::STATUS_VALIDATED:
                return 'Validé';
            case KataoMemberDeposit::STATUS_PENDING:
                return 'Provisoire';
            case KataoMemberDeposit::STATUS_EXPIRED:
                return 'Expiré';
        }
        return '';
    }

		public static function addPaypalDepot($kataoMemberId,$montant,$commentaire){
			$depot = new KataoMemberDeposit();
			$depot->setKataoMemberId($kataoMemberId);
			$depot->setAmount($montant);
			$depot->setComment($commentaire);
			$depot->setCurrency(KataoMemberDeposit::CURRENCY_SOL);
			$depot->setPaymentMode(KataoMemberDeposit::PAYMENT_MODE_OTHER);
			$depot->setStatus(KataoMemberDeposit::STATUS_VALIDATED);
			$depot->setValuedAt(time());
			$depot->save();

			return $depot;
		}
}