Exemplo n.º 1
0
 public function __construct($field, $label, $query, $keysField, $valuesField, $default = "", $emptyValue = "Selecione")
 {
     $this->setField($field);
     $this->setLabel($label);
     $this->emptyValue = $emptyValue;
     $this->keysField = $keysField;
     $this->valuesField = $valuesField;
     $model = new ModelAbstract();
     $res = $model->fetchAll($query);
     if (!empty($res)) {
         $this->data = $res;
     }
 }
Exemplo n.º 2
0
 /**
  * @param $directoryName
  * @param string $modelName
  * @param bool $useRealPath
  * @return ModelList
  * @throws Exception\RuntimeException
  */
 public static function fromDirectory($directoryName, $modelName = 'HealthCheck\\Model\\Service', $useRealPath = false)
 {
     $useRealPath = (bool) $useRealPath;
     if ($useRealPath) {
         $path = $directoryName;
     } else {
         $pathsArray = array(ModelAbstract::getRootPath(), $directoryName);
         $path = implode(DIRECTORY_SEPARATOR, $pathsArray);
     }
     if (!is_dir($path)) {
         throw new Exception\RuntimeException(sprintf('Directory "%s" (origin "%s") cannot be found relative to the working directory', $path, $directoryName));
     }
     $files = array();
     foreach (scandir($path) as $item) {
         if (preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $item)) {
             continue;
         }
         if (!is_file($path . DIRECTORY_SEPARATOR . $item)) {
             continue;
         }
         $pathInfo = pathinfo($item);
         if (!in_array($pathInfo['extension'], self::$extensions, true)) {
             continue;
         }
         $files[] = $path . DIRECTORY_SEPARATOR . $item;
     }
     return new ModelList($files, $modelName, true);
 }
Exemplo n.º 3
0
 /**
  * State Change notifier
  *
  * @param  string 	$name  The state name being changed
  * @return void
  */
 public function onStateChange($name)
 {
     parent::onStateChange($name);
     //If limit has been changed, adjust offset accordingly
     if ($name == 'limit') {
         $limit = $this->getState()->limit;
         $this->getState()->offset = $limit != 0 ? floor($this->getState()->offset / $limit) * $limit : 0;
     }
 }
Exemplo n.º 4
0
 /**
  * @since 4.8.1
  * @param callable $data The {@link set_function() function} to give to the command.
  */
 public function __construct($data = array())
 {
     if (is_callable($data, true)) {
         $data = array('function' => $data);
     }
     if (isset($data['function'])) {
         $this->setFunction($data['function']);
         unset($data['function']);
     }
     if (isset($data['args'])) {
         $this->setArgs($data['args']);
         unset($data['args']);
     }
     parent::__construct($data);
 }
Exemplo n.º 5
0
 /**
  *
  * {@inheritDoc}
  * @see \Spark\Project\DataMapper\MapperAbstract::populate()
  */
 protected function populate(ModelAbstract $model, array $data)
 {
     if (empty($data)) {
         return null;
     }
     // Populate the properties on the UserModel. I could use and __set for this
     $model->setId($data['id']);
     $model->setName($data['name']);
     $model->setRole($data['role']);
     $model->setEmail($data['email']);
     $model->setPhone($data['phone']);
     $model->setCreatedAt($data['created_at']);
     $model->setUpdatedAt($data['updated_at']);
     $model->setToken($data['token']);
     return $model;
 }
Exemplo n.º 6
0
 /**
  * Get the model context
  *
  * @return  ModelContext
  */
 public function getContext()
 {
     $context = new ModelContextDatabase(parent::getContext());
     $context->setQuery($this->getObject('lib:database.query.select'));
     return $context;
 }
Exemplo n.º 7
0
 /**
  * Constructor for ModelCustomer
  */
 public function __construct()
 {
     parent::__construct();
     $this->table = 'product';
     $this->tableFieldsMap = array('id' => 'id', 'title' => 'title', 'price' => 'price', 'sku' => 'sku', 'code' => 'code', 'tax' => 'tax', 'image' => 'image');
 }
