<script>
    $(document).ready(function() {
        $('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();
                    });
                });	
        jQuery('.datepicker2').datepicker({
            dateFormat: 'dd-mm-yy',
            changeMonth: true,
            changeYear: true
        });

        $("table.editable").on("click", ".edit", function() {
            var eRow = $(this).parents('tr');
            var eState = $(this).attr('data-state');

            if (eState == null) {
                $(this).html('Save');
                eState = 1;
            }
            if (eState == 1)
                $(this).attr('data-state', '2');
            else {
                $(this).removeAttr('data-state');
                $(this).html('Edit');
            }
        });
		if(!$("#gstRegisteredNo").val())
			$("#gstRegisteredDate").attr("disabled","disabled");

    });

function gstRegisteredAttr(){
	$("#gstRegisteredDate").removeAttr("disabled");
}

function isThisRegister(){
        if($.trim($("#gstRegisteredNo").val()).length > 0){
            $("#gstRegisteredDate").removeAttr("disabled");
            $("#taxablePeriod").select2('enable',true);
        }else{
              $("#taxablePeriod").select2("val","NULL");
            $("#taxablePeriod").select2('disable',true);
            $("#gstRegisteredDate").attr("disabled","disabled");
            $("#gstRegisteredDate").val("");
          
        }
    }
    
