<?php require_once('../auth/auth.php'); ?>
<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: 5px 8px;"><h3 class="card-title">New Company  Add</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>
                <form id="company_form" action="#" method="post" autocomplete="off">
                   <input type="hidden" name="newreg" required="true">
                    <div class="card-body">
                       <div class="col-md-12">
                           <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                      <label>Organization/Company Name <b class="text-danger"> *</b></label>
                                      <input type="text" name="co_name"  class="form-control form-control-sm inputselect" placeholder="Organization Name"  required="true">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                  <div class="form-group">
                                     <label>Proprietor Name <b class="text-danger"> *</b></label>
                                     <input type="text" name="co_owner_name"  class="form-control form-control-sm inputselect" placeholder="Proprietor Name"  required="true">
                                  </div>
                                </div>
                                        <div class="col-md-4">
                                    <div class="form-group">
                                      <label>Phone Number  <span id="number-availability-status"></span> <b class="text-danger">  *</b></label>
                                       <input type="number" name="co_gsm" id="co_number" onBlur="checkenumberAvailability()"  class="form-control form-control-sm inputselect" placeholder="01XXXXXXXXX"  required="true">
                                    </div>
                                 </div>
                          <div class="col-md-6">
                           <div class="form-group">
                              <label>Username  <span id="user-availability-status"></span> <b class="text-danger"> *</b></label>
                              <input type="text" name="username"  id="username"  onBlur="checkeuserAvailability()" class="form-control form-control-sm inputselect" placeholder="Username " style="text-align:center;" required="true">
                           </div>
                        </div>
                        <div class="col-md-6">
                           <div class="form-group">
                              <label>Password  <b class="text-danger"> *</b></label>
                              <input type="text" name="password"  class="form-control form-control-sm inputselect" placeholder="******" style="text-align:center;" required="true">
                           </div>
                        </div>
                      
                        <div class="col-md-3">
                           <div class="form-group">
                              <label>Select Division   </label>
                              <select name="divisions" id="divisions" onchange="divisionsList();" class="form-control" required="true">
                                 <option disabled selected>Select Division</option>
                                 <option value="Barishal">Barishal</option>
                                 <option value="Chattogram">Chattogram</option>
                                 <option value="Dhaka">Dhaka</option>
                                 <option value="Khulna">Khulna</option>
                                 <option value="Mymensingh">Mymensingh</option>
                                 <option value="Rajshahi">Rajshahi</option>
                                 <option value="Rangpur">Rangpur</option>
                                 <option value="Sylhet">Sylhet</option>
                              </select>
                           </div>
                        </div>

                        <div class="col-md-3">
                           <div class="form-group">
                              <label>Select District   </label>
                              <select  id="distr" name="distr" onchange="thanaList();" class="form-control select2" style="width: 100%;" required="true">
                              </select>
                           </div>
                        </div>

                        <div class="col-md-3">
                           <div class="form-group">
                              <label>Select Police Station   </label>
                              <select  id="polic_sta" name="polic_sta"  class="form-control select2" style="width: 100%;" required="true">
                              </select>
                           </div>
                        </div>

                        <div class="col-md-3">
                           <div class="form-group">
                              <label>Head Office Address <b class="text-danger"> *</b></label>
                              <input name="co_address" class="form-control form-control-sm inputselect" rows="2" placeholder="Enter Your Office Address ..." required="" >
                           </div>
                        </div>
                        <!-- part one  Start -->
                        <div class="col-md-4" >
                           <div class="form-group">
                              <label>SMS Api Key</label>
                              <input type="text" name="smsapi"  class="form-control form-control-sm inputselect" placeholder="Enter Your SMS Key"  >
                           </div>
                        </div>
                        <div class="col-md-4" >
                           <div class="form-group">
                              <label>Whatsapp Api Key </label>
                              <input type="text" name="waapi"  class="form-control form-control-sm inputselect" placeholder="Enter Your Whatsapp Key"  >
                           </div>
                        </div>
                        <div class="col-md-4" >
                           <div class="form-group">
                              <label>Others Api Key</label>
                              <input type="text" name="otherapi"  class="form-control form-control-sm inputselect" placeholder="Enter Your Key" >
                           </div>
                        </div>
                    
                        <!-- part one  -->
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Currency symbols </label>
                                 <select name="currency" class="form-control"  required="true">
                                    <option value=""></option>
                                    <option value="AED">United Arab Emirates dirham</option>
                                    <option value="AFN">Afghan afghani</option>
                                    <option value="ALL">Albanian lek</option>
                                    <option value="AMD">Armenian dram</option>
                                    <option value="AOA">Angolan kwanza</option>
                                    <option value="ARS">Argentine peso</option>
                                    <option value="AUD">Australian dollar</option>
                                    <option value="AWG">Aruban florin</option>
                                    <option value="AZN">Azerbaijani manat</option>
                                    <option value="BAM">Bosnia and Herzegovina convertible mark</option>
                                    <option value="BBD">Barbadian dollar</option>
                                    <option selected value="BDT">Bangladeshi taka</option>
                                    <option value="BGN">Bulgarian lev</option>
                                    <option value="BHD">Bahraini dinar</option>
                                    <option value="BIF">Burundian franc</option>
                                    <option value="BMD">Bermudian dollar</option>
                                    <option value="BND">Brunei dollar</option>
                                    <option value="BOB">Bolivian boliviano</option>
                                    <option value="BRL">Brazilian real</option>
                                    <option value="BSD">Bahamian dollar</option>
                                    <option value="BTN">Bhutanese ngultrum</option>
                                    <option value="BWP">Botswana pula</option>
                                    <option value="BYR">Belarusian ruble</option>
                                    <option value="BZD">Belize dollar</option>
                                    <option value="CAD">Canadian dollar</option>
                                    <option value="CDF">Congolese franc</option>
                                    <option value="CHF">Swiss franc</option>
                                    <option value="CLP">Chilean peso</option>
                                    <option value="CNY">Chinese yuan</option>
                                    <option value="COP">Colombian peso</option>
                                    <option value="CRC">Costa Rican colón</option>
                                    <option value="CUP">Cuban convertible peso</option>
                                    <option value="CVE">Cape Verdean escudo</option>
                                    <option value="CZK">Czech koruna</option>
                                    <option value="DJF">Djiboutian franc</option>
                                    <option value="DKK">Danish krone</option>
                                    <option value="DOP">Dominican peso</option>
                                    <option value="DZD">Algerian dinar</option>
                                    <option value="EGP">Egyptian pound</option>
                                    <option value="ERN">Eritrean nakfa</option>
                                    <option value="ETB">Ethiopian birr</option>
                                    <option value="EUR">Euro</option>
                                    <option value="FJD">Fijian dollar</option>
                                    <option value="FKP">Falkland Islands pound</option>
                                    <option value="GBP">British pound</option>
                                    <option value="GEL">Georgian lari</option>
                                    <option value="GHS">Ghana cedi</option>
                                    <option value="GMD">Gambian dalasi</option>
                                    <option value="GNF">Guinean franc</option>
                                    <option value="GTQ">Guatemalan quetzal</option>
                                    <option value="GYD">Guyanese dollar</option>
                                    <option value="HKD">Hong Kong dollar</option>
                                    <option value="HNL">Honduran lempira</option>
                                    <option value="HRK">Croatian kuna</option>
                                    <option value="HTG">Haitian gourde</option>
                                    <option value="HUF">Hungarian forint</option>
                                    <option value="IDR">Indonesian rupiah</option>
                                    <option value="ILS">Israeli new shekel</option>
                                    <option value="IMP">Manx pound</option>
                                    <option value="INR">Indian rupee</option>
                                    <option value="IQD">Iraqi dinar</option>
                                    <option value="IRR">Iranian rial</option>
                                    <option value="ISK">Icelandic króna</option>
                                    <option value="JEP">Jersey pound</option>
                                    <option value="JMD">Jamaican dollar</option>
                                    <option value="JOD">Jordanian dinar</option>
                                    <option value="JPY">Japanese yen</option>
                                    <option value="KES">Kenyan shilling</option>
                                    <option value="KGS">Kyrgyzstani som</option>
                                    <option value="KHR">Cambodian riel</option>
                                    <option value="KMF">Comorian franc</option>
                                    <option value="KPW">North Korean won</option>
                                    <option value="KRW">South Korean won</option>
                                    <option value="KWD">Kuwaiti dinar</option>
                                    <option value="KYD">Cayman Islands dollar</option>
                                    <option value="KZT">Kazakhstani tenge</option>
                                    <option value="LAK">Lao kip</option>
                                    <option value="LBP">Lebanese pound</option>
                                    <option value="LKR">Sri Lankan rupee</option>
                                    <option value="LRD">Liberian dollar</option>
                                    <option value="LSL">Lesotho loti</option>
                                    <option value="LTL">Lithuanian litas</option>
                                    <option value="LVL">Latvian lats</option>
                                    <option value="LYD">Libyan dinar</option>
                                    <option value="MAD">Moroccan dirham</option>
                                    <option value="MDL">Moldovan leu</option>
                                    <option value="MGA">Malagasy ariary</option>
                                    <option value="MKD">Macedonian denar</option>
                                    <option value="MMK">Burmese kyat</option>
                                    <option value="MNT">Mongolian tögrög</option>
                                    <option value="MOP">Macanese pataca</option>
                                    <option value="MRO">Mauritanian ouguiya</option>
                                    <option value="MUR">Mauritian rupee</option>
                                    <option value="MVR">Maldivian rufiyaa</option>
                                    <option value="MWK">Malawian kwacha</option>
                                    <option value="MXN">Mexican peso</option>
                                    <option value="MYR">Malaysian ringgit</option>
                                    <option value="MZN">Mozambican metical</option>
                                    <option value="NAD">Namibian dollar</option>
                                    <option value="NGN">Nigerian naira</option>
                                    <option value="NIO">Nicaraguan córdoba</option>
                                    <option value="NOK">Norwegian krone</option>
                                    <option value="NPR">Nepalese rupee</option>
                                    <option value="NZD">New Zealand dollar</option>
                                    <option value="OMR">Omani rial</option>
                                    <option value="PAB">Panamanian balboa</option>
                                    <option value="PEN">Peruvian nuevo sol</option>
                                    <option value="PGK">Papua New Guinean kina</option>
                                    <option value="PHP">Philippine peso</option>
                                    <option value="PKR">Pakistani rupee</option>
                                    <option value="PLN">Polish złoty</option>
                                    <option value="PRB">Transnistrian ruble</option>
                                    <option value="PYG">Paraguayan guaraní</option>
                                    <option value="QAR">Qatari riyal</option>
                                    <option value="RON">Romanian leu</option>
                                    <option value="RSD">Serbian dinar</option>
                                    <option value="RUB">Russian ruble</option>
                                    <option value="RWF">Rwandan franc</option>
                                    <option value="SAR">Saudi riyal</option>
                                    <option value="SBD">Solomon Islands dollar</option>
                                    <option value="SCR">Seychellois rupee</option>
                                    <option value="SDG">Singapore dollar</option>
                                    <option value="SEK">Swedish krona</option>
                                    <option value="SGD">Singapore dollar</option>
                                    <option value="SHP">Saint Helena pound</option>
                                    <option value="SLL">Sierra Leonean leone</option>
                                    <option value="SOS">Somali shilling</option>
                                    <option value="SRD">Surinamese dollar</option>
                                    <option value="SSP">South Sudanese pound</option>
                                    <option value="STD">São Tomé and Príncipe dobra</option>
                                    <option value="SVC">Salvadoran colón</option>
                                    <option value="SYP">Syrian pound</option>
                                    <option value="SZL">Swazi lilangeni</option>
                                    <option value="THB">Thai baht</option>
                                    <option value="TJS">Tajikistani somoni</option>
                                    <option value="TMT">Turkmenistan manat</option>
                                    <option value="TND">Tunisian dinar</option>
                                    <option value="TOP">Tongan paʻanga</option>
                                    <option value="TRY">Turkish lira</option>
                                    <option value="TTD">Trinidad and Tobago dollar</option>
                                    <option value="TWD">New Taiwan dollar</option>
                                    <option value="TZS">Tanzanian shilling</option>
                                    <option value="UAH">Ukrainian hryvnia</option>
                                    <option value="UGX">Ugandan shilling</option>
                                    <option value="USD">United States dollar</option>
                                    <option value="UYU">Uruguayan peso</option>
                                    <option value="UZS">Uzbekistani som</option>
                                    <option value="VEF">Venezuelan bolívar</option>
                                    <option value="VND">Vietnamese đồng</option>
                                    <option value="VUV">Vanuatu vatu</option>
                                    <option value="WST">Samoan tālā</option>
                                    <option value="XAF">Central African CFA franc</option>
                                    <option value="XCD">East Caribbean dollar</option>
                                    <option value="XOF">West African CFA franc</option>
                                    <option value="XPF">CFP franc</option>
                                    <option value="YER">Yemeni rial</option>
                                    <option value="ZAR">South African rand</option>
                                    <option value="ZMW">Zambian kwacha</option>
                                    <option value="ZWL">Zimbabwean dollar</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Language   </label>
                                 <select id="language" name="language"  class="form-control" required="true">
                                    <option selected value="1">English</option>
                                    <option  value="2">Bangla</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Time Zone  </label>
                                 <select  name="timezone"  class="form-control"  required="true">
                                    <option value="<?php echo date_default_timezone_get(); ?>"><?php echo date_default_timezone_get(); ?></option>
                                    <option value="Asia/Dhaka">Asia/Dhaka</option>
                                    <option value="Asia/Kuala_Lumpur">Asia/Kuala_Lumpur</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                <label>Tin/passport Number </label>
                                 <input type="text" name="tinpass"  class="form-control form-control-sm inputselect" placeholder="xxx"  >
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>National Id  <b class="text-danger"> *</b></label> 
                                 <input type="number" name="nid"  class="form-control form-control-sm inputselect" placeholder="xxx" required="true">
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Email <b class="text-danger"> *</b></label>
                                 <input type="email" value="youmail@gmail.com" name="co_email"  class="form-control form-control-sm inputselect" placeholder="youmail@gmail.com"  required="true">
                              </div>
                           </div>
                    
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Tax  %    </label>
                                 <input type="number" name="taxrate" value="00.00"  class="form-control form-control-sm inputselect" placeholder="Txt Rate %" style="text-align:center;" required="true">
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group" >
                           <label >Frist  day of your financial year
                                  </label>  <span style="float: right;" >  <i  title="একটি শুরু তারিখ কি? শুরুর তারিখ হল আর্থিক বছরের প্রথম দিন যেদিন আপনি আপনার নিবন্ধিত স্থায়ী সম্পদের অবচয় গণনা শুরু করতে চান  আপনি একটি আর্থিক বছরের প্রথম দিন নির্বাচন করতে পারেন, যে সময়ের মধ্যে আপনি WellDiv ব্যবহার শুরু করেছেন পরবর্তী আর্থিক বছরে " style="float: " class="fa fa-play"></i>
                                </span>
                                
                                 <input type="text" name="sf_y_date" class="form-control form-control-sm" onmouseover="lcdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label>Last day of your financial year</label>
                                 <input type="text" name="ef_y_date" class="form-control form-control-sm" onmouseover="stdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                              </div>
                           </div>
                           <div class="col-md-6">
                              <div class="form-group">
                                 <label>Receipt A/c (Debitt) <b class="text-danger"> *</b></label>
                                 <dt id="show1" style="float: right;"></dt>
                                 <select  name="payid"  class="form-control" required="true">
                                    <option></option>
                                    <?php 
                                       $accat1= mysqli_query($conn,"SELECT acid,ac_name,ac_alise,ac_number,balance FROM accounts LEFT JOIN ac_sub_g_category ON(accounts.gcatid=ac_sub_g_category.ac_g_catid) WHERE accounts.coid='$coid' AND bid='$bid' AND brid='$brid' AND active=1 AND g_type IN('mcash','bank')") or die (mysql_error());
                                       while($acat1= mysqli_fetch_assoc($accat1)){
                                           echo '<option value='.$acat1["acid"].'>'.$acat1["ac_name"]."-".$acat1["ac_number"].' '.'('.$acat1["ac_alise"].')</option>';
                                       }?>  
                                 </select>
                              </div>
                           </div>

                                     <div class="col-md-6">
                              <div class="form-group">
                                 <label>Business Type <b class="text-danger"> *</b></label>
                                 <dt id="show1" style="float: right;"></dt>
                                 <select  name="bid_type"  class="form-control" required="true">
                                    <option></option>
                                    <?php 
                                       $btquery= mysqli_query($conn,"SELECT * FROM business_type  WHERE btid ") or die (mysql_error());
                                       while($rowbt= mysqli_fetch_assoc($btquery)){
                                           echo '<option value='.$rowbt["btid"].'>'.$rowbt["bt_name"].'</option>';
                                       }?>  
                                 </select>
                              </div>
                           </div>





                           <div class="col-md-3">
                              <div class="form-group">
                                 <label>OnTime Payment </label>
                                 <input type="number" name="ontime"  value="0" class="form-control form-control-sm inputselect" placeholder="00.00" style="text-align:center;" required="true">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label>Monthly Bill  <b class="text-danger"> *</b></label>
                                 <input type="number" name="mothlybill"  class="form-control form-control-sm inputselect" placeholder="00.00" style="text-align:center;" value="499.99" required="true">
                              </div>
                           </div>
                           <div class="col-md-12">
                              <hr style="margin-top:-5px;margin-bottom: 7px;">
                           </div>
                           <div class="col-md-12">
                              <div class="form-group">
                                 <label>Narration</label>
                                 <textarea name="co_note" class="form-control form-control-sm inputselect" rows="2" placeholder="Enter ..."></textarea>
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <div class="custom-control custom-checkbox">
                                    <input name="sendemail" class="custom-control-input" type="checkbox" id="customCheckbox1" value="yes">
                                    <label for="customCheckbox1" class="custom-control-label">Send Via E-Mail</label>
                                 </div>
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <div class="custom-control custom-checkbox">
                                    <input name="sendsms" class="custom-control-input" type="checkbox" id="customCheckbox2" value="yes">
                                    <label for="customCheckbox2" class="custom-control-label">Send via SMS</label>
                                 </div>
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group"><span style="float: right;margin: 2px -64px;">Reg Date</span>
                                 <input type="text" name="co_op_date" class="form-control form-control-sm"  style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                              </div>
                           </div>
                   

                         <div class="col-md-12">
                              <div class="form-group">
                                 <div class="custom-control custom-checkbox">
                                    <input name="policy_read" class="custom-control-input" type="checkbox" id="customCheckbox3" value="1" required="true">
                                    <label for="customCheckbox3" class="custom-control-label">I confirm that I have read and agree to WellDiv Terms of Service and Privacy Policy. <span> <a href="#">Terms of use</a> , <a href="#">privacy notice </a>, and  <a href="#">offer details </a> .</span>
                                    </label>
                                 </div>
                              </div>
                           </div>

                    </div>
                </div>
                 



                  <center>
                     <div class="card-footer" style="padding: 8px 5px;">
                        <button type="submit" id="save" class="btn btn-success btn-xs">Save</button>
                        <button type="reset" class="btn btn-secondary btn-xs">Reset</button>
                     </div>
                  </center>
               </form>
            </div>
         </div>
         <div class="col-md-2"></div>
      </div>
   </div>
</section>
<script>
   $(document).ready(function() {
      $("select").select2();
       $('#company_form').on('submit', function(e){
           $('#save').prop('disabled', true);
           $('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
           e.preventDefault();  
           $.post("../company_setup/company_db.php",$(this).serialize(),function(data){
              $('#company_form')[0].reset();
              $('#save').prop('disabled', false);
              $('#save').html('Company Save');
               $.post('../company_setup/compnay_index.php?running='+1,{},function(res){
               $('#settingview').html(res);
              }); 
               toastr.success(Showing, '<?php echo "New Company Add Successful" ?>');
          });
       });
   });  
</script>

<script type="text/javascript">
   function checkenumberAvailability() {
      jQuery.ajax({
         url: "../duplicate_check/number_check.php",
         data:'co_number='+$("#co_number").val(),
         type: "POST",
         success:function(data){
         $("#number-availability-status").html(data);
         },
         error:function (){}
      });
   }
</script>
<script type="text/javascript">
   function checkeuserAvailability() {
      jQuery.ajax({
         url: "../duplicate_check/number_check.php",
         data:'username='+$("#username").val(),
         type: "POST",
         success:function(data){
         $("#user-availability-status").html(data);
         },
         error:function (){}
      });
   }
</script>