<?php

$accessControl = array("Admin" => true);
require_once '../../AccessControl.php';
?>                        
                        <div>
                            
                            <div class="callout-success-template callout callout-success" style="display:none;">                              
                                <h4></h4>                               
                            </div>

                            <div class="callout-danger-template callout callout-danger" style="display:none;">                              
                                <h4></h4>                               
                            </div>

                        </div>


                        <div class="box box-solid box-primary" id="global_lang">
                            <div class="box-header">
                                <h3 class="box-title"><?php echo _CHANGE_DEFAULT_FORMAT; ?></h3>
                                
                            </div><!-- /.box-header -->

                            <div class="box-body table-responsive">

                                <p><!-- Use the form below to set a default date format. This format will be used in all reporting.                                                                
                                Users can override this date format in the edit profile section.  --></p>

                                <div id="change_custom_format" title="<?php echo _CHANGE_DEFAULT_FORMAT; ?>">
                                    
                                    <form id="DateFormatForm">                                                                  
                                    <?php   
                                        $timeformat = json_decode(getGlobalSetting("profileDateFormat",$dateFormat), true);
                                        
                                        if(empty($timeformat)) {
                                           $timeformat = array(
                                                "format1" => "d",
                                                "seperator1" => " ",
                                                "format2" => "M",
                                                "seperator2" => " ",
                                                "format3" => "Y",
                                                "seperator3" => " ",
                                                "format4" => ""             
                                            );
                                        }
                                        ?>     
                                        <div class="form-group col-sm-2">
                                        <select class="form-control format1 " name="format1">
                                            <option value="d" <?php if($timeformat["format1"] == "d"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (31)</option>
                                            <option value="D" <?php if($timeformat["format1"] == "D"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (Mon)</option>
                                            <option value="m" <?php if($timeformat["format1"] == "m"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (12)</option>
                                            <option value="M" <?php if($timeformat["format1"] == "M"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (Dec)</option>
                                            <option value="Y" <?php if($timeformat["format1"] == "Y"){ echo 'selected="selected"'; } ?>><?php echo _YEAR; ?></option>
                                            <option value="" <?php if($timeformat["format1"] == ""){ echo 'selected="selected"'; } ?>><?php echo _NONE; ?></option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-1">
                                        <select class="form-control seperator1 " name="seperator1">
                                            <option value=" " <?php if($timeformat["seperator1"] == " "){ echo 'selected="selected"'; } ?>> </option>
                                            <option value="-" <?php if($timeformat["seperator1"] == "-"){ echo 'selected="selected"'; } ?>>-</option>
                                            <option value="/" <?php if($timeformat["seperator1"] == "/"){ echo 'selected="selected"'; } ?>>/</option>
                                            <option value="," <?php if($timeformat["seperator1"] == ","){ echo 'selected="selected"'; } ?>>, </option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-2">
                                        <select class="form-control format2 " name="format2">
                                            <option value="d" <?php if($timeformat["format2"] == "d"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (31)</option>
                                            <option value="D" <?php if($timeformat["format2"] == "D"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (Mon)</option>
                                            <option value="m" <?php if($timeformat["format2"] == "m"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (12)</option>
                                            <option value="M" <?php if($timeformat["format2"] == "M"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (Dec)</option>
                                            <option value="Y" <?php if($timeformat["format2"] == "Y"){ echo 'selected="selected"'; } ?>><?php echo _YEAR; ?></option>
                                            <option value="" <?php if($timeformat["format2"] == ""){ echo 'selected="selected"'; } ?>><?php echo _NONE; ?></option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-1">
                                        <select class="form-control seperator2 " name="seperator2">
                                            <option value=" " <?php if($timeformat["seperator2"] == " "){ echo 'selected="selected"'; } ?>> </option>
                                            <option value="-" <?php if($timeformat["seperator2"] == "-"){ echo 'selected="selected"'; } ?>>-</option>
                                            <option value="/" <?php if($timeformat["seperator2"] == "/"){ echo 'selected="selected"'; } ?>>/</option>
                                            <option value="," <?php if($timeformat["seperator2"] == ","){ echo 'selected="selected"'; } ?>>, </option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-2">
                                        <select class="form-control format3 " name="format3">
                                            <option value="d" <?php if($timeformat["format3"] == "d"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (31)</option>
                                            <option value="D" <?php if($timeformat["format3"] == "D"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (Mon)</option>
                                            <option value="m" <?php if($timeformat["format3"] == "m"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (12)</option>
                                            <option value="M" <?php if($timeformat["format3"] == "M"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (Dec)</option>
                                            <option value="Y" <?php if($timeformat["format3"] == "Y"){ echo 'selected="selected"'; } ?>><?php echo _YEAR; ?></option>
                                            <option value="" <?php if($timeformat["format3"] == ""){ echo 'selected="selected"'; } ?>><?php echo _NONE; ?></option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-1">
                                        <select class="form-control seperator3 " name="seperator3">
                                            <option value=" " <?php if($timeformat["seperator3"] == " "){ echo 'selected="selected"'; } ?>> </option>
                                            <option value="-" <?php if($timeformat["seperator3"] == "-"){ echo 'selected="selected"'; } ?>>-</option>
                                            <option value="/" <?php if($timeformat["seperator3"] == "/"){ echo 'selected="selected"'; } ?>>/</option>
                                            <option value="," <?php if($timeformat["seperator3"] == ","){ echo 'selected="selected"'; } ?>>, </option>
                                        </select>
                                        </div>
                                        <div class="form-group col-sm-2">
                                        <select class="form-control format4 " name="format4">
                                            <option value="d" <?php if($timeformat["format4"] == "d"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (31)</option>
                                            <option value="D" <?php if($timeformat["format4"] == "D"){ echo 'selected="selected"'; } ?>><?php echo _DAY; ?> (Mon)</option>
                                            <option value="m" <?php if($timeformat["format4"] == "m"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (12)</option>
                                            <option value="M" <?php if($timeformat["format4"] == "M"){ echo 'selected="selected"'; } ?>><?php echo _MONTH; ?> (Dec)</option>
                                            <option value="Y" <?php if($timeformat["format4"] == "Y"){ echo 'selected="selected"'; } ?>><?php echo _YEAR; ?></option>
                                            <option value="" <?php if($timeformat["format4"] == ""){ echo 'selected="selected"'; } ?>><?php echo _NONE; ?></option>
                                        </select>
                                        </div>
                                        <br/>
                                        <div class="datepreview" style="clear:both"></div> 

                                    </form>
                                </div>
                                
                                <div class="formatform-buttons">
                                    <button class="btn btn-primary sumbitDefaultFormat"><?php echo _SAVE; ?></button>
                                    <button class="btn btn-warning restore-default-date-format-settings"><?php echo _RESTORE_TO_DEFAULT_FORMAT; ?></button>
                                </div>

                                &nbsp;<br />

                                <div class="alert alert-info"><i class="fa fa-info"></i><?php echo _CHANGE_DEFAULT_FORMAT_INFO; ?></div>

                            </div><!-- /.box-body -->
                            
                        </div><!-- /.box -->   