<!-- For menu pop up form -->

<!--Author  Herpan / 04/08/2014 / Form Import Journal--> 
<div id="dlg_importjournal" class="easyui-dialog" style="width:430px;height:220px;padding:10px 20px" buttons="#dlg-buttons" data-options="modal:true" closed="true">
    <form method="post" enctype="multipart/form-data" id="fm_importjournal" novalidate class="fm_popup">
        <div class="fitem" id="source">
            <input type="radio" name="rdo_source" id="rdo_source" value="local" onclick="form_importjurnal();" checked="checked">Local
        </div>

        <div class="fitem" style="height:30px">
            <input type="radio" name="rdo_source" id="rdo_source" value="remote" onclick="form_importjurnal();">Remote
        
            <span style="margin-left:40px;display:none" id="servername">   Server Name
                <input name="txt_servername" type="text" id="txt_servername" size="20" />
            </span>
        </div>
	
        <div class="fitem">
            <fieldset style="border:1px solid #CCC; width:320px; height:40px">
                <legend>Database Location</legend>
                <input type="file" name="fil_databaselocation" id="fil_databaselocation">
                <input name="txt_databaselocation" type="text" id="txt_databaselocation" size="20" style="display:none"/>     		
            </fieldset>	
        </div>
    </form>

    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="save_data('');">OK</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dlg_importjournal');">Cancel</a>
    </div>
</div>

<!-- Author : Herpan // Last update : 23/7/2014 // Form Change Password -->
<div id="changepassword" class="easyui-dialog" style="width:370px;height:175px;padding:10px 20px" buttons="#dlg-buttons" data-options="modal:true" closed="true">
    <form method="post" enctype="multipart/form-data" id="fm_changepassword" novalidate class="fm_popup" action="<?php echo base_url()?>setup/change_password/update_password">  
        <?php foreach($password_info as $row):?>
            <input id="old_pwd" name="old_pwd" type="hidden" class="easyui-validatebox" value="<?php echo $row->EmployeePassword;?>">
        <?php endforeach;?>
        
        <table width="100%" cellpadding="2" cellspacing="0">
            <tr>
        	<td><b>Old password</b></td>
                <td>:</td>

                <td align="right"><input type="password" name="txt_oldpassword" id="txt_oldpassword" class="easyui-validatebox" required="required" /></td>
            </tr>

            <tr>
                <td><b>New password</b></td>
                <td>:</td>

                <td align="right"><input type="password" name="txt_newpassword" id="txt_newpassword" class="easyui-validatebox" required="required" data-options="validType:'minLength[4]'"/></td>
            </tr>

            <tr>
                <td><b>Confirm password</b></td>
                <td>:</td>

                <td align="right"><input type="password" name="txt_confirmation" id="txt_confirmation" class="easyui-validatebox" required="required" /></td>
            </tr>
        
        </table>
            
        <div id="dlg-buttons" style="border:none;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="update_password()">Ok</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="modal_close('changepassword')">Cancel</a>
        </div>
    </form>
</div>

<!-- Author : Herpan // Last update : 05/08/2014 // Desc : Dialog for new company -->
<div id="dlg_new_company" class="easyui-dialog" style="width:370px;height:140px;padding:10px 20px" buttons="#dlg-buttons" data-options="modal:true" closed="true">
    <div style="font-size:12px;">
        <p align="center">This will close all active windows, are you sure?</p>
    </div>  	

    <div id="dlg-buttons" style="border:none;">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="$('#dlg_new_company').dialog('close'); new_company();">Ok</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dlg_new_company');">Cancel</a>
    </div>
</div>

<!-- Author : Herpan // Last update : 06/08/2014 // Desc : Form Create Database -->
<div id="dlg_company_code" class="easyui-dialog" style="width:410px;height:200px;padding:10px 20px" buttons="#dlg-buttons" data-options="modal:true" closed="true">
    <form method="post" enctype="multipart/form-data" id="fm_companycode" novalidate class="fm_popup">		
        <fieldset style="border:1px solid #CCC; width:280px; height:40px">
            <legend>Company code</legend>
            <input name="txt_company_code" type="text" id="txt_company_code" size="50" class="easyui-validatebox"  data-options="required:true"/>					
        </fieldset>							
    </form>

    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="create_database();">OK</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dlg_create_database');">Cancel</a>
    </div>
</div>
<!-- ---------------------------------------------------------------------------------------------------------------------------- -->