</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 base_url(); ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href="home"><?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="wrap">                    
                <div class="row-fluid">
                    <div class="span12">
                        <div class="block">
                            <div class="row-fluid">

                                <div class="span12">
                                    <?php
                                    $hidden = array('order_time' => date('Y-m-d H-i-s'), 'ID' => $umaster->ID);
                                    $attrib = array('id' => 'validate');
                                    echo form_open_multipart('', $attrib, $hidden);
                                    ?>
                                    <!-- form id="validate" method="POST" action="javascript:alert('Form #validate submited');"-->
                                    <div class="block">
                                        <div class="head">
                                            <h2><?php echo $this->lang->line('title') ?></h2>
                                        </div>
                                        <div class="content np">    
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('companyNo')); ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'readonly' =>'readonly',
                                                        'name' => 'companyNo',
                                                        'class' => 'span12 validate[required,minSize[5],maxSize[10]]',);
                                                    echo form_input($data, $umaster->companyNo);
                                                    ?>
                                                </div>
                                            </div>                    
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('companyName')); ?></div>
                                                <div class="span8">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'companyName',
                                                        'id' => 'companyName',
                                                        'class' => 'span12 validate[required,maxSize[128]]',);
                                                    //$js='Readonly';	 
                                                    echo form_input($data, $umaster->companyName);
                                                    ?>
                                                </div>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('incorporateDate')); ?></div>
                                                <div class="span4">
                                                    <div class="input-prepend span12">
                                                        <span class="add-on span2"><i class="i-calendar"></i></span>
                                                        <?php
                                                        $data = array(
                                                            'name' => 'incorporateDate',
                                                            'id' => 'incorporateDate',
                                                            'type' => 'text',
                                                            'class' => 'datepicker2 span10 financhk',);
                                                        echo form_input($data, date("d-m-Y", strtotime($umaster->incorporateDate)));
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"><?php echo "Address"; ?></div>
                                                <div class="span8">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'line1',
                                                        'class' => 'span12 validate[required,maxSize[128]]',);
                                                    echo form_input($data, $umaster->line1);
                                                    ?>
                                                </div>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"></div>
                                                <div class="span8">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'line2',
                                                        'class' => 'span12 validate[required,maxSize[128]]',);
                                                    echo form_input($data, $umaster->line2);
                                                    ?>
                                                </div>
                                            </div>


                                            <div class="controls-row">
                                                <div class="span2"></div>
                                                <div class="span8">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'line3',
                                                        'class' => 'span12 validate[maxSize[128]]',);
                                                    echo form_input($data, $umaster->line3);
                                                    ?>
                                                </div>
                                            </div> 
                                            <div class="controls-row">
                                                <div class="span2"><?php echo $this->lang->line('city') ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'city',
                                                        'id' => 'city',
                                                        'class' => 'span12',);
                                                    echo form_input($data, $umaster->city);
                                                    ?> 

                                                </div>
                                                <div class="span1" TAR><?php echo $this->lang->line('companyPostCode') ?></div>
                                                <div class="span3">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'companyPostCode',
                                                        'id' => 'companyPostCode',
                                                        'class' => 'span12 validate[minSize[5],maxSize[5]]',);
                                                    echo form_input($data, $umaster->companyPostCode);
                                                    ?> 
                                                </div>
                                            </div>
                                            <div class="controls-row"> <!-- row 1 -->
                                                <div class="span2"><?php echo $this->lang->line('country') ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $preselcat = $umaster->countryID;

                                                    $options[NULL] = $this->lang->line('select');
                                                    foreach ($country as $row) {
                                                        $options[$row->fldid] = $row->fldcountry;
                                                    }
                                                    $js = 'onChange="changeList(this)", class="span12" validate[required]';
                                                    echo form_dropdown('countryID', $options, $preselcat, $js);
                                                    ?>       
                                                </div>                
                                                <div class="span1" TAR><?php echo $this->lang->line('state') ?></div>
                                                <div class="span3">
                                                    <?php
                                                    $preselcat = $umaster->companyStateID;

                                                    $options = '';
                                                    $options[NULL] = $this->lang->line('select');
                                                    if ($state != '') {
                                                        foreach ($state as $row) {
                                                            $options[$row->fldid] = $row->fldname;
                                                        }
                                                    }
                                                    $js = 'id=stateID, class="span12" validate[required]';
                                                    echo form_dropdown('stateID', $options, $preselcat, $js);
                                                    ?>       
                                                </div>                
                                            </div><!-- End Row 1 -->  
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('phoneNo')); ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'class' => 'span12',
                                                        'name' => 'phoneNo',);
                                                    echo form_input($data, $umaster->phoneNo);
                                                    ?>
                                                </div>
		                                        <span class="help-inline"><?php echo $this->lang->line('example') ?>: +603-2261 4180</span>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('faxNo')); ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'class' => 'span12',
                                                        'name' => 'faxNo',);
                                                    echo form_input($data, $umaster->faxNo);
                                                    ?>
                                                </div>
												<span class="help-inline"><?php echo $this->lang->line('example') ?>: +603-2261 4182</span>
                                            </div>             
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('email')); ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'class' => 'span12',
                                                        'name' => 'email',);
                                                    echo form_input($data, $umaster->email);
                                                    ?>
                                                </div>
												<span class="help-inline"><?php echo $this->lang->line('example') ?>: sps@salihin.com.my</span>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('website')); ?></div>
                                                <div class="span4">
                                                    <?php
														$data = array(
    														'name' => 'website',
    														'class' => 'span12 validate[custom[url]]',);
														if ($umaster) {
															$data = array(
    															'name' => 'website',
																'value' => $umaster->website,
    															'class' => 'span12 validate[custom[url]]',);
    														echo form_input($data, $umaster->website);
														} else {
    														echo form_input($data, set_value('website'));
														}
													?>
                                                </div>
												<span class="help-inline"><?php echo $this->lang->line('example') ?>: http://www.salihinpremier.com</span>
                                            </div>  
                                            <div class="controls-row">
                                                <div class="span2"><?php echo $this->lang->line('currency') ?></div>
                                                <div class="span4">
                                                    <?php
													$options = '';
                                                    $preseldept = $umaster->currencyID;
                                                    $options[NULL] = $this->lang->line('select');
                                                    foreach ($currency as $row) {
                                                        $options[$row->fldid] = $row->fldcurr_code . " [" . $row->fldcurr_desc . "]";
                                                    }
                                                    $js = 'class="span12"';
                                                    echo form_dropdown('currencyID', $options, $preseldept, $js);
                                                    ?>
                                                </div>
                                            </div>
                                            <div class="controls-row">
                                                <div class="span2"><?php echo form_label($this->lang->line('uploadLogo'), 'userfile'); ?></div>
                                                <div class="span4">
                                                    <?php
                                                    $data = array(
                                                        'name' => 'userfile',                                                       
                                                        'id' => 'userfile',
														'type ' => 'file',
                                                        'value' => '');
                                                    echo form_upload($data, set_value('userfile'));
                                                    ?>                       
                                                </div>
                                                <div class="span5">
                                                    <div id="gallery">
                                                        <?php if ($umaster->uploadLogo) { ?>
                                                            <div class="pic" align="center">
                                                                <a class="fancybox" href="<?php echo base_url() . 'images/' . $umaster->uploadLogo ?>">
                                                                    <img class="img-polaroid" src="<?php echo base_url() . 'images/thumbs/' . $umaster->uploadLogo; ?>" />
                                                                </a>
                                                            </div>
                                                        <?php } ?>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="head">
                                                <h2><?php echo $this->lang->line('title2'); ?></h2>
                                                <ul class="buttons">
                                                    <li><a href="#mygst"  data-toggle="collapse" data-target="#mygst">
                                                            <span class="i-arrow-down-3"></span></a></li>
                                                </ul>                                        
                                            </div><!-- head -->

                                            <div class="content">
                                                <div class="collapse in" id="mygst">

                                                    <div class="controls-row">
                                                        <div class="span2"><?php echo form_label($this->lang->line('gstRegNo')); ?></div>
                                                        <div class="span4">
                                                            <?php
                                                            $data = array(
                                                                'class' => 'span12 validate[custom[integer],minSize[12],maxSize[12]]',
                                                                'name' => 'gstRegisteredNo',
                                                                'id' => 'gstRegisteredNo',);
																$js = "onChange=isThisRegister()";
                                                            echo form_input($data, $umaster->gstRegisteredNo, $js);
                                                            ?>
                                                        </div>
														<!--iv class="span3"><p><small><?php echo form_label('12 digits'); ?></small></p></div-->
                                                    </div>    
                                                    <div class="controls-row">
                                                        <div class="span2"><?php echo form_label($this->lang->line('gstRegDate')); ?></div>
                                                        <div class="span4">
                                                            <div class="input-prepend span12">
                                                                
                                                                <?php
                                                                $data = array(
                                                                    'name' => 'gstRegisteredDate',
                                                                    'id' => 'gstRegisteredDate',
                                                                    'type' => 'text',
                                                                    'class' => 'datepicker2 span10 financhk',);
																if($umaster->gstRegisteredDate <> "0000-00-00"){
                                                                	echo form_input($data, date("d-m-Y", strtotime($umaster->gstRegisteredDate)),"onblur='isThisRegister()'");
																}
																else{
																	echo form_input($data, date(""),"onblur='isThisRegister()'");
																}
																?>
                                                            <span class="add-on span2"><i class="i-calendar"></i></span></div>
                                                        </div>
                                                        </div>  
                                                    <div style="display:none;" class="controls-row">
                                                        <div class="span2"><?php echo form_label($this->lang->line('gstSubmissionBuffer')); ?></div>
                                                        <div class="span10">
                                                            <?php
                                                            $data = array(
                                                                'name' => 'gstSubmissionBuffer',);
                                                            echo form_input($data, $umaster->gstSubmissionBuffer);
                                                            ?>
                                                        </div>
                                                    </div>    
                                                     <div class="controls-row">    
                                                        <div class="span2"><?php echo form_label($this->lang->line('taxablePeriod')); ?></div>
                                                        <div class="span4">
                                                              <?php
													$options = '';
                                                    $preseldept = $umaster->taxablePeriod;
                                                    $options[NULL] = $this->lang->line('select');
                                                    $options[1] = $this->lang->line('taxablePeriodMonthly');
                                                    $options[3] = $this->lang->line('taxablePeriodTrimonthly');
                                                    $options[6] = $this->lang->line('taxablePeriod6');
                                                    $options[12] = $this->lang->line('taxablePeriod12');
                                                    $js = 'id = "taxablePeriod" class="span12" onblur="isThisRegister()"';
                                                    echo form_dropdown('taxablePeriod', $options, $preseldept, $js);
                                                    ?>
                                                        </div>
                                                    </div> 
                                                </div>
                                            </div>

                                            <div class="head">
                                                <h2>Zakat & Wakaf</h2>
                                                <ul class="buttons">
                                                    <li><a href="#myzakat"  data-toggle="collapse" data-target="#myzakat">
                                                            <span class="i-arrow-down-3"></span></a></li>
                                                </ul>                                        
                                            </div><!-- head -->

                                            <div class="content">
                                                <div class="collapse in" id="myzakat">
                                                    <div class="controls-row">    
                                                        <div class="span2"><?php echo form_label($this->lang->line('muslimShareholder')); ?></div>
                                                        <div class="span4">
                                                            <div class="input-prepend span12">
                                                                
                                                                 <?php
                                                            $data = array(
                                                                'name' => 'muslimShareholder',
                                                                'class' => 'span10 tar');
                                                            echo form_input($data, $umaster->muslimShareholder);
                                                            ?>
                                                            <span class="add-on span2">%</span></div>
                                                        </div>
                                                           
                                                        </div>
                                                    
                                                    <div class="controls-row">    
                                                        <div class="span2"></div>
                                                        <div class="span4">
                                                           
                                                        </div>
                                                    </div> 
                                                    
                                                    </div> 
                                                </div>
                                            </div>
                                                <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');
if($umaster->companyNo!='demo'){
                                                            $data = array(
                                                                'name' => 'submit',
                                                                'class' => 'btn-form btn-success-form');
}else{
                                                            $data = array(
                                                                'name' => 'submit',
                                                                'class' => 'btn-form btn-success-form',
'disabled' =>'disabled',
'title' => 'You can not edit while in demo mode');
}
                                                            $js = '';
                                                            echo form_submit($data, 'Submit', $js);
                                                            ?>
                                                        </div>
                                                    </div>
                                                </div>                                    
                                            </div>
                                            </form>

                                        </div>

                                    </div>

                                </div>
                            </div>
                        </div>  


                    </div>
                </div>
            </div> 
        </div>
    </div>