Exemplo n.º 8
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Spark\Project\DataMapper\MapperAbstract::populate()
  */
 protected function populate(ModelAbstract $model, array $data)
 {
     if (empty($data)) {
         return null;
     }
     // Populate the properties on the ShiftModel. I could use and __set for this
     $model->setId($data['id']);
     $model->setManagerId($data['manager_id']);
     $model->setEmployeeId($data['employee_id']);
     $model->setBreak($data['break']);
     $model->setStartTime($data['start_time']);
     $model->setEndTime($data['end_time']);
     $model->setCreatedAt($data['created_at']);
     $model->setUpdatedAt($data['updated_at']);
     return $model;
 }
Exemplo n.º 9
0
 /**
  * Constructor for ModelCustomer
  */
 public function __construct()
 {
     parent::__construct();
     $this->table = 'customer';
     $this->tableFieldsMap = array('id' => 'id', 'created' => 'created', 'email' => 'email', 'hashedPassword' => 'hashedPassword', 'modified' => 'modified');
 }
Exemplo n.º 10
0
 /**
  * Constructor for ModelCard
  */
 public function __construct()
 {
     parent::__construct();
     $this->table = 'customercard';
     $this->tableFieldsMap = array('id' => 'id', 'created' => 'created', 'last4digits' => 'last4digits', 'modified' => 'modified', 'token' => 'token', 'customer_id' => 'customer_id');
 }
