<?php
require_once('constants.php');
class General
{
	public function __construct()
	{
		
		?>
         
        <script language="javascript" src="js/index_sub.js?t=<?=time();?>" type="text/javascript">       
        </script>
        
        <?php
	}
	
	 
	public function showGeneralList()
	{
		//if(count($_SESSION['cat'])<=0)
			 
				/*echo '<PRE/>';
				print_r($_SESSION['cat']);
				echo '<PRE/>';*/
	
	?>
      
 

      <div class="am-mainpanel">
      <div class="am-pagebody">

        <div class="card pd-20 pd-sm-20">
          <h6 class="card-body-title"><?=TITLE_PAGE;?></h6>
           
		  
          <div class="mg-0  col-md-12 mg-b-10 search_options">	
          <form action="#" id="searching_arguments">
          		<input type="hidden" id="task" name="task" value="GeneralDetails">
          		
               
                   
                 <div class=" col-md-12" > 
                  
                 
                  
   <button type="button" onclick="GeneralDetails(1);" style="float:right; margin:0px;" class="dt-button buttons-pdf buttons-html5 btn-sm"><i class="fa fa-search mg-r-5"></i>Search</button>
</div>

   
          </form>
          </div>
          <div class="table-wrapper">
             
             <div class="x_content" id="main_result_div">
                     <script language="javascript" type="text/javascript">GeneralDetails(1);</script>
					
					
                  </div>
             
          </div><!-- table-wrapper -->
        </div><!-- card -->

           
                     
    <?php
	}
	
