Ejemplo n.º 1
0
 function doc($id, $type)
 {
     $this->load->model('barcode');
     $this->load->model('uuid');
     $this->load->model('comm');
     $uuid = $this->uuid->generate_uuid();
     $barcode = new Barcode();
     $barcode->Barcode39("{$type}-{$id}", $uuid);
     $data = $this->comm->get_info($id, $type);
     $uType = $this->session->userdata('utype');
     if ($data['position'] <= $uType) {
         die('DENIED');
     }
     $data['appeal'] = '';
     if ($data['store_state'] == 'MT' && $data['terminated']) {
         //if state == mt and terminated = true
         $data['appeal'] = "<table style=\"border: solid 1px;\"><tr><td style=\"font-size: 12px;\"><b>If you wish to appeal this discharge, you may present a written statement to your Regional Manager, Human Resources, the Director of Operations, or the President within ten (10) calendar days after you are informed of the discharge.  The written statement shall recite any facts which you believe appropriate.  Your statement will be considered, and you will be advised of a final decision regarding your grievance within thirty (30) calendar days after you initiate the process.</b></td></tr></table><br />";
     }
     $data['agreement'] = '';
     if ($data['terminated'] == 0) {
         $data['agreement'] = "<p>I have read the above disciplinary warning.  I understand what is expected of me to improve my job performance.  Furthermore, I understand my failure to abide by and Company policies or procedure will result in further disciplinary action up to and including termination of my employment.</p>";
     }
     $data['barcode'] = $uuid;
     $output = $this->parser->parse('communication', $data, true);
     $whandle = fopen("/usr/share/cpm/tmp/{$uuid}.html", "w");
     fwrite($whandle, $output);
     fclose($whandle);
     passthru("/usr/share/cpm/bin/wkhtmltopdf-amd64 --footer-right [page]/[topage] -s Letter https://cpm.carischinc.com/cpm/tmp/{$uuid}.html /usr/share/cpm/tmp/{$uuid}.pdf");
     unlink("/usr/share/cpm/tmp/{$uuid}.html");
     unlink("/usr/share/cpm/tmp/{$uuid}.jpg");
     $rhandle = fopen("/usr/share/cpm/tmp/{$uuid}.pdf", "rb");
     $data = stream_get_contents($rhandle);
     fclose($rhandle);
     unlink("/usr/share/cpm/tmp/{$uuid}.pdf");
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Type: application/pdf');
     header('Content-Disposition: inline; filename="example.pdf"');
     echo $data;
 }
Ejemplo n.º 2
0
function pdf_barcode($pdf, $productId, $col, $row)
{
    $product = \Pasteque\ProductsService::get($productId);
    $x = H_MARGIN + $col * COL_SIZE + $col * H_PADDING;
    $y = V_MARGIN + $row * ROW_SIZE + $row * V_PADDING;
    $pdf->SetXY($x, $y);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, utf8_decode($product->reference), 0, 1, "C");
    $pdf->SetXY($x, $y + TEXT_HEIGHT);
    $data = \Barcode::fpdf($pdf, "000000", $pdf->GetX() + BARCODE_WIDTH / 2, $pdf->GetY() + BARCODE_HEIGHT / 2, 0, "ean13", array('code' => $product->barcode), BARCODE_WIDTH / (15 * 7), BARCODE_HEIGHT);
    $pdf->SetXY($x, $y + BARCODE_HEIGHT + TEXT_HEIGHT);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, $product->barcode, 0, 1, "C");
}
 /**
  * Metodo para gerar o arquivo
  * @param string $valor
  * @param string $filename	caminho onde sera salvo o arquivo e nome mais extensao
  * @since 18/12/2012
  */
 public function gerar($valor, $filename, $font1, $marg, $x1, $y1, $height1, $width1, $angle1, $x2, $y2, $x3, $y3)
 {
     $fontSize = $font1;
     // GD1 in px ; GD2 in point
     $marge = $marg;
     // between barcode and hri in pixel
     $x = $x1;
     // barcode center
     $y = $y1;
     // barcode center
     $height = $height1;
     // barcode height in 1D ; module size in 2D
     $width = $width1;
     // barcode height in 1D ; not use in 2D
     $angle = $angle1;
     // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
     $code = $valor;
     // barcode, of course ;)
     $type = 'code128';
     // -------------------------------------------------- //
     //            ALLOCATE GD RESSOURCE
     // -------------------------------------------------- //
     $im = imagecreatetruecolor($x2, $y2);
     $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
     $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
     $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
     $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
     imagefilledrectangle($im, 0, 0, $x3, $y3, $white);
     // -------------------------------------------------- //
     //                      BARCODE
     // -------------------------------------------------- //
     $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
     // -------------------------------------------------- //
     //                        HRI						  //
     // -------------------------------------------------- //
     if (isset($font)) {
         $box = imagettfbbox($fontSize, 0, $font, $data['hri']);
         $len = $box[2] - $box[0];
         Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
         imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
     }
     //header('Content-type: image/gif');
     imagegif($im, $filename);
     //imagegif($image,$this->file);
     imagedestroy($im);
 }
