<script language="javascript" type="text/javascript">
	function validateAddFile()
	{
		if(document.formAddFile.categoryId.value == 0)
		{
			alert('<?php echo $numberLBL["selectCategory"];?>');
			return false;
		}
		if(document.formAddFile.file.value == '')
		{
			alert('<?php echo $numberLBL["fileTitle"];?>');
			return false;
		}
		return true;
	}
	function checkCategory(){
		if (formAddFile.categoryId.value == "X")
			formAddFile.category1.disabled=false;
		else
			formAddFile.category1.disabled=true;
	}
	function checkCategory2(){
		if (formAddFile.category1.value==1){
		deleteOption(formAddFile.category2,1)
		deleteOption(formAddFile.category3,1)
		}
		else{
		addOption(formAddFile.category2,'<?php echo $numberLBL["category"]?>','1');
		addOption(formAddFile.category3,'<?php echo $numberLBL["category"]?>','1');
		}
		if (formAddFile.category1.value==2){
			deleteOption(formAddFile.category2,2)
			deleteOption(formAddFile.category3,2)
		}
		else{
			addOption(formAddFile.category2,'<?php echo $numberLBL["name"]?>','2');
			addOption(formAddFile.category3,'<?php echo $numberLBL["name"]?>','2');
		}
		if (formAddFile.category1.value==3){
			deleteOption(formAddFile.category2,3)
			deleteOption(formAddFile.category3,3)
		}
		else{
			addOption(formAddFile.category2,'<?php echo $numberLBL["mobile"]?>','3');
			addOption(formAddFile.category3,'<?php echo $numberLBL["mobile"]?>','3');
		}
		if (formAddFile.category2.value==1){
			deleteOption(formAddFile.category3,1)
		}
		else if (formAddFile.category1.value!=1){
			addOption(formAddFile.category3,'<?php echo $numberLBL["category"]?>','1');
		}
		if (formAddFile.category2.value==2){
			deleteOption(formAddFile.category3,2)
		}
		else if (formAddFile.category1.value!=2){
			addOption(formAddFile.category3,'<?php echo $numberLBL["name"]?>','2');
		}
		if (formAddFile.category2.value==3){
		deleteOption(formAddFile.category3,3)
		}
		else if (formAddFile.category1.value!=3){
			addOption(formAddFile.category3,'<?php echo $numberLBL["mobile"]?>','3');
		}
		if (formAddFile.category3.value==1){
			deleteOption(formAddFile.category2,1)
		}
		else if (formAddFile.category1.value!=1){
			addOption(formAddFile.category2,'<?php echo $numberLBL["category"]?>','1');
		}
		if (formAddFile.category3.value==2) {
			deleteOption(formAddFile.category2,2)
		}
		else if (formAddFile.category1.value!=2){
			addOption(formAddFile.category2,'<?php echo $numberLBL["name"]?>','2');
		}
		if (formAddFile.category3.value==3) {
			deleteOption(formAddFile.category2,3)
		}
		else if (formAddFile.category1.value!=3){
			addOption(formAddFile.category2,'<?php echo $numberLBL["mobile"]?>','3');
		}
	}
	function addOption(selectObject,optionText,optionValue) {
     for (i=0;i<selectObject.options.length;i++)
   		if(selectObject.options[i].value==optionValue)
      return 0;
    var optionObject = new Option(optionText,optionValue)
    var optionRank = selectObject.options.length
     selectObject.options[optionRank]=optionObject
	}
	function deleteOption(selectObject,optionRank){
	   for (i=0;i<selectObject.options.length;i++)
	   if(selectObject.options[i].value==optionRank)
	   selectObject.options[i]=null;
	}
    </script> 
  	<form name="formAddFile" method="POST" action="numberModalImportFile2.php" onsubmit="return validateAddFile();" style="margin:0px" enctype="multipart/form-data">
   <div class="modal fade bd-example-modal-lg" style="z-index:10000;padding-<?php echo $align;?>:0px" id="importFile" tabindex="-1" role="dialog" aria-labelledby="importFileTitle" aria-hidden="true">
      <div class="modal-dialog modal-lg" role="document">
         <div class="modal-content text-right">
            <div class="modal-header modal-header-primary">
               <h5 class="modal-title" id="importFileTitle"><?php echo  $numberLBL["importFile"];?></h5>
               <button type="button" class="close slidedown" data-dismiss="modal" aria-label="Close">
               <span aria-hidden="true">&times;</span>
               </button>
            </div>
            <div class="modal-body" style="text-align: <?php echo $align;?>;">
               <div class="form-group" >
             	 <select name="categoryId" class="form-control" onchange="return checkCategory()" style="padding: 0px">
                 <option value="0"><?php echo $numberLBL["selectCategory"];?></option>
                   <?php
                   		$queryCategory  = "SELECT id, name FROM $userCategory WHERE userId='".$_SESSION["userId"]."'";
						$resultCategory = mysqli_query($conn, $queryCategory);
						$numCategory = mysqli_num_rows($resultCategory);
						for($c=0;$c<$numCategory;$c++) {
							$rowCategory= mysqli_fetch_row($resultCategory);?>
							<option value='<?php echo $rowCategory[0];?>'><?php echo $rowCategory[1]?></option>
							<?php
						}
                        ?>
                  <option value='X'><?php echo $numberLBL["catInFile"];?></option>
                </select>
           		</div>
                <div class="row form-group" >
                    <div class="col-4">
                     <select id="category1" name="category1" class="indexs form-control" style="padding: 0px" onchange='checkCategory2()' disabled="disabled">
                        <option value='1' selected><?php echo $numberLBL["category"];?></option>
                        <option value='2' ><?php echo $numberLBL["name"];?></option>
                        <option value='3'><?php echo $numberLBL["mobile"];?></option>
                        <option value=''><?php echo $numberLBL["empty"];?></option>
                    </select>
                    </div>
                    <div class="col-4">
                     <select id="category2" name="category2" class="indexs form-control" style="padding: 0px" onchange='checkCategory2()'>
                        <option value='2' ><?php echo $numberLBL["name"];?></option>
                        <option value='3'><?php echo $numberLBL["mobile"];?></option>
                        <option value=''><?php echo $numberLBL["empty"];?></option>
                    </select>
                    </div>
                    <div class="col-4">
                     <select id="category3" name="category3" class="indexs form-control" style="padding: 0px" onchange='checkCategory2()'>
                        <option value='3'><?php echo $numberLBL["mobile"];?></option>
                        <option value=''><?php echo $numberLBL["empty"];?></option>
                    </select>
                    </div>
                </div>
                <div class="form-group custom-file" style="margin-top:15px">
                    <input type="file" name="file" id="file" class="custom-file-input" >
                    <label class="custom-file-label" for="validatedCustomFile"><?php echo $numberLBL["fileTitle"] ;?></label>
                </div>
                <div class="form-group" style="margin-bottom: 0px">
              		<label for="name" class="col-form-label myModalLabel" style="color:#FF0000;font-size:11px;"> 
					<?php echo '<br>'.$numberLBL["numbersNote20"].'<br>'.$numberLBL["numbersNote40"].'<br>';?>
                    </label>
           		</div>
                <div class="form-group" style="margin-bottom: 0px">
              		<label for="name" class="col-form-label myModalLabel" style="color:#FF0000;font-size:11px"> 
					<?php echo $numberLBL["numbersNote3"];?><br />
					<?php echo $numberLBL["numbersNote4"];?> <a href=number1.xls>number1.xls</a><br />
                    <?php echo $numberLBL["numbersNote5"];?> <a href=number1.xls>number1.xls</a><br />
                    <?php echo $numberLBL["numbersNote6"];?> <a href=number1.xls>number1.xls</a>
                    </label>
           		</div>
                <div class="form-group" style="margin-bottom: 0px">
              		<label for="name" class="col-form-label myModalLabel" style="color:#FF0000;font-size:11px"> 
					<?php echo $numberLBL["numbersNote8"];?><br />
                   	<?php echo $numberLBL["numbersNote4"];?> <a href="number1_xls.zip">number1_xls.zip</a><br />
                    <?php echo $numberLBL["numbersNote5"];?> <a href="number2_xls.zip">number2_xls.zip</a><br />
                    <?php echo $numberLBL["numbersNote6"];?> <a href="number3_xls.zip">number3_xls.zip</a>
                    </label>
           		</div>
                <div class="form-group" style="margin-bottom: 0px">
              		<label for="name" class="col-form-label myModalLabel" style="color:#FF0000;font-size:11px"> 
					<?php echo $numberLBL["numbersNote7"];?><br />
                   	<?php echo $numberLBL["numbersNote4"];?> <a href=number1.xlsx>number1.xlsx</a><br />
                    <?php echo $numberLBL["numbersNote5"];?> <a href=number1.xlsx>number1.xlsx</a><br />
                    <?php echo $numberLBL["numbersNote6"];?> <a href=number1.xlsx>number1.xlsx</a>
                    </label>
           		</div>
                <div class="form-group" style="margin-bottom: 0px">
              		<label for="name" class="col-form-label myModalLabel" style="color:#FF0000;font-size:11px"> 
					<?php echo $numberLBL["numbersNote9"];?><br />
                   	<?php echo $numberLBL["numbersNote4"];?> <a href="number1_xlsx.zip">number1_xlsx.zip</a><br />
                    <?php echo $numberLBL["numbersNote5"];?> <a href="number2_xlsx.zip">number2_xlsx.zip</a><br />
                    <?php echo $numberLBL["numbersNote6"];?> <a href="number3_xlsx.zip">number3_xlsx.zip</a>
                    </label>
           		</div>
            </div>
            
            <div class="modal-footer">
               <button type="button" class="btn bg-danger btn-flat text-white m-1" data-dismiss="modal"><?php echo $button["close"];?></button>
               <input type="submit" value='<?php echo $button["add"];?>' name="addFileBTN" class="btn bg-primary btn-flat text-white m-1">
            </div>
         </div>
      </div>
   </div>
</form>
<style>
select:disabled {
  background: #ccc !important
}
</style>
