<?php
 require_once('class.WebRAD.inc.php'); class PopCard2 extends WebRAD { public function __construct( $app) { parent::__construct( $app); $this->owner->set_help( get_class($this)); $this->can_access = ValidateLevel( $this->owner->config['SECURITY']['PROVIDER_OPERATORS']); $this->can_add = ValidateLevel( $this->owner->config['SECURITY']['PROVIDER_OPERATORS']+LVL_ADD); $this->can_edit = ValidateLevel( $this->owner->config['SECURITY']['PROVIDER_OPERATORS']+LVL_EDIT); $this->can_remove = ValidateLevel( $this->owner->config['SECURITY']['PROVIDER_OPERATORS']+LVL_REMOVE); if ( !isset( $this->owner->config['pdf_page_size'])) $this->owner->config['pdf_page_size'] = 0; } public function csv() { if ( !$this->can_access) { $this->owner->permission_denied(); return; } if ( isset($GLOBALS['sid'])) { $query = "SELECT descr, cost FROM sk_card_series WHERE sid = %s"; $res = $this->db->GetAll(sprintf($query, $GLOBALS['sid'])); $query = "SELECT username, password as pin
				FROM sk_users WHERE sid = %s AND blocked = 0
				ORDER BY uid"; $result = $this->db->GetAll(sprintf($query, $GLOBALS['sid'])); if ($result) { echo('<html><head><meta content="text/html;" http-equiv="Content-Type" /></head><body>'); echo "\nSerie - '".$res[0][0]."', Cost - '".$res[0][1]."'<br />,<br />"; echo "'Login','Password'<br />,<br />"; $i = 0; while (isset($result[$i]) && is_array($result[$i])) { echo $result[$i][0].",".$result[$i][1]."<br />"; $i ++; } echo('</body></html>'); exit(); } } } public function pdf() { if ( !$this->can_access) { $this->owner->permission_denied(); return; } if ( isset($GLOBALS['sid'])) { $query = "SELECT cost, date_expire AS expire, url FROM sk_card_series WHERE sid = %s"; $user = $this->db->GetAll(sprintf($query, $GLOBALS['sid'])); $query = "SELECT sk_users.username , sk_users.password as pin, sk_packets.packet
				FROM sk_users, sk_packets WHERE sk_packets.gid=sk_users.gid AND sk_users.sid = %s AND sk_users.blocked = 0
				ORDER BY sk_users.uid"; $result = $this->db->GetAll(sprintf($query, $GLOBALS['sid'])); if ( !$result) return; require_once(dirname(__FILE__).'/../../tcpdf/tcpdf.php'); $pdf_currency = $this->owner->db->get_currency_sign(1); if ( $this->owner->config['pdf_page_size'] == 1) $pdf = new TCPDF('P','mm','A3'); else $pdf = new TCPDF('P','mm','A4'); $pdf->Open(); $pdf->SetMargins(10,10,20); $pdf->SetAutoPageBreak('on',20); $pdf->AddFont('Arial', '', 'arial.php'); $pdf->AddFont('Arial','B','arialb.php'); $pdf->AddFont('Courier', '', 'cour.php'); $pdf->SetFont('Arial','',10); $box = 0; $line = 0; $i = 0; while (isset($result[$i]) && is_array($result[$i])) { if ( $line == 0 && $box == 0) $pdf->AddPage(); $pdf->SetY( 20+57*$line); $pdf->SetX( 10+92*$box); $pdf->Cell( 92, 57, '', 1, 0); $pdf->Image('/opt/stasoft/www'.$user[0]['url'], 11+92*$box, 21+57*$line, 90, 55); $pdf->Ln(); $pdf->SetY( 21+57*$line); $pdf->SetX( 52+92*$box); $pdf->SetFont('Arial','B',16); $pdf->Cell(35,10,$user[0]['cost'],0,0,'R'); $pdf->Ln(); $pdf->SetY(30+57*$line); $pdf->SetX( 52+92*$box); $pdf->SetFont('Arial','',8); $pdf->Cell(50,6,$result[$i]['packet'],0,0,'C'); $pdf->Ln(); $pdf->SetY(54+57*$line); $pdf->SetX( 55+92*$box); $pdf->SetFont('Arial','B', 12); $pdf->Cell(50,6,$result[$i]['username'],0,0,'C'); $pdf->Ln(); $pdf->SetY(63+57*$line); $pdf->SetX( 55+92*$box); $pdf->Cell(50,6,$result[$i]['pin'],0,0,'C'); $box ++; if ( $this->owner->config['pdf_page_size'] == 1) { if ( $box == 3) { $line ++; $box = 0; } if ( $line == 6) $line = 0; } else { if ( $box == 2) { $line ++; $box = 0; } if ( $line == 4) $line = 0; } $i ++; } $pdf->Output('users - Series_'.$GLOBALS['sid'].'_Nominal_'.number_format($user[0]['cost'], 0, '', '').'.pdf', true); } } public function pdf_one() { if ( isset($GLOBALS['uid'])) { $query = "SELECT sk_users.username , sk_users.password, sk_users.sid as pin, sk_packets.packet
				FROM sk_users, sk_packets WHERE sk_packets.gid=sk_users.gid AND sk_users.uid = ? AND sk_users.blocked = 0"; $result = $this->db->GetAll($query, $GLOBALS['uid']); if ( !$result) return; $query = "SELECT cost, date_expire AS expire, url FROM sk_card_series WHERE sid = ?"; $user = $this->db->GetAll($query, $result[0]['pin']); require_once(dirname(__FILE__).'/../../tcpdf/tcpdf.php'); $pdf_currency = $this->owner->db->get_currency_sign(1); $pdf = new TCPDF('P','mm','A4'); $pdf->Open(); $pdf->SetMargins(10,10,20); $pdf->SetAutoPageBreak('on',20); $pdf->AddFont('Arial', '', 'arial.php'); $pdf->AddFont('Arial','B','arialb.php'); $pdf->AddFont('Courier', '', 'cour.php'); $pdf->SetFont('Arial','',10); $box = 0; $line = 0; $i = 0; while (isset($result[$i]) && is_array($result[$i])) { if ( $line == 0 && $box == 0) $pdf->AddPage(); $pdf->SetY( 20+57*$line); $pdf->SetX( 10+92*$box); $pdf->Cell( 92, 57, '', 1, 0); $pdf->Image('/opt/stasoft/www'.$user[0]['url'], 11+92*$box, 21+57*$line, 90, 55); $pdf->Ln(); $pdf->SetY( 21+57*$line); $pdf->SetX( 52+92*$box); $pdf->SetFont('Arial','B',16); $pdf->Cell(35,10,$user[0]['cost'],0,0,'R'); $pdf->Ln(); $pdf->SetY(30+57*$line); $pdf->SetX( 52+92*$box); $pdf->SetFont('Arial','',8); $pdf->Cell(50,6,$result[$i]['packet'],0,0,'C'); $pdf->Ln(); $pdf->SetY(54+57*$line); $pdf->SetX( 55+92*$box); $pdf->SetFont('Arial','B', 12); $pdf->Cell(50,6,$result[$i]['username'],0,0,'C'); $pdf->Ln(); $pdf->SetY(63+57*$line); $pdf->SetX( 55+92*$box); $pdf->Cell(50,6,$result[$i]['pin'],0,0,'C'); $box ++; if ( $box == 2) { $line ++; $box = 0; } if ( $line == 4) $line = 0; $i ++; } $pdf->Output('user-'.$GLOBALS['uid'].'-Nominal_'.number_format($user[0]['cost'], 0, '', '').'.pdf', true); } Refresh('q=rad.RecCard2.print_card_as_pdf&page=0'); } } ?>
