<?php

include('views/_header.tpl.php');

?>

<script type="text/javascript" src="/static/js/jQuery/js/jquery.lightbox.js"></script>
<link rel="stylesheet" type="text/css" href="/static/js/jQuery/css/jquery.lightbox.css" media="screen" />

<style>
div.spacer { padding-top: 60px; }
    label { width:75px !important; }
    #mmen { display:none; }
    .form .txt { 
        margin-bottom:10px;
        padding: 15px;
        font-size:15px;
    }    
    .form .row-item .lbl {
        float: left;
        padding-top: 14px;
    }    
   .form .description-input {
        margin-left: 79px;    
    }
.form .row-item .btn {
    padding: 10px 30px;
    margin-bottom: 3px;
    margin-left: 5px;
    margin-right:5px;
}    
input[type="button"], input[type="reset"], input[type="submit"], input[type="radio"], input[type="checkbox"] {
    font-size:15px;
    padding: 7px 20px;
}    

input[type="button"], input[type="reset"], input[type="submit"] {
    font-size: 15px;
    padding: 7px 20px;
    font-weight:300;
    border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px;
}    
    
a.confirm { 
    margin-top: 7px;
    color:#ff0000; 
    background: rgba(255,255,255,.2);
    padding:5px 15px;
    border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px;
}   

    .fancybox-close {
        position: absolute;
        top: 250px;
        right: -50px;
        width: 36px;
        height: 36px;
        cursor: pointer;
        z-index: 8040;
    } 
    
    .fancybox-next span {
    right: 5px;
    position: fixed;
}

#footer {
    padding: 0px 0 0 0;
}

#footer .main-footer {
    display:none;
}

