<?php
 namespace App\Form\Input; class Select_CreditCards extends \Engine\Form\Input\Select { protected $includeAgency = false; protected $includeIdCorporates = []; protected $includeIdCustomers = []; protected $includeIdManualCards = []; protected $includeNewCard = false; public function addAgencyCards($include = true) { $this->includeAgency = $include; } public function addCorporatesCards(array $idCorporates) { $this->includeIdCorporates = $idCorporates; } public function addCustomersCards(array $idCustomers) { $this->includeIdCustomers = $idCustomers; } public function addManualCards(array $idCreditCards) { $this->includeIdManualCards = $idCreditCards; } public function addNewCard($include=true) { $this->includeNewCard = $include; } protected function determinePossibleValues() { $values = []; $_LANG = \App\Loader_Lang::getInstance()->getAll(); $creditCardsStorage = new \App\Utils\CreditCard\Storage(); if ($this->includeAgency) { $agencyCcsObj = new \App\EntityList\AgencyCreditCards(); $agencyCcsObj->setColumns(['name', 'idCreditCard']); $agencyCcs = $agencyCcsObj->exportRecords(); if ($agencyCcs) { $values[ $_LANG['offers']['formOfCashing']['CcTypes']['agency'] ] = []; foreach ($agencyCcs as $agCcDet) { $ccDet = $creditCardsStorage->getCard($agCcDet['idCreditCard']); $values['Agency']['agency_'.$agCcDet['id']] = $agCcDet['name'].': '.($ccDet['company']?($ccDet['company'].' - '):'') . $ccDet['truncatedNumber']; } } } if ($this->includeIdCorporates) { $corpCcsObj = new \App\EntityList\CorporateCreditCards(); $corpCcsObj->setColumns(['idCreditCard', 'idCorporate']); $corpCcsObj->setFilter('idCorporate', 'IN', $this->includeIdCorporates); $corpCcsObj->setOrderBy('idCorporate', 'ASC'); $corpCcs = $corpCcsObj->exportRecords(); if ($corpCcs) { foreach ($corpCcs as $corpCcDet) { $cat = $_LANG['offers']['formOfCashing']['CcTypes']['corporate'].' - '.\Entity\Corporate::select($corpCcDet['idCorporate'])->alias; if (!array_key_exists($cat, $values)) { $values[$cat] = []; } $ccDet = $creditCardsStorage->getCard($corpCcDet['idCreditCard']); $values[$cat]['corporate_'.$corpCcDet['id']] = ($ccDet['company']?($ccDet['company'].' - '):'') . $ccDet['truncatedNumber']; } } } if ($this->includeIdCustomers) { $custCcsObj = new \App\EntityList\CustomerCreditCards(); $custCcsObj->setColumns(['idCreditCard', 'idCustomer']); $custCcsObj->setFilter('idCustomer', 'IN', $this->includeIdCustomers); $custCcsObj->setOrderBy('idCustomer', 'ASC'); $custCcs = $custCcsObj->exportRecords(); if ($custCcs) { foreach ($custCcs as $custCcDet) { $cat = $_LANG['offers']['formOfCashing']['CcTypes']['customer'].' - '.\Entity\Customer::select($custCcDet['idCustomer'])->name; if (!array_key_exists($cat, $values)) { $values[$cat] = []; } $ccDet = $creditCardsStorage->getCard($custCcDet['idCreditCard']); $values[$cat]['customer_'.$custCcDet['id']] = ($ccDet['company']?($ccDet['company'].' - '):'') . $ccDet['truncatedNumber']; } } } if ($this->includeIdManualCards) { foreach ($this->includeIdManualCards as $idCreditCard) { $cat = $_LANG['offers']['formOfCashing']['CcTypes']['manual']; if (!array_key_exists($cat, $values)) { $values[$cat] = []; } $ccDet = $creditCardsStorage->getCard($idCreditCard); $values[$cat]['manual_'.$idCreditCard] = ($ccDet['company']?($ccDet['company'].' - '):'') . $ccDet['truncatedNumber']; } } if ($this->includeNewCard) { $values['new'] = $_LANG['offers']['formOfCashing']['CcTypes']['new']; } return $values; } } 