Ejemplo n.º 4
0
 /**
  *
  *
  * @version 0.1 17/05/2011 Initial
  */
 public static function getImage($code)
 {
     $barcode = new Barcode();
     $barcode->getBarcode($code);
 }
 /**
  * mkdir method
  * Crea el código de barras del usuario
  */
 function make_codebar($usuario_id)
 {
     //Default filename
     $filename = "barcode.png";
     $file = $this->rutaUpload . $usuario_id . '/' . $filename;
     $barcode = new Barcode();
     if (file_exists($file)) {
         //echo "El archivo existe¡";
     } else {
         $data_to_encode = $usuario_id;
         // Generate Barcode data
         $barcode->barcode();
         $barcode->setType('C128');
         $barcode->setCode($data_to_encode);
         $barcode->setSize(80, 150);
         // Generates image file on server
         $barcode->writeBarcodeFile($file);
     }
 }
Ejemplo n.º 6
0
 /**
  * Checks if the given barcode has the same book-data as this instance
  * @param  Barcode $compareBarcode The barcode to compare to
  * @return bool                    true if it has the same data, else false
  */
 public function sameBookDataAs($compareBarcode)
 {
     return $this_subject == $compareBarcode->getSubject() && $this->_class == $compareBarcode->getClass() && $this->_bundle == $compareBarcode->getBundle();
 }
Ejemplo n.º 7
0
function DrawBarCode($params, $text, $fx, $fy)
{
    if (!isset($params['image'])) {
        return;
    }
    $img = $params['image'];
    $w = imagesx($img);
    $h = imagesy($img);
    if (isset($params['color'])) {
        $color = $params['color'];
    } else {
        $color = ImageColorAllocate($img, 0x0, 0x0, 0x0);
    }
    if (isset($params['angle'])) {
        $angle = $params['angle'];
    } else {
        $angle = 0.0;
    }
    if (isset($params['height'])) {
        $barheight = $params['height'];
    } else {
        $barheight = 0.2 * $h;
    }
    // about 1/5 of the image size.
    if (isset($params['width'])) {
        $barwidth = $params['width'];
    } else {
        $barwidth = $w / 200;
    }
    // Just a guess.  Works out to be about 3px.
    $type = 'code128';
    $x0 = intval($fx * $w);
    $y0 = intval($fy * $h);
    $data = Barcode::gd($img, $color, $x0, $y0, $angle, $type, array('code' => $text), $barwidth, $barheight);
}
Ejemplo n.º 8
0
 /**
  * Genera il nuovo tesserino per il socio ordinario sulla base della richiesta
  * @return bool(false)|File     Il tesserino del volontario, o false in caso di fallimento
  */
 public function generaTesserinoOrdinario()
 {
     $utente = $this->utente();
     // Verifica l'assegnazione di un codice al tesserino
     if (!$this->haCodice()) {
         $codice = $this->assegnaCodice();
     } else {
         $codice = $this->codice;
     }
     $f = new PDF('tesseriniordinari', "Tesserino_{$codice}.pdf");
     $f->formato = 'cr80';
     $f->orientamento = ORIENTAMENTO_ORIZZONTALE;
     $f->_NOME = $utente->nome;
     $f->_COGNOME = $utente->cognome;
     $f->_CODICEFISCALE = $utente->codiceFiscale;
     $f->_COMITATO = $utente->unComitato(MEMBRO_ORDINARIO)->locale()->formattato;
     $int = "Croce Rossa Italiana<br />{$utente->unComitato(MEMBRO_ORDINARIO)->locale()->nome}";
     $f->_INTESTAZIONE = $int;
     $socio = 'SOCIA';
     if ($utente->sesso == UOMO) {
         $socio = 'SOCIO';
     }
     $f->_SOCIO = $socio;
     $f->_INGRESSO = $utente->ingresso()->format('d/m/Y');
     $f->_CODICE = $codice;
     $scadenza = $this->timestamp + 5 * ANNO;
     $f->_SCADENZA = date('m/Y', $scadenza);
     $barcode = new Barcode();
     $barcode->genera($codice);
     $f->_BARCODE = $barcode->percorso();
     return $f->salvaFile();
 }
                
                <!--  sacado  -->
                <div id="sacado" class="">
                    <div class="">
                         <label>Sacado</label>
                         <?php 