a.btn-red { background:#cd1000; }

    
/* ############################################### */
/* ####### The Switch - the box around the slider ####### */
/* ############################################### */

.switch {
  position: relative;
  display: inline-block;
  width: 60px !important;
  height: 32px;
}

/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
.sliderr {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.sliderr:before {
  position: absolute;
  content: "";
  height: 28px;
  width: 28px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .sliderr {
  background-color: #98cb54;
}

input:focus + .sliderr {
  box-shadow: 0 0 1px #98cb54;
}

input:checked + .sliderr:before {
  -webkit-transform: translateX(28px);
  -ms-transform: translateX(28px);
  transform: translateX(28px);
}

/* Rounded sliders */
.sliderr.round {
  border-radius: 32px; -moz-border-radius: 32px; -webkit-border-radius: 32px;
}

.sliderr.round:before {
  border-radius: 50%;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  
}
/* ##################################################### */
/* ##############     The Switch ENDS     ############## */
/* ##################################################### */    
</style>

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

        <h1 style="margin-bottom:0px;">
			<a href="/admin/users">« Back</a> | 
        <?php
        
        if ($squareuser) {
            echo "Edit";
            $actual_balance = $squareuser['virtual_balance']/100;
            $ewallet_balance = number_format($actual_balance,2,".",",");      
        } else {
            echo "Add";
            $def = "/static/system/placeholder.jpg";
        }
        
        ?> Member Account</h1>

        <form method="post" class="form form-profile" enctype="multipart/form-data" style="padding:15px 0px 0px;">
            <div class="row-item clearfix" style="padding-bottom:10px;">
                
                <div style="max-width:450px; background:none; font-weight:300; font-size:11px;">
                    <a href='/api/webservices/index.php?command=SquareCreateCustomer&sq_id=<?= $squareuser['id'] ?>'  target="_blank">Create Member ID</a> -         
                    This is the Member&rsquo;s same Unique QR Code from their App. So you can scan it with the 
                    QR Scanner on the App&rsquo;s Manage E-Wallet page or the Give Stars page to adjust their 
                    E-Wallet Balance or give them more Loyalty/Rewards Stars.
                </div>
                <br />
                <?php 
                    require_once '3rdparty/phpqrcode/qrlib.php';
                    
                    $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'members'.DIRECTORY_SEPARATOR;
                    $PNG_WEB_DIR = '3rdparty/phpqrcode/members/';
                    $fname = 'member_' . $squareuser['token'] . '.png';
                    $filename2 = __DIR__ . '/../../3rdparty/phpqrcode/members/' . $fname;
                    $filename = $PNG_TEMP_DIR.$fname;
                    
                    $qr_string = array(
                        'type' => 'virtual_balance',
                        'customer_id' => $squareuser['token'],
                        'device_id' => $squareuser['device_id']
                    );
                    
                    $qrString = json_encode($qr_string);
                    
                    QRcode::png($qrString, $filename2);
                
                    echo '<img src="/'.$PNG_WEB_DIR.basename($filename).'" style="max-width:200px" />';  
               ?>
                <br /><br />
                
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Img:</label>
                <div class="val" style="margin-left:0px; margin-bottom:10px;">
                    <img src="<?php if($squareuser) { echo "/static/images/users/agency/" .$squareuser['image']. ""; } else { echo "" . $def . ""; } ?>" 
                    style="border:3px solid #fff; border-radius:50%; height:95px; width:auto;" 
                        onerror="this.src='/static/images/users/default-avatar.jpg'" />
                    <br />
                </div>    
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">User Img:</label>
                <div class="val" style="margin-left:0px; font-size:12px !important;">
					<input type="file" name="image" style="font-size:12px; background:none;">
                    <p class="rs description-input"></p>
                </div>           
                
                <br />                            
 
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Reg Email:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="email" value="<?= $squareuser['email'] ?>" style="background:#ccc;">
                    <p class="rs description-input"></p>
                </div>
                
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">USlug:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="user_slug" value="<?= $squareuser['user_slug'] ?>" style="">
					<p class="rs description-input"></p>
				</div>                
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Square ID:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="square_id" value="<?= $squareuser['square_id'] ?>" 
                    readonly style="background:#ccc;">
                    <p class="rs description-input">if, this is missing click the Create Square ID button at bottom</p>
                </div>   
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Device ID:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="device_id" value="<?= $squareuser['device_id'] ?>" 
                    readonly style="background:#ccc;">
                    <p class="rs description-input"></p>
                </div>                  
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Token:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="token" value="<?= $squareuser['token'] ?>" 
                    readonly style="background:#ccc;">
                    <p class="rs description-input"></p>
                </div>                                 
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Phone:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="phone" value="<?= $squareuser['phone'] ?>">
                    <p class="rs description-input"></p>
                </div>                  
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Reg Date:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="reg_date" value="<?= $squareuser['reg_date'] ?>" 
                    readonly style="background:#ccc;">
                    <p class="rs description-input"></p>
                </div>         
                
                <br />
                
				<!-- /* ##################################################### */ -->
				<!-- /* ##############       MEMBER INFO       ############## */ -->
				<!-- /* ##################################################### */ -->  
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">&nbsp;</label>
                <div class="val" style="margin-left:0px; font-weight:800; color:#ccc; font-size:32px;">  
                            MEMBER INFO
                    <p class="rs description-input"></p>
                </div>       
                <div class="clear"></div>  
                
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">SocID:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="social_id" value="<?= $squareuser['social_id'] ?>">
					<p class="rs description-input"></p>
				</div>   
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Balance:</label>
                <div class="val" style="margin-left:0px; margin-bottom:10px;">
                    <input class="txt" type="text" name="virtual_balance" value="<?= $squareuser['virtual_balance'] ?>">
					<p class="rs description-input" style="color:#000;">Balance is in cents, so $<?php echo number_format($actual_balance,0,'',','); ?></p>
                </div>                                     
                
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Shares:</label>
				<div class="val" style="margin-left:0px; margin-bottom:10px;">
					<input class="txt" type="text" name="shares" value="<?= $squareuser['shares'] ?>">
					<p class="rs description-input">DevShares Shares</p>
				</div>  

				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Credits:</label>
				<div class="val" style="margin-left:0px; margin-bottom:10px;">
					<input class="txt" type="text" name="credits" value="<?= $squareuser['credits'] ?>">
					<p class="rs description-input">Managed Service Credits</p>
				</div>    
				
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Bids:</label>
				<div class="val" style="margin-left:0px; margin-bottom:10px;">
					<input class="txt" type="text" name="bids" value="<?= $squareuser['bids'] ?>">
					<p class="rs description-input">Bid Credits</p>
				</div>                                                                        

                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Full Name:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="name" value="<?= $squareuser['name'] ?>">
                    <p class="rs description-input"></p>
                </div>  

                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">First Name:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="given_name" value="<?= $squareuser['given_name'] ?>">
                    <p class="rs description-input"></p>
                </div>  
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Last Name:</label>
                <div class="val" style="margin-left:0px;">
                    <input class="txt" type="text" name="family_name" value="<?= $squareuser['family_name'] ?>">
                    <p class="rs description-input"></p>
                </div>          
                
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">BDay:</label>
				<div class="val" style="margin-left:0px; margin-bottom:10px;">
					<input class="txt" type="text" name="birthday" value="<?= $squareuser['birthday'] ?>"
					 style="margin-bottom:0px;">
                    <p class="rs description-input"><?= date('m/d/Y',strtotime($squareuser['birthday'])) ?></p>
                </div>   
                
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">PIN:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="pin_code" value="<?= $squareuser['pin_code'] ?>">
					<p class="rs description-input"></p>
				</div>   
				  
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">DevID:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="sentdevid" value="<?= $squareuser['sentdevid'] ?>">
					<p class="rs description-input">1 means it was sent. Set to 0 so the system sends again 
					(usually within 1 min)</p>
				</div> 
				
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">RefCode:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="refcode" value="<?= $squareuser['refcode'] ?>">
					<p class="rs description-input"></p>
				</div>   
				
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Ref:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="ref" value="<?= $squareuser['ref'] ?>">
					<p class="rs description-input"></p>
				</div>
				
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">RefBy:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="refby" value="<?= $squareuser['refby'] ?>">
					<p class="rs description-input"></p>
				</div>    
 
                <label class="lbl" for="txt_name1" 
                style="text-align:left; width:auto; margin-right:5px; margin-top:10px;">Type:</label>
                
                <div class="val" style="margin-left:0px; margin-top:10px;">
					<select name="usertype" id="" class="txt" type="number" style="background:#fff; line-height:45px; height:45px; padding:10px;" <!--name="projectid"-->>
			           <option value="">Select User Type</option>
			           <option value="Customer" <?php if($squareuser['usertype'] == 'Customer') echo "selected"; ?>>Customer</option>
			           <option value="Team" <?php if($squareuser['usertype'] == 'Team') echo "selected"; ?>>Team</option>
			           <option value="Admin" <?php if($squareuser['usertype'] == 'Admin') echo "selected"; ?>>Admin</option>                
			       </select> 
                    <p class="rs description-input"></p>
                </div>  
                                                  
                 <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px; 
                 margin-top:10px;">Level:</label>
                <div class="val" style="margin-left:0px; margin-top:10px;">
					<select name="permissions" id="" class="txt" type="number" style="background:#fff; 
					line-height:45px; height:45px; padding:10px;" <!--name="projectid"-->>
			           <option value="">Select User Type</option>
			           <option value="0" <?php if($squareuser['permissions'] == '0') echo "selected"; ?>>Level 0</option>
			           <option value="1" <?php if($squareuser['permissions'] == '1') echo "selected"; ?>>Level 1</option>
			           <option value="2" <?php if($squareuser['permissions'] == '2') echo "selected"; ?>>Level 2</option>
			           <option value="3" <?php if($squareuser['permissions'] == '3') echo "selected"; ?>>Level 3</option>
			           <option value="4" <?php if($squareuser['permissions'] == '4') echo "selected"; ?>>Level 4</option>     
			           <option value="10" <?php if($squareuser['permissions'] == '10') echo "selected"; ?>>Level 10</option>           
			       </select> 
                    <p class="rs description-input"><?= $squareuser['permission'] ?></p>
                </div>  
                               
                <br />

                <div class="clear"></div>                                                                       
     
                <!-- ########### SWITCH FIELD STARTS HERE ########### -->
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; 
                margin-right:5px; margin-top:5px">PhVerified?</label>
                
                    <div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; 
                    line-height:41px; background:none; padding-top:9px; margin-top:5px;">
                        <?php 
                            $is_verified = !empty($squareuser['is_verified_phone']) ? " checked='checked'" : ""; 
                            $is_active = isset($squareuser['is_verified']) ? 1 : 0;                            
                        ?>
                         <label class='switch'>                           
							 <input class='' id='' data-toggle='toggle' type='checkbox' 
							 name="is_verified_phone"<?= $is_verified ?> /><span class='sliderr round'></span>
                         </label>                                          
                    </div>                         
                   <div class="clear"></div>   
                   
                <!-- ########### SWITCH FIELD STARTS HERE ########### -->
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; 
                margin-right:5px; margin-top:5px">Approved?</label>
                
                    <div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; 
                    line-height:41px; background:none; padding-top:9px; margin-top:5px;">
                        <?php 
                            $is_approved = !empty($squareuser['is_approved']) ? " checked='checked'" : "";                  
                        ?>
                         <label class='switch'>                           
							 <input class='' id='' data-toggle='toggle' type='checkbox' 
							 name="is_approved"<?= $is_approved ?> /><span class='sliderr round'></span>
                         </label>                                          
                    </div>                         
                   <div class="clear"></div>   
                   
                <!-- ########### SWITCH FIELD STARTS HERE ########### -->
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; 
                margin-right:5px; margin-top:5px">Activated?</label>
                
                    <div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; 
                    line-height:41px; background:none; padding-top:9px; margin-top:5px;">
                        <?php 
                            $is_activated = !empty($squareuser['is_activated']) ? " checked='checked'" : "";                
                        ?>
                         <label class='switch'>                           
							 <input class='' id='' data-toggle='toggle' type='checkbox' 
							 name="is_activated"<?= $is_activated ?> /><span class='sliderr round'></span>
                         </label>                                          
                    </div>                         
                   <div class="clear"></div>  
                   
                <!-- ########### SWITCH FIELD STARTS HERE ########### -->
                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; 
                margin-right:5px; margin-top:5px">Directory?</label>
                
                    <div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; 
                    line-height:41px; background:none; padding-top:9px; margin-top:5px;">
                        <?php 
                            $is_directory = !empty($squareuser['directory']) ? " checked='checked'" : "";                
                        ?>
                         <label class='switch'>                           
							 <input class='' id='' data-toggle='toggle' type='checkbox' 
							 name="directory"<?= $is_directory ?> /><span class='sliderr round'></span>
                         </label>                                          
                    </div>                         
                   <div class="clear"></div>                                                                              
  
                <!-- ########### SWITCH FIELD STARTS HERE ########### -->
                <label class="lbl" for="txt_name1" style="display:none; text-align:left; width:auto; 
                margin-right:5px; margin-top:5px">Premium?</label>
                    <!-- this was display:inline-block; -->
                    <div style="display:none; float:left; width:auto; min-width:150px; height:41px; 
                    line-height:41px; background:none; padding-top:9px; margin-top:5px;">
                        <?php 
                            $is_premium = !empty($squareuser['is_premium']) ? " checked='checked'" : ""; 
                            $is_active = isset($squareuser['is_premium']) ? 1 : 0;                            
                        ?>
                         <label class='switch'>                           
                           <input class='' id='' data-toggle='toggle' type='checkbox' 
                           name="is_premium"<?= $is_premium ?> /><span class='sliderr round'></span>
                         </label>                                          
                    </div>                         
                   <div class="clear"></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/users'" />
        </form>
        
        <br />
            <!--<a href='/api/webservices/index.php?command=SquareCreateCustomer&sq_id=<?= $squareuser['id'] ?>' 
                class='confirm btn btn-red' style="color:#fff;">Create Customer ID</a>
            <br /><br />-->
            <!--
            <form class="" action="/api/webservices/index.php?command=SquareCreateCustomer" method="post" style="margin-top: 0px;" target="_blank">
                     <input type="hidden" id="sq_id" name="sq_id" placeholder="0" value="<?= $squareuser['id'] ?>">
                    
                    <input type="submit" value="Create Square ID" class="btn btn-green" style="font-size:15px; margin-bottom:10px;" />

             </form>
            <form class="" action="/api/webservices/shop/create_new_square_customer" method="post" style="margin-top: 0px;" target="_blank">
                    
                    <input type="hidden" id="sq_id" name="token" placeholder="0" value="<?= $squareuser['token'] ?>">
                    <input type="hidden" id="sq_id" name="given_name" placeholder="0" value="<?= $squareuser['given_name'] ?>">
                    <input type="hidden" id="sq_id" name="email" placeholder="0" value="<?= $squareuser['email'] ?>">
                    <input type="submit" value="Create Square ID" class="btn btn-green" style="font-size:15px; margin-bottom:10px;" />

             </form>   
             -->          
             <span style="font-weight:300">Tip: Make sure there are values in (or enter something for) 
             First Name, Last Name, Email and Phone</span>
        </div><!-- DIV 12 -->
    </div><!-- DIV 12 CONTAINER -->
</div><!-- DIV HOME -->

<?php

include('views/_footer.tpl.php');

?>