	//Add 
		public function add_edit($data='',$extra='')
		{
			
			//echo $_SESSION['role_level'];
			
			
			 
			$data['id'] = $data['admin_id'];
			
			/*if($data['dob'])
				$data['dob'] = $data['dob'];
			else
				$data['dob'] = date("Y-m-d");
				*/
		?> 

            <div id="add_edit"  >
                <form   name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' data-parsley-validate >
               <div class="header_box"><?=($data['id']>0)?'Edit - ':'Add - ';?><?=TITLE_PAGE;?></div>
               <div class="body_box"> <?php if($data['id']>0) { 
				
				?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   
				   
                   
				   <?php }else{ 
				   
				   //$data['under'] = $extra['under'];
				  // $data['designation'] = $extra['designation'];
				   ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   
                 
              	
                
                    <div class="">
                       
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Name : <span class="tx-danger">*</span></label>                           
                          <input type="text" name="<?=$name='name';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""   required>
                            
                        </div><!-- form-group -->
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Mobile Number : <span class="tx-danger">*</span></label>
                           
                           <input type="number" maxlength="10" min='1' max='9999999999' name="<?=$name='mobile';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  required>
                            
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Email <span class="tx-danger">*</span></label>
                           
                           <input type="email"  name="<?=$name='email_address';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder="" required>
                        </div>
                        
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          
                          <label>Date of Birth : <span class="tx-danger">*</span></label>
                           
                           <div class="input-group">
                        
                           <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input readonly="readonly" type="text" class="form-control fc-datepicker form-control wd-200 wd-sm-250" placeholder="DD/MM/YYYY"  name="<?=$name='dob';?>" id="<?=$name;?>" value="<?=date("d-m-Y",strtotime(clear_blank_date($data[$name])));?>">
                             
                             </div>
                            
                        </div>
                        
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Date of Joining : <span class="tx-danger">*</span></label>
                           
                           <div class="input-group">
                        
                           <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input readonly="readonly" type="text" class="form-control fc-datepicker form-control wd-200 wd-sm-250" placeholder="DD/MM/YYYY"  name="<?=$name='doj';?>" id="<?=$name;?>" value="<?=date("d-m-Y",strtotime(clear_blank_date($data[$name])));?>">
                             
                             </div>
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          
                          <label>Gender : <span class="tx-danger">*</span></label>
                           
                             
						<?php 
							$table = "master_gender";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['gender'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "gender";		//$id = id of select
							$displayName = "title";		//displayName = display name
							$value ="title";  			// $value = value of Select
							
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value);
                            ?>
                            
                        </div> 
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Designation <span class="tx-danger">*</span></label>
                           
                           <input type="text"  name="<?=$name='designation_employee';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder="" required>
                        </div>
                        </div>
                        
                        
                        <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0" style="width:100%;">
                        	 <label>Permanent Address : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='permanent_address';?>" id="<?=$name;?>" class="form-control " value="<?=$data[$name];?>" placeholder=""  required>
                             
                        </div>
                        </div>
                        
                        <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0" style="width:100%;">
                        	 <label>Communtication Address : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='communtication_address';?>" id="<?=$name;?>" class="form-control " value="<?=$data[$name];?>" placeholder="" required >
                             
                        </div>
                        </div>
                         
                      <div class=" mg-b-30">
                        <div class="f">
                          
                          	<label class="ckbox">
                              <input type="checkbox" id="<?=$name='is_panel_access';?>" name="<?=$name;?>" <?=($data['is_panel_access']==1)?'checked="checked"':'';?> value="1" />
                              <span>Have Admin Panel Access?</span>
                            </label>
                        </div><!-- form-group -->
                      </div>
                      
                      <?php
                      
                      if($data['is_panel_access']==0)
							$other = 'disabled="disabled" ';
						else
							$other = '';
							
					  ?>
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        
                          <label>Role : <span class="tx-danger">*</span></label>
                         	   <?php 
									$table = " admin_user_type";	//$table = name of table
									$fields = "*";			//Fields = Fields of tables
									$matchField = " ppanel =1 and is_deleted    ";		//$matchField = matching fields
									$code = "0";				//$code = where $code
									$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
									$sel = $data['user_type'];				//$sel = selected fields
									$function ="";			//$function = javascript function
									$id = "user_type";		//$id = id of select
									$displayName = "admin_type";		//displayName = display name
									$value ="admin_code";  			// $value = value of Select
									
									
									echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other)
								?>
                        </div>
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          <label>Username : <span class="tx-danger">*</span></label>
                           
                           <input type="text" name="<?=$name='email';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  <?=$other;?> required>
                            
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          <label>Access Type : <span class="tx-danger">*</span></label>
                           
                           	<?php
                            $out = '<select id="access_type" name="access_type" class="form-control selct wd-200 wd-sm-250" '.$other.'>';
								 
								
								 	
									 $sel='';
									 if($data['access_type']==2)
									 		$sel = 'selected';
									 $out .='<option '.$sel.' value="2"  >All Bookings</option>';
									 
									 $sel='';
									 if($data['access_type']==1)
									 		$sel = 'selected';
									 $out .='<option '.$sel.' value="1"  >Limited Bookings Only</option>';
									 
								 
								$out .= '</select>';
								echo  $out;
								
								?>
                            
                        </div>
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          <label>Payment : <span class="tx-danger">*</span></label>
                           
                           	<?php
                            $out = '<select id="payment_approval" name="payment_approval" class="form-control selct wd-200 wd-sm-250" '.$other.'>';
								 
								
								 	
									 $sel='';
									 if($data['payment_approval']==1)
									 		$sel = 'selected';
									 $out .='<option '.$sel.' value="1"  >Need Approval</option>';
									 
									 $sel='';
									 if($data['payment_approval']==2)
									 		$sel = 'selected';
									 $out .='<option '.$sel.' value="2"  >Direct Payment</option>';
									 
								 
								$out .= '</select>';
								echo  $out;
								
								?>
                            
                        </div>
                        <!-- form-group -->
                        
                        
                       <!--<div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Password : <span class="tx-danger">*</span></label>
                         	  <input type="password" name="<?=$name='password';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="" placeholder=""   required <?=$other;?>>
                        </div>-->
                      </div>
                      
                      <div class=" mg-b-30">
                        <div class="f">
                          
                          	<label class="ckbox">
                              <input type="checkbox" id="<?=$name='is_sale';?>" name="<?=$name;?>" <?=($data['is_sale']==1)?'checked="checked"':'';?> value="1" />
                              <span>Member of sale team</span>
                            </label>
                        </div><!-- form-group -->
                      </div>
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">     
                          <label>Sale Desigtnation : <span class="tx-danger">*</span></label>
						<?php 
							$table = "designation";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['designation'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "designation";		//$id = id of select
							$displayName = "designation_name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							if($data['is_sale']==0)
								$other = 'disabled="disabled" ';
							else
								$other = '';
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other);
                            ?>
                            
                        </div> 
                        
                        
                       <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Reporting to : <span class="tx-danger"></span></label><div id="reporing">
                            <?php
							   
							    $s44 = "select * from designation where code='".$data['designation']."' ";
								$r44 = mysql_query($s44);
								$ro44 = mysql_fetch_assoc($r44);
								
								
								
								  $qry = "SELECT s.*,designation_name FROM admin_users s 
									INNER JOIN  designation b  ON s.is_deleted=0 and b.code='".$ro44['under_designation']."' and not s.admin_id='".$data['id']."' and b.code=s.designation   ";
								 
								
								 
							
								if($data['is_sale']==0)
									$other = 'disabled="disabled" ';
								else
									$other = '';
								
								$res=mysql_query($qry);
								
								$out = '<select id="designation_reporting" name="designation_reporting" class="form-control selct wd-200 wd-sm-250" '.$other.'>';
								$out .='<option value="" >--Select--</option>';
								
								while($result=mysql_fetch_array($res))
								{	
									$sel='';
									 if($data['designation_reporting']==$result['admin_id'])
									 	$sel = 'selected';
									 $out .='<option '.$sel.' value="'.$result['admin_id'].'"  >'.$result['name'].' ('.$result['designation_name'].')</option>';
									 
								}
								$out .= '</select>';
								echo  $out;
								
								?>
                          </div>
                        </div>
						
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">     
                          <label>Sale Branch : <span class="tx-danger">*</span></label>
						<?php 
							$table = "sale_employee_brm";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['branch'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "branch";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							if($data['is_sale']==0)
								$other = 'disabled="disabled" ';
							else
								$other = '';							
							
							//echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value);
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other);
                            ?>
                        </div>
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">     
                          <label>Target : <span class="tx-danger">*</span></label>
                           <input type="number" name="target" id="sale_target" class="form-control wd-200 wd-sm-250" value="<?=$data['target'];?>">
                        </div>		
                      </div>
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Store/Location : <span class="tx-danger">*</span></label>
                           
                             
						<?php 
							$table = "store_master";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "is_deleted";		//$matchField = matching fields
							$code = "0";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['store_code'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "store_code";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							 	$other = '';
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other);
                            ?>
                            
                        </div> 
                      </div>
					  
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                          <label>Status : <span class="tx-danger">*</span></label>
                         	   <?php 
							$table = " master_status";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['admin_users_status'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "admin_users_status";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							$other =" required"; 
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other)
					?>
                        </div>
                        
                       </div>   
                      <div class="d-md-flex">
                         <div  id="res"></div>
                      </div>
                       <div class="d-md-flex mg-b-30">
                        <button type="submit"  id="submit_66"  class="dt-button btn btn-primary btn-success btn-sm">Submit</button> 
                        
                        <button type="button" class="dt-button btn btn-default btn-success btn-sm" onclick="GeneralDetails(<?=$_SESSION['page'];?>)">Go Back</button>
                        </div>
                    </div>
           <!--
           		<button type="button" id="btnInsertPro" name="btnInsertPro" onclick="addNew_Key(this.form)">Save</button>
                <button type="button" id="as" name="as" onclick="GeneralDetails(<?=$_SESSION['page'];?>)" >Go Back</button>-->
            
            	</form>
            </div>
                
		 
        <?php
	}
	
}

?>
</div>
