<? global $vis_language; ?>
<link href="<?= VIS_PATH_SCRIPT; ?>colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $operation['view_title'];?></h3>
      <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
         <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
         <li><a class="link" href="#/setting/setting_menu/<? echo $vis_language['TXTSETTINGS'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTSETTINGS']; ?>',{'vis_module':'setting','vis_operation':'setting_menu'});"><? echo $vis_language['TXTSETTINGS']; ?></a></li>
         <li><a  class="link" href="#/setting/view_procure_mode/<? echo $vis_language['TXTPROCUREMODE']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTPROCUREMODE']; ?>',{'vis_module':'setting','vis_operation':'view_procure_mode'});" class="link"><? echo $operation['view_title']; ?></a> </li>
         <li class="active"><?echo $vis_language['TXTUPDATEPROCUREMODE'];?></li>
      </ul>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATEPROCUREMODE']; ?></header>
      <div class="panel-body">
         <form class="form-horizontal" id="vis_procure_mode_form" name="vis_procure_mode_form" method="post" >
            <input type="hidden" name="vis_procurement_id" value="<? echo $procure_mode_details['procurement_id']; ?>" />
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNAME']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_name" id="vis_name" value="<? echo htmlentities($procure_mode_details['name'], ENT_COMPAT, 'UTF-8'); ?>">
               </div>
            </div>
			 <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTCOLOR']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm demo-auto" type="text" name="vis_color" id="vis_color"  value="<? echo $procure_mode_details['color']; ?>">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDESCRIPTION']; ?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm" type="text" name="vis_description" id="vis_description"><? echo $procure_mode_details['description']; ?></textarea>
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYORDER']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_displayorder" id="vis_displayorder"  value="<? echo $procure_mode_details['display_order']; ?>">
               </div>
            </div>
           <div id="department_access123">
		   <div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENTACCESS']; ?></label>
               <div class="col-sm-10">
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" value="1" id="vis_department_all" onchange="toggle_dept_list();" name="vis_department_all"  <? if($procure_mode_details['department_access']==0) echo ' checked="checked"'; ?> ><i></i> <? echo $vis_language['TXTALLDEPARTMENTS']; ?>
                  </label>
               </div>
            </div>
            <div id="vis_dept_list_section" class="form-group" style="<?= ($procure_mode_details['department_access']==0)?'display:none':'';?>">
               <label class="col-sm-2 control-label"></label>
               <div class="col-sm-10">
				   <div class="dept_access_list">
                  <? $dept_list=array();
                      for($i=0;$i<count($department_details);$i++) {?>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" id="vis_department" name="vis_department[]" <? if(in_array($department_details[$i]['department_id'], $procure_mode_department)) echo ' checked="checked"'; ?>value="<? echo $department_details[$i]['department_id']; ?>" /> <i></i><? echo $department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_name']; ?></label><br/>
                  <?
                     $dept_list[]=$department_details[$i]['department_id'];
                     } ?>
               </div>
              </div>
            </div>
            </div>
			<? if($language_details!=-1) { ?>
            <div class="form-group">
               <div class="col-sm-12"><h5><? echo $vis_language['MSGLANGTRANSFORPROCUREMODE']; ?></h5></div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <?
               for($i=0;$i<count($language_details);$i++) { ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $language_details[$i]['language_name']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_language_<? echo $language_details[$i]['language_id']; ?>" type="text" value="<? echo $procure_mode_lang[$language_details[$i]['language_id']]; ?>" />
               </div>
            </div>
            <?
               }
               }  ?>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <div class="form-group">
               <div class="col-sm-4 col-sm-offset-2">
                  <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'subsetting', 'vis_operation':'update_procure_mode', 'vis_form':'vis_procure_mode_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<script src="<?= VIS_PATH_SCRIPT; ?>colorpicker/js/bootstrap-colorpicker.js"></script>
<script type="text/javascript">
  /* if ($(vis_access_yes).is(":checked"))
   {
    $('#department_access123').hide();
   }
	$(document).ready(function () {
	   $('#vis_access_yes').click(function () {
		  $('#department_access123').hide();
   });
   $('#vis_access_no').click(function () {
		 $('#department_access123').show();
	});
  });*/
  $(function() {
   	function createColorpickers() {
   		$('.demo-auto').colorpicker();
   	}
   	createColorpickers();
   });
      $(".selectpicker").selectpicker();
   function toggle_dept_list(){
       if($('#vis_department_all').is(":checked")){ $('#vis_dept_list_section').hide();
							}else{ $('#vis_dept_list_section').show();
							$('.dept_access_list').each(function(index) {
        $(this).find('input[type="checkbox"]').removeAttr('checked');
       });
							}
   }
</script>