Exemplo n.º 11
0
    public function display()
    {
        try {
            $this->processButtons();
            $smarty_ListaDados = new XSmarty();
            $dadosTabela = array();
            $this->applyFilters();
            $whereList = $this->listaDb->getWhereList();
            if (empty($whereList) && $this->filterRequired) {
                throw new \Xlib\XListaDados\Exception_EmptySearchFilter("Favor forneça ao menos um argumento de busca ");
            }
            if (!empty($this->permission) && !$this->hasPermission()) {
                $message = "Desculpe, você não tem permissão suficiente para acessar o recurso solicitado.";
                return '
                <div style="min-width:500px;background:#FFFAFA;padding:10px;min-height:100px;text-align:center;margin-left:auto;margin-right:auto;text-align:center;color:#F00;font-family:verdana;font-size:12px;margin:10px;">
					<div style="display:block;text-align:left;">
						<pre style="border:2px solid #D00;font-size:1.3em;color:#D00;padding:10px;"> <span class="glyphicon glyphicon-warning-sign"></span> ' . $message . '</pre>
					</div>
				</div>
                ';
            }
            $this->setFiltrosOrdem();
            if ($this->ListaDadosDisplay !== null) {
                return $this->ListaDadosDisplay;
            }
            $this->queryCount = $this->listaDb->queryCount();
            $this->setDados();
            $totalRegistros = $this->queryCount;
            $totalPaginas = ceil($this->queryCount / $this->linhasPorTabela);
            $paginacao['inicio'] = $paginacao['anterior'] = $paginacao['proxima'] = $paginacao['fim'] = '_off';
            if ($this->paginaAtual > 1) {
                $paginacao['inicio'] = $paginacao['anterior'] = '_on';
            }
            if ($this->paginaAtual < $totalRegistros / $this->linhasPorTabela) {
                $paginacao['fim'] = $paginacao['proxima'] = '_on';
            }
            $linha = 0;
            $checkboxValues = array();
            if (!empty($this->dadosQuery)) {
                foreach ($this->dadosQuery as $registro) {
                    $url = '';
                    if (sizeof($this->checkbox) != 0) {
                        $checkboxValues[$linha]['valor'] = $registro[$this->checkbox['valor']];
                        $checkboxValues[$linha]['display'] = 'none';
                        if (!empty($registro[$this->checkbox['campoComparacao']])) {
                            eval("\$condicaoDisplay = '" . $registro[$this->checkbox['campoComparacao']] . "'" . $this->checkbox['condicao'] . ";");
                            if ($condicaoDisplay) {
                                $checkboxValues[$linha]['display'] = '';
                            }
                        }
                    }
                    /**
                     * CRIA OS PARAMETROS PARA ENVIAR PARA O BOTÃO ANTIGO
                     * @TODO: VERIFICAR A NECESSIDADE DO FOREACH ABAIXO E CODIGOS NA SEQUENCIA
                     *
                     */
                    foreach ($this->getCampos() as $campo) {
                        if ($campo->getTipoSaida() != "T") {
                            $url .= $campo->getNome() . "=" . str_replace("'", " ", $registro[$campo->getNome()]) . "&";
                        }
                        if ($campo->getTipoSaida() != "P") {
                            if ($campo->getFormat() == "S") {
                                $dadosTabela[$linha][$campo->getNome()] = number_format($registro[$campo->getNome()], 2, '.', '');
                            } else {
                                $dadosTabela[$linha][$campo->getNome()] = $registro[$campo->getNome()];
                            }
                        }
                        foreach ($this->condicao as $key => $cond) {
                            if (!isset($condicao[$key])) {
                                $condicao[$key]['condicao'] = trim($cond['condicao']);
                                $condicao[$key]['STATUS'] = FALSE;
                            }
                            if (eregi($campo->getNome() . " ", $condicao[$key]['condicao'])) {
                                $condicao[$key]['condicao'] = str_replace($campo->getNome(), "'" . $registro[$campo->getNome()] . "'", $condicao[$key]['condicao']);
                                $condicao[$key]['STATUS'] = TRUE;
                            }
                        }
                    }
                    $dadosTabela[$linha]["Style"] = "";
                    if (!empty($condicao)) {
                        foreach ($condicao as $key => $cond) {
                            if ($cond['STATUS']) {
                                eval("\$resultcon = " . $cond['condicao'] . "; ");
                                if ($resultcon) {
                                    $dadosTabela[$linha]["Style"] = $this->condicao[$key]['style'];
                                    if (is_array($this->condicao[$key]['acao'])) {
                                        $hiddenimg = $this->condicao[$key]['acao'];
                                    }
                                }
                            }
                        }
                    }
                    unset($condicao);
                    foreach ($this->getAcoes() as $acao) {
                        $viewacao = true;
                        if (is_array($hiddenimg) && in_array($acao->getImagem(), $hiddenimg)) {
                            $viewacao = false;
                        }
                        $acao->setParametros(substr($url, 0, strlen($url) - 1));
                        $acaoComLink = new XAcao($acao->getImagem(), $acao->getHref(), $acao->getAlt(), $acao->getLabel(), $acao->getOutros(), $acao->getParametros(), $viewacao);
                        $dadosTabela[$linha]['acoes'][] = $acaoComLink;
                        unset($acaoComLink);
                    }
                    unset($hiddenimg);
                    $linha++;
                }
            }
            foreach ($this->getCampos() as $campo) {
                if ($campo->getTipoSaida() != "P") {
                    $temp = $campo;
                    $camposTabela[] = $temp;
                    $this->incrementTotColum();
                    unset($temp);
                }
            }
            $optionsComboPagina = $this->montaOptionComboPagina($totalPaginas);
            $smarty_ListaDados->assign("UsaPaginacao", $this->paginacao);
            $smarty_ListaDados->assign("ordenacao", $this->ordenacao);
            $smarty_ListaDados->assign("paginacao", $paginacao);
            // seta o status das imagens
            $smarty_ListaDados->assign("listaId", $this->id);
            $smarty_ListaDados->assign("arr_campos_exibicao", $camposTabela);
            $smarty_ListaDados->assign("order", $this->setFiltrosOrdem());
            $smarty_ListaDados->assign("optionsComboPagina", $optionsComboPagina);
            $smarty_ListaDados->assign('comboPagina', $this->comboPagina);
            $smarty_ListaDados->assign('UsaBackgroundIndex', $this->UsaBackgroundIndex);
            $smarty_ListaDados->assign('query', \Xlib\ModelAbstract::queryBeautifier($this->getQuery()));
            //$smarty_ListaDados->assign("corTrue",COR_TRUE);
            //$smarty_ListaDados->assign("corFalse",COR_FALSE);
            //$smarty_ListaDados->assign("corOnMouseOver",COR_OVER);
            $smarty_ListaDados->assign("tableClassList", $this->tableClassList);
            $smarty_ListaDados->assign("tableTitle", $this->tableTitle);
            $smarty_ListaDados->assign("arr_campos_exibicao_values", $dadosTabela);
            $smarty_ListaDados->assign("qry_pag_inicio", $this->paginaAtual);
            $smarty_ListaDados->assign("qry_pag_paginas", ceil($totalPaginas));
            $smarty_ListaDados->assign("qtd_linha", $linha);
            $smarty_ListaDados->assign("qry_pag_registros", $totalRegistros);
            $smarty_ListaDados->assign("checkboxValues", $checkboxValues);
            $smarty_ListaDados->assign("showLineCounter", $this->showLineCounter);
            $checkcol = sizeof($this->checkbox) != 0 ? 1 : 0;
            if (!$this->showLineCounter) {
                $checkcol--;
            }
            $smarty_ListaDados->assign("total_colunas", $this->totColum + $checkcol);
            $smarty_ListaDados->assign("AutoDetalhes", $this->AutoDetalhes);
            $smarty_ListaDados->assign("AutoDetalhesStr", $this->AutoDetalhesStr);
            $smarty_ListaDados->assign("checkbox", $this->checkbox);
            $smarty_ListaDados->assign("createPageLink", $this->createPageLink);
            // link da página de inserir registro caso não tenha sido encontrado nenhum
            $db = \Xlib\ModelAbstract::getDB();
            $pagina = $_SERVER['REQUEST_URI'];
            if (!isset($_GET['paginacao' . $this->id])) {
                $_GET['paginacao' . $this->id] = '1';
            }
            if (!isset($_GET['orderCampo' . $this->id])) {
                $_GET['orderCampo' . $this->id] = '1';
            }
            $hidden = "<input type=\"hidden\" name=\"paginacao" . $this->id . "\" value=\"" . $_GET['paginacao' . $this->id] . "\">" . "<input type=\"hidden\" name=\"orderCampo" . $this->id . "\" value=\"" . $_GET['orderCampo' . $this->id] . "\">";
            foreach ($_GET as $key => $value) {
                if ($key === 'orderCampo' . $this->id || $key === 'paginacao' . $this->id) {
                    continue;
                }
                $hidden .= '<input type="hidden" name="' . $key . '" value="' . $value . '">';
            }
            $javas = '<form action="' . $pagina . '" method="get" name="' . $this->id . '" id="' . $this->id . '">' . $hidden . '</form>' . '<form action="' . $pagina . '" method="get" name="paginacaoform' . $this->id . '" id="paginacao' . $this->id . '">' . $hidden . '</form>
<script language="javascript">

    function ordenacao' . $this->id . '(campo,ordem){
        document.' . $this->id . '.orderCampo' . $this->id . '.value = campo+":"+ordem;
        document.' . $this->id . '.submit();
    }

    function goToPage' . $this->id . '() {
        var paginaAtual = document.paginacaoform' . $this->id . '.paginacao' . $this->getId() . '.value
        var proximaPagina = window.prompt("Digite o número da página" , paginaAtual ) ;

        proximaPagina = proximaPagina.replace(/[^\\d]+/,\'\');
        if ( proximaPagina === "" ) return false ;
        proximaPagina = parseInt ( proximaPagina , 10 );

        if ( paginaAtual === proximaPagina ) return false ;
        if ( proximaPagina <= 0 ) return false ;
        if ( proximaPagina > ' . $totalPaginas . ' ) return false ;

        document.paginacaoform' . $this->id . '.paginacao' . $this->getId() . '.value = proximaPagina;
        document.paginacaoform' . $this->id . '.submit();
    }

    function pagina' . $this->id . ' (variavel){

        var paginaAtual = ' . $this->paginaAtual . ' ;

        if ( variavel === "inicio" ) {
            paginaAtual = 1;
        } else if ( variavel === "anterior" ) {
            paginaAtual--;
            if ( paginaAtual < 1 ) paginaAtual = 1 ;
        } else if ( variavel === "proximo" ) {
            paginaAtual++;
            if ( paginaAtual > ' . $totalPaginas . ' ) paginaAtual = ' . $totalPaginas . ' ;
        } else if ( variavel === "fim" ) {
            paginaAtual = ' . $totalPaginas . ';
        }

        document.paginacaoform' . $this->id . '.paginacao' . $this->getId() . '.value = paginaAtual;
        document.paginacaoform' . $this->id . '.submit();
    }
</script>';
            $smarty_ListaDados->assign("javascriptListaDados", $javas);
            $template = empty($this->template) ? XListaDados::$defaultTemplate : $this->template;
            $ListaDadosDisplay = $smarty_ListaDados->getDisplay(dirname(__FILE__) . "/view/" . $template . ".phtml");
            $this->ListaDadosDisplay = $ListaDadosDisplay;
            return $this->ListaDadosDisplay;
        } catch (\Xlib\XListaDados\Exception_EmptySearchFilter $err) {
            $smarty_ListaDados->assign('mensagem', $err->getMessage());
            return $smarty_ListaDados->getDisplay(dirname(__FILE__) . "/view/XListaDadosEmpty.phtml");
        } catch (Exception $err) {
            $backtrace = $errorMessage = $query = $errorDetail = $dbLastQuery = $dbAccess = $connectorReport = '';
            // $errorMessage = translateError ( $err->getMessage ( ) );
            $errorMessage = $err->getMessage();
            if (DEBUG) {
                $backtrace = print_r(debug_backtrace(), true);
                $errorDetail = $err->getTraceAsString();
                $connectorReport = ModelAbstract::dumpQueries();
                $dbLastQuery = $this->listaDb->getDB()->last_query;
            }
            $smarty_ListaDados->assign('connectorReport', $connectorReport);
            $smarty_ListaDados->assign('dbLastQuery', $dbLastQuery);
            $smarty_ListaDados->assign('debug', DEBUG);
            $smarty_ListaDados->assign('errorMessage', $errorMessage);
            //            $smarty_ListaDados->assign ( 'errorMessage' , translateError ( $errorMessage ) ) ;
            $smarty_ListaDados->assign('errorDetail', $errorDetail);
            $smarty_ListaDados->assign('backtrace', $backtrace);
            return $smarty_ListaDados->getDisplay(dirname(__FILE__) . "/view/XListaDadosException.phtml");
        }
    }
Exemplo n.º 12
0
 /**
  * Constructor
  *
  * @param  ObjectConfig $config    An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     $this->_entity = $this->getObject('lib:model.entity.immutable');
 }
Exemplo n.º 13
0
 public function closeConnect()
 {
     ModelAbstract::$db->disconnect();
     ModelAbstract::$db = null;
 }
Exemplo n.º 14
0
 /**
  * Constructor for ModelPayment
  */
 public function __construct()
 {
     parent::__construct();
     $this->table = 'payment';
     $this->tableFieldsMap = array('VendorTxCode' => 'vendorTxCode', 'AddressResult' => 'addressResult', 'AddressStatus' => 'addressStatus', 'Amount' => 'amount', 'AVSCV2' => 'avsCv2', 'Basket' => 'basket', 'BasketXML' => 'basketXml', 'BillingAddress1' => 'billingAddress1', 'BillingAddress2' => 'billingAddress2', 'BillingCity' => 'billingCity', 'BillingCountry' => 'billingCountry', 'BillingFirstnames' => 'billingFirstnames', 'BillingPhone' => 'billingPhone', 'BillingPostCode' => 'billingPostCode', 'BillingState' => 'billingState', 'BillingSurname' => 'billingSurname', 'CapturedAmount' => 'capturedAmount', 'CardType' => 'cardType', 'CAVV' => 'cavv', 'CreateToken' => 'createToken', 'created' => 'created', 'Currency' => 'currency', 'CustomerEMail' => 'customerEmail', 'CV2Result' => 'cv2Result', 'DeliveryAddress1' => 'deliveryAddress1', 'DeliveryAddress2' => 'deliveryAddress2', 'DeliveryCity' => 'deliveryCity', 'DeliveryCountry' => 'deliveryCountry', 'DeliveryFirstnames' => 'deliveryFirstnames', 'DeliveryPhone' => 'deliveryPhone', 'DeliveryPostCode' => 'deliveryPostCode', 'DeliveryState' => 'deliveryState', 'DeliverySurname' => 'deliverySurname', 'ExpiryDate' => 'expiryDate', 'AllowGiftAid' => 'giftAid', 'Last4Digits' => 'last4Digits', 'modified' => 'modified', 'PayerId' => 'payerId', 'PayerStatus' => 'payerStatus', 'PostCodeResult' => 'postCodeResult', 'RelatedVendorTxCode' => 'relatedVendorTxCode', 'SecurityKey' => 'securityKey', 'Status' => 'status', 'StatusDetail' => 'statusMessage', 'Surcharge' => 'surcharge', '3DSecureStatus' => 'threeDSecureStatus', 'Token' => 'token', 'TxType' => 'transactionType', 'TxAuthNo' => 'txAuthNo', 'VPSTxId' => 'vpsTxId', 'BankAuthCode' => 'bankAuthCode', 'DeclineCode' => 'declineCode', 'FraudResponse' => 'fraudResponse');
 }
Exemplo n.º 15
0
 /**
  * Action remove all the customers DIRECT mode
  */
 public function actionDeleteAllCustomers()
 {
     HelperCommon::clearStore('account');
     $sagepayToken = new SagepayToken($this->sagepayConfig);
     $cardTokens = ModelAbstract::factory('Card')->getAll();
     foreach ($cardTokens as $card) {
         $sagepayToken->remove($card->token);
     }
     $view = new HelperView('admin/deleted');
     $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'numDeleted' => ModelAbstract::factory('Customer')->deleteAll()));
     $view->render();
 }
