Cara membuat barcode di codeigniter dengan zend barcode

Cara membuat barcode di codeigniter dengan zend barcode

Untuk membuat barcode di codeigniter cukup mudah sobat kita hanya perlu library zend barcode yang kita taruh di third_party folder pada application dan juga membuat library zend.

Keyword search: belajar codeigniter pdf,belajar codeigniter 4,tutorial codeigniter malasngoding,codeigniter database tutorial,membuat aplikasi dengan codeigniter dan bootstrap,codeigniter 3,codeigniter tutorial w3schools,codeigniter 3 1 9 tutorial pdf,belajar codeigniter 4,belajar codeigniter pdf,belajar codeigniter dan bootstrap,belajar codeigniter 4 pdf,belajar codeigniter malasngoding,belajar codeigniter crud,belajar codeigniter atau laravel,belajar codeigniter terbaru,belajar codeigniter pemula pdf,tutorial belajar codeigniter,cara belajar codeigniter,cara cepat belajar codeigniter,ebook belajar codeigniter,situs belajar codeigniter,belajar codeigniter 3 pdf,belajar membuat website dengan codeigniter,belajar dasar codeigniter,belajar crud codeigniter,belajar api codeigniter,belajarphp.net codeigniter,belajar ajax codeigniter,belajar mvc codeigniter,belajar vue js codeigniter,belajar session codeigniter

Untuk scriptnya sebagai berikut:

Library Zend.php
<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Zend {

public function __construct($class = NULL)
{
ini_set('include_path',
ini_get('include_path'). PATH_SEPARATOR. APPPATH. 'third_party');

if($class)
{
require_once(string) $class.'.php'; //fixed CI 3 issue by lilsammy
log_message('debug', "Zend Class $class Loaded");
}else
{
log_message('debug', "Zend Class Initialized");
}
}

public function load($class)
{
require_once(string) $class.'.php'; //fixed CI 3 issue by lilsammy
log_message('debug', "Zend Class $class Loaded");
}
}

Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends APP_Controller {
var $template = array();

public function __construct()
{
parent::__construct();

if (!$this->ion_auth->logged_in()){
redirect('auth/login', 'refresh');
}

$this->template['module'] = 'product';
     
        $this->load->model("Product_model","p");
}

public function barcode(){
$qty = $this->input->post_get('qty',true);
$name = $this->input->post_get('name',true);
$price = $this->input->post_get('price',true);
$barcode = $this->input->post_get('barcode',true);
$mbottom = $this->input->post_get('mbottom',true);

$this->template['qty'] = $qty;
$this->template['name'] = $name;
$this->template['price'] = $price;
$this->template['barcode'] = $barcode;
$this->template['mbottom'] = ($mbottom)? $mbottom : 10;

    $html = $this->load->view('../../modules/product/views/barcode',$this->template,true);
 
echo $html;
}

public function generate_barcode(){
$qty = $this->input->get('qty',true);
$name = $this->input->get('name',true);
$price = $this->input->get('price',true);
$barcode = $this->input->get('barcode',true);

//load library
$this->load->library('zend');

//load in folder Zend
$this->zend->load('Zend/Barcode');

//generate barcode
Zend_Barcode::render('code128', 'image', array('text'=>$barcode,'barHeight'=> 30, 'fontSize'=>12), array());
}

}

View
<?php
mb_internal_encoding("iso-8859-1");
mb_http_output( "UTF-8" );
ob_start("mb_output_handler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
<title>Invoice #<?php echo isset($billing_info['order_id'])? $billing_info['order_id'] : ''; ?></title>
<style>
body {
background: #FFFFFF;
}
</style>
</head>
<script type="text/javascript">
window.print();
setTimeout(function(){window.close();}, 100);
</script>
<body>
<?php if(!empty($qty)){ ?>
<?php for($i=1;$i<=$qty;$i++){ ?>
<div style="margin-bottom:<?php echo $mbottom;?>px !important; height:241px; width:150px !important; border:1px solid #ccc;">
    <div style="width:100% !important; height:40% !important; margin-bottom:30px; clear: both; padding-top:10px;">
        <span style="float:left; font-size:10px; padding-left:12px;"><?php echo $name; ?></span><br>
        <span style="float:left; font-size:10px; padding-left:12px;">Rp. <?php echo number_format($price,0,"",","); ?></span>
    </div>
    <div style="width:90% !important; clear: both;">
        <img src="<?php echo base_url($module.'/generate_barcode?qty='.$i.'&name='.$name.'&price='.$price.'&barcode='.$barcode);?>" style="margin:0px 0px; padding:0px 0px;">
    </div>
</div>
<?php } ?>
<?php } ?>
</body>
</html>

Untuk video tutorialnya bisa sobat liat sebagai berikut semoga bisa bermanfaat.

Lebih baru Lebih lama

نموذج الاتصال