<?php

$pageTitle = 'Category';

$pageTitle_Forpage = ucfirst($action).' '.$pageTitle; 

$actUrl = 'admin/'.$categoryFor.'/category_manager';
if(!empty($categoryId)){
	$actUrl = 'admin/'.$categoryFor.'/category_manager/'.$action.'/'.$categoryId;
}

// $arrQuesLanguageItemList = $this->admin_onelink_model->getQuestionLanguageList();
// $ARR_LANGUAGE_MENUS = array(0=>'Select Language');
// $iniLangId = "";
// if(!empty($arrQuesLanguageItemList)){
// 	foreach($arrQuesLanguageItemList as $sublangRow)
// 	{
// 	    if($iniLangId == "") $iniLangId = $sublangRow->id;
	    
// 		$ARR_LANGUAGE_MENUS[$sublangRow->id] = $sublangRow->name;
// 	}
// }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title><?php echo $pageTitle; ?> - ACP - <?php echo site_name(); ?></title>

<?php $this->load->view('admin/ap_top'); ?>

<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ap_assets/multi-select/css/multi-select.css" type="text/css"/>
<script src="<?php echo base_url(); ?>assets/ap_assets/multi-select/js/jquery.multi-select.js"></script>
<script src="<?php echo base_url(); ?>assets/ap_assets/multi-select/jquery.quicksearch.js"></script>

<style type="text/css">
.ms-container
{
    width:100%;
}
.ms-container .ms-list
{
    height:130px;
}
.select2-container--default{
    width:100% !important; 
}
</style>

<script type="text/javascript">
function doActionFn(action,id){
	 if(action == 'edit' || action == 'view'){
			window.location= '<?php echo base_url('admin/'.$categoryFor.'/category_manager/'); ?>/'+action+'/'+id;
	}else{
		 $('#doAction').val(action);	
		 if(action == 'delete'){
			if (confirm("Are you sure you want to delete?")) {
				$('#listFrm').submit();
			}	
		} else{
			$('#listFrm').submit();
		}
	}
}
function validateAccountForm(){
	clrErr();
	$errStaus = false; 
	var action = '<?php echo $action ?>';
	//if(validateFormFields('parantCategory','Please select parent.',''))$errStaus=true;
   	if(validateFormFields('categoryTitle','Please enter the title.',''))$errStaus=true;
	if(validateFormFields('categoryOrder','Please enter the category ref id.',''))$errStaus=true;
// 	if(validateFormFields('categoryLang','Please enter the category Language.',''))$errStaus=true;
	
  	if($errStaus) {
		return false;
	} else {
	    return true;		
	}
}
</script>
</head>

