<?php 
define('DOCUMENT_ROOT_CLASS','../');
define('DOCUMENT_ROOT_INC_FOLDER','');
$filepath = realpath(dirname(__FILE__));
require "../inc/header.php";
$msg = Session::get('msg');
Session::set("msg", NULL);
$customerData = $commonFunctions->getRowData('crm_cust_details'," WHERE id = '".@$_GET['customer_id']."' ");

$cntB = $commonFunctions->getRecordCount('sys_erp_organaization','');
if($cntB == 1){
    $companyData = $commonFunctions->getRowData('sys_erp_organaization'," WHERE id != '0' ");
}

?>

    <!-- Page-Title -->
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col form-row">
                    	<div class="col-sm-9">
                            <h4 class="page-title"><?php echo @$companyData['erp_sys_org_name'];?></h4>
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="javascript:void(0);">CRM</a></li>
                                <li class="breadcrumb-item"><a href="javascript:void(0);">Customer<?php echo (!empty($_GET['state']) and $_GET['state'] == "customer-form")?" Form ":" List "; ?></a></li>
                                <li class="breadcrumb-item"><a href="javascript:void(0);"><?php echo @$companyData['erp_sys_org_name'];?></a></li>
                            </ol>
                        </div>
                        <div class="col-sm-3" style="text-align: end;">
                            <a href="customer.php?state=customer-form&customer_id=<?php echo $customerData['id'];?>">
                            	<button type="button" class="btn btn-sm btn-outline-primary">Edit</button>
                            </a>
                            
                            <a href="customer.php?state=customer-list"><button type="button" class="btn btn-sm btn-outline-secondary clear_form">Back to Products List</button></a>
                            <!-- <button type="button" class="btn btn-sm btn-outline-danger">Delete</button> -->
                        </div>
                    </div><!--end col-->
                </div><!--end row-->                                                              
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="dastone-profile">
                        <div class="row">
                            <div class="col-lg-5 align-self-center mb-lg-0">
                                <div class="dastone-profile-main">
                                    <div class="dastone-profile_user-detail">
                                        <img src="../uploads/admin-setting/company/<?php echo (@$companyData['erp_sys_org_logo'])?$companyData['erp_sys_org_logo']:'default-img.jpg';?>" alt="" height="110" class="thumb-lx rounded" style='max-width:300px;'>                                            
                                    </div>
                                </div>                                                
                            </div><!--end col-->
                            <div class="col-lg-4 align-self-center mb-lg-0">
                                <div class="dastone-profile-main">     
                                    <div class="dastone-profile_user-detail">
                                        <h5 class="dastone-user-name"><?php echo $companyData['erp_sys_org_name'];?></h5>
                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $companyData['erp_sys_org_address'];?></p>
                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $companyData['erp_sys_org_city'];?>, P.O.Box - <?php echo $companyData['erp_sys_org_province'];?></p>
                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $commonFunctions->getName(@$companyData['erp_sys_org_country'],'sys_erp_adm_countries','label','rowid');?></p>
                                    </div>
                                </div>                                                
                            </div><!--end col-->
                            <div class="col-lg-3 align-self-center mb-lg-0">
                                <ul class="list-unstyled personal-detail mb-0">
                                    <li class="mt-2"><i class="las la-phone mr-2 text-secondary font-22 align-middle"></i> <b> Phone </b> :  <?php echo $companyData['erp_sys_org_phone_work'];?></li>
                                    <li class="mt-2"><i class="las la-mobile mr-2 text-secondary font-22 align-middle"></i> <b> Mobile </b> :  0</li>
                                    <li class="mt-2"><i class="las la-envelope text-secondary font-22 align-middle mr-2"></i> <b> Email </b> :   <a href="mailto:<?php echo $companyData['erp_sys_email_work'];?>"><?php echo $companyData['erp_sys_email_work'];?></a></li>                                                  
                                </ul>                                             
                            </div><!--end col-->

                        </div><!--end row-->
                    </div><!--end f_profile-->                                                                                
                </div><!--end card-body-->          
            </div> <!--end card-->    
        </div><!--end col-->
    </div><!--end row-->
    <div class="pb-4">
        <ul class="nav-border nav nav-pills mb-0" id="pills-tab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" id="CompanyProfileTab" data-toggle="pill" href="#CompanyProfileDetails">Company Profile</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="ContactPersonDetails_tab" data-toggle="pill" href="#ContactPersonDetails">Contact Person</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="BranchORShippingAddress_tab" data-toggle="pill" href="#BranchORShippingAddress">Branch & Shipping Address</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="Invoice_tab" data-toggle="pill" href="#Invoice">Invoice</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="DeliveryNote_tab" data-toggle="pill" href="#DeliveryNote">Delivery Note</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="QuoteTab" data-toggle="pill" href="#quote">Quote</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="PurchasesTab" data-toggle="pill" href="#Purchases">Purchases</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="note_tab" data-toggle="pill" href="#note">Notes</a>
            </li>
        </ul>        
    </div><!--end card-body-->
    <style type="text/css">
    	label.form-control1 {display: block;}
    	label.label-title {font-weight: 600;}
    </style>
    <div class="row">
        <div class="col-12">
            <div class="tab-content" id="pills-tabContent">
                <div class="tab-pane fade show active" id="CompanyProfileDetails" role="tabpanel" aria-labelledby="CompanyProfileTab">
                    <div class="row">
                    	<div class="col-lg-6 col-xl-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Company Profile</h4>
                                        </div><!--end col-->                                   
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                              
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Company Name</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["name"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Alias (Trademark etc.)</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["alias_name"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Company Registration</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"></h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Customer No</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["customer_code"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Commercial Registration Type</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"></h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Reporting Manager</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"></h5>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Social Media</h4>
                                        </div><!--end col-->                                   
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                              
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Linkedin</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["org_sm_page_linkedin"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Twitter</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["org_sm_page_twitter"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Facebook</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["org_sm_page_facebook"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Instagram</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["org_sm_page_instagram"];?> </h5>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-lg-6 col-xl-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Company Contact Information ( Official )</h4>
                                        </div><!--end col-->                                   
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                              
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Phone</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["phone"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Fax</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["fax"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Email Address</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["email"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Website / URL</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["web"];?> </h5>
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Office Address</h4>
                                        </div><!--end col-->                                   
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                              
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Address</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["address"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">City</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["city"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">State / Province</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $commonFunctions->getName(@$customerData['state'],'sys_erp_adm_countries_states','label','rowid');?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Zip / Pin / PO Box</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $customerData["postcode"];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                   
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Country</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"><?php echo $commonFunctions->getName(@$customerData['country'],'sys_erp_adm_countries','label','rowid');?></h5>
                                        </div>
                                    </div>

                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="ContactPersonDetails" role="tabpanel" aria-labelledby="ContactPersonDetails_tab">
                    <div class="card">
                		<div class="card-body">
                            <?php 
                            $where = " WHERE third_party_id = '".@$_GET['customer_id']."' ";
                            $resultData = $commonFunctions->getData('crm_add_bk',$where); ?>
                        	<table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th  class="text-center">First Name</th>
                                        <th  class="text-center">Last Name</th>
                                        <th  class="text-center">Title</th>
                                        <th  class="text-center">Job Position</th>
                                        <th  class="text-center">Address</th>
                                        <th  class="text-center">City</th>
                                        <th  class="text-center">State / Province</th>
                                        <th  class="text-center">Country</th>
                                        <th  class="text-center">Postcode</th>
                                        <th  class="text-center">Prof Phone</th>
                                        <th  class="text-center">Pers Phone</th>
                                        <th  class="text-center">Email</th>
                                    </tr>

                                </thead>
                                <tbody>
                                    <?php foreach ($resultData as $rw) { ?>
                                        <tr>
                                            <td><?php echo $rw['first_name'];?></td>
                                            <td><?php echo $rw['last_name'];?></td>
                                            <td><?php echo $rw['title'];?></td>
                                            <td><?php echo $rw['job_position'];?></td>
                                            <td><?php echo $rw['address'];?></td>
                                            <td><?php echo $rw['city'];?></td>
                                            <td><?php echo @$commonFunctions->getname($rw['state_id'],"sys_erp_adm_countries_states","label",'rowid');?></td>
                                            <td><?php echo @$commonFunctions->getname($rw['country_id'],"sys_erp_adm_countries","label",'rowid');?></td>
                                            <td><?php echo $rw['postcode'];?></td>
                                            <td><?php echo $rw['prof_phone'];?></td>
                                            <td><?php echo $rw['pers_phone'];?></td>
                                            <td><?php echo $rw['email'];?></td>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>

                    	</div><!--end row-->    
                    </div>
                </div>
                <div class="tab-pane" id="BranchORShippingAddress" role="tabpanel" aria-labelledby="BranchORShippingAddress_tab">
                    <div class="card">
                		<div class="card-body">
                        	<table style="width: 100% !important;" class="table datatable_t table-hover table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th class="text-center">SR No.</th>
                                        <th class="text-center">Warehouse Name</th>
                                        <th class="text-center">Warehouse Ref</th>
                                        <th class="text-center">Address</th>
                                        <th class="text-center">Zip / Pin Code</th>
                                        <th class="text-center">City</th>
                                        <th class="text-center">Country</th>
                                        <!-- <th class="text-center">Status</th> -->
                                        <!-- <th class="text-center">Action</th> -->
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $where = ""; 
                                    $productData = $commonFunctions->getData('invty_wrhus',$where); 
                                    foreach ($productData as $row) { 
                                        $i++;?>
                                        <tr onclick="redirect_1('../product-services/warehouse/warehouse.php?state=edit&warehouse_id=<?php echo $row['id'];?>')" >
                                        <th class="text-center text-primary" ><?php echo $row['reference_number'];?></th>
                                        <th class="text-center text-primary"><?php echo $row['short_name_location'];?></th>
                                        <th class="text-center"><?php echo $row['description'];?></th>
                                        <th class="text-center"><?php echo $row['address'];?></th>
                                        <th class="text-center"><?php echo $row['zip_code'];?></th>
                                        <th class="text-center"><?php echo $row['city'];?></th>
                                        <th class="text-center"><?php echo $row['country_id'];?></th>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                    	</div><!--end row-->    
                    </div> <!--end row-->
				</div>
				<div class="tab-pane" id="DeliveryNote" role="tabpanel" aria-labelledby="DeliveryNote_tab">
                    <div class="card">
                		<div class="card-body">
                        	<?php 
                        	$where1 = " WHERE ship_to = '".@$_GET["customer_id"]."' ";
                        	$invtData = $commonFunctions->getData('sys_erp_sales_delivery_note',$where1); ?>
                        	<table style="margin-top: 10px;width: 100% !important;" class="table datatable_t table-hover table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th class="text-center">Delivery Note No#</th>
                                        <th class="text-center">Invoice No#</th>
                                        <th class="text-center">Customer</th>
                                        <th class="text-center">Delivery Date</th>
                                        <th class="text-center">Amount</th>
                                        <th class="text-center">Status</th>
                                        <th class="text-center">Created By</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    foreach ($invtData as $row) { ?>
                                        <tr onclick="redirect_('delivery-note-card.php?delivery_note_id=<?php echo $row['id'];?>')"> 
                                        <!-- <tr> -->
                                            <th class="text-center">
                                                <?php echo $row['delivery_note_no']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $row['invoice_no']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php 
                                                $bill_to = $commonFunctions->getname($row['invoice_id'],"sys_erp_sales_invoice","bill_to","id");
                                                echo $commonFunctions->getname($bill_to,"crm_cust_details","name","id");
                                                ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $row['delivery_date']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $row['total']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php if($row['dn_status'] == 1){ echo "<span class='btn btn-soft-danger btn-sm'>Drafted</span>"; }
                                                if($row['dn_status'] == 2){ echo "<span class='btn btn-soft-success btn-sm'>Partially Delivered</span>"; }
                                                if($row['dn_status'] == 3){ echo "<span class='btn btn-soft-primary btn-sm'>Delivered</span>"; } ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $commonFunctions->getname($row['delivery_note_creator'],"sys_erp_adm_user","erp_sys_user_name_first","id")." ".$commonFunctions->getname($row['delivery_note_creator'],"sys_erp_adm_user","erp_sys_user_name_last","id");
                                                ?>
                                            </th>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                    	</div><!--end row-->    
                    </div> <!--end row-->
				</div>
                <div class="tab-pane" id="Invoice" role="tabpanel" aria-labelledby="Invoice_tab">
                    <div class="card">
                		<div class="card-body">
                        	<?php 
                        	$where = " WHERE bill_to = '".@$_GET["customer_id"]."' ";
                        	$invtData = $commonFunctions->getData('sys_erp_sales_invoice',$where); ?>
                        	<table style="margin-top: 10px;width: 100% !important;" class="table datatable_t table-hover table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th class="text-center">Invoice No#</th>
                                        <th class="text-center">Customer</th>
                                        <th class="text-center">Invoice Date</th>
                                        <th class="text-center">Amount</th>
                                        <th class="text-center">Status</th>
                                        <th class="text-center">Created By</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    foreach ($invtData as $row) { ?>
                                        <tr onclick="redirect_('invoice-card.php?invoice_id=<?php echo $row['id'];?>')">
                                            <th class="text-center">
                                                <?php echo $row['invoice_no']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $commonFunctions->getname($row['bill_to'],"crm_cust_details","name","id");
                                                ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $row['invoice_date']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $row['total']; ?>
                                            </th>
                                            <th class="text-center">
                                                <?php if($row['invoice_status'] == 0){ echo "<span class='btn btn-soft-danger btn-sm'>Unpaid</span>"; }
                                                if($row['invoice_status'] == 1){ echo "<span class='btn btn-soft-success btn-sm'>Paid</span>"; }
                                                if($row['invoice_status'] == 2){ echo "<span class='btn btn-soft-primary btn-sm'>Overdue</span>"; } ?>
                                            </th>
                                            <th class="text-center">
                                                <?php echo $commonFunctions->getname($row['invoice_creator'],"sys_erp_adm_user","erp_sys_user_name_first","id")." ".$commonFunctions->getname($row['invoice_creator'],"sys_erp_adm_user","erp_sys_user_name_last","id");
                                                ?>
                                            </th>
                                        </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                    	</div><!--end row-->    
                    </div>
                </div>
                <div class="tab-pane" id="quote" role="tabpanel" aria-labelledby="QuoteTab">
                    <div class="card">
                        <div class="card-body">
                            Statistics
                        </div><!--end row-->    
                    </div>
                </div>
                <div class="tab-pane" id="Purchases" role="tabpanel" aria-labelledby="PurchasesTab">
                    <div class="card">
                        <div class="card-body">
                            Purchases
                        </div><!--end row-->    
                    </div>
                </div>

                <div class="tab-pane" id="note" role="tabpanel" aria-labelledby="note_tab">
                    <div class="card">
                		<div class="card-body">
                        	<div class="form-row">
                        		<div class="col-md-12 position-relative form-group">
                        			<?php echo @$customerData['description'];?>
                        		</div>
                        	</div>
                        </div>
                    </div><!--end row-->
                </div>
            </div>
        </div>
    </div>


<?php require "../inc/footer.php"; ?>
<script type="text/javascript" src="https://www.jqueryscript.net/demo/Simple-jQuery-Based-Barcode-Generator-Barcode/jquery-barcode.js"></script>
<script type="text/javascript">
    
  	function generateBarcode(){
	    var value = "<?php echo strtolower(@$customerData['barcode_value']); ?>";
	    var btype = "<?php echo strtolower(@$barcode_type); ?>";
	    var renderer = "css";
    	var quietZone = false;
	    
	    var settings = {
	      	output:renderer,
	      	bgColor: "#FFFFFF",
	      	color: "#000000",
	      	barWidth: "2",
	     	barHeight: "50",
	      	moduleSize: "5",
	      	posX: "10",
	      	posY: "20",
	      	addQuietZone: "1"
	    };
    	if (renderer == 'canvas'){
      		clearCanvas();
	      	$("#barcodeTarget").hide();
	      	$("#canvasTarget").show().barcode(value, btype, settings);
    	} else {
      		$("#canvasTarget").hide();
      		$("#barcodeTarget").html("").show().barcode(value, btype, settings);
    	}
  	}
      
  	function showConfig1D(){
	    $('.config .barcode1D').show();
	    $('.config .barcode2D').hide();
  	}
  
  	function showConfig2D(){
	    $('.config .barcode1D').hide();
	    $('.config .barcode2D').show();
  	}
  
  	function clearCanvas(){
	    var canvas = $('#canvasTarget').get(0);
	    var ctx = canvas.getContext('2d');
	    ctx.lineWidth = 1;
	    ctx.lineCap = 'butt';
	    ctx.fillStyle = '#FFFFFF';
	    ctx.strokeStyle  = '#000000';
	    ctx.clearRect (0, 0, canvas.width, canvas.height);
	    ctx.strokeRect (0, 0, canvas.width, canvas.height);
  	}
  
  	$(function(){
    	generateBarcode();
  	});
function redirect_1(uri){
    $("<a>").prop({ target: "_blank",href: uri })[0].click();
}
</script>