PHP code example of kamaro / sdc

1. Go to this page and download the library: Download kamaro/sdc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kamaro / sdc example snippets



// Set Data
$data = "NS01012345,100600570,14/04/2017 12:35:20,23,0.00,18.00,0.00,0.00,11.00,12.00,0.00,0.00,0.00,1.83,0.00,0.00";

// Get Device Instance on PORT 5
$device = new Kamaro\Sdc\SDCController('COM5');
echo $device->sendReceiptData($data); // P for success or ERROR


	$receipt = __DIR__.'/stubs/A8.txt';
	$lines   = file($receipt);
	$endLine = count($lines) - 1;

	$sequence = 32;

	$device = new Kamaro\Sdc\SDCController('COM5');

	foreach ($lines as $key => $line) {
	    // Update sequence
	    if ($sequence > 127) {
			$sequence = 32;
		}
		switch ($key) {
			case 0:
				$results = $device->sendElectronicJournal('B'.$line,$sequence);
				break;
			case $endLine:
				$results = $device->sendElectronicJournal('E'.$line,$sequence);
				break;				
			default:
				$results = $device->sendElectronicJournal('N'.$line,$sequence);
				break;
		}
		$sequence++;
	}
 php

$device = new Kamaro\Sdc\SDCController('COM5','KAMARO LAMBERT #1','12345123'); // Assume your SDC is connect to COM Port 5
echo $device->isOpen(); // true
 php

$device = new Kamaro\Sdc\SDCController('COM5'); // Assume your SDC is connect to COM Port 5
echo $device->getID(); // SDC002001531 equivalent to the connected SDC
 php

$device = new Kamaro\Sdc\SDCController('COM5');
print_r($device->getStatus());

 php
array(6) {                                            
  ["SDC_SERIAL_NUMBER"]=>                                    
  string(12) "SDC002000173"                                  
  ["FIRMWARE_VERSION"]=>                                     
  string(10) "2.1302.2.8"                                    
  ["HARDWARE_REVISION"]=>                                    
  string(3) "530"                                            
  ["THE_NUMBER_OF_CURRENT_SDC_DAILY_REPORT"]=>               
  string(2) "37"                                             
  ["LAST_REMOTE_AUDIT_DATE_TIME"]=>                          
  string(19) "28/03/2014 11:14:08"                           
  ["LAST_LOCAL_AUDIT_DATE_TIME"]=>                           
  string(0) ""                                               
}                                                          

NS01012345,100600570,11/05/2016 12:35:20,23,0.00,18.00,0.00,0.00,11.00,12.00,0.00,0.00,0.00,1.83,0.00,0.00
 php

// Get Device Instance on PORT 5
$device = new Kamaro\Sdc\SDCController('COM5');
$results = $device->getSignature(23); // Previous Sent Invoice Number 23

var_dump($results);
 php
array(5) {                                                 
  ["date_time"]=>                                                     
  string(19) "14/04/2017 15:50:40"                                    
  ["SDC_ID"]=>                                                        
  string(12) "SDC002000173"                                           
  ["SDC_RECEIPT_NUMBER"]=>                                            
  string(12) "1127/1429/NS"                                           
  ["INTERNAL_DATA"]=>                                                 
  string(32) "6RUG-P4NR-7UIJ-EL7I-WS54-UN7R-MI"                       
  ["RECEIPT_SIGNATURE"]=>                                             
  string(19) "5T54-N5GG-B2WY-IY6S"
}