<!-- Author : Ferry // Last update   : 01/06/2015, edit : Daswan // Form Periode End -->
<div id="dlg_periode_end" class="easyui-dialog" style="width:524px;height:378px;" buttons="#dlg-buttons" data-options="modal:true" closed="true">
    <form method="post" enctype="multipart/form-data" id="dlg_periode_end" novalidate class="fm_popup">
        <table width="100%" bgcolor="#CCCCFF">
            <tr>
        	<td width="70" style="padding-left:4px;"><b>Month</b></td>
                <td width="10"><b>:</b></td>

                <td width="150">
                    <select name="cbo_period_month" id="cbo_period_month" class="easyui-combobox" style="width:100px;height:22px">
                        <option value="01">January</option>
                        <option value="02">February</option>
                        <option value="03">March</option>
                        <option value="04">April</option>
                        <option value="05">May</option>
                        <option value="06">June</option>
                        <option value="07">July</option>
                        <option value="08">August</option>
                        <option value="09">September</option>
                        <option value="10">October</option>
                        <option value="11">November</option>
                        <option value="12">December</option>
                    </select>
                </td>

                <td width="500">&nbsp;</td>
                <td width="70"><b>Year</b></td>
                <td width="10"><b>:</b></td>

                <td width="100" style="padding-right:4px;">
                    <input name="nsp_period_year" id="nsp_period_year" class="easyui-numberspinner" style="width:100px;height:22px" data-options="min:2012,max:new Date().getFullYear()" value="<?php echo date("Y");?>">
                </td>
            </tr>
        </table>
        
        <div style="margin:5px 5px 5px;">Last Periode End : <span id="last_period_end"><b>None</b></span></div>
        
        <center>
            <table id="dtg_item" class="easyui-edatagrid" singleSelect="true" collapsible="true" style="width:500px;height:193px;margin:auto;" 
                url="<?=base_url() . 'custom/get_data/currency' ?>">
                <thead>
                    <tr>
                        <th field="CurrencyCode" width="100" data-options="halign:'center',align:'left'" hidden><strong>Currency Code</strong></th>
                        <th field="CurrencyName" width="346" data-options="halign:'center',align:'left'"><strong>Currency Name</strong></th>
                        <th field="CurrencyRate" width="150" data-options="halign:'center',align:'right'" editor="{type:'numberbox',options:{min:0,precision:2,decimalSeparator:',',required:true}}" formatter='formatRp'><strong>Exchange Rate</strong></th>
                    </tr>
                </thead>
            </table>
        </center>

        <table width="100%" cellpadding="3">
            <tr>
                <td>
                    <textarea name="txa_description" id="txa_description" rows="3" placeholder="Description..." style="width:494px;margin:auto;"></textarea>
                </td>
            </tr>
        </table>
        
<!--        <div id="periode_end_progress" class="easyui-progressbar" style="width:500px;margin:10px auto 10px;"></div> -->
    </form>
    
    <div id="dlg-buttons" style="border:none;">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="period_end();">&nbsp; OK &nbsp; &nbsp;</a>
         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="reverse_period_end();">&nbsp; Reverse &nbsp; &nbsp;</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dlg_periode_end');">Cancel</a>
    </div>
</div>
<!-- ---------------------------------------------------------------------------------------------------------------------------- -->

<div id="dlg_about" class="easyui-dialog" data-options="modal:true" closed="true">
   
 <div style="background:#F0F0F0; padding:3px 3px 3px;">
        <a href="javascript:void(0)" iconCls="icon-cancel" onClick="modal_close('dlg_about');">Close</a>
    </div>
    <div id="about-body">
    	<div id="body-apps">
           <img src="<?=base_url()?>assets/custom/img/logo_dev.png" height="422" alt="" border="0">
        </div>
    </div>
   
</div>

<script>
    $(document).ready(function(){
		$('.panel-tool-close').hide();
        $('#cbo_period_month').combobox('setValue', '<?= date('m') ?>');
        
        $("#dlg_periode_end").click(function() {
            $('#dtg_item').edatagrid('saveRow');
	});
    });
    
    function period_end(){

	    $('#dtg_item').edatagrid('saveRow');
        PeriodMonth     = $('#cbo_period_month').combobox('getValue');
        PeriodYear      = $('#nsp_period_year').val();
        Description     = $('#txa_description').val();

        $.messager.confirm('Confirmation :', 'Anda yakin, ingin melakukan Proses Period End untuk Period : "' + PeriodMonth + ' - ' + PeriodYear + '"',  
        function(r){
            if (r){
                var url     = base_url + 'list/period_end/process_period_end';
                var item    = $('#dtg_item').datagrid('getRows');
                Detail      = JSON.stringify(item);

                $.post(url, {PeriodMonth:PeriodMonth, PeriodYear:PeriodYear, Description:Description, Detail:Detail}, function(result){
                    if (result.status == true){
                        $.messager.alert('Success',result.message,'info',function(){
                            location.reload();						                    
                        });				
                    } 
                    else {
                        $.messager.alert('Error',result.message,'error',function(){
//                            location.reload();						                    
                        });				
                    }
                },'json');
            }
        });
    }

    function reverse_period_end(){
       $('#dtg_item').edatagrid('saveRow');
        PeriodMonth     = $('#cbo_period_month').combobox('getValue');
        PeriodYear      = $('#nsp_period_year').val();
        Description     = $('#txa_description').val();

        $.messager.confirm('Confirmation :', 'Anda yakin, akan melakukan Proses Reverse Period End untuk Period : "' + PeriodMonth + ' - ' + PeriodYear + '"',  
        function(r){
            if (r){
                var url     = base_url + 'list/period_end/reverse_period_end';
                var item    = $('#dtg_item').datagrid('getRows');
                Detail      = JSON.stringify(item);

                $.post(url, {PeriodMonth:PeriodMonth, PeriodYear:PeriodYear, Description:Description, Detail:Detail}, function(result){
                    if (result.status == true){
                        $.messager.alert('Success',result.message,'info',function(){
                            location.reload();                                          
                        });             
                    } 
                    else {
                        $.messager.alert('Error',result.message,'error',function(){
//                            location.reload();                                            
                        });             
                    }
                },'json');
            }
        }); 
    }
</script>    