Advertisement
Guest User

membercard_generator untuk cendana1

a guest
Oct 20th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 24.71 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * Copyright (C) 2007,2008  Arie Nugraha (dicarve@yahoo.com)
  4.      *
  5.      * This program is free software; you can redistribute it and/or modify
  6.      * it under the terms of the GNU General Public License as published by
  7.      * the Free Software Foundation; either version 3 of the License, or
  8.      * (at your option) any later version.
  9.      *
  10.      * This program is distributed in the hope that it will be useful,
  11.      * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.      * GNU General Public License for more details.
  14.      *
  15.      * You should have received a copy of the GNU General Public License
  16.      * along with this program; if not, write to the Free Software
  17.      * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  18.      *
  19.      */
  20.      
  21.     /* Member card print */
  22.      
  23.     // key to authenticate
  24.     define('INDEX_AUTH', '1');
  25.      
  26.     // main system configuration
  27.     require '../../../sysconfig.inc.php';
  28.     // IP based access limitation
  29.     require LIB.'ip_based_access.inc.php';
  30.     do_checkIP('smc');
  31.     do_checkIP('smc-membership');
  32.     // start the session
  33.     require SB.'admin/default/session.inc.php';
  34.     require SB.'admin/default/session_check.inc.php';
  35.     require SIMBIO.'simbio_GUI/table/simbio_table.inc.php';
  36.     require SIMBIO.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
  37.     require SIMBIO.'simbio_GUI/paging/simbio_paging.inc.php';
  38.     require SIMBIO.'simbio_DB/datagrid/simbio_dbgrid.inc.php';
  39.     require SIMBIO.'simbio_DB/simbio_dbop.inc.php';
  40.      
  41.     // privileges checking
  42.     $can_read = utility::havePrivilege('membership', 'r');
  43.      
  44.     if (!$can_read) {
  45.         die('<div class="errorBox">You dont have enough privileges to view this section</div>');
  46.     }
  47.      
  48.     // local settings
  49.     $max_print = 10;
  50.      
  51.     // clean print queue
  52.     if (isset($_GET['action']) AND $_GET['action'] == 'clear') {
  53.         // update print queue count object
  54.         echo '<script type="text/javascript">parent.$(\'#queueCount\').html(\'0\');</script>';
  55.         utility::jsAlert(__('Print queue cleared!'));
  56.         unset($_SESSION['card']);
  57.         exit();
  58.     }
  59.      
  60.     if (isset($_POST['itemID']) AND !empty($_POST['itemID']) AND isset($_POST['itemAction'])) {
  61.         if (!$can_read) {
  62.             die();
  63.         }
  64.         if (!is_array($_POST['itemID'])) {
  65.             // make an array
  66.             $_POST['itemID'] = array($_POST['itemID']);
  67.         }
  68.         // loop array
  69.         if (isset($_SESSION['card'])) {
  70.             $print_count = count($_SESSION['card']);
  71.         } else {
  72.             $print_count = 0;
  73.         }
  74.         // card size
  75.         $size = 2;
  76.         // create AJAX request
  77.         echo '<script type="text/javascript" src="'.JWB.'jquery.js"></script>';
  78.         echo '<script type="text/javascript">';
  79.         // loop array
  80.         foreach ($_POST['itemID'] as $itemID) {
  81.             if ($print_count == $max_print) {
  82.                 $limit_reach = true;
  83.                 break;
  84.             }
  85.             if (isset($_SESSION['card'][$itemID])) {
  86.                 continue;
  87.             }
  88.             if (!empty($itemID)) {
  89.                 $card_text = trim($itemID);
  90.                 echo '$.ajax({url: \''.SWB.'lib/phpbarcode/barcode.php?code='.$card_text.'&encoding='.$sysconf['barcode_encoding'].'&scale='.$size.'&mode=png\', type: \'GET\', error: function() { alert(\'Error creating member card!\'); } });'."\n";
  91.                 // add to sessions
  92.                 $_SESSION['card'][$itemID] = $itemID;
  93.                 $print_count++;
  94.             }
  95.         }
  96.         echo '</script>';
  97.         if (isset($limit_reach)) {
  98.             $msg = str_replace('{max_print}', $max_print, __('Selected items NOT ADDED to print queue. Only {max_print} can be printed at once')); //mfc
  99.             utility::jsAlert($msg);
  100.         } else {
  101.             // update print queue count object
  102.             echo '<script type="text/javascript">parent.$(\'#queueCount\').html(\''.$print_count.'\');</script>';
  103.             utility::jsAlert(__('Selected items added to print queue'));
  104.         }
  105.         exit();
  106.     }
  107.      
  108.     // card pdf download
  109.     if (isset($_GET['action']) AND $_GET['action'] == 'print') {
  110.         // check if label session array is available
  111.         if (!isset($_SESSION['card'])) {
  112.             utility::jsAlert(__('There is no data to print!'));
  113.             die();
  114.         }
  115.         if (count($_SESSION['card']) < 1) {
  116.             utility::jsAlert(__('There is no data to print!'));
  117.             die();
  118.         }
  119.         // concat all ID together
  120.         $member_ids = '';
  121.         foreach ($_SESSION['card'] as $id) {
  122.             $member_ids .= '\''.$id.'\',';
  123.         }
  124.         // strip the last comma
  125.         $member_ids = substr_replace($member_ids, '', -1);
  126.         // send query to database
  127.         /*$member_q = $dbs->query('SELECT m.member_name, m.member_id, m.member_image, mt.member_type_name FROM member AS m
  128.             LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id
  129.             WHERE m.member_id IN('.$member_ids.')'); */
  130.             /*
  131.             member_id       member_name     member_image member_type_id     member_address  member_mail_address     member_email    postal_code     inst_name                       member_phone    member_since_date       register_date   expire_date     input_date
  132.      
  133.             */
  134.      
  135.             $member_q = $dbs->query('SELECT m.member_name, m.member_id, m.member_image, m.member_address, m.member_email, m.inst_name, m.postal_code, m.pin, m.member_phone, m.expire_date, m.register_date, mt.member_type_name FROM member AS m
  136.            LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id
  137.            WHERE m.member_id IN('.$member_ids.')');
  138.         $member_datas = array();
  139.         while ($member_d = $member_q->fetch_assoc()) {
  140.             if ($member_d['member_id']) {
  141.                 $member_datas[] = $member_d;
  142.             }
  143.         }
  144.      
  145.         // include printed settings configuration file
  146.         include SB.'admin'.DS.'admin_template'.DS.'printed_settings.inc.php';
  147.         // check for custom template settings
  148.         $custom_settings = SB.'admin'.DS.$sysconf['admin_template']['dir'].DS.$sysconf['template']['theme'].DS.'printed_settings.inc.php';
  149.         if (file_exists($custom_settings)) {
  150.             include $custom_settings;
  151.         }
  152.      
  153.               // load print settings from database to override value from printed_settings file
  154.         loadPrintSettings($dbs, 'membercard');
  155.      
  156.         // chunk cards array
  157.         $chunked_card_arrays = array_chunk($member_datas, $sysconf['print']['membercard']['items_per_row']);
  158.         // create html ouput
  159.         $html_str = '<!DOCTYPE html>'."\n";
  160.         $html_str .= '<html><head><title>Member Card by Jushadi Arman Saz</title>'."\n";
  161.         $html_str .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
  162.         $html_str .= '<meta http-equiv="Pragma" content="no-cache" /><meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0" /><meta http-equiv="Expires" content="Fry, 02 Oct 2012 12:00:00 GMT" />';
  163.         $html_str .= '<style type="text/css">'."\n";
  164.         $html_str .= '*{font:'.$sysconf['print']['membercard']['bio_font_size'].'px Arial, Helvetica, sans-serif;}'."\n";
  165.         $html_str .= 'p, li{position: relative;}'."\n";
  166.         $html_str .= 'p{margin-bottom: 0px;margin-top: 0px;font-weight: bold;}'."\n";
  167.         $html_str .= 'li{margin-bottom: 0px; margin-top: 0px;list-style-type: disc;font-size: '.$sysconf['print']['membercard']['rules_font_size'].'px;}'."\n";
  168.         $html_str .= 'ul{margin: 0px;padding-left: 10px;}'."\n";
  169.         $html_str .= 'h1{margin: 0px;font-weight: bold;text-align: center;font-size:'.$sysconf['print']['membercard']['front_header1_font_size'].'px;}'."\n";
  170.         $html_str .= 'h2{margin: 0px;font-weight: bold;text-align: center;padding-bottom:3px;font-size:'.$sysconf['print']['membercard']['front_header2_font_size'].'px;}'."\n";
  171.         $html_str .= 'h3{margin: 0px;font-weight: bold;text-align: center;padding-bottom:3px;font-size:'.$sysconf['print']['membercard']['back_header2_font_size'].'px;}'."\n";
  172.         $html_str .= 'hr{margin: 0px;border: 1px solid '.$sysconf['print']['membercard']['header_color'].';position: relative;}'."\n";
  173.         $html_str .= '#header1_div{z-index:2;position: absolute;left: 61px;top: 4px;width:245px;height: 45px;color:'.$sysconf['print']['membercard']['header_color'].';}'."\n";
  174.         $html_str .= '#header2_div{z-index:3;position: absolute;left: 10px;top: 4px;width:300px;height: 43px;color:'.$sysconf['print']['membercard']['header_color'].';}'."\n";
  175.         $html_str .= '#rules_div{z-index:4;position: absolute;left: 12px;top: 58px;width:300px;height: 142px;text-align: justify;}'."\n";
  176.         $html_str .= '#address_div{z-index:4;position: absolute;left: 9px;top: 175px;width:300px;height: 20px;font-size:'.$sysconf['print']['membercard']['address_font_size'].'px;}'."\n";
  177.         $html_str .= '#logo_div{z-index:5;position: absolute;left: 10px;top: 4px;width: 35px;height:35px;}'."\n";
  178.         $html_str .= '#photo_blank_div{z-index:5;position: absolute;left: 10px;top:130px;font-size: 7px;text-align: center;border:#cccccc solid 1px;width:'.($sysconf['print']['membercard']['photo_width']*$sysconf['print']['membercard']['factor']).'px; height:'.($sysconf['print']['membercard']['photo_height']*$sysconf['print']['membercard']['factor']).'px;}'."\n";
  179.         $html_str .= '#photo_div{z-index:6;position: absolute;left: 10px;top:130px;border:#cccccc solid 1px;width:'.($sysconf['print']['membercard']['photo_width']*$sysconf['print']['membercard']['factor']).'px; height:'.($sysconf['print']['membercard']['photo_height']*$sysconf['print']['membercard']['factor']).'px;}'."\n";
  180.         $html_str .= '#front_side{background: url('.SWB.'files/membercard/'.$sysconf['print']['membercard']['front_side_image'].') center center;}'."\n";
  181.         $html_str .= '#back_side{background: url('.SWB.'files/membercard/'.$sysconf['print']['membercard']['back_side_image'].') center center;}'."\n";
  182.         $html_str .= '.container_div{z-index:1;position: relative; width:'.($sysconf['print']['membercard']['box_width']*$sysconf['print']['membercard']['factor']).'px; height:'.($sysconf['print']['membercard']['box_height']*$sysconf['print']['membercard']['factor']).'px;margin-bottom:'.($sysconf['print']['membercard']['items_margin']*$sysconf['print']['membercard']['factor']).'px;;border:#CCCCCC solid 1px;-moz-border-radius: 8px;border-radius: 8px;}'."\n";
  183.         $html_str .= '.bio_div{z-index:7;position: absolute;left: 0px;top:48px;height: 110px;margin: 0px;text-align: justify;}'."\n";
  184.         $html_str .= '.bio_address{z-index:8;top: 0px;}'."\n";
  185.         $html_str .= '.bio_label{ z-index:9;float: left;width: 100px;text-align:left;padding-left: 10px;}'."\n";
  186.         $html_str .= '.label_address{z-index:10;float: left; width: 200px;margin-bottom:0px;margin-left:3px;}'."\n";
  187.         $html_str .= '.stamp_div{z-index:11;position: absolute;left: 100px;top:140px;margin-bottom: 34px;width: 118px;}'."\n";
  188.         $html_str .= '.stamp{z-index:12;text-align: left;margin: 0px;}'."\n";
  189.         $html_str .= '.city{z-index:13;font-size:8px;margin: 0px;}'."\n";
  190.         $html_str .= '.title{z-index:14;font-size:8px;margin: 0px;}'."\n";
  191.         $html_str .= '.officials{z-index:15;top: 0px;font-size: 8px;margin: 0px;}'."\n";
  192.         $html_str .= '.sign_file_div{z-index:16;position: absolute;left: -10px;top: 10px;width:107px;height: 25px;}'."\n";
  193.         $html_str .= '.stamp_file_div{z-index:17;position: absolute;left:-20px;top: 5px;width: 40px;height: 40px;}'."\n";
  194.         $html_str .= '.exp_div{z-index:18;position: absolute;left: 200px;top: 142px;width:110px;height: 12px;font-size: 8px;text-align: right;}'."\n";
  195.         $html_str .= '.barcode_div{z-index:19;position: absolute;left: 200px;top: 154px;width:112px;height: 42px;}'."\n";
  196.         $html_str .= '.mirror{display:block;-moz-transform: matrix(-1, 0, 0, 1, 0, 0);-webkit-transform: matrix(-1, 0, 0, 1, 0, 0);-o-transform:matrix(-1, 0, 0, 1, 0, 0);       }'."\n";
  197.         $html_str .= '</style>'."\n";
  198.         $html_str .= '</head>'."\n";
  199.          if (!$_GET[mirror])  
  200.             { $html_str .= '<body>'."\n"; }
  201.             else                            
  202.             { $html_str .= '<body class="mirror">'."\n"; }
  203.         $html_str .= '<a href="#" onclick="window.print()">Print Again</a><br /><br />'."\n";
  204.         $html_str .= '<table style="margin: 0; padding: 0;" cellspacing="0" cellpadding="0">'."\n";
  205.         // loop the chunked arrays to row
  206.         foreach ($chunked_card_arrays as $membercard_rows) {
  207.             $html_str .= '<tr>'."\n";
  208.             foreach ($membercard_rows as $card) {
  209.               $html_str .= '<td valign="top">';
  210.               $html_str .= '<div class="container_div" id="front_side">';
  211.               $html_str .= '<div><img width="'.($sysconf['print']['membercard']['box_width']*$sysconf['print']['membercard']['factor']).'px" height="'.($sysconf['print']['membercard']['box_height']*$sysconf['print']['membercard']['factor']).'px" src="'.SWB.'files/membercard/card1.png" style="border-radius: 8px; -moz-border-radius: 8px;-khtml-border-radius: 8px;-webkit-border-radius: 8px;" /></div>';
  212.               $html_str .= '<div id="logo_div"><img height="40px" width="40px" src="'.SWB.'files/membercard/'.$sysconf['print']['membercard']['logo'].'" /></div>';
  213.               $html_str .= '<div id="header1_div">';
  214.               $html_str .= '<h1>'.$sysconf['print']['membercard']['front_header1_text'].'</h1>';
  215.               $html_str .= '<h2>'.$sysconf['print']['membercard']['front_header2_text'].'</h2></div>';
  216.               $html_str .= '<div class="bio_div">';
  217.               $html_str .= ''.( $sysconf['print']['membercard']['include_id_label']?'':'<!--').'<p class="bio"><label class="bio_label">'.__('Member ID').'</label><span>: </span>'.$card['member_id'].'</p>'.( $sysconf['print']['membercard']['include_id_label']?'':'-->').'';
  218.               $html_str .= ''.( $sysconf['print']['membercard']['include_name_label']?'':'<!--').'<p class="bio"><label class="bio_label">'.__('Member Name').'</label><span>: </span>'.$card['member_name'].'</p>'.( $sysconf['print']['membercard']['include_name_label']?'':'-->').'';
  219.               $html_str .= ''.( $sysconf['print']['membercard']['include_pin_label']?'':'<!--').'<p class="bio"><label class="bio_label">'.__('Personal ID Number').'</label><span>: </span>'.$card['pin'].'</p>'.( $sysconf['print']['membercard']['include_pin_label']?'':'-->').'';
  220.               $html_str .= ''.( $sysconf['print']['membercard']['include_inst_label']?'':'<!--').'<p class="bio_address"><label class="bio_label">'.__('Institution').'</label><span style="float:left">: </span>'.( $sysconf['print']['membercard']['include_inst_label']?'':'-->').'';
  221.               $html_str .= ''.( $sysconf['print']['membercard']['include_inst_label']?'':'<!--').'<span class="label_address">'.$card['inst_name'].'</span></p>'.( $sysconf['print']['membercard']['include_inst_label']?'':'-->').'';
  222.               $html_str .= ''.( $sysconf['print']['membercard']['include_email_label']?'':'<!--').'<p class="bio"><label class="bio_label">'.__('E-mail').'</label><span>: </span>'.$card['member_email'].'</p>'.( $sysconf['print']['membercard']['include_email_label']?'':'-->').'';
  223.               $html_str .= ''.( $sysconf['print']['membercard']['include_address_label']?'':'<!--').'<p class="bio_address"><label class="bio_label">'.__('Address').' / '.__('Phone Number').'</label><span style="float:left">: </span>'.( $sysconf['print']['membercard']['include_address_label']?'':'-->').'';
  224.               $html_str .= ''.( $sysconf['print']['membercard']['include_address_label']?'':'<!--').'<span class="label_address">'.$card['member_address'].' / '.$card['member_phone'].'</span></p>'.( $sysconf['print']['membercard']['include_address_label']?'':'-->').'';
  225.               $html_str .= '</div>';
  226.               $html_str .= '<div id="photo_blank_div"><br />Photo size:<br />'.$sysconf['print']['membercard']['photo_width'].' X '.$sysconf['print']['membercard']['photo_height'].' cm</div>';
  227.               $html_str .= '<div id="photo_div"><img width="'.($sysconf['print']['membercard']['photo_width']*$sysconf['print']['membercard']['factor']).'px" height="'.($sysconf['print']['membercard']['photo_height']*$sysconf['print']['membercard']['factor']).'px" src="'.SWB.IMG.'/persons/'.$card['member_image'].'" /></div>';
  228.               $html_str .= ''.( $sysconf['print']['membercard']['include_expired_label']?'':'<!--').'<div class="exp_div">'.__('Expiry Date').' : '.$card['expire_date'].'</div>'.( $sysconf['print']['membercard']['include_expired_label']?'':'-->').'';
  229.               $html_str .= ''.( $sysconf['print']['membercard']['include_barcode_label']?'':'<!--').'<div class="barcode_div">';
  230.               $html_str .= '<img  width="175px" height="40px" src="'.SWB.IMG.'/barcodes/'.str_replace(array(' '), '_', $card['member_id']).'.png" style="width: '.$sysconf['print']['membercard']['barcode_scale'].'%; border="0px" /></img></div>'.( $sysconf['print']['membercard']['include_barcode_label']?'':'-->').'';
  231.               $html_str .= '<div class="stamp_div">';
  232.               $html_str .= '<div class="stamp_file_div"><img class="" height="35px" width="35px" src="'.SWB.'files/membercard/'.$sysconf['print']['membercard']['stamp_file'].'"></img></div>';
  233.               $html_str .= '<div class="sign_file_div"><img class="" height="30px" width="100px" src="'.SWB.'files/membercard/'.$sysconf['print']['membercard']['signature_file'].'"></img></div>';
  234.               $html_str .= '<p class="stamp city">'.$sysconf['print']['membercard']['city'].', '.$card['register_date'].'</p><p class="stamp title">'.$sysconf['print']['membercard']['title'].'</p><br>';
  235.               $html_str .= '<p class="stamp officials">'.$sysconf['print']['membercard']['officials'].'<br />'.$sysconf['print']['membercard']['officials_id'].'</p></div></div></td>';
  236.               $html_str .= '<td valign="top">';
  237.               $html_str .= '<div class="container_div" id="back_side">';
  238.               $html_str .= '<div><img height="'.($sysconf['print']['membercard']['box_height']*$sysconf['print']['membercard']['factor']).'px" width="'.($sysconf['print']['membercard']['box_width']*$sysconf['print']['membercard']['factor']).'px" src="'.SWB.'files/membercard/card2.png" style="border-radius: 8px; -moz-border-radius: 8px;-khtml-border-radius: 8px;-webkit-border-radius: 8px;" /></div>';
  239.               $html_str .= '<div id="logo_div"><img height="35px" width="35px" src="'.SWB.'files/membercard/'.$sysconf['print']['membercard']['logo'].'" /></div>';
  240.               $html_str .= '<div id="header2_div">';
  241.               $html_str .= '<h1>'.$sysconf['print']['membercard']['back_header1_text'].'</h1>';
  242.               $html_str .= '<h3>'.$sysconf['print']['membercard']['back_header2_text'].'</h3><hr></div>';
  243.               $html_str .= '<div id="rules_div">'.$sysconf['print']['membercard']['rules'].'</div>';
  244.               $html_str .= '<div id="address_div">'.$sysconf['print']['membercard']['address'].'</div></div>';
  245.               $html_str .= '</td>';
  246.             }
  247.             $html_str .= '<tr>'."\n";
  248.         }
  249.         $html_str .= '</table>'."\n";
  250.         $html_str .= '<script type="text/javascript">self.print();</script>'."\n";
  251.         $html_str .= '</body></html>'."\n";
  252.         // unset the session
  253.         unset($_SESSION['card']);
  254.         // write to file
  255.         $print_file_name = 'member_card_gen_print_result_'.strtolower(str_replace(' ', '_', $_SESSION['uname'])).'.html';
  256.         $file_write = @file_put_contents(UPLOAD.$print_file_name, $html_str);
  257.         if ($file_write) {
  258.             // update print queue count object
  259.             echo '<script type="text/javascript">parent.$(\'#queueCount\').html(\'0\');</script>';
  260.             // open result in window
  261.             echo '<script type="text/javascript">top.jQuery.colorbox({href: "'.SWB.FLS.'/'.$print_file_name.'", iframe: true, width: 800, height: 500, title: "'.__('Member Card Printing').'"})</script>';
  262.         } else { utility::jsAlert('ERROR! Cards failed to generate, possibly because '.SB.FLS.' directory is not writable'); }
  263.         exit();
  264.     }
  265.      
  266.     ?>
  267.     <fieldset class="menuBox">
  268.     <div class="menuBoxInner printIcon">
  269.             <div class="per_title">
  270.             <h2><?php echo __('Member Card Printing'); ?></h2>
  271.         </div>
  272.             <div class="sub_section">
  273.                     <div class="btn-group">
  274.                     <a target="blindSubmit" href="<?php echo MWB; ?>membership/member_card_generator.php?action=clear" class="notAJAX btn btn-default" style="color: #f00;"><i class="glyphicon glyphicon-trash"></i>&nbsp;<?php echo __('Clear Print Queue'); ?></a>
  275.                     <a target="blindSubmit" href="<?php echo MWB; ?>membership/member_card_generator.php?action=print" class="notAJAX btn btn-default"><i class="glyphicon glyphicon-print"></i>&nbsp;<?php echo __('Print Member Cards for Selected Data'); ?></a>
  276.                     <a target="blindSubmit" href="<?php echo MWB; ?>membership/member_card_generator.php?action=print&mirror=1" class="notAJAX btn btn-default><i class="glyphicon glyphicon-print"></i><?php echo __('Print Mirror Member Cards for Selected Data'); ?></a>
  277.                     <a href="<?php echo MWB; ?>bibliography/pop_print_settings.php?type=membercard" class="notAJAX btn btn-default openPopUp" title="<?php echo __('Member card print settings'); ?>"><i class="glyphicon glyphicon-wrench"></i></a>
  278.         </div>
  279.                 <form name="search" action="<?php echo MWB; ?>membership/member_card_generator.php" id="search" method="get" style="display: inline;"><?php echo __('Search'); ?>:
  280.                 <input type="text" name="keywords" size="30" />
  281.                 <input type="submit" id="doSearch" value="<?php echo __('Search'); ?>" class="button" />
  282.                 </form>
  283.         </div>
  284.         <div class="infoBox">
  285.         <?php
  286.         echo __('Maximum').' <font style="color: #f00">'.$max_print.'</font> '.__('records can be printed at once. Currently there is').' '; //mfc
  287.         if (isset($_SESSION['card'])) {
  288.             echo '<font id="queueCount" style="color: #f00">'.count($_SESSION['card']).'</font>';
  289.         } else { echo '<font id="queueCount" style="color: #f00">0</font>'; }
  290.         echo ' '.__('in queue waiting to be printed.'); //mfc
  291.         ?>
  292.         </div>
  293.     </div>
  294.     </fieldset>
  295.     <?php
  296.     /* search form end */
  297.     /* ITEM LIST */
  298.     // table spec
  299.     $table_spec = 'member AS m
  300.        LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id';
  301.     // create datagrid
  302.     $datagrid = new simbio_datagrid();
  303.     $datagrid->setSQLColumn('m.member_id',
  304.         'm.member_id AS \''.__('Member ID').'\'',
  305.         'm.member_name AS \''.__('Member Name').'\'',
  306.         'mt.member_type_name AS \''.__('Membership Type').'\'');
  307.     $datagrid->setSQLorder('m.last_update DESC');
  308.     // is there any search
  309.     if (isset($_GET['keywords']) AND $_GET['keywords']) {
  310.         $keyword = $dbs->escape_string(trim($_GET['keywords']));
  311.         $words = explode(' ', $keyword);
  312.         if (count($words) > 1) {
  313.             $concat_sql = ' (';
  314.             foreach ($words as $word) {
  315.                 $concat_sql .= " (m.member_id LIKE '%$word%' OR m.member_name LIKE '%$word%'";
  316.             }
  317.             // remove the last AND
  318.             $concat_sql = substr_replace($concat_sql, '', -3);
  319.             $concat_sql .= ') ';
  320.             $datagrid->setSQLCriteria($concat_sql);
  321.         } else {
  322.             $datagrid->setSQLCriteria("m.member_id LIKE '%$keyword%' OR m.member_name LIKE '%$keyword%'");
  323.         }
  324.     }
  325.     // set table and table header attributes
  326.     $datagrid->table_attr = 'align="center" id="dataList" cellpadding="5" cellspacing="0"';
  327.     $datagrid->table_header_attr = 'class="dataListHeader" style="font-weight: bold;"';
  328.     // edit and checkbox property
  329.     $datagrid->edit_property = false;
  330.     $datagrid->chbox_property = array('itemID', __('Add'));
  331.     $datagrid->chbox_action_button = __('Add To Print Queue');
  332.     $datagrid->chbox_confirm_msg = __('Add to print queue?');
  333.     $datagrid->column_width = array('10%', '70%', '15%');
  334.     // set checkbox action URL
  335.     $datagrid->chbox_form_URL = $_SERVER['PHP_SELF'];
  336.     // put the result into variables
  337.     $datagrid_result = $datagrid->createDataGrid($dbs, $table_spec, 20, $can_read);
  338.     if (isset($_GET['keywords']) AND $_GET['keywords']) {
  339.         echo '<div class="infoBox">'.__('Found').' '.$datagrid->num_rows.' '.__('from your search with keyword').': "'.$_GET['keywords'].'"</div>'; //mfc
  340.     }
  341.     echo $datagrid_result;
  342.     /* main content end */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement