<style>
    .btn { background:#aaa; font-weight:200; }
    .btn-red { font-size: 14px; }
    p, td { font-weight:200; }
    table td { padding: 5px; } 
    
    .admintable td, .admintable th {
        /* padding: 5px !important; */
    }   
    
    @media screen and (max-device-width: 979px), screen and (max-width: 979px) {
        .form-profile {
            padding: 20px 0px;
            width: 85%;
        }        
    }
</style>
    
    <div class="tab-pane accordion-content">
        <div class="form form-profile aif" style='width:auto'>
            
        <h2 style="margin-top:0px;">
            Customers <i class="fa fa-caret-down" style="float:right; margin:3px 5px 0 5px;"></i>
        </h2>
		This page will be retired soon - new
		<a href="/admin/users" title="Visit New Manage User page">Manage Admins + Customers page</a>
		<br /><br />        

        <table class="admintable" id="projects_table" style="width:100%; overflow:hidden; margin-bottom:12px">
            <tr>
                <th>Email</th>
                <th>Device ID</th>
                <th>RegDate</th>
                <th>Edit</th>
            </tr>

            <?php
            foreach ($square_users as $squser) :
                if($squser['device_type'] == 'Android'){
                    $deviceType = 'Android';
                } else {
                    $deviceType = 'iOS';
                }
                if($squser['given_name'] !=''){
                    $customer_name = $squser['given_name'] . " ". $squser['family_name'] ;
                }else{
                    $customer_name = "Not provided";
                }      
                         
                if(strlen($squser['phone']) == 11){
                    $formatted_phone =  "1 (".substr($squser['phone'],1,3).") ".substr($squser['phone'],4,3)."-".substr($squser['phone'],7);
                 }elseif(strlen($squser['phone']) == 10){
                    $formatted_phone_number = $squser['phone'];
                    $formatted_phone =  "(".substr($squser['phone'],0,3).") ".substr($squser['phone'],3,3)."-".substr($squser['phone'],6);
                }elseif(strlen($squser['phone']) > 0){
                    $formatted_phone_number = $squser['phone'];
                    $formatted_phone = $squser['phone'];
                }else{
                    $formatted_phone_number = '0';
                    $formatted_phone = '<span style="color:#ff0000; font-weight:600;">Not provided</span>';
                }
                
                if($squser['square_id'] != ''){
                    $square_cust_id = $squser['square_id'];
                } else {
                    $square_cust_id = '<span style="color:#ff0000; font-weight:600;">Missing Customer ID</span>';
                }
                
                 ?>
            
            
                <tr data-uid="<?= $squser['id'] ?>">
                    <td>
                        <img src="/static/images/users/default-avatar.jpg" style="border:3px solid #fff; border-radius:50%; height:75px; width:auto; margin-right:10px;" 
                        onerror="this.src='/static/images/users/default-avatar.jpg'" align="left">
                        
                        <h2 style="font-weight:800; font-size:15px; margin-bottom:1px; padding-bottom:1px; margin-top:10px;"><?= $customer_name?></h3>
                        <a href="mailto:<?= $squser['email'] ?>" title="Email"><?= $squser['email'] ?></a><br />
                        <a href="tel:<?= $formatted_phone_number ?>" title="Call"><?= $formatted_phone ?></a>                        
                    </td>
                    <td><?= $squser['device_id'] ?><br />
                        <span style="font-weight:600;">SQID:</span> <?= $square_cust_id ?><br />
                        <span style="font-weight:600;">Type:</span> <?= $deviceType ?>
                        <?php if($squser['square_id'] =="") : ?>
                            <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="<?= $squser['id'] ?>">
                    
                            <input type="submit" value="Create Square ID" class="btn btn-green" style="font-size:12px; margin-bottom:3px;" />
                        
                            <!--<input type="hidden" id="interestedin" name="interestedin" placeholder="vip" value="vip">-->
                        </form>
                        <?php endif; ?>
                        
                    </td>
                    <td style="text-align:center;"><?= date("m-d-Y h:i A", strtotime($squser['reg_date'])) ?></td>
                    <td style="text-align:center;"><a href="?squareuser&edit=<?= $squser['id'] ?>" title="<?= $squser['name'] ?>" target="_blank" style="text-align:center;">Edit</a>
                        <br /><br />
                    <a href='?deleteSquareUser&delete=<?= $squser['id'] ?>&uid'>Delete</a><br />
                        <a href='/admin/deleteSquareUser' class='delete-user confirm' ><img src="/static/images/icons/delete_icon.png" alt="Delete!" style="height:15px; width:15px" /></a></td>
                </tr>
            <?php
            endforeach; ?>

        </table>

    </div><!--end: .tab-pane (Approvals) -->
	<br /><br /><br /><br /><br /><br /><br /><br />
</div>         