Exemplo n.º 16
0
 /**
  * Action to view basket page
  */
 public function actionBasket()
 {
     $this->checkAccount();
     $message = '';
     $selectedProducts = array();
     // Check if form was submitted
     if (count(filter_input_array(INPUT_POST))) {
         $selectedProducts = array();
         // Fill selected product from request
         foreach (array_keys(filter_input_array(INPUT_POST)) as $key) {
             $matches = array();
             if (preg_match('/^quantity([0-9]*)$/', $key, $matches) && isset($matches[1])) {
                 $selectedProducts[$matches[1]] = filter_input(INPUT_POST, $key, FILTER_VALIDATE_FLOAT);
             }
         }
         HelperCommon::clearStore('products');
         // Check if was select at least 1 item
         if ($this->checkProducts($selectedProducts)) {
             HelperCommon::setStore('products', $selectedProducts);
             $this->redirect($this->integrationType, $this->integrationType == SAGEPAY_DIRECT ? 'basket_checkout' : 'details');
         } else {
             $this->error = true;
             $message = 'You did not select any items to buy. Please select at least 1 item.';
         }
     }
     $productsRows = ModelAbstract::factory('Product')->getAll();
     // Create list of products for view
     $products = array();
     foreach ($productsRows as $row) {
         $products[] = array('id' => $row->id, 'title' => $row->title, 'price' => $row->price, 'tax' => $row->tax, 'image' => $row->image);
     }
     // Render view basket
     $view = new HelperView('common/basket');
     $view->setData(array('actionUrl' => url(array($this->integrationType, 'basket')), 'backUrl' => $this->integrationType == SAGEPAY_FORM ? url(array('form')) : url(array($this->integrationType, 'welcome')), 'message' => $message, 'error' => $this->error, 'products' => $products, 'selectedProducts' => $selectedProducts, 'env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'currency' => $this->sagepayConfig->getCurrency(), 'integrationType' => $this->integrationType));
     $view->render();
 }
Exemplo n.º 17
0
 /**
  * Action card page for direct payment
  */
 public function actionCard()
 {
     $message = '';
     // Check if form was submitted
     if (count(filter_input_array(INPUT_POST))) {
         $useToken = filter_input(INPUT_POST, 'useToken');
         $giftAid = filter_input(INPUT_POST, 'giftAid');
         $card = array('cardType' => filter_input(INPUT_POST, 'cardType'), 'cardNumber' => filter_input(INPUT_POST, 'cardNumber'), 'cardHolder' => filter_input(INPUT_POST, 'cardHolder'), 'startDate' => filter_input(INPUT_POST, 'startDate'), 'expiryDate' => filter_input(INPUT_POST, 'expiryDate'), 'cv2' => filter_input(INPUT_POST, 'cv2'), 'giftAid' => !!$giftAid);
         $cardDetails = new SagepayCardDetails();
         $this->_populateCardDetails($cardDetails, $card);
         // Check cardType
         if ($card['cardType'] == 'PAYPAL') {
             $errors = array();
         } else {
             $errors = $cardDetails->validate();
         }
         $hMessage = new HelperMessage();
         $message = $hMessage->getAllMessages($errors, array('cardNumber' => 'Card Number', 'cardHolder' => 'Card Holder Name', 'startDate' => 'Start Date', 'expiryDate' => 'Expiry Date', 'cv2' => 'Card Verification Value'));
         // Check if card data was failed
         if ($errors) {
             $this->error = true;
             $message = "Sorry, the following problems were found: " . $message;
         } else {
             if ($useToken) {
                 $account = HelperCommon::getStore('account');
                 $sagepayToken = new SagepayToken($this->sagepayConfig);
                 $token = $sagepayToken->register($card);
                 if (!$token) {
                     $this->helperError('Card Details are invalid ', url(array('direct', 'card')));
                     exit;
                 }
                 ModelAbstract::factory('Card')->insert(array('last4digits' => SagepayUtil::getLast4Digits(filter_input(INPUT_POST, 'cardNumber')), 'token' => $token, 'customer_id' => $account['id']));
                 $account['token'] = $token;
                 HelperCommon::setStore('account', $account);
                 $card = array('cardType' => '', 'cardNumber' => '', 'cardHolder' => '', 'startDate' => '', 'expiryDate' => '', 'cv2' => filter_input(INPUT_POST, 'cv2'), 'giftAid' => $giftAid);
             }
             HelperCommon::setStore('card', $card);
             $this->redirect('direct', 'confirm');
         }
     }
     // render view card
     $view = new HelperView('direct/card');
     $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'error' => $this->error, 'message' => $message, 'allowGiftAid' => $this->sagepayConfig->getAllowGiftAid()));
     $view->render();
 }