echo $OB->Cliente->Nome . '<br>' . 'CPF: ' . $OB->Cliente->Cpf . '<br>' . $OB->Cliente->Endereco;
?>
                    </div>
                </div>
                
                <!--  codigo_barras  -->
                <div id="codigo_barras" class="">
                    <div>
                        <label>Sacador/Avalista</label>
                        <?php 
echo Barcode::getHtml($OB->geraCodigo());
?>
                    </div>
                    <div class="">
                        <span>Ficha de Compensação</span>
                        <label>Autenticação Mecânica</label>
                    </div>
                </div>
                
                <!--Linha pontilhada para corte-->
                <div class="linha_corte"><label>Corte na linha pontilhada</label></div>
                
            <!--Encerra ficha de compensação-->    
            </div>
Ejemplo n.º 10
0
 /**
  * 	standard 2 of 5 (std25)
  * 	interleaved 2 of 5 (int25)
  * 	ean 8 (ean8)
  * 	ean 13 (ean13)
  * 	upc (upc)
  * 	code 11 (code11)
  * 	code 39 (code39)
  * 	code 93 (code93)
  * 	code 128 (code128)
  * 	codabar (codabar)
  * 	msi (msi)
  * 	datamatrix (datamatrix)
  **/
 public function dataImage($type, $code, $ops)
 {
     if (is_array($code)) {
         $code = $this->setCodeData($code);
     }
     // -------------------------------------------------- //
     //            ALLOCATE GD RESSOURCE
     // -------------------------------------------------- //
     $im = imagecreatetruecolor($this->imageWidth, $this->imageHeigth);
     $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
     $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
     $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
     $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
     imagefilledrectangle($im, 0, 0, $this->imageWidth, $this->imageHeigth, $white);
     // -------------------------------------------------- //
     //                      BARCODE
     // -------------------------------------------------- //
     $data = Barcode::gd($im, $black, $this->x, $this->y, $this->angle, $type, array('code' => $code), $this->width, $this->height);
     $code = implode(' ', str_split($code));
     $fw = imagefontwidth($this->fontSize);
     // width of a character
     $l = strlen($code);
     // number of characters
     $tw = $l * $fw;
     // text width
     $iw = imagesx($im);
     // image width
     $xpos = ($iw - $tw) / 2;
     imagestring($im, $this->fontSize, $xpos, $this->y + 60, $code, $black);
     // -------------------------------------------------- //
     //                        HRI
     // -------------------------------------------------- //
     if (isset($this->font)) {
         $box = imagettfbbox($this->fontSize, 0, $this->font, $data['hri']);
         $len = $box[2] - $box[0];
         Barcode::rotate(-$len / 2, $data['height'] / 2 + $this->fontSize + $this->marge, $this->angle, $xt, $yt);
         imagettftext($im, $this->fontSize, $this->angle, $this->x + $xt, $this->y + $yt, $blue, $this->font, $data['hri']);
     }
     // -------------------------------------------------- //
     //                    MIDDLE AXE
     // -------------------------------------------------- //
     //imageline($im, $this->x, 0, $this->x, 250, $red);
     //imageline($im, 0, $this->y, 250, $this->y, $red);
     // -------------------------------------------------- //
     //                  BARCODE BOUNDARIES
     // -------------------------------------------------- //
     for ($i = 1; $i < 5; $i++) {
         // $this->__drawCross($im, $blue, $data['p'.$i]['x'], $data['p'.$i]['y']);
     }
     // -------------------------------------------------- //
     //                    GENERATE
     // -------------------------------------------------- //
     // header('Content-type: image/gif');
     $temp = tmpfile();
     $metaDatas = stream_get_meta_data($temp);
     $tmpFilename = $metaDatas['uri'];
     imagepng($im, $tmpFilename);
     $fcon = file_get_contents($tmpFilename);
     imagedestroy($im);
     $media = array('type' => 'jpg', 'file' => $fcon);
     $pxiimg = $this->PxHtml->imageData($media, $ops);
     return $pxiimg;
 }
Ejemplo n.º 11
0
Archivo: Barcode.php Proyecto: cicb/tpc
 public static function getCodigo($code)
 {
     $im = imagecreatetruecolor(200, 50);
     $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
     $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
     //imagefilledrectangle($im, 0, 0, 300, 300, $white);
     imagefill($im, 0, 0, $white);
     $data = Barcode::gd($im, $black, 100, 25, 0, 'ean13', array('code' => $code), 2, 40);
     //$data =Barcode::fpdf($im, $black, 125, 125, 0, 'ean13',   array('code'=>$code), 2, 50);
     ob_start();
     imagepng($im);
     $image_data = ob_get_contents();
     ob_end_clean();
     imagedestroy($im);
     echo '<img src="data:image/png;base64,' . base64_encode($image_data) . '" />';
 }
