https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/rabbithabit.com/public_html/application/views/admin/stocks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/rabbithabit.com/public_html/application/views/admin/stocks/view.php
<script>
    function btn_closemodal(){
        $("div.responseMinusAll").html("");
        $("div.responseAddAll").html("");
        $("input.inp_stock").val("");
        $("input.remark_add_stock").val("");
    }   
</script>
<div class="row">
    <div class="col-sm-12">
         <p><a href="<?= base_url('admin/products'); ?>"><i class="fa fa-arrow-left" aria-hidden="true"></i> Kembali ke Produk</a></p>
        <h3>Stok Produk : <?= ucfirst($product->title); ?></h3>
        <?= $this->session->flashdata('success'); ?> 
    </div>
</div> 

<div class="row">
    <div class="col-sm-12">

    <div class="table-responsive">    
    <table class="table table-striped">
    <thead>
        <tr>
            <th>Stok Sekarang</th>
        </tr>
    </thead>
    <tbody>
    	<?php if(count($product)) : ?> 
        	<tr>
                <td><?= ucfirst($product->title); ?></td>
                <td>
                    <table class="table table-striped">
                        <tr>
                            <th>Varian/Gudang</th>
                            <?php foreach ($warehouses as $warehouse) : ?>
                                <th><?= ucwords($warehouse->name); ?></th> 
                            <?php endforeach; ?>  
                            <th>Ubah Stok</th> 
                            <th>Mutasi</th>
                        </tr>  

                        <?php
                            //get product details for current product
                            $this->db->select('id, sku')->from('product_details')->where('product_id', $product->id_products)->order_by('id', 'ASC');
                            $product_details = $this->db->get()->result();
                        ?> 

                        <?php foreach ($product_details as $product_detail) : ?>
                            
                            <?php 
                            //get varian
                            $this->db->select('attribute_detail_id')->from('product_combination')->where('product_details_id', $product_detail->id);
                            $attributes = $this->db->get()->result();
                            
                            $attributes_name = '';
                            foreach($attributes as $attribute) {
                                //get atrribute detail name
                                $this->db->select('attribute_detail')->from('product_attributes_detail')->where('id', $attribute->attribute_detail_id);
                                $attribute_detail = $this->db->get()->row();

                                if(count($attribute_detail) > 0) {
                                    $attribute_detail_name = $attribute_detail->attribute_detail;
                                    $attributes_name = ucwords($attributes_name)  . ' ' . ucwords($attribute_detail_name);
                                } else {
                                    $attributes_name = ucwords($attributes_name);
                                } 
                            }
                            ?>  

                            <tr>
                                <td><?= $product_detail->sku; ?><br><?= $attributes_name; ?></td>
                                
                                <?php foreach ($warehouses as $warehouse) : ?>
                                    <?php
                                        //get current stock
                                        $this->db->select('stock')->from('stock')->where('id_product', $product->id_products)->where('id_product_detail', $product_detail->id)->where('warehouse_id', $warehouse->id);
                                        $current_stock = $this->db->get()->row();
                                    ?> 
                                    <td>
                                        <?php if(count($current_stock) == 0) : ?>
                                                <span id="stock-<?= $product_detail->id; ?>-<?= $warehouse->id; ?>">0</span> 
                                        <?php else : ?>
                                                <span id="stock-<?= $product_detail->id; ?>-<?= $warehouse->id; ?>"><?= $current_stock->stock; ?></span>
                                        <?php endif; ?> 
                                    </td>
                                <?php endforeach; ?>  
                                <td>
                                    <a href="#tambahStok<?= $product_detail->id; ?>" data-toggle="modal" class="btn btn-primary" title="Tambah Stok">+</a>
                                    <a href="#kurangStok<?= $product_detail->id; ?>" data-toggle="modal" class="btn btn-success" title="Kurangi Stok">-</a>

                                    <div class="modal fade" id="tambahStok<?= $product_detail->id; ?>" role="dialog" style="display: none;">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" onclick="btn_closemodal();" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                                                    <h4 class="modal-title">Tambah Stok</h4>
                                                    <p><?= ucfirst($product->title); ?><br>
                                                    <?= $product_detail->sku; ?>. <?= $attributes_name; ?></p>
                                                </div>
                                                <div class="modal-body">

                                                    <form id="addForm<?= $product_detail->id; ?>" method="post">

                                                    <input type="hidden" name="id_product" value="<?= $product->id_products; ?>">  
                                                    
                                                    <input type="hidden" name="id_product_detail" value="<?= $product_detail->id; ?>">    
                                                    <input type="hidden" name="<?=$this->security->get_csrf_token_name();?>" value="<?=$this->security->get_csrf_hash();?>">

                                                    <div class="row">
                                                        <div class="col-sm-3">
                                                            <label>Gudang</label>
                                                        </div>   
                                                        <div class="col-sm-2">
                                                            <label>Stok +</label>
                                                        </div> 
                                                        <div class="col-sm-7">
                                                            <label>Keterangan <i class="fa fa-info-circle" data-toggle="tooltip" title="Contoh: Beli dari PT ABC"></i></label>
                                                        </div>  
                                                    </div> 
                                                    
                                                    <?php foreach ($warehouses as $warehouse) : ?> 
                                                        <div class="row">
                                                            <div class="col-sm-3">
                                                                <?= ucwords($warehouse->name); ?>
                                                            </div>   
                                                            <div class="col-sm-2">
                                                                <input class="inp_stock form-control" type="number" name="stock[stock_amount][<?= $warehouse->id; ?>]" id="stock<?= $warehouse->id; ?>" value="">
                                                            </div>  
                                                            <div class="col-sm-7">
                                                                <input class="remark_add_stock form-control" type="text" name="stock[remark][<?= $warehouse->id; ?>]" id="remark<?= $warehouse->id; ?>">
                                                            </div>  
                                                        </div> 
                                                    <?php endforeach; ?>
                                                   
                                                   <div class="row">
                                                        <div class="col-sm-9 col-sm-offset-3">
                                                            <input id="tambah<?= $product_detail->id; ?>" class="form-control btn btn-success" type="submit" name="tambah" value="TAMBAH STOK">
                                                            <br>
                                                            <div style="color:green; font-weight: bold; padding-top: 10px;" class="responseAddAll" id="responseAdd<?= $product_detail->id; ?>"></div>
                                                        </div>    
                                                   </div> 

                                               </form>

                                                    <script>
                                                    $(document).ready(function() {
                                                        $("#addForm<?= $product_detail->id; ?>").submit(function(e){
                                                            if(confirm("Apakah Anda yakin mau menambah stok ?")) {
                                                                ajax_add_stock<?= $product_detail->id; ?>();
                                                            }    
                                                            e.preventDefault();       
                                                        });
                                                    });   

                                                    function ajax_add_stock<?= $product_detail->id; ?>() {
                                                        $.ajax({
                                                            'url'       : '<?= base_url(); ?>' + 'admin/stocks/ajax_add_stock',
                                                            'type'      : 'POST',
                                                            'data'      : $("#addForm<?= $product_detail->id; ?>").serialize(),  
                                                            'success'   : function(data) {
                                                                if (data) {
                                                                    /*---success----*/
                                                                    var ajax_data = JSON.parse(data);

                                                                     $('#responseAdd<?= $product_detail->id; ?>').html(ajax_data.message);
                                                                    
                                                                    var stock_data = ajax_data.stock_data;
                                                                    for (var i = 0; i < stock_data.length; i++) { 
                                                                         $('#stock-' +  ajax_data.id_product_detail + '-' + stock_data[i]['warehouse_id']).html(stock_data[i]['stock']);
                                                                    }
                                                                };
                                                            }
                                                        });
                                                    }
                                                    </script>    

                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" onclick="btn_closemodal();" data-dismiss="modal">Tutup</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>  

                                    <div class="modal fade" id="kurangStok<?= $product_detail->id; ?>" role="dialog" style="display: none;">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" onclick="btn_closemodal();" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                                                    <h4 class="modal-title">Kurangi Stok</h4>
                                                    <p>Produk: <?= ucfirst($product->title); ?><br>
                                                    <?= $product_detail->sku; ?>. <?= $attributes_name; ?></p>
                                                </div>
                                                <div class="modal-body">
                                                   
                                                     <form id="minusForm<?= $product_detail->id; ?>" method="post">

                                                    <input type="hidden" name="id_product" value="<?= $product->id_products; ?>">  
                                                    
                                                    <input type="hidden" name="id_product_detail" value="<?= $product_detail->id; ?>">    

                                                    <input type="hidden" name="<?=$this->security->get_csrf_token_name();?>" value="<?=$this->security->get_csrf_hash();?>">

                                                    <div class="row">
                                                        <div class="col-sm-3">
                                                            <label>Gudang</label>
                                                        </div>   
                                                        <div class="col-sm-2">
                                                            <label>Stok -</label>
                                                        </div>  
                                                        <div class="col-sm-7">
                                                            <label>Keterangan <i class="fa fa-info-circle" data-toggle="tooltip" title="Contoh: Produk sudah expired tidak dapat dijual"></i></label>
                                                        </div>  
                                                    </div> 
                                                    
                                                    <?php foreach ($warehouses as $warehouse) : ?> 
                                                        <div class="row">
                                                            <div class="col-sm-3">
                                                                <?= ucwords($warehouse->name); ?>
                                                            </div>   
                                                            <div class="col-sm-2">
                                                                <input class="inp_stock form-control" type="number" name="stock[stock_amount][<?= $warehouse->id; ?>]" id="stock<?= $warehouse->id; ?>" value="">
                                                            </div>  
                                                            <div class="col-sm-7">
                                                                 <input class="remark_add_stock form-control" type="text" name="stock[remark][<?= $warehouse->id; ?>]" id="remark<?= $warehouse->id; ?>">
                                                            </div>  
                                                        </div> 
                                                    <?php endforeach; ?>
                                                   
                                                   <div class="row">
                                                        <div class="col-sm-9 col-sm-offset-3">
                                                            <input id="minus<?= $product_detail->id; ?>" class="form-control btn btn-success" type="submit" name="minus" value="KURANGI STOK">
                                                            
                                                            <div style="color:green; font-weight: bold; padding-top: 10px;" class="responseMinusAll" id="responseMinus<?= $product_detail->id; ?>"></div>
                                                        </div>    
                                                   </div> 

                                               </form>

