<?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 vendor! 
    <br>
    This vendor is not available.
</div>
<?php die(); }
if($permissions->hasPermission('edit_vendor')){
    include("Views/Inventory/vendor_modal.php");
}?>
<style>
    .b-r {
        border-left-width: 1px;
    }
</style>
<div class="wrapper">
    <div class="panel invoice">
        <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_vendor') && smc_session()['default_setting']['sync_type'] != 2){?>
                <a href="#" class="mainPageLinks edit_vendor btn btn-primary pull-right" data-id="<?php  echo $Results_Details[0]["Supplier_ID"];?>" data-toggle="modal" data-target="#supplier_modal" ><i class='fa fa-pencil'></i> <?php print CommonLanguage::getMessage('Edit'); ?></a>
                <?php }?>
                <h4 class="bold"><?php print CommonLanguage::getMessage('vendor_details'); ?></h4>
                <div class="col-md-12 b-r  b-dashed " id="VendorDetails">
                    <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 Supplier_Name"><?php echo $Results_Details[0]["Supplier_Name"]; ?> </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Email'); ?></label>
                            <div class="col-sm-4 Supplier_Email">
                                <?php echo $Results_Details[0]["Supplier_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 Supplier_Phone ">
                                <?php echo $Results_Details[0]["Supplier_Phone"]; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('mobile_phone'); ?></label>
                            <div class="col-sm-4 Supplier_Mobile">
                                <?php echo $Results_Details[0]["Supplier_Mobile"]; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('work_phone'); ?></label>
                            <div class="col-sm-4 Supplier_Work_Phone">
                                <?php echo $Results_Details[0]["Supplier_Work_Phone"]; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('company'); ?></label>
                            <div class="col-sm-4 Supplier_Company">
                                <?php echo $Results_Details[0]["Supplier_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 Supplier_CR">
                                <?php echo $Results_Details[0]["Supplier_CR"]; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('address'); ?></label>
                            <div class="col-sm-4 Supplier_Address">
                                <?php echo $Results_Details[0]["Supplier_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('postal_code'); ?></label>
                            <div class="col-sm-4 Supplier_PostalCode">
                                <?php echo $Results_Details[0]["Supplier_PostalCode"]; ?>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('country'); ?></label>
                            <div class="col-sm-4 Country_Name">
                                <?php echo $Results_Details[0]["Country_Name"]; ?>
                            </div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Currency'); ?></label>
                            <div class="col-sm-4 CurrencyName">
                                <?php echo $Results_Details[0]["Currency_Name"]; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){
        if($('#is_modal_shown').val() == 1){
            $('.edit_vendor').trigger('click');
            $('#supplier_modal').modal('show');
        }
    })
</script>