Ejemplo n.º 12
0
     $INPUT_IMAGE_ORIENTATON = intval($_REQUEST['INPUT_IMAGE_ORIENTATON']);
 }
 if (isset($_REQUEST['INPUT_IMAGE_QUALITY'])) {
     $INPUT_IMAGE_QUALITY = intval($_REQUEST['INPUT_IMAGE_QUALITY']);
 }
 if (isset($_REQUEST['INPUT_IMAGE_FORMAT'])) {
     $INPUT_IMAGE_FORMAT = intval($_REQUEST['INPUT_IMAGE_FORMAT']);
 }
 if (isset($_REQUEST['INPUT_IMAGE_OUTPUT'])) {
     $INPUT_IMAGE_OUTPUT = intval($_REQUEST['INPUT_IMAGE_OUTPUT']);
 }
 if (isset($_REQUEST['INPUT_IMAGE_FILE_NAME'])) {
     $INPUT_IMAGE_FILE_NAME = htmlentities(stripslashes(urldecode(trim($_REQUEST['INPUT_IMAGE_FILE_NAME']))), ENT_QUOTES, 'UTF-8');
 }
 try {
     $barcode = new Barcode();
     switch ($INPUT_BARCODE_TYPE) {
         case 1:
             $barcode->type('STD25');
             break;
         case 2:
             $barcode->type('INT25');
             break;
         case 3:
             $barcode->type('EAN8');
             break;
         case 4:
             $barcode->type('EAN13');
             break;
         case 5:
             $barcode->type('UPC');
Ejemplo n.º 13
0
function getBarCodePicture(&$assetOf)
{
    dol_include_once('/asset/php_barcode/php-barcode.php');
    $code = $assetOf->numero;
    $fontSize = 10;
    // GD1 in px ; GD2 in point
    $marge = 10;
    // between barcode and hri in pixel
    $x = 145;
    // barcode center
    $y = 50;
    // barcode center
    $height = 50;
    // barcode height in 1D ; module size in 2D
    $width = 2;
    // barcode height in 1D ; not use in 2D
    $angle = 0;
    // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
    $type = 'code128';
    $im = imagecreatetruecolor(300, 100);
    $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
    $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
    $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
    $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
    imagefilledrectangle($im, 0, 0, 300, 300, $white);
    $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
    if (isset($font)) {
        $box = imagettfbbox($fontSize, 0, $font, $data['hri']);
        $len = $box[2] - $box[0];
        Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
        imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
    }
    $tmpfname = tempnam(sys_get_temp_dir(), 'barcode_pic');
    imagepng($im, $tmpfname);
    imagedestroy($im);
    return $tmpfname;
}
Ejemplo n.º 14
0
    // write the barcode
    $code = $item['fake_barcode'];
    if ($item['barcode']) {
        foreach ($item['barcode'] as $barcode => $quantity) {
            if ($quantity == 1) {
                $code = $barcode;
                break;
            }
        }
    }
    $types = array(8 => 'ean8', 12 => 'upc', 13 => 'ean13');
    $type = $types[strlen($code)];
    if (!$type) {
        $type = 'code39';
    }
    $info = Barcode::fpdf($dummy, '000000', 0, 0, 0, $type, $code, 1 / 72, $basefontsize / 2 / 72);
    Barcode::fpdf($pdf, '000000', $label_width - $left_margin - $info['width'] / 2 - 2 / 72, $label_height - $vmargin - 7 / 72, 0, $type, $code, 1 / 72, $basefontsize / 2 / 72);
    // write the code
    $pdf->SetFontSize($size = $basefontsize / 2);
    $width = $pdf->GetStringWidth($item['code']);
    $pdf->Text($label_width - $width - $left_margin - 2 / 72, $label_height - $vmargin, $item['code']);
}
$tmpfname = tempnam("/tmp", "lab");
if ($_REQUEST['DEBUG']) {
    $pdf->Output("test.pdf", 'I');
    exit;
}
$pdf->Output($tmpfname, 'F');
$printer = LABEL_PRINTER;
shell_exec("lpr -P{$printer} {$tmpfname}");
echo jsonp(array("result" => "Printed."));
Ejemplo n.º 15
0
/**
 *
 */
function caGenerateBarcode($ps_value, $pa_options = null)
{
    $ps_barcode_type = caGetOption('type', $pa_options, 'code128', array('forceLowercase' => true));
    $pn_barcode_height = caConvertMeasurementToPoints(caGetOption('height', $pa_options, '9px'));
    $vs_tmp = null;
    switch ($ps_barcode_type) {
        case 'qr':
        case 'qrcode':
            $vs_tmp = tempnam(caGetTempDirPath(), 'caQRCode');
            $vs_tmp2 = tempnam(caGetTempDirPath(), 'caQRCodeResize');
            if (!defined('QR_LOG_DIR')) {
                define('QR_LOG_DIR', false);
            }
            if ($pn_barcode_height < 1 || $pn_barcode_height > 8) {
                $pn_barcode_height = 1;
            }
            QRcode::png($ps_value, "{$vs_tmp}.png", QR_ECLEVEL_H, $pn_barcode_height);
            return $vs_tmp;
            break;
        case 'code128':
        case 'code39':
        case 'ean13':
        case 'int25':
        case 'postnet':
        case 'upca':
            $o_barcode = new Barcode();
            $vs_tmp = tempnam(caGetTempDirPath(), 'caBarCode');
            if (!($va_dimensions = $o_barcode->draw($ps_value, "{$vs_tmp}.png", $ps_barcode_type, 'png', $pn_barcode_height))) {
                return null;
            }
            return $vs_tmp;
            break;
        default:
            // invalid barcode
            break;
    }
    return null;
}
Ejemplo n.º 16
0
function generate_barcode($type, $data)
{
    require_once PT::$ABSPATH . "/lib/barcode-master/php-barcode.php";
    $font = "./lib/barcode-master/NOTTB___.TTF";
    $fontSize = 10;
    // GD1 in px ; GD2 in point
    $marge = 2;
    // between barcode and hri in pixel
    $y = 25;
    // barcode center
    $height = 50;
    // barcode height in 1D ; module size in 2D
    $width = 2;
    // barcode height in 1D ; not use in 2D
    $angle = 0;
    // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
    $code = $data;
    $type = $type;
    // Precompute digits to set image width
    switch ($type) {
        case 'std25':
        case 'int25':
            $digit = \BarcodeI25::getDigit($code, $crc, $type);
            break;
        case 'ean8':
        case 'ean13':
            $digit = \BarcodeEAN::getDigit($code, $type);
            break;
        case 'upc':
            $digit = \BarcodeUPC::getDigit($code);
            break;
        case 'code11':
            $digit = \Barcode11::getDigit($code);
            break;
        case 'code39':
            $digit = \Barcode39::getDigit($code);
            break;
        case 'code93':
            $digit = \Barcode93::getDigit($code, $crc);
            break;
        case 'code128':
            $digit = \Barcode128::getDigit($code);
            break;
        case 'codabar':
            $digit = \BarcodeCodabar::getDigit($code);
            break;
        case 'msi':
            $digit = \BarcodeMSI::getDigit($code, $crc);
            break;
        case 'datamatrix':
            $digit = \BarcodeDatamatrix::getDigit($code, $rect);
            break;
    }
    $imgWidth = strlen($digit) * $width;
    $x = $imgWidth / 2;
    $im = imagecreatetruecolor($imgWidth, 62);
    $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
    $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
    $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
    $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
    imagefilledrectangle($im, 0, 0, $imgWidth, 62, $white);
    $data = \Barcode::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
    if (isset($font)) {
        $box = imagettfbbox($fontSize, 0, $font, $data['hri']);
        $len = $box[2] - $box[0];
        \Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
        imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $black, $font, $data['hri']);
    }
    header('Content-type: image/gif');
    imagegif($im);
    imagedestroy($im);
}
Ejemplo n.º 17
0
Route::get('hashme/{mypass}', function ($mypass) {
    print Hash::make($mypass);
});
Route::get('xtest', function () {
    Excel::load('WEBSITE_INVESTORS_ALLIANCE.xlsx')->calculate()->dump();
});
Route::get('xcat', function () {
    print_r(Prefs::getCategory());
});
Route::get('barcode/dl/{txt}', function ($txt) {
    $barcode = new Barcode();
    $barcode->make($txt, 'code128', 60, 'horizontal', true);
    return $barcode->render('jpg', $txt, true);
});
Route::get('barcode/{txt}', function ($txt) {
    $barcode = new Barcode();
    $barcode->make($txt, 'code128', 60, 'horizontal', true);
    return $barcode->render('jpg', $txt);
});
Route::get('media', function () {
    $media = Product::all();
    print $media->toJson();
});
Route::get('login', function () {
    return View::make('login');
});
Route::post('login', function () {
    // validate the info, create rules for the inputs
    $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
    // run the validation rules on the inputs from the form
    $validator = Validator::make(Input::all(), $rules);
Ejemplo n.º 18
0
 public function addBarcode($code)
 {
     $fontSize = 2.4;
     $marge = 1;
     // between barcode and hri in pixel
     $x = $this->GetX() + 45;
     // barcode center
     $y = $this->GetY() + 6;
     // barcode center
     $height = 9;
     // barcode height in 1D ; module size in 2D
     $width = 0.37;
     // barcode height in 1D ; not use in 2D
     $angle = 0;
     // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
     $type = 'code39';
     $black = '000000';
     // color in hexa
     //$this->SetFont('Arial','B',$fontSize);
     $data = Barcode::fpdf($this, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
     //$this->SetFont('Arial','B',$fontSize);
     //$this->SetTextColor(0, 0, 0);
     $len = $this->GetStringWidth($data['hri']);
     Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
     $this->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
     $this->setLineWidth(0.12);
 }
Ejemplo n.º 19
0
    // obtiene los valores de las varibles
    // crea las variables y les asigna el valor
    for ($i = 0; $i < $numero; $i++) {
        ${$tags}[$i] = $valores[$i];
    }
    // Agrega ademas las variables de sesion
    if (!empty($_SESSION)) {
        extract($_SESSION);
    }
}
$x = $AnchoImagen / 2;
// Centro X del codigo en la imagen
$y = $AltoImagen / 2;
// Centro Y del codigo dentro de la imagen
if ($Tipo != "datamatrix") {
    $height = $AltoCodigo;
    // Alto del codigo en 1D o tamano de modulo en 2D
    $width = $AnchoCodigo;
    // Ancho del codigo en 1D ; no usar en 2D
}
//Separa recursos de trabajo en GD
$im = imagecreatetruecolor($AnchoImagen, $AltoImagen);
$black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
$white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
imagefilledrectangle($im, 0, 0, $AnchoImagen, $AltoImagen, $white);
//Llama el metodo para generar el codigo
$data = Barcode::gd($im, $black, $x, $y, 0, $Tipo, array('code' => $Cadena), $width, $height);
//Genera la imagen
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
 function render($po_pdf, $pn_x = null, $pn_y = null)
 {
     switch (get_class($this->opo_form)) {
         case 'PrintForms':
             if ($va_element_info = $this->opa_element_info) {
                 $vn_x = $this->opo_form->getValueInPoints($va_element_info['left']);
                 $vn_y = $this->opo_form->getFormSetting('pageHeight') - $this->opo_form->getValueInPoints($va_element_info['top']);
             }
             break;
         case 'PrintSubForms':
             if ($va_element_info = $this->opa_element_info) {
                 $vn_x = $pn_x + $this->opo_form->getValueInPoints($va_element_info['left']);
                 $vn_y = $pn_y - $this->opo_form->getValueInPoints($va_element_info['top']);
             }
             break;
         default:
             $this->opo_form->postError(2275, _t("Invalid class '%1'", get_class($this->opo_form)), "PrintFormBarcodeElement->render()");
             break;
     }
     $va_style = $this->opo_form->getStyle($va_element_info['style']);
     $vn_w = $this->opo_form->getValueInPoints($va_element_info['width']);
     $vn_h = $this->opo_form->getValueInPoints($va_element_info['height']);
     $o_barcode = new Barcode();
     if (!isset($va_element_info['barcode'])) {
         $va_element_info['barcode'] = $va_style['barcode'];
     }
     $vs_tmp = tempnam('/tmp', 'caBarCode');
     $va_dimensions = $o_barcode->draw($this->getValue(), $vs_tmp . '.png', isset($va_element_info['barcode']) ? $va_element_info['barcode'] : 'code128', 'png', $vn_h);
     $vn_image_width = $va_dimensions['width'];
     $vn_image_height = $va_dimensions['height'];
     if (!$vn_image_width || !$vn_image_height) {
         return false;
     }
     if ($vn_image_width / $vn_w > $vn_image_height / $vn_h) {
         $vn_r = $vn_w / $vn_image_width;
     } else {
         $vn_r = $vn_h / $vn_image_height;
     }
     $vn_image_width *= $vn_r;
     $vn_image_height *= $vn_r;
     if ($this->opo_form->getPDFLibrary() == __PDF_LIBRARY_ZEND__) {
         if ($vn_image_ref = $this->opo_form->loadImage($po_pdf, $vs_tmp . '.png')) {
             $po_pdf->pages[sizeof($po_pdf->pages) - 1]->drawImage($vn_image_ref, $vn_x, $vn_y - $vn_h, $vn_x + $vn_image_width, $vn_y - $vn_h + $vn_image_height);
         }
     } else {
         if ($vn_image_ref = $this->opo_form->loadImage($po_pdf, $vs_tmp . '.png')) {
             if (!($vs_display = $va_element_info['display'])) {
                 $vs_display = $va_style['display'];
             }
             if (!in_array($vs_display, array('nofit', 'clip', 'meet', 'auto', 'slice', 'entire'))) {
                 $vs_display = 'meet';
             }
             $vs_opts = "fitmethod={$vs_display} boxsize={" . $vn_image_width . " " . $vn_image_height . "}";
             if ($va_element_info['rotate']) {
                 $vs_opts .= ' rotate=' . intval($va_element_info['rotate']);
             } else {
                 if ($va_style['rotate']) {
                     $vs_opts .= ' rotate=' . intval($va_style['rotate']);
                 }
             }
             $po_pdf->fit_image($vn_image_ref, $vn_x, $vn_y - $vn_h, $vs_opts);
         }
     }
     @unlink($vs_tmp);
     @unlink($vs_tmp . '.png');
     return true;
 }
Ejemplo n.º 21
0
 public function ean()
 {
     if (isset($this->request->get['text'])) {
         require DIR_SYSTEM . "library/barcode.php";
         $barcode = new Barcode();
         $widthScale = isset($this->request->get['widthScale']) ? $this->request->get['widthScale'] : 1;
         $height = isset($this->request->get['height']) ? $this->request->get['height'] : 50;
         $barcode->code39($this->request->get['text'], $height, $widthScale);
     }
 }
Ejemplo n.º 22
0
<?php

include 'php-barcode/php-barcode.php';
//http://cariprogram.blogspot.com
//nuramijaya@gmail.com
$fontSize = 10;
// GD1 in px ; GD2 in point
$marge = 10;
// between barcode and hri in pixel
$x = 125;
// barcode center
$y = 125;
// barcode center
$height = 50;
// barcode height in 1D ; module size in 2D
$width = 2;
// barcode height in 1D ; not use in 2D
$angle = 0;
// rotation in degrees
$code = '1234';
// barcode, of course ;)
$type = 'code39';
$im = imagecreatetruecolor(300, 300);
$black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
$white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
imagefilledrectangle($im, 0, 0, 300, 300, $white);
$data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
header('Content-type: image/png');
//imagepng($im, "barcode.png");
imagepng($im);
imagedestroy($im);
Ejemplo n.º 23
0
} else {
    $marge = 5;
    // between barcode and hri in pixel
    $x = 30;
    // barcode center
    $y = 120;
    // barcode center
    $height = 40;
    // barcode height in 1D ; module size in 2D
    $width = 1;
    // barcode height in 1D ; not use in 2D
}
// -------------------------------------------------- //
//            ALLOCATE FPDF RESSOURCE
// -------------------------------------------------- //
$pdf = new eFPDF('P', 'mm', array(102, 252));
// set the orentation, unit of measure and size of the page
$pdf->AddPage();
// -------------------------------------------------- //
//                      BARCODE
// -------------------------------------------------- //
$data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
$pdf->SetFont('Arial', 'B', $fontSize);
$pdf->SetTextColor(0, 0, 0);
$len = $pdf->GetStringWidth($data['hri']);
Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
// -------------------------------------------------- //
//                      OUTPUT
// -------------------------------------------------- //
$pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
$pdf->Output();
Ejemplo n.º 24
0
 public static function generateBarCode($num)
 {
     Barcode::getImage($num);
 }
Ejemplo n.º 25
0
$requiredKeys = array('dpi', 'scale', 'rotation', 'text');
// Check if everything is present in the request
foreach ($requiredKeys as $key) {
    if (!isset($_GET[$key])) {
        showError();
    }
}
$class_dir = 'Codebar';
include_once $class_dir . DIRECTORY_SEPARATOR . 'Barcode.php';
require_once $class_dir . DIRECTORY_SEPARATOR . 'Color.php';
require_once $class_dir . DIRECTORY_SEPARATOR . 'Draw.php';
$drawException = null;
try {
    $color_black = new Color(0, 0, 0);
    $color_white = new Color(255, 255, 255);
    $code_generated = new Barcode();
    $code_generated->setScale(max(1, min(4, $_GET['scale'])));
    $code_generated->setBackgroundColor($color_white);
    $code_generated->setForegroundColor($color_black);
    if ($_GET['text'] !== '') {
        $text = convertText($_GET['text']);
        $code_generated->parse($text);
    }
} catch (Exception $exception) {
    $drawException = $exception;
}
$drawing = new Draw('', $color_white);
if ($drawException) {
    $drawing->drawException($drawException);
} else {
    $drawing->setBarcode($code_generated);
Ejemplo n.º 26
0
<?php

include '../php-barcode.php';
require 'fpdf/fpdf.php';
$fontSize = 10;
$marge = 10;
// between barcode and hri in pixel
$x = 200;
// barcode center
$y = 200;
// barcode center
$height = 50;
// barcode height in 1D ; module size in 2D
$width = 2;
// barcode height in 1D ; not use in 2D
$angle = 60;
// rotation in degrees
$code = '123456789012';
// barcode, of course ;)
$type = 'ean13';
$black = '000000';
// color in hexa
$pdf = new ePDF('P', 'pt');
$pdf->AddPage();
$data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
$pdf->SetFont('Arial', 'B', $fontSize);
$pdf->Output();
Ejemplo n.º 27
-12
function generate_barcode($first, $code, $terminal)
{
    if ($first) {
        $len = strlen($code);
        if ($len > 9) {
            $code = substr($code, $len - 9);
            $len = 9;
        }
        for ($i = 0; $i < 9 - $len; $i++) {
            $code = '0' . $code;
        }
        $code = '1' . $terminal . $code;
    }
    // -------------------------------------------------- //
    //                  PROPERTIES
    // -------------------------------------------------- //
    // download a ttf font here for example : http://www.dafont.com/fr/nottke.font
    //$font     = './NOTTB___.TTF';
    // - -
    $folio = BarcodeEAN::compute($code, 'ean13');
    $fontSize = 10;
    // GD1 in px ; GD2 in point
    $marge = 10;
    // between barcode and hri in pixel
    $x = 110;
    // barcode center
    $y = 40;
    // barcode center
    $height = 50;
    // barcode height in 1D ; module size in 2D
    $width = 2;
    // barcode height in 1D ; not use in 2D
    $angle = 0;
    // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
    //$code     = '750000000001'; // barcode, of course ;)
    $type = 'ean13';
    // -------------------------------------------------- //
    //                    USEFUL
    // -------------------------------------------------- //
    /*function drawCross($im, $color, $x, $y){
        imageline($im, $x - 10, $y, $x + 10, $y, $color);
        imageline($im, $x, $y- 10, $x, $y + 10, $color);
      }*/
    // -------------------------------------------------- //
    //            ALLOCATE GD RESSOURCE
    // -------------------------------------------------- //
    $im = imagecreatetruecolor(220, 80);
    $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
    $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
    $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
    $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
    imagefilledrectangle($im, 0, 0, 220, 80, $white);
    // -------------------------------------------------- //
    //                      BARCODE
    // -------------------------------------------------- //
    $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
    // -------------------------------------------------- //
    //                        HRI
    // -------------------------------------------------- //
    if (isset($font)) {
        $box = imagettfbbox($fontSize, 0, $font, $data['hri']);
        $len = $box[2] - $box[0];
        Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
        imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
    }
    // -------------------------------------------------- //
    //                     ROTATE
    // -------------------------------------------------- //
    // Beware ! the rotate function should be use only with right angle
    // Remove the comment below to see a non right rotation
    /** /
        $rot = imagerotate($im, 45, $white);
        imagedestroy($im);
        $im     = imagecreatetruecolor(900, 300);
        $black  = ImageColorAllocate($im,0x00,0x00,0x00);
        $white  = ImageColorAllocate($im,0xff,0xff,0xff);
        $red    = ImageColorAllocate($im,0xff,0x00,0x00);
        $blue   = ImageColorAllocate($im,0x00,0x00,0xff);
        imagefilledrectangle($im, 0, 0, 900, 300, $white);
        
        // Barcode rotation : 90�
        $angle = 90;
        $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
        Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
        imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
        imagettftext($im, 10, 0, 60, 290, $black, $font, 'BARCODE ROTATION : 90�');
        
        // barcode rotation : 135
        $angle = 135;
        Barcode::gd($im, $black, $x+300, $y, $angle, $type, array('code'=>$code), $width, $height);
        Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
        imagettftext($im, $fontSize, $angle, $x + 300 + $xt, $y + $yt, $blue, $font, $data['hri']);
        imagettftext($im, 10, 0, 360, 290, $black, $font, 'BARCODE ROTATION : 135�');
        
        // last one : image rotation
        imagecopy($im, $rot, 580, -50, 0, 0, 300, 300);
        imagerectangle($im, 0, 0, 299, 299, $black);
        imagerectangle($im, 299, 0, 599, 299, $black);
        imagerectangle($im, 599, 0, 899, 299, $black);
        imagettftext($im, 10, 0, 690, 290, $black, $font, 'IMAGE ROTATION');
        /**/
    // -------------------------------------------------- //
    //                    MIDDLE AXE
    // -------------------------------------------------- //
    /*imageline($im, $x, 0, $x, 250, $red);
      imageline($im, 0, $y, 250, $y, $red);*/
    // -------------------------------------------------- //
    //                  BARCODE BOUNDARIES
    // -------------------------------------------------- //
    /*for($i=1; $i<5; $i++){
        drawCross($im, $blue, $data['p'.$i]['x'], $data['p'.$i]['y']);
      }*/
    // -------------------------------------------------- //
    //                    GENERATE
    // -------------------------------------------------- //
    header('Content-type: image/png');
    imagepng($im, $folio . ".png");
    imagedestroy($im);
    return $folio;
}