<?php
include("company_func.php");
$hddnCompanyId = $_SESSION['caller']['args'][1];
if ($_SESSION['user']['access_level'] < SABLE_ACCESS_MANAGER)
{
	if ((isset($hddnCompanyId)) && ($hddnCompanyId != $_SESSION['user']['user_code'])) SableGeneralFunctions::divertFromPage("company/view.php");
}
$onclick = "fileUpload('edtCompanyLogo', 'imgProfile', '1', false)";
$imgHTML = SableSystem::getClickableImgHTML(SableSystem::getSableImgPath("profile/profile.png"), 200, "imgProfile", $onclick);

//$coyTypeWhere = isSPSAdmin() ? "" : "where company_type_id == ".$_SESSION['company']['company_type_id'];
$coyTypeWhere = "";
$coyTypeID = isSPSAdmin() ? '3' : '2';
?>
<script src="<?php SableGeneralFunctions::printModuleJS('company'); ?>"></script>
<?php include(SABLE_INCLUDES_PATH.'googleMaps.php'); ?>
<!--// Company -->

<form id="frmCompany" name="frmCompany" autocomplete="on">
  <div class="forms">
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-12 form-grid">
          <h3 class="title"><i class="fa fa-plus" aria-hidden="true"></i>&nbsp;Add 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"
			onfocus="showHint('edtCompanyName');" onblur="hideHint('edtCompanyName'); validate_edtCompanyName()"
			 placeholder="Company Name"	onkeypress="handleEnter(this, event)" />
        </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"
onfocus="showHint('edtCompanyEmail');" onblur="hideHint('edtCompanyEmail'); validate_edtCompanyEmail()"
 placeholder="Email"	
onkeypress="handleEnter(this, event)" 
 />
        </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">
          <input name="edtCompanyLogo" type="text" id="edtCompanyLogo" onfocus="showHint('edtCompanyLogo');" 
				 onclick="<?php echo($onclick); ?>" style="visibility: hidden;" onblur="hideHint('edtCompanyLogo'); validate_edtCompanyLogo()" placeholder="Logo" onkeypress="handleEnter(this, event)" class="pointer" />
          <!--// the image -->
          <p></p>
          <div class="container">
            <div class="forms-grids">
              <div class="col-md-4 forms-grid"><?php echo($imgHTML); ?></div>
            </div>
          </div>
          <!-- the image //--> 
        </div>
        <div class="col-md-8">
          <div class="fieldHint pointer" id="hint_edtCompanyLogo" onClick="<?php echo($onclick); ?>"><i class="fa fa-image"></i>&nbsp; Click here to set 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"
onfocus="showHint('edtCompanyAddress');" onblur="hideHint('edtCompanyAddress'); validate_edtCompanyAddress()"
 placeholder="Physical Address"	
 onKeyUp="updateMapData();" ></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 //-->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-12 forms-grid">
          <div id="searchResults"></div>
        </div>
      </div>
    </div>
    <p></p>
    <!--// edtCompanyURL -->
    <div class="container">
      <div class="forms-grids">
        <div class="col-md-4 forms-grid">
          <input name="edtCompanyURL" type="text" id="edtCompanyURL"
onfocus="showHint('edtCompanyURL');" onblur="hideHint('edtCompanyURL'); validate_edtCompanyURL()"
 placeholder="Website"	
onkeypress="handleEnter(this, event)" 
 />
        </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" onfocus="showHint('edtCompanyPhone');" 
				 onblur="hideHint('edtCompanyPhone'); validate_edtCompanyPhone()" placeholder="Phone" onkeypress="handleEnter(this, event)" 
 />
        </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">
          <div class="dropdown">
            <select name="edtCompanyType" type="select" id="edtCompanyType" onfocus="showHint('edtCompanyType');" 
					placeholder="Company Type" onblur="hideHint('edtCompanyType'); validate_edtCompanyType()" onkeypress="handleEnter(this, event)">
            <?php SableDBFunctions::printOptions("company_type", "company_type_id", "company_type_name", $coyTypeID, $coyTypeWhere); ?>
            </select>
          </div>
        </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="edtCompanyRegNoYear" type="number" maxlength="4" max="<?php echo(date('Y')); ?>" min="1900" id="edtCompanyRegNoYear"
            onfocus="showHint('edtCompanyRegNo');" onblur="hideHint('edtCompanyRegNo'); validate_edtCompanyRegNoYear()" onkeypress="handleEnter(this, event)" style="width:25%;"/>&nbsp;/&nbsp;
        <input name="edtCompanyRegNoMid" type="number" maxlength="6" min="1" id="edtCompanyRegNoMid" onfocus="showHint('edtCompanyRegNo');" 
        onblur="hideHint('edtCompanyRegNo'); validate_edtCompanyRegNoMid()" onkeypress="handleEnter(this, event)"  style="width:35%;"/>&nbsp;/&nbsp;
        <input name="edtCompanyRegNoType" type="number" maxlength="2" max="30" min="6" id="edtCompanyRegNoType" onfocus="showHint('edtCompanyRegNo');" 
        onblur="hideHint('edtCompanyRegNo'); validate_edtCompanyRegNoType()" onkeypress="handleEnter(this, event)"  style="width:25%;"/>
    
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtCompanyRegNo">Company Registration No.</div>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <!-- edtCompanyRegNo //-->
<p></p>
<!--// edtCompanyVatNo -->
<div class="container">
  <div class="forms-grids">
    <div class="col-md-4 forms-grid">
<input name="edtCompanyVatNo" type="number" id="edtCompanyVatNo"
onfocus="showHint('edtCompanyVatNo');" onblur="hideHint('edtCompanyVatNo'); validate_edtCompanyVatNo()"
 placeholder="VAT No."	
onkeypress="handleEnter(this, event)" 
 />	
    </div>
    <div class="col-md-8">
      <div class="fieldHint" id="hint_edtCompanyVatNo">Company VAT No.</div>
    </div>
    <div class="clearfix"> </div>
  </div>
</div>
<!-- edtCompanyVatNo //-->    
    <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="insertCompany()" value="Add Company" class="submit"/>
        </div>
      </div>
    </div>
    <!-- buttons //-->
    <?php include(SABLE_INCLUDES_PATH.'googleMapsDisplay.php'); ?>
  </div>
</form>
<!-- Company //--> 