<script>
$(document).ready(function() {
    $("#minusForm<?= $product_detail->id; ?>").submit(function(e){
        if(confirm("Apakah Anda yakin mau mengurangi stok ?")) {
            ajax_minus_stock<?= $product_detail->id; ?>();
        }    
        e.preventDefault();       
    });
});   

function ajax_minus_stock<?= $product_detail->id; ?>() {
    $.ajax({
        'url'       : '<?= base_url(); ?>' + 'admin/stocks/ajax_minus_stock',
        'type'      : 'POST',
        'data'      : $("#minusForm<?= $product_detail->id; ?>").serialize(),  
        'success'   : function(data) {
            if (data) {
                /*---success----*/
                var ajax_data = JSON.parse(data);

                 $('#responseMinus<?= $product_detail->id; ?>').html(ajax_data.message);
                
                var stock_data = ajax_data.stock_data;
                var i;
                for (i = 0; i < stock_data.length; i++) { 
                     $('#stock-' +  ajax_data.id_product_detail + '-' + stock_data[i]['warehouse_id']).html(stock_data[i]['stock']);
                }
            };
        }
    });
}
</script>  

                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" onclick="btn_closemodal();" class="btn btn-default" data-dismiss="modal">Tutup</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>  
                                </td>    
                                <td>
                                    <a onclick="setval_mutasi(<?= $product_detail->id; ?>);" href="#lihatMutasi<?= $product_detail->id; ?>" data-toggle="modal" class="btn btn-primary">Lihat</a>

