<?php require_once('../auth/auth.php');require_once('../auth/function.php');?>
<?php
$getcoid = $_GET['coid'];
$acc= mysqli_query($conn,"SELECT * FROM company WHERE coid='$getcoid'  LIMIT 1") or die (mysql_error());
$co_row= mysqli_fetch_assoc($acc);
$coid       = $co_row['coid'];
$co_logo    = $co_row['co_logo'];
$co_op_date = $co_row['co_op_date']
?>


<section class="content">
   <div class="container-fluid">
      <div class="row">
         <div class="col-md-12">
      <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
        <div class="card-header" style="padding: 3px 8px;">
          <h3 class="card-title"> <?php echo language(318);?> </h3>
          <div class="card-tools">
            <button type="button" class="btn btn-tool" data-card-widget="remove">
            <i class="fas fa-times"></i>
            </button>
          </div>
        </div>
        <div style="display: flex;">
          <div class="col-md-2 pt-1" style="border-right:1px solid #969c9d;">
            <div class="card-body box-profile">
              <div class="text-center">
                <span style="float:right;position: relative;margin-left: -12px;cursor:pointer;">
                  <input type="file" id="new_img" accept="image/*" style="position: absolute;opacity: 0;"><i class="fa fa-edit new_Btn"></i>
                </span>
                <?php if($co_logo != ""): ?>
                <img id="img_data" class="profile-user-img img-fluid img-circle" src="data:image/gif;base64,<?php echo $co_logo;?>" alt="User profile picture">
                <?php else : ?>
                <img id="img_data" class="profile-user-img img-fluid img-circle" src="../../dist/img/no_img.jpg" alt="User profile picture">
                <?php endif; ?>
              </div>
              <h6 class="text-center pt-1 m-0"><dt> <?php echo $co_row['owner_name']; ?></dt></h6>
              <p class="text-muted text-center m-0 text-xsm"><?php echo $co_row['co_phone']; ?></p>
              <hr class="m-0 pt-1">
              
              <hr class="mb-0 mt-1">
              <strong><i class="fas fa-book mr-1"></i> <?php echo language(112);?>  </strong>
              <p class="text-muted pl-3 m-0"><?php echo $co_row['co_email'];?></p>
              <hr>
              <strong><i class="fa-solid fa-phone"></i> <?php echo language(111);?> </strong>
              <p class="text-muted pl-3 m-0"><?php echo $co_row['owner_phone'];?></p>
              <hr>
              <strong><i class="fa-solid fa-calendar-days"></i> <?php echo language(131);?> </strong>
              <p class="text-muted pl-3 m-0"><?php echo date('d/m/y ', strtotime($co_op_date));?></p>
              <hr>
              <strong><i class="fas fa-map-marker-alt mr-1"></i> <?php echo language(150);?></strong>
              <p class="text-muted pl-3 m-0"><?php echo $co_row['co_address']; ?></p>
            </div>
          </div>
          <div class="col-md-10 p-0">
            <ul class="nav nav-pills ml-auto" style="background-color: honeydew;padding: 2px 0;border-bottom:1px solid #dee2e6;">
              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" data-toggle="tab" onclick="pagecall('../company_setup/company_update.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');"><i class="fa fa-fw fa-calculator"></i> <?php echo language(25);?> </a></li>|

              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" data-toggle="tab" onclick="pagecall('../company_setup/business_add.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');"><i class="fa fa-fw fa-calculator"></i> <?php echo language(319);?></a></li>|
              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" data-toggle="tab" onclick="pagecall('../company_setup/branch_add.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');"><i class="fa fa-fw fa-calculator"></i> <?php echo language(320);?></a></li>|
              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" data-toggle="tab"><i class="fa fa-fw fa-calculator"></i><?php echo language(198);?></a></li>|

              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" onclick="pagecall('../company_setup/printer_setup.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');" data-toggle="tab"><i class="fa fa-fw fa-calculator"></i><?php echo language(336);?></a></li>|

              <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" onclick="pagecall('../company_setup/signature_index.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');" data-toggle="tab"><i class="fa fa-fw fa-calculator"></i><?php echo language(367);?></a></li>|
   <li class="nav-item"><a style="padding: 0px 8px;" class="nav-link" href="#" onclick="pagecall('../company_setup/prefix_index.php?comid='+'<?php echo $co_row['coid']?>','#com_profile_view');" data-toggle="tab"><i class="fa fa-fw fa-calculator"></i><?php echo language(372);?></a></li>|
            </ul>
            <div id="com_profile_view" class="pt-1"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</section>
<script type="text/javascript">
$("#new_img").on('change', function (e) {
var ac_img_id = '<?php echo $coid;?>';
if (e.target.files) {
let imageFile = e.target.files[0];
var reader = new FileReader();
reader.onload = function (e) {
var img = document.createElement("img");
img.onload = function (event) {
var canvas = document.createElement("canvas");
var MAX_WIDTH = 300;
var MAX_HEIGHT = 300;
var width = img.width;
var height = img.height;
if (width > height) {
if (width > MAX_WIDTH) {
height *= MAX_WIDTH / width;
width = MAX_WIDTH;
}
} else {
if (height > MAX_HEIGHT) {
width *= MAX_HEIGHT / height;
height = MAX_HEIGHT;
}
}
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, width, height);
var dataurl = canvas.toDataURL(imageFile.type);
$.ajax({
type: "POST",
url: "../company_setup/company_db.php",
data: ({ac_img_id: ac_img_id,dataurl:dataurl}),
cache:false,
success:function(data){
}
});
document.getElementById("img_data").src = dataurl;
}
img.src = e.target.result;
}
reader.readAsDataURL(imageFile);
}
});
$('.new_Btn').click(function() {
$('#new_img').click();
});
</script>