/** * @param string $name * @param string $label * @param string $mask * @param int $maxLength * @return Mask */ public function addMask($name, $label = NULL, $mask = NULL, $maxLength = NULL) { $control = new Mask($label, $maxLength); if ($mask) { $control->setMask($mask); } return $this[$name] = $control; }
public function __construct($name, $label, $model) { // parent::__construct($name, $label, $model); // $this->addAttribute(['style' => 'text-transform: uppercase;']); }
public function __construct($name, $label, $model) { // parent::__construct($name, $label, $model); // $this->addAttribute(['style' => 'text-align: right;']); }
public function afterFind($results, $primary = false) { foreach ($results as $key => $val) { if (isset($val['WaitingPeriod']['DATA_CARENCIA'])) { $results[$key]['WaitingPeriod']['DATA_CARENCIA'] = Mask::printDateFromSQLServer($val['WaitingPeriod']['DATA_CARENCIA']); } } return $results; }
public function afterFind($results, $primary = false) { foreach ($results as $key => $val) { if (isset($val['PatientPhone']['number'])) { $results[$key]['PatientPhone']['number'] = Mask::phone($val['PatientPhone']['number']); } } return $results; }
function calcFrete($cepRemetente, $cepDestinatario) { if (empty($this->Produtos)) { throw new CorreiosHellperException('Nenhum produto foi adicionado para o cálculo.'); } $calc = max(1, $this->getPeso() / 30); $dados = ['StrRetorno' => 'xml', 'nCdEmpresa' => '', 'sDsSenha' => '', 'nVlDiametro' => 0, 'nCdServico' => '41106,40010', 'sCepOrigem' => preg_replace('/[^0-9]/', NULL, $cepRemetente), 'sCepDestino' => preg_replace('/[^0-9]/', NULL, $cepDestinatario), 'nVlComprimento' => 16, 'nVlLargura' => 11, 'nVlAltura' => 2, 'nVlPeso' => max(1, min(30, $this->getPeso())), 'nCdFormato' => 1, 'sCdMaoPropria' => 'N', 'nVlValorDeclarado' => 0, 'sCdAvisoRecebimento' => 'N']; $url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?' . http_build_query($dados); if ($xml = @simplexml_load_file($url)) { $frete = ['pac' => ['codigo' => 41106, 'cepR' => Mask::cep($cepRemetente), 'cepD' => Mask::cep($cepDestinatario), 'valor' => Number::float(Number::float($xml->cServico[0]->Valor, 2) * $calc, 2), 'prazo' => (int) $xml->cServico[0]->PrazoEntrega, 'errorCode' => (string) $xml->cServico[0]->Erro, 'error' => $this->errorMessage($xml->cServico[0]->Erro), 'errorMessage' => str_replace(' Busca CEP', ' <a href="http://www.buscacep.correios.com.br/" target="_blank" ><b>Busca CEP</b></a>', (string) $xml->cServico[1]->MsgErro)], 'sedex' => ['codigo' => 40010, 'cepR' => Mask::cep($cepRemetente), 'cepD' => Mask::cep($cepDestinatario), 'valor' => Number::float(Number::float($xml->cServico[1]->Valor, 2) * $calc, 2), 'prazo' => (int) $xml->cServico[1]->PrazoEntrega, 'errorCode' => (string) $xml->cServico[1]->Erro, 'error' => $this->errorMessage($xml->cServico[1]->Erro), 'errorMessage' => str_replace(' Busca CEP', ' <a href="http://www.buscacep.correios.com.br/" target="_blank" ><b>Busca CEP</b></a>', (string) $xml->cServico[1]->MsgErro)]]; if ($frete['pac']['error']) { throw new CorreiosHellperException($frete['pac']['errorMessage'], (int) $frete['pac']['errorCode']); } return $frete; } else { throw new CorreiosHellperException('Não foi possível calcular o frete.', (int) '-999'); } }
/** * define a mascara que sera aplicada * * @param string $content * */ public function __construct($content = NULL) { parent::__construct(); $this->_mask = '###.###.###-##'; $this->_content = $content; }
function getCelular() { return Mask::telefone($this->Celular); }
public function apply($resource) { // Format @(list(, $size, $type, $corners) = func_get_args()); $size = $size ? (int) $size : 10; $type = (int) $type; $corners = (int) $corners; // Normalize if (!$size) { $size = 10; } if ($corners != self::ALL && $corners != self::TOPLEFT && $corners != self::TOPRIGHT && $corners != self::BOTTOMRIGHT && $corners != self::BOTTOMLEFT) { $corners = self::ALL; } // Get resolution $width = imagesx($resource); $height = imagesy($resource); if ($width === false || $height === false) { throw new Exception("An error was encountered while getting image resolution"); } // Create mask $corner = $this->_createTrueColor($size, $size); imageantialias($corner, true); $white = imagecolorallocate($corner, 255, 255, 255); $gray = imagecolorallocate($corner, 150, 150, 150); $black = imagecolorallocate($corner, 0, 0, 0); imagefill($corner, 0, 0, $white); switch ($type) { case self::BEVELLED: imagefilledarc($corner, $size, $size, $size * 2 + 2, $size * 2 + 2, 180, 270, $gray, IMG_ARC_CHORD); // anti-aliasing imagefilledarc($corner, $size, $size, $size * 2 + 1, $size * 2 + 1, 180, 270, $black, IMG_ARC_CHORD); break; case self::TRUNCATED: break; case self::ROUNDED: default: imagefilledarc($corner, $size, $size, $size * 2 + 2, $size * 2 + 2, 180, 270, $gray, IMG_ARC_PIE); // anti-aliasing imagefilledarc($corner, $size, $size, $size * 2 + 1, $size * 2 + 1, 180, 270, $black, IMG_ARC_PIE); } // Prepare corners to apply if ($corners == self::ALL || $corners == self::TOPLEFT) { $topleft = $corner; } if ($corners == self::ALL || $corners == self::TOPRIGHT) { $topright = imagerotate($corner, 270, 0); } if ($corners == self::ALL || $corners == self::BOTTOMRIGHT) { $bottomright = imagerotate($corner, 180, 0); } if ($corners == self::ALL || $corners == self::BOTTOMLEFT) { $bottomleft = imagerotate($corner, 90, 0); } // Apply corners if (isset($topleft)) { $resource = parent::apply($resource, $topleft, 0); } if (isset($topright)) { $resource = parent::apply($resource, $topright, $width - $size); } if (isset($bottomright)) { $resource = parent::apply($resource, $bottomright, $width - $size, $height - $size); } if (isset($bottomleft)) { $resource = parent::apply($resource, $bottomleft, 0, $height - $size); } // Clean up @imagedestroy($topleft); @imagedestroy($topright); @imagedestroy($bottomright); @imagedestroy($bottomleft); return $resource; }
public function testDecimal() { $decimal = $this->object->decimal(123123123.2, '0.000,0'); var_dump($decimal); $this->assertEquals('123.123.123,2', $decimal); }