<div class="modal fade modal_lihatMutasi" id="lihatMutasi<?= $product_detail->id; ?>" role="dialog" style="display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" onclick="btn_closemodal();" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title">Mutasi Stok</h4>
                <p><?= ucfirst($product->title); ?><br>
                <?= $product_detail->sku; ?>. <?= $attributes_name; ?></p>
            </div>
            <div class="modal-body">
                <?php 

                $query_warehouse = $this->db->select('*')->from('warehouse')->order_by('priority','asc')->get();
                 ?>   
                 <?php foreach ($query_warehouse->result() as $key): ?>
                    <div>
                        <?= strtoupper($key->name); ?>    
                    </div>
                    <hr>
                    <table id="warehouse_id_<?= $key->id; ?>" class="tbl_warehouse_mutasi table table-striped">
                        <thead>
                            <tr>
                                <th>Tanggal & Jam</th>
                                <th>Mutasi</th>
                                <th>Keterangan</th>
                            </tr>
                        </thead>
                        <tbody> 
                        </tbody>
                    </table>
                    <br>
                 <?php endforeach ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="btn_closemodal();" data-dismiss="modal">Tutup</button>
            </div>
        </div>
    </div>
</div>  
                                </td>  
                            </tr> 
                        <?php endforeach; ?>
                    </table>    
                </td>
            </tr> 
        <?php else: ?>
        	<tr>
            <td colspan="3">Produk tidak ditemukan.</td>
            </tr>
        <?php endif; ?>
    </tbody> 
    </table>
    </div><!-- end class responsive-->

    </div><!-- end class="col-sm-12" -->
</div> <!-- end row -->  

<div class="row">
    <div class="col-sm-12">
        <?php if($use_pagination == 'yes') : ?>
             <div style="text-align:center;"><?= $this->pagination->create_links(); ?></div>
        <?php endif; ?> 
    </div><!-- end class="col-sm-12" -->
</div> <!-- end row --> 


<script>
    function setval_mutasi(id) {

        callAjax('admin/stocks/callajax_setval_mutasi',{
            id_product_detail : id,
            '<?= $this->security->get_csrf_token_name(); ?>' : '<?= $this->security->get_csrf_hash(); ?>'

        },function(rs){
            console.log(rs);
            var div_modal = $('div#lihatMutasi'+id)
                            .find('div.modal-body');

            var cek_tbrow = $('div#lihatMutasi'+id)
                            .find('div.modal-body')
                            .find("table.tbl_warehouse_mutasi");
  
            cek_tbrow.find('tbody').html("");  

            $.each(rs.data,function(idx,key){
                div_modal.find("table#warehouse_id_"+key.warehouse_id)
                .find("tbody")
                .append("<tr>"+
                    "<td>"+key.val.tanggal+"</td>"+
                    "<td>"+key.val.mutasi+"</td>"+
                    "<td>"+key.val.keterangan+"</td>"+
                "</tr>");
            });

             
            $.each(cek_tbrow,function(idx,key){
                if($(this).find('tbody tr').length == 0){
                    $(this).find('tbody').html("<tr>"+
                         "<td colspan='3' style='color:grey; text-align:left;'>Data Kosong...</td>"+ 
                    "</tr>");
                }
            });
        });
    }
</script>

https://t.me/RX1948 - 2025