<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDPQfukDXQUdWN4XNMa8asJryBPtJ9iBsQ"></script>
<?php
if (empty($Results_Details)) { ?>
<div class="alert alert-danger" role="alert">
    <button class="close" data-dismiss="alert"></button>
    <strong>Danger: </strong>you can not edit this customer! 
    <br>
    This customer is not available.
</div>
<?php die(); }
if($permissions->hasPermission('edit_customer')){
    include("Views/Inventory/customer_modal.php"); 
}
include 'Views/Inventory/customer_map_modal.php';

?>
<style>
    .b-r {
        border-left-width: 1px;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
</style>
<div class="wrapper">
    <div class="panel">
        <div class="panel-body">
            <div class="row">
                <input type="hidden" value="<?php echo !empty($_GET['modal']) ? 1 : 0 ;?>" id="is_modal_shown"/>
                <?php if($permissions->hasPermission('edit_customer') && smc_session()['default_setting']['sync_type'] != 2){?>
                <a href="#" class="mainPageLinks " data-toggle="modal" id="edit_customer" data-id="<?php  echo $Results_Details[0]["Customer_ID"];?>" data-target="#customer_modal" ><button type='button' class='btn btn-primary pull-right' ><i class='fa fa-pencil'></i> <?php print CommonLanguage::getMessage('Edit');?></button></a>
                <?php }?>
                <h4 class="bold"><?php print CommonLanguage::getMessage('customer_details');?></h4>
                <div class="col-md-12 b-r  b-dashed" id="CustomerDetails">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Name');?></label>
                            <div class="col-sm-4 Customer_Name"><?php echo $Results_Details[0]["Customer_Name"] ; ?> </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Email');?></label>
                            <div class="col-sm-4 Customer_Email">
                                <?php echo $Results_Details[0]["Customer_Email"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row ">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Phone');?></label>
                            <div class="col-sm-4 Customer_Mobile">
                                <?php  echo $Results_Details[0]["Customer_Mobile"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('second_phone');?></label>
                            <div class="col-sm-4 Customer_Work_Phone">
                                <?php echo $Results_Details[0]["Customer_Work_Phone"]; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('third_phone');?></label>
                            <div class="col-sm-4 Customer_Phone ">
                                <?php echo $Results_Details[0]["Customer_Phone"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('company');?></label>
                            <div class="col-sm-4 Customer_Company">
                                <?php echo $Results_Details[0]["Customer_Company"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('commercial_registry');?></label>
                            <div class="col-sm-4 Customer_CR">
                                <?php echo $Results_Details[0]["Customer_CR"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('address');?></label>
                            <div class="col-sm-4 Customer_Address">
                                <?php echo $Results_Details[0]["Customer_Address"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('city');?></label>
                            <div class="col-sm-4 City_Name">
                                <?php echo $Results_Details[0]["Name"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('city');?></label>
                            <div class="col-sm-4 Country_Name">
                                <?php echo $Results_Details[0]["Country_Name"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('discount');?></label>
                            <div class="col-sm-4 Customer_Discount">
                                <?php echo $Results_Details[0]["Customer_Discount"].'%' ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('limit_balance');?></label>
                            <div class="col-sm-4 Customer_Limit_Balance">
                                <?php echo $Results_Details[0]["Customer_Limit_Balance"].' '.$Results_Details[0]["Currency_Symbol"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('pricing_class');?></label>
                            <div class="col-sm-4 Customer_Class">
                                <?php echo $Results_Details[0]["Class_Name"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('due_date_days');?></label>
                            <div class="col-sm-4 customer_due_date_period">
                                <?php echo $Results_Details[0]["customer_due_date_period"] ; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('latitude');?></label>
                            <div class="col-sm-4 Customer_Lat">
                                <?php echo $Results_Details[0]["Customer_Lat"] ; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('longitude');?></label>
                            <div class="col-sm-4 Customer_Lng">
                                <?php echo $Results_Details[0]["Customer_Lng"] ; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <br>
        </div>
    </div>
</div>
<script>
    $(function(){
        if($('#is_modal_shown').val() == 1){
            $('#edit_customer').trigger('click');
        }     
    });
</script>
