<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');
            }
        });

    });

    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("#stateID").empty();
                    jQuery("#stateID").append(items.join('</br>'));
                } else {
                    $("#error").html('<p>' + content.message + '</p>');
                }
            }
        });
        return false;
    }
    
    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("");

        }
    }
    
    function verifyKey(){
        $.ajax({
            type: "POST",
            url: "<?php echo base_url() ?>license/verifyCompanyKey",
            data: { 
                activationKey: $("#activationKey").val(),
                companyNo : $("#id_companyNo").val()
            },
            success: function(content) {

                switch ($.trim(content)){
                    case "error 721: key not found":
                        $("#activationKey").val("");
                        alertbox("Key Invalide",2);
                        break;
                    case "exist":
                        $("#activationKey").val("");
                        alertbox("Key Already been used",2);
                    case "success":
                        break;
                    default:
                        $("#activationKey").val("");
                        alertbox("Key Not found or Invalide",2);
                        break;
                }
            }
        });
    }
    
</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() ."home" ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href='<?php echo base_url() ."setting/companysetup" ?>'><?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'));
                $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>
						<ul class="buttons">
							<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                        </ul>
                        </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(
                                    'id' => "id_companyNo",
                                    'name' => 'companyNo',
                                    'class' => 'span12 validate[required,minSize[2],maxSize[20]]',);
										echo form_input($data, set_value('companyNo'));
                                ?>
                                </div>
                                <div class="span4">
                                <?php
								$data = array(
                                    'placeholder' =>'Company Activation Key',
                                    'name' => 'activationKey',
                                    'onblur' =>'verifyKey()',
                                    'id' => 'activationKey',
                                    'class' => 'span12 validate[required]',);
										echo form_input($data, set_value('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',
									'class' => 'span12 validate[required,maxSize[128]]',);
										echo form_input($data, set_value('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"));
                                        ?>
                                    </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, set_value('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, set_value('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, set_value('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 validate[required,maxSize[64]]',);
										echo form_input($data, set_value('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[required,maxSize[16]]',);
										echo form_input($data, set_value('companyPostCode'));
                                 ?> 
								</div>
							</div>
                            <div class="controls-row"> <!-- row 1 -->
								<div class="span2"><?php echo $this->lang->line('country') ?></div>
								<div class="span4">
								<?php
								$preselcat = '458';
								$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 = '0';
								$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, set_value('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, set_value('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 validate[custom[email]]',
    								'name' => 'email',);
										echo form_input($data, set_value('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(
									'class' => 'span12 validate[custom[url]]',
                                    'name' => 'website',);
										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
								$preseldept = '1';
								$options ='';
								$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="span5">
                                <?php
                                $data = array(
									'name' => 'userfile',
                                    'id' => 'userfile',
                                    'type ' => 'file',
                                    'value' => '');
										echo form_upload($data, set_value('userfile'));
                                ?>                       
                                </div>
							</div>
						</div> <!--content np -->
					</div> <!--block -->
				</div> <!--span 12 -->
			</div> <!--row fluid -->
			
			<div class="row-fluid">	
				<div class="span 12">
					<div class="block">
						<div class="head">
							<h2><?php echo $this->lang->line('title2'); ?></h2>
							<ul class="buttons">
								<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                            </ul>                                        
                        </div><!-- head -->
						<div class="content np">
							<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',
									'placeholder' => $this->lang->line('example') . ':123456789012',
                                    'id'=>'gstRegisteredNo');
										echo form_input($data, set_value('gstRegisteredNo'),"onblur='isThisRegister()'");
                                ?>
                                </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' => 'span10 datepicker2 financhk',);
											echo form_input($data, '',"");
									?>
                                    <span class="add-on span2"><i class="i-calendar"></i></span></div>
                                </div>
							</div>      
							<div class="controls-row">
								<div class="span2"><?php echo form_label($this->lang->line('taxablePeriod')); ?></div>
                                <div class="span4">
                                <select disabled id="taxablePeriod" name="taxablePeriod" class="span12">
									<option value="0"><?php echo $this->lang->line('select'); ?></option>
                                    <option value ="1"><?php echo form_label($this->lang->line('taxablePeriodMonthly')); ?></option>
                                    <option value="3"><?php echo form_label($this->lang->line('taxablePeriodTrimonthly')); ?></option>
                                    <option value="6"><?php echo form_label($this->lang->line('taxablePeriod6')); ?></option>
									<option value="12"><?php echo form_label($this->lang->line('taxablePeriod12')); ?></option>
                                </select>
								</div>
                            </div>
                            <div class="controls-row">
								<div class="span2"><?php echo form_label($this->lang->line('masterMSIC')); ?></div>
                                <div class="span4">
                                <?php
                                $data = array(
									'class' => 'span12 validate[custom[integer]]',
                                    'name' => 'masterMSIC',
									'placeholder' => $this->lang->line('example') . ':12345',
                                    'id'=>'masterMSIC');
										echo form_input($data, set_value('masterMSIC'));
                                ?>
                                </div>
                            </div>
                            <div class="controls-row" style="display:none;" >
								<div class="span2"><?php echo form_label($this->lang->line('gstSubmissionBuffer')); ?></div>
                                <div class="span10">
                                <?php
								$data = array(
									'name' => 'gstSubmissionBuffer',);
										echo form_input($data, set_value('gstSubmissionBuffer'));
                                ?>
                                </div>   
                            </div>
						</div> <!--content np -->
					</div> <!--block -->
				</div> <!--span 12 -->
			</div> <!--row fluid -->
			
			<div class="row-fluid">	
				<div class="span 12">
					<div class="block">
						<div class="head">
							<h2>Zakat & Wakaf</h2>
                            <ul class="buttons">
								<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                            </ul>                                        
                        </div><!-- head -->
                        <div class="content np">
							<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 validate[custom[integer],Max[3]]');
											echo form_input($data, set_value('muslimShareholder'));
									?> 
                                    <span class="add-on span2">%</span>
                                    </div>
								</div>
							</div> 
                        </div><!--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' => 'submit',
										'class' => 'btn-form btn-success-form');
									$js = 'onclick="return confirm(\'Press OK to continue...\')"';
										echo form_submit($data, 'Submit', $js);
								?>
								</div>
							</div>
						</div><!--footer -->                                    
						</form>
					</div> <!--block -->
				</div> <!--span 12 -->
			</div> <!--row fluid -->
			
		</div>  <!--content class -->
	</div>  <!--wrap -->
</div> <!--content id -->


