<style>
     .btn-group button {
        height:30px; }
</style>
<script>
$(document).ready(function(){
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
	jQuery("#supplierCode").keyup(function() {
		jQuery(this).val(jQuery(this).val().toUpperCase());
	});
        
         $('select').select2(); 
          $.each($(".select2-container"), function (i, n) {
                    $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
                    $(n).prepend($(n).next());
                    $(n).delay(500).queue(function () {
                        $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
                        $(this).dequeue();
                    });
                });	
});
	function changeList(obj){
		var id = obj.value;
		$.ajax({
			type: "POST",
			url: "<?php base_url()?>../setting/getState/",
			data: "region="+id,
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option>-Please Select-</option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].fldid+'">'
						+ content.message[i].fldname + '</option>');
					}
					jQuery("#customerStateID").empty();
					jQuery("#customerStateID").append(items.join('</br>'));
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
			}
		});
		return false;
	}
function refreshProjectManager(){
 $.ajax({
	type: "POST",
	url: "<?php echo base_url() ?>employeeSetup/refreshEmployee",
	success: function(data) {
	
	   var resul = eval ("(" + data + ")"); 
	   var n=resul.records.length;
	   var i=0;
	   var opt='' +
		'<option></option>';
		for (i=0;i<n;i++)
			opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].employeeName + '</option>';
		$('#projectManager').empty();
		$('#projectManager').append(opt);
	}
   });	
}

</script>
<div id="content">                        
<div class="wrap">
                  
<div class="head">
	<div class="info">
		<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
		<?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>
			<ul class="breadcrumb">
            	<li><a href="#"><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                <li><a href="#"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                <li class="active"><?php echo $this->lang->line('title') ?></li>
            </ul>
	</div>
                        
	<div class="search">
		<form action="<?php echo base_url() ?>admin/search" method="post">
			<input name="search_text" type="text" placeholder="search..."/>                                
            <button type="submit"><span class="i-magnifier"></span></button>
		</form>
	</div>                        
</div>  <!-- Head -->                                                                  
                    
<div class="content">
                    
	<div class="row-fluid">
		<div class="span12">
			<?php 
				$hidden = array('order_time' => date('Y-m-d H-i-s'));
				if($project)
				$hidden['ID'] = $project->ID;
				$attrib = array('id'=>'validate'); 
				echo form_open('', $attrib, $hidden);?>
            	<div class="block">
                	<div class="head">
                    	<h2><?php echo $this->lang->line('title') ?></h2>
                        <div class="side fr">
                        <button class="btn-form btn-danger-form" onClick="clear_form('#validate');" type="button"><?php echo $this->lang->line('clear') ?></button>
                    </div>
                            <ul class="buttons">                                            
                            	<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                        	</ul>                                         
				</div>
				<div class="content np"> <!-- Content 1 -->   
                  <!--div class="controls-row"> <!-- hide companyid as no needed to display->
                  	<div class="span2"><?php echo $this->lang->line('companyID') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'companyID', 
									'id'=>'companyID', 									
									'class'=>'span3 validate[required]',); 
							if($project){		
								echo form_input($data, $project->companyID); 
							}else{
								echo form_input($data, set_value('companyID')); 
                            }                       ?> 
                  </div>
                  </div-->
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('project_name') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'project_name', 
									'id'=>'project_name', 									
									'class'=>'span5 validate[required]',); 
							if($project){		
								echo form_input($data, $project->project_name); 
							}else{
								echo form_input($data, set_value('project_name')); 
                            }                       ?> 
                  </div>
                  </div>
                	<!--div class="controls-row">
                    	<div class="span2"><?php echo $this->lang->line('projectManagerID') ?></div>
                   	<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'projectManagerID', 
									'id'=>'projectManagerID', 
									'class'=>'span3 validate[required,maxSize[128]]',); 
							if($project){		
								echo form_input($data, $project->projectManagerID); 
							}else{
								echo form_input($data, set_value('projectManagerID')); 
                            }                       ?> 
                  </div>
                  </div-->
            <div class="controls-row">
         	<div class="span2"><?php echo $this->lang->line('projectManagerID') ?></div>
         	<div class="span10">

                 <?php
					$options = '';
					$options[] = '--Please Select--';
				if($projectManager ){
				 foreach($projectManager as $row){
					$options[$row->ID] = $row->employeeName ;

				 }} 
				if ($project) $preselgen= $project->projectManagerID; 
				else $preselgen= '';
				echo form_dropdown('projectManagerID', $options, $preselgen,"class='span5'");
?>
                <div class="btn-group span1">
                 <button class="btn-icon btn-small dropdown-toggle" data-toggle="dropdown">
                	<span class="i-arrow-down-2"></span>
                  </button>
                  	<ul class="dropdown-menu">
                        <!-- dropdown menu links -->
                        <li><a target="_blank" href="<?php echo base_url() ?>employeeSetup/EmployeeNew"  id="btnNewPro">
                        <i class="icon-plus-sign"></i><?php echo $this->lang->line('addNewEmployee')?></a></li>
                        <li><a href="#" onclick="refreshProjectManager()"><i class="icon-refresh"></i><?php echo $this->lang->line('refreshlist')?></a>
                        </li>
             		 </ul>
                     </div> <!-- btn group -->
            </div><!-- span -->
        	
          </div> <!-- row control -->

		<div class="content np">    
                  <div class="controls-row">
                    	<div class="span2"><?php echo $this->lang->line('totalBudget') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'totalBudget', 
									'id'=>'totalBudget', 									
									'class'=>'span5 validate[maxSize[128]]',); 
							if($project){		
								echo form_input($data, $project->totalBudget); 
							}else{
								echo form_input($data, set_value('totalBudget')); 
                            }                       ?> 
                  </div>
                  </div>
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('remarks') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'remarks', 
									'id'=>'remarks', 									
									'class'=>'span8',); 
							if($project){		
								echo form_input($data, $project->remarks); 
							}else{
								echo form_input($data, set_value('remarks')); 
                            }                       ?> 
        
                  </div>
                  </div>
		<div class="content np">    
            <div class="footer">
            	<div class="side fr">
                	<div class="btn-group">
                        <?php 
							$data = array(
									'name'=>'validat', 
									'class'=>'btn-form btn-warning-form',
									'onClick'=>"$('#validate').validationEngine('hide');"); 
							echo form_button($data,'Hide prompts');
							$data = array(
									'name'=>'mysubmit', 
									'class'=>'btn-form btn-success-form');
							echo form_submit($data,'Submit');
							?>
                    </div>
                </div>
            </div>                                    
        </div>
		</div>
	</form>
</div>
</div>                        
</div>
</div>
</div>
