how to make QR code

Topics related to AppGini plugins/add-ons go here.
Post Reply
lramirez
Veteran Member
Posts: 46
Joined: 2019-11-01 23:23

how to make QR code

Post by lramirez » 2021-09-05 23:31

Hello...
How can I make the app that I build with AppGini do the barcode ...?
I would like to have something like in the attached image ...
My question is how do I make the code or how is the process ... ???
Thanks....
Attachments
qr.png
qr.png (37.91 KiB) Viewed 1920 times
Luis Ramirez R.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: how to make QR code

Post by D Oliveira » 2021-09-06 05:48

edit desired template_DV html file, output a QR code in a <div> and you're all set

xbox2007
Veteran Member
Posts: 129
Joined: 2016-12-16 16:49

Re: how to make QR code

Post by xbox2007 » 2022-02-03 06:03

hello

you need to download library name : PHP QR Code

you can download from here :

http://phpqrcode.sourceforge.net/

This my code to make QR Code

Code: Select all

<?php
	$currDir = dirname(__FILE__);
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");
	include_once("$currDir/header.php");

	/* grant access to all users who have access to the Collectors table */
	$boxs_from = get_sql_from('Boxs');
	if(!$boxs_from) exit(error_message('Access denied!', false));

	/* get invoice */
	$box_id = intval($_REQUEST['ID']);
	if(!$box_id) exit(error_message('Invalid Box ID!', false));
	
	$res = sql("select * from boxs where ID={$box_id}", $eo);
	while($row = db_fetch_assoc($res)){
		$items[] = $row;
	}
	
	//var_dump($items);
	
	//Photo 	Number 	Kind 	Lnumber 	Location 	Start_Date 	End_Date 	Area 	Project 	Street 	Building 	Unit 	Status 	Notes 	
	
	foreach($items as $i => $item){ 
		$ID = $item['ID'];
		$Area = $item['Area'];
		$Street = $item['Street'];
		$Building = $item['Building'];
		
		$FF = "box".$ID.$Area.$Street.$Building;
				
		//$filepath = 'QR/'.$FF.'.png';
		//echo $filepath;
	}
	
	require_once("phpqrcode/qrlib.php");	
		$filepath = 'QR/'.$FF.'.png';
		$file     = $FF.'.png';
		$logopath = 'img/qsrn.png';
		// qr code content
		echo $item['Location'];
		$codeContents  = 'Line one'."\n";
		$codeContents .= 'Project Info : '.$item['Project']."\n";
		$codeContents .= 'Number : '.$item['Number']."\n";
		$codeContents .= 'Kind: '.$item['Kind']."\n";
		$codeContents .= 'Lnumber : '.$item['Lnumber']."\n";	
		$codeContents .= 'Start_Date : '.$item['Start_Date']."\n";
		$codeContents .= 'End_Date: '.$item['End_Date']."\n";
		$codeContents .= 'Location : '.$item['Location']."\n";
		$codeContents .= 'Building : '.$item['Building'].' - Street : '.$item['Street'].' - Zone : '.$item['Zone'].' - Unit : '.$item['Unit']."\n";		
		// Create the file in the providen path
		// Customize how you want
		QRcode::png($codeContents,$filepath , QR_ECLEVEL_H, 3);
		//QRcode::png($codeContents,$filepath_dv , QR_ECLEVEL_H, 2);
		//QRcode::png($codeContents,$filepath_tv , QR_ECLEVEL_H, 1);
		// Start DRAWING LOGO IN QRCODE

		$QR = imagecreatefrompng($filepath);

		// START TO DRAW THE IMAGE ON THE QR CODE
		$logo = imagecreatefromstring(file_get_contents($logopath));
		$QR_width = imagesx($QR);
		$QR_height = imagesy($QR);

		$logo_width = imagesx($logo);
		$logo_height = imagesy($logo);

		// Scale logo to fit in the QR Code
		$logo_qr_width = $QR_width/3;
		$scale = $logo_width/$logo_qr_width;
		$logo_qr_height = $logo_height/$scale;

		imagecopyresampled($QR, $logo, $QR_width/3, $QR_height/3, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);

		// Save QR code again, but with logo on it
		imagepng($QR,$filepath);

		// End DRAWING LOGO IN QR CODE
		
		sql("update Boxs set Photo= '{$file}' where ID={$box_id}", $eo);
		
		// Ouput image in the browser
		//echo '<p align="center"><img src="img/center.jpg" />';
		echo '<p align="center"><img src="'.$filepath.'" />';
	include_once("$currDir/footer.php");
?>
please check

Post Reply