Exemplo n.º 18
0
}
define('ST_DIR', ENGINE_DIR . "/modules/Statement");
require_once ST_DIR . '/Interfaces/IEventSubscriber.php';
require_once ST_DIR . '/includes/functions.php';
require_once ST_DIR . '/Classes/Request.php';
require_once ST_DIR . '/Classes/Session.php';
require_once ST_DIR . '/Controller/ControllerAbstract.php';
require_once ST_DIR . '/Controller/FrontController.php';
require_once ST_DIR . '/Model/ModelAbstract.php';
require_once ST_DIR . '/Model/Statement.php';
require_once ST_DIR . '/Model/Comment.php';
require_once ST_DIR . '/Classes/Events.php';
require_once ST_DIR . '/Classes/MailsEvent.php';
require_once ST_DIR . '/Classes/SubscribeEvent.php';
mb_internal_encoding($config['charset']);
ModelAbstract::$db = $db;
$request = new Request();
$front = new FrontController($request, $member_id);
$front->setTpl($tpl);
$js_array[] = 'engine/modules/Statement/Resources/js/statement.js';
try {
    $front->dispatch();
} catch (Exception $e) {
    switch ($e->getCode()) {
        case 404:
            header("HTTP/1.0 404 Not Found");
            $front->msg('Error', $e->getMessage(), 'error');
            break;
        default:
            $front->msg('Error', $e->getMessage(), 'error');
            break;
Exemplo n.º 19
0
 public function __destruct()
 {
     ModelAbstract::$instances--;
     if (ModelAbstract::$instances > 0) {
         return false;
     }
     if (empty(ModelAbstract::$queryHistory)) {
         return false;
     }
     if (ModelAbstract::$hasError && DEBUG === TRUE || SHOW_SQL_QUERIES === true) {
         echo ModelAbstract::dumpQueries() . "<br><br>";
         ModelAbstract::$queryHistory = null;
     }
 }