<?php
namespace Models;

class bonus_pay {
	public $f3, $sets, $config, $nofr=true;

	function __construct($f3, $sets, $config) {
		$this->f3=$f3;
		$this->sets=$sets;
		if(!isset($config['onlyThis']) || $config['onlyThis']!=1) {
			$config['onlyThis']=1;
		}
		if(!isset($config['bonusPay']) || $config['bonusPay']!=1) {
			$config['bonusPay']=1;
		}

		if(!isset($config['PrintSalesReceipt']) || ($config['PrintSalesReceipt']!=0 && $config['PrintSalesReceipt']!=1)) {
			$config['PrintSalesReceipt']=1;
		}

		if(!isset($config['fiscalization']) || ((int)$config['fiscalization']!=-1 && (int)$config['fiscalization']!=0 && (int)$config['fiscalization']!=1 && (int)$config['fiscalization']!=2)) {
			$config['fiscalization']=-1;
		}
		$this->config=$config;
		if((int)$this->config['fiscalization']<0) {
			$this->nofr=true;
		}
		else {
			$this->nofr=false;
		}
	}

	function ticket($type, $sum, $return_bt=null, $lines=array()) {
		return array(
			'success'=>true,
			'txt'=>'',
			'slip'=>'',
			'pan'=>0,
			'transid'=>0,
			'authcode'=>0,
			'nofr'=>$this->nofr,
			'create_receipt'=>$this->f3->get('receipt_add_bonus'),
			'bonus_add'=>0,
			'fiscalization_type'=>$this->config['fiscalization'],
			'sales_receipts'=>$this->config['PrintSalesReceipt']
		);
	}

	function z($change) {
		$cheq=$this->sets['title']."\nСмена успешно закрыта";
		return array(
			'success'=>true,
			'txt'=>'',
			'slip'=>$cheq,
			'pan'=>0,
			'transid'=>0,
			'authcode'=>0
		);
	}

	function x($change) {
		$cheq='';
		return array(
			'success'=>true,
			'txt'=>'',
			'slip'=>'',
			'pan'=>0,
			'transid'=>0,
			'authcode'=>0
		);
	}
}