<?php
include("company_func.php");

if (isset($_SESSION['caller']['args'][1])&&(!empty($_SESSION['caller']['args'][1])))
{
	$hddnCompanyId = $_SESSION['caller']['args'][1];
}
else
{
	$hddnCompanyId = $_SESSION['user']['company_id'];
}

if ($_SESSION['user']['access_level'] < SABLE_ACCESS_MANAGER)
{
	SableGeneralFunctions::divertFromPage("/home/");
}
$row = $sableDB->getRow("select * from company where company_id = ".$hddnCompanyId);

$addr = $sableDB->getRow("select * from address where address_id = ".$row['address_id']);
$row['company_address'] = $addr['address'];

$regNo = str_replace('//', '', $row['company_reg_no']);
if(empty($row['company_logo'])||(!isset($row['company_logo']))) $row['company_logo'] = SABLE_UNKNOWN_IMAGE;

$type = $sableDB->getValue('select company_type_name from company_type where company_type_id = '.$row['company_type_id']);
?>
<script src="<?php SableGeneralFunctions::printModuleJS('company'); ?>"></script>
<?php include(SABLE_INCLUDES_PATH.'googleMaps.php'); ?>
<!--// Company -->

<form id="frmCompany" name="frmCompany" autocomplete="on">
  <input type="hidden" value="<?php echo(SableSystem::sableEncode($hddnCompanyId)); ?>" id="hddnCompanyId" name="hddnCompanyId" />
  <div class="forms">
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-12 form-grid">
          <h3 class="title"><i class="fa fa-eye" aria-hidden="true"></i>&nbsp;View Company</h3>
          <p></p>
          <div class="clearfix"> </div>
        </div>
      </div>
    </div>
    <p></p>
    <!--// edtCompanyName -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyName" type="text" id="edtCompanyName"
readonly value="<?php echo($row['company_name'])?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyName">The name of the company</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyName //-->
    <p></p>
    <!--// edtCompanyEmail -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyEmail" type="email" id="edtCompanyEmail"
readonly value="<?php echo($row['company_email'])?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyEmail">The main company email address</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyEmail //-->
    <p></p>
    <!--// edtCompanyLogo -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <div class="container">
            <div class="forms-grids">
              <div class="col-md-4 forms-grid"> <?php SableSystem::printImgHTML($row['company_logo'], 200, "imgProfile", true, $row['company_name']); ?> </div>
            </div>
          </div>
          <!-- the image //--> 
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyLogo">The company logo</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyLogo //-->
    <p></p>
    <!--// edtCompanyAddress -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <textarea name="edtCompanyAddress" type="textarea" id="edtCompanyAddress"
readonly ><?php echo($row['company_address'])?></textarea>
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyAddress">The physical address of the company</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyAddress //-->
    <p></p>
    <!--// edtCompanyURL -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyURL" type="text" id="edtCompanyURL"
readonly value="<?php echo($row['company_url'])?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyURL">The website address</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyURL //-->
    <p></p>
    <!--// edtCompanyPhone -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyPhone" type="tel" id="edtCompanyPhone"
readonly value="<?php echo($row['company_phone'])?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyPhone">The phone number for this company</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyPhone //-->
    <p></p>
    <!--// edtCompanyType -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyType" type="text" id="edtCompanyType"
readonly value="<?php echo($type)?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyType">The company type</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyType //-->
    <p></p>
    <!--// edtCompanyRegNo -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyRegNo" type="text" id="edtCompanyRegNo" readonly value="<?php echo($regNo)?>" />
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyRegNo">The company registration number</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyRegNo //-->
    <p></p>
    <!--// buttons -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-2 forms-grid">
          <input type="button" id="btnCancel" value="Cancel"
class="submit" onclick="window.location = '<?php SableSystem::printCallPageLink('/company/'); ?>'"/>
        </div>
        <div class="col-md-2 forms-grid">
          <input id="btnOk" type="button" onclick="editCompany('<?php echo($hddnCompanyId); ?>')" value="Modify Company" class="submit"/>
        </div>
      </div>
    </div>
    <!-- buttons //-->
    <?php include(SABLE_INCLUDES_PATH.'googleMapsDisplay.php'); ?>
  </div>
</form>
<!--// Google Maps --> 
<!-- Google Maps //--> 
<!-- Company //-->
<script>$(document).ready(showAddress('<?php echo($addr['address_lng']); ?>', '<?php echo($addr['address_lat']); ?>', '<?php echo($addr['address']); ?>'));</script>
