<?php
namespace SabaiApps\Directories\Component\PaymentGateway\FieldType;

use SabaiApps\Directories\Component\Field\IField;
use SabaiApps\Directories\Application;
use SabaiApps\Directories\Component\Entity\Type\IEntity;

class OrderFieldType extends AbstractOrderFieldType {

	public function __construct( Application $application, $name ) {
		parent::__construct( $application, $name, __( 'Order Information', 'directories-pro' ) );
	}

	public function fieldTypeSchema( array $settings = array() ) {
		$schema                      = parent::fieldTypeSchema( $settings );
		$schema['columns']['action'] = array(
			'type'    => Application::COLUMN_VARCHAR,
			'length'  => 20,
			'notnull' => true,
			'was'     => 'action',
			'default' => '',
		);
		return $schema;
	}

	public function fieldColumnableInfo( IField $field ) {
		$info          = parent::fieldColumnableInfo( $field );
		$info['total'] = array(
			'label' => __( 'Total', 'directories-pro' ),
		);
		return $info;
	}

	public function fieldColumnableColumn( IField $field, IEntity $entity, $column = '' ) {
		if ( $column === 'total' ) {
			return $this->_application->PaymentGateway_Order_totalAmount( $entity );
		}
		return parent::fieldColumnableColumn( $field, $entity, $column );
	}

	protected function _getStatuses() {
		return $this->_application->PaymentGateway_Order_statuses();
	}

	protected function _getStatusLabel( $status, $html = true, $badge = true ) {
		return $this->_application->PaymentGateway_Order_statusLabel( $status, $html, $badge );
	}
}
