3

タスクのタイム シートに作業時間数を入力する必要があります。これは、HH:MM 形式のみである必要があります。特定のタスクの時間を合計する必要があります。

24 時間増加する場合は、このタスクの総作業時間 = 25:45 時間または 39:50 時間のように、再度更新する必要があります。私は最初に jQuery timepicker を使用し、それを 12 時間に制限しましたが、時間単位と分単位で期間を追加および更新する方法がわかりません。

午前/午後は必要ありません。勤務時間と分数だけです。時間間隔 = 10 分。

また、ユーザーはタスクに :30 分、:35 分、:40 分の作業を追加できる必要があります。Zoho ポータルを見たことがあれば、タスクにログ時間を追加する方法をご存知でしょう。私も全く同じようにしたいです。

これが私が使用したものです-

<link rel="stylesheet"  href="<?php echo base_url(); ?>assets/css/jquery.timepicker.css" >
<script src="<?php echo base_url(); ?>assets/javascripts/jquery.timepicker.min.js" ></script>


<section class="form-row">
                        <section class="form-row-left">
                            <label class="required" for="time_spent"><?php echo $this->lang->line('time_spent_hh_mm');?></label></section>
                        <section class="form-row-right">
                            <input class="" id="time_spent" name="time_spent" type="text">
<?php echo form_error('time_spent', '<div class="error">', '</div>'); ?>
                        </section>

     
     <script>
    $(document).ready(function () {
        $('#time_spent').timepicker({
            defaultTime: 'value',
            minuteStep: 1,
            disableFocus: true,
            template: 'dropdown',
            controlType: 'select',
            timeFormat: "HH:mm",
            ampm: false
        });
    });

</script>

4

1 に答える 1

1

独自の計算を作成する方が簡単だとわかったので、このようなものを作成します。time_input の入力と、合計時間を表示するために使用する time_spent を追加することに注意してください。

<link rel="stylesheet"  href="<?php echo base_url('assets/css/jquery.timepicker.css'); ?>" >

<section class="form-row">
<section class="form-row-left">
    <label class="required" for="time_spent">
        <?php echo $this->lang->line('time_spent_hh_mm');?>
    </label>
</section>
<section class="form-row-right">
    <label>Input time</label>
    <input class="" id="time_input" name="time_input" type="text">
    <input type="button" id="add_time" name="add_time" value="Add">
    <label>Total Time</label>
    <input class="" id="time_spent" name="time_spent" type="text" readonly>
    <?php echo form_error('time_spent', '<div class="error">', '</div>'); ?>
</section>

<script src="<?php echo base_url('assets/js/jquery.timepicker.js'); ?>" ></script>
<script>
    $(document).ready(function () {
        $('#time_input').timepicker({
            defaultTime: 'value',
            minuteStep: 1,
            disableFocus: true,
            template: 'dropdown',
            controlType: 'select',
            timeFormat: "H:i",
            ampm: false
        });

        $(document).on('click',"#add_time",function(){
            var time_total = $("#time_spent").val();
            var time_input = $("#time_input").val();
            if(time_total == ""){ time_total = "00:00"; }
            if(time_input == ""){ time_input = "00:00"; }

            temp_total = time_total.split(":");

            total_h = parseInt(temp_total[0]);
            total_m = parseInt(temp_total[1]);
            total_in_m = parseInt((total_h * 60) + total_m);            

            temp_input = time_input.split(":");
            input_h = parseInt(temp_input[0]);
            input_m = parseInt(temp_input[1]);
            input_in_m = parseInt((input_h * 60) + input_m);

            new_time = parseInt(total_in_m + input_in_m);

            if(new_time < 60) {
                new_h = 0;   
                new_m = new_time;
                console.log(new_h +":"+ new_m)
            }else{
                new_h = parseInt(new_time / 60);
                new_m = new_time % 60;
                console.log(new_h +":"+ new_m)
            }

            /*http://stackoverflow.com/questions/2998784/how-to-output-integers-with-leading-zeros-in-javascript*/
            function pad(num, size) {
                var s = num+"";
                while (s.length < size) s = "0" + s;
                return s;
            }

            $("#time_spent").val(pad(new_h,2) +":"+ pad(new_m,2));
        });
    });

</script>

さらに、パラメーターを挿入できますbase_url('path/to/script/')

于 2015-09-25T08:21:27.190 に答える