<?php include('views/_header.tpl.php'); ?>
<style>
	#mmen { display:none; }
	.spacer { padding-top:57px; }
	.form .row-item .val { margin-bottom:10px; }
	.form .row-item .lbl { min-width:70px; margin-top:5px; }
	.form .txt { font-weight:300; }
	.btn { padding: 15px 25px; font-size:15px;  font-weight:300; margin-right:10px; }
</style>

 <div class="home-feature-category" style="background:none; border:none;">
        <div class="container_12 clearfix">
        <div class="grid_8 marked-category">

        <h1 style="margin-bottom:0px;"><a href="/admin/promocodes">&laquo; Back</a> | <?php
        
        if ($pcode) {
            echo "Edit";
        } else {
            echo "Add";
            $def = "/static/uploads/promocodes/placeholder.jpg";
        }
        
        ?> Promo Code</h1>

        <form method="post" class="form form-profile" enctype="multipart/form-data" style="padding:25px 0px 0px;">
            <div class="row-item clearfix" style="padding-bottom:10px; font-size:17px; color:#000; font-weight:300;">
            
                When a person scans this QR Code it&rsquo;ll return <span style="font-weight:600;"><?= $pcode['code'] ?></span>
                <br /><br />
                <?php 
                    require_once '3rdparty/phpqrcode/qrlib.php';
                    
                    $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'promocodes'.DIRECTORY_SEPARATOR;
                    $PNG_WEB_DIR = '3rdparty/phpqrcode/promocodes/';
                    $fname = 'promocodes_' . $pcode['code'] . '.png';
                    $filename2 = __DIR__ . '/../../3rdparty/phpqrcode/promocodes/' . $fname;
                    $filename = $PNG_TEMP_DIR.$fname;
                    
                    $qr_string = array(
                        'type' => 'promocode',
                        'code' => $pcode['code']
                    );
                    
                    $qrString = json_encode($qr_string);
                    
                    QRcode::png($qrString, $filename2);
                
                    echo '<img src="/'.$PNG_WEB_DIR.basename($filename).'" style="max-width:200px;" />';  
               ?>
                <br /><br /><br />            
        
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">ID:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="id" value="<?= $pcode['id'] ?>" readonly>
                    <p class="rs description-input"></p>
                </div>

                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Code:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="code" value="<?= $pcode['code'] ?>">
                    <p class="rs description-input"></p>
                </div>
                      
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Type:</label>
                <div class="val" style="margin-left:0px;">
			       <select name="type" id="" class="txt" type="number" style="background:#fff;" <!--name="projectid"-->>
			           <option value="">Select User Type</option>
			           <option value="1" <?php if($pcode['type'] == '1') echo "selected"; ?>>Percentage</option>
			           <option value="2" <?php if($pcode['type'] == '2') echo "selected"; ?>>Flat</option>     
			       </select>                 
                    <p class="rs description-input"></p>
                </div>
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Amount:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="amount" value="<?= $pcode['amount'] ?>">
                    <p class="rs description-input"></p>
                </div>

                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Allowed:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="allowed" value="<?= $pcode['allowed'] ?>">
                    <p class="rs description-input"></p>
                </div>              
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Claimed:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="claimed" value="<?= $pcode['claimed'] ?>">
                    <p class="rs description-input"></p>
                </div>       
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Client:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="client" value="<?= $pcode['client'] ?>">
                    <p class="rs description-input"></p>
                </div>     
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Total:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="total" value="<?= $pcode['total'] ?>">
                    <p class="rs description-input">sometimes used to store the total claimed value</p>
                </div>                                              
    
            </div>
            <br />
            <input type="submit" style="font-weight:300" class="btn btn-blue" /> 
            <input type="button" value="Cancel" class="btn btn-blue" onclick="location = '/admin/promocodes'" />
        </form>

        </div>
    </div>
</div>

<?php include('views/_footer.tpl.php'); ?>