<body>
    
    <div class="wrapper" >
        <?php $this->load->view('admin/navbar'); ?>
            
		<div class="main-panel main-panel-custom">
		    <div class="content">
				<div class="page-inner">
					<div class="page-header">
						<h4 class="page-title"><?php echo $categoryForPage ; ?></h4>
						<ul class="breadcrumbs">
							<li class="nav-home">
								<a href="<?php echo base_url('admin/dashboard');?>">
									<i class="flaticon-home"></i>
								</a>
							</li>
							<li class="separator">
								<i class="flaticon-right-arrow"></i>
							</li>
							<li class="nav-item">
								<a href="<?php echo base_url('admin/'.$categoryFor.'');?>/category"><?php echo $pageTitle; ?> List</a>
							</li>
							<li class="separator">
								<i class="flaticon-right-arrow"></i>
							</li>
							<li class="nav-item">
								<a href="#"><?php echo $pageTitle_Forpage; ?></a>
							</li>
						</ul>
					</div>
					
					 <?php
                    	if($action == 'edit' || $action == 'add'){
                    	    //add, edit card
                	    ?>
                    	    <div class="row">
						        <div class="col-md-12">
    							<div class="card">
    							    
    								<div class="card-header">
    									<h4 class="card-title"><?php echo $pageTitle_Forpage; ?></h4>
    								</div>
    								
    								<!--notifiactions-->
        							<div class="container" id="">
                                        <?php 
                                 		$errMsg = validation_errors('* ');
                                		if(empty($errMsg)){ $errMsg = $this->session->flashdata('errMsg');  }
                                		$warningMsg = $this->session->flashdata('warningMsg');
                                		$successMsg = $this->session->flashdata('successMsg');
                                		if(isset($errMsg) && !empty($errMsg)){ echo showMessage($errMsg,'error'); }  
                                		if(isset($warningMsg) && !empty($warningMsg)){ echo showMessage($warningMsg,'warning'); }
                                		if(isset($successMsg) && !empty($successMsg)){ echo showMessage($successMsg,'success'); }
                                	?>
                                    </div>
    								
    								<div class="card-body">
    								    
    							        <?php echo form_open_multipart( $actUrl,array('name' => 'accAdminFrm', 'id' => 'accAdminFrm','onSubmit' => 'return validateAccountForm()'));?>
                                          
                                                <div class="form-group form-inline" id="div_categoryTitle">
    												 <label class="control-label col-md-2 " for="categoryTitle">Title<span style="color:red;">&nbsp;*</span></label>
    												<div class="col-md-6 p-0" >
    												    <?php   $data = array( 'name' => 'categoryTitle','value' => set_value('title',isset($categoryRow->categoryTitle)?$categoryRow->categoryTitle:$this->input->post('categoryTitle')),  'id' => 'categoryTitle',  'placeholder'   => 'Title', 'class' => 'input-full form-control required', );
                                      						 echo form_input($data);
                                    					?>
    													<small class="form-text text-muted text-danger err_msg" id="err_categoryTitle"></small>
    												</div>
    											</div>
                                                
                                                <div class="form-group form-inline" id="div_categoryOrder">
    												 <label class="control-label col-md-2 " for="div_categoryOrder">Category Ref Id<span style="color:red;">&nbsp;*</span></label>
    												<div class="col-md-6 p-0" >
    												    <?php   $data = array( 'name' => 'categoryOrder','value' => set_value('categoryOrder',isset($categoryRow->categoryRefId)?$categoryRow->categoryRefId:$this->input->post('categoryOrder')),  'id' => 'categoryOrder',  'placeholder'   => 'Id', 'class' => 'input-full form-control required', );
                                      						 echo form_input($data);
                                    					?>
    													<small class="form-text text-muted text-danger err_msg" id="err_categoryOrder"></small>
    												</div>
    											</div>
                                                
                                                <!--<div class="form-group form-inline" id="div_categoryLang">-->
                                                <!--  <label class="control-label col-md-2" for="categoryLang">Language<span style="color:red;">&nbsp;*</span></label>-->
                                                <!--  <div class="col-md-6 p-0" >-->
                                                  <?php  
                                            //           if($categoryFor == "questions") $js = 'class="input-full form-control" id="categoryLang" '; 
                                            //           else 
                                         			// 	$js = 'class="form-control" id="categoryLang"  '; 
                                         				
                                         			// 	if(isset($categoryRow->categoryLang))
                                         			//     {
                                         			//         $set_v_lang = $categoryRow->categoryLang;
                                         			//     }
                                         			//     else if($this->session->userdata('categoryLangTemp'))
                                         			//     {
                                         			//         $set_v_lang =   $this->session->userdata('categoryLangTemp');
                                         			//     }
                                         			//     else
                                         			//     {
                                         			//         $set_v_lang =  $this->input->post('categoryLang');
                                         			//     }
                                         			    
                                        				// echo form_dropdown('categoryLang',$ARR_LANGUAGE_MENUS,
                                        				// set_value('categoryLang',$set_v_lang),
                                        				// $js); 
                                        		  ?>
                                                  <!--<p class="text-danger err_msg" id="err_categoryLang"></p>-->
                                                  <!--</div>-->
                                                <!--</div>-->
                                            
                                            
                                          
                                            <div class="form-group form-inline">
    												<label for="inlineinput" class="col-md-2 col-form-label "></label>
    												<div class="col-md-6 p-0">
                                              <?php
                                		        $data = array( 'name' => 'iconBtn','value' => 'true', 'id' => 'iconBtn',  'type' => 'submit','content' => 'Submit', 'class' => 'btn btn-success',   );
                                 			    echo form_button($data);
                                			    $data = array( 'name' => 'resetBtn','value' => 'true', 'id' => 'resetBtn', 
                                			    'type' => 'reset','content' => 'Cancel', 'class' => 'btn btn-warning' , 'onclick' => 'window.location.href=document.referrer'  );
                                			    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                                 			    echo form_button($data) ;
                                 			?>
                                            </div>
                                          </div>
                                          <?php echo form_close();?>
    								</div>
    							</div>
    						</div>
					        </div>
                    	    
                	    <?php
                    	}
                    	else
                    	{
                    	    //view card
                    	    ?>
                    	    <div class="row">
        						<div class="col-md-12">
        							<div class="card">
        								<div class="card-header">
        								    <div class="card-head-row">
        									    <h4 class="card-title">Category Info</h4>
        									</div>
        								</div>
							            <div class="card-body">
        							        <div class="table-responsive">
        										<table id="" class="table table-bordered">
        									    	<tr>
        											    <th>Category Title</th><td><?php echo ( (!empty($categoryRow->categoryTitle)&&(isset($categoryRow->categoryTitle))) ? $categoryRow->categoryTitle:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Category Ref Id</th><td><?php echo ( (!empty($categoryRow->categoryRefId)&&(isset($categoryRow->categoryRefId))) ? $categoryRow->categoryRefId:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Language</th><td><?php echo ( (!empty($categoryRow->categoryLang)&&(isset($categoryRow->categoryLang))) ? $categoryRow->categoryLang:'-');  ?></td>
        										    </tr>
        										    
                								</table>
        									</div>
        								</div>
        							</div>
        						</div>
        						
        					</div>
                    	    <?php
                    	}
                	?>
				</div>
			</div>
		    <!--<footer class="footer">-->
			    <?php //footer();?>
			<!--</footer>-->
		</div>
		
	</div>
 
</body>

<script>



$(document).ready(function(){
            
    $("#categoryLang").select2();

});
</script>
 
</html>