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/blue-sky.co.id/public_html/application/views/admin/categories/ |
Upload File : |
<div class="row"> <div class="col-sm-6"> <p><a href="<?= base_url('admin/dashboard'); ?>"><i class="fa fa-arrow-left" aria-hidden="true"></i> Kembali ke beranda</a></p> <h2>Kategori Ide Produk</h2> <?= $this->session->flashdata('success'); ?> </div> </div> <div class="row"> <div class="col-sm-12"> <p><?= anchor('admin/categories/edit', '<i class="fa fa-plus" aria-hidden="true"></i> Buat Kategori Baru', array('class' => 'btn btn-primary')); ?></p> </div> </div> <div class="row"> <div class="col-sm-12"> <div class="table-responsive"> <?= form_open(base_url('admin/categories/delete_all'),array('id'=>'frm_delete_all')); ?> <table class="table table-striped"> <thead> <tr> <th style="text-align: center;"> <button type="submit" id="delall_slc_checkbox" style="background: transparent;border: none;font-size: 23px;cursor: pointer;"> <i class="fa fa fa-trash-o"></i> </button> <input id="slcall_checkbox" type="checkbox"> </th> <th>Nama Kategori (id)</th> <th>Nama Kategori (en)</th> <th> Urutan <button style="font-weight: bold;" onclick="refreshDisplayPriority();" class="btn btn-sm btn-success" type="button">Ubah</button> </th> <th>Aktif?</th> <th>Edit</th> <th>Hapus</th> </tr> </thead> <tbody> <?php if(count($parent_categories)) : ?> <?php foreach($parent_categories as $category): ?> <tr> <td style="text-align: center;"> <input class="checkbox_for_del" name="checkbox_for_del[]" value="<?= $category->id_categories; ?>" type="checkbox"> </td> <td><?= ucfirst($category->category); ?></td> <td><?= ucfirst($category->category_en); ?></td> <td> <input data-id="<?= $category->id_categories; ?>" class="inp_change_priority" type="text" style="border: 0;outline: 0;background: transparent;border-bottom: 1px solid gray; text-align: center; width: 40px;" value="<?= $category->priority; ?>"> </td> <td> <?php if ($category->status == 1) { ?> <button onclick="exchangeStatusAct('tidak',<?= $category->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; background: silver;">Ya</span> <span style="padding: 5px; border-radius: 5px; ">Tidak</span> </button> <?php } else { ?> <button onclick="exchangeStatusAct('ya',<?= $category->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; ">Ya</span> <span style="padding: 5px; border-radius: 5px; background: silver;">Tidak</span> </button> <?php } ?> </td> <td><?= bt_edit('admin/categories/edit/' . $category->id_categories); ?></td> <td><?= bt_delete('admin/categories/delete/' . $category->id_categories); ?></td> </tr> <?php //GET CATEGORY LEVEL 2 $this->db->select('id_categories, category, category_en, parent, priority, status')->from('categories')->where('parent', $category->id_categories)->order_by('priority', 'ASC'); $categories_level2 = $this->db->get()->result(); ?> <?php foreach($categories_level2 as $category2): ?> <tr> <td style="text-align: center;"> <input class="checkbox_for_del" name="checkbox_for_del[]" value="<?= $category2->id_categories; ?>" type="checkbox"> </td> <td>- <?= ucfirst($category2->category); ?></td> <td>- <?= ucfirst($category2->category_en); ?></td> <td><?php //get category name from category table $this->db->select('category, category_en')->from('categories')->where('id_categories', $category2->parent); $category_name = $this->db->get()->row(); echo ucfirst($category_name->category); ?> </td> <td> <input data-id="<?= $category2->id_categories; ?>" class="inp_change_priority" type="text" style="border: 0;outline: 0;background: transparent;border-bottom: 1px solid gray; text-align: center; width: 40px;" value="<?= $category2->priority; ?>"> </td> <td> <?php if ($category2->status == 1) { ?> <button onclick="exchangeStatusAct('tidak',<?= $category2->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; background: silver;">Ya</span> <span style="padding: 5px; border-radius: 5px; ">Tidak</span> </button> <?php } else { ?> <button onclick="exchangeStatusAct('ya',<?= $category2->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; ">Ya</span> <span style="padding: 5px; border-radius: 5px; background: silver;">Tidak</span> </button> <?php } ?> </td> <td><?= bt_edit('admin/categories/edit/' . $category2->id_categories); ?></td> <td><?= bt_delete('admin/categories/delete/' . $category2->id_categories); ?></td> </tr> <?php //GET CATEGORY LEVEL 3 $this->db->select('id_categories, category, category_en, parent, priority, status')->from('categories')->where('parent', $category2->id_categories)->order_by('priority', 'ASC'); $categories_level3 = $this->db->get()->result(); ?> <?php foreach($categories_level3 as $category3): ?> <tr> <td style="text-align: center;"> <input class="checkbox_for_del" name="checkbox_for_del[]" value="<?= $category3->id_categories; ?>" type="checkbox"> </td> <td>-- <?= ucfirst($category3->category); ?></td> <td>-- <?= ucfirst($category3->category_en); ?></td> <td><?php //get category name from category table $this->db->select('category, category_en')->from('categories')->where('id_categories', $category3->parent); $category_name = $this->db->get()->row(); echo ucfirst($category_name->category); ?> </td> <td> <input data-id="<?= $category3->id_categories; ?>" class="inp_change_priority" type="text" style="border: 0;outline: 0;background: transparent;border-bottom: 1px solid gray; text-align: center; width: 40px;" value="<?= $category3->priority; ?>"> </td> <td> <?php if ($category3->status == 1) { ?> <button onclick="exchangeStatusAct('tidak',<?= $category3->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; background: silver;">Ya</span> <span style="padding: 5px; border-radius: 5px; ">Tidak</span> </button> <?php } else { ?> <button onclick="exchangeStatusAct('ya',<?= $category3->id_categories; ?>);" type="button" style="border:none; background: transparent;"> <span style="padding: 5px; border-radius: 5px; ">Ya</span> <span style="padding: 5px; border-radius: 5px; background: silver;">Tidak</span> </button> <?php } ?> </td> <td><?= bt_edit('admin/categories/edit/' . $category3->id_categories); ?></td> <td><?= bt_delete('admin/categories/delete/' . $category3->id_categories); ?></td> </tr> <?php endforeach; ?> <?php endforeach; ?> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="3"> Kategori Produk tidak ditemukan. </td> </tr> <?php endif; ?> </tbody> </table> <?= form_close(); ?> </div> </div> </div> <div class="row"> <div class="col-sm-12"> <?= '<div style="text-align:center;">' . $this->pagination->create_links() . '</div>'; ?> </div> </div> <script> jQuery(document).ready(function($){ $("form#frm_delete_all").submit(function(ev){ ev.preventDefault(); var csrfHash = '<?= $this->security->get_csrf_hash(); ?>'; if(confirm('Are you sure?')==true){ var input_check = $( "input[type='checkbox'].checkbox_for_del:checked" ); var checkbox_del = [[]]; $.each(input_check,function(idx,key){ checkbox_del[idx]=$(this).val(); }); $.ajax({ 'url' : "<?= base_url('admin/categories/delete_all'); ?>", 'type' : 'POST', 'dataType' :'json', 'data' : { 'checkbox_del' : checkbox_del, 'csrftestname' : csrfHash }, 'success' : function(res) { // console.log(res); if (res.result == 'sukses') { window.location.href="<?= base_url('admin/categories'); ?>"; } } }); } }); $("input#slcall_checkbox").click(function(){ var input_check = $( "input[type='checkbox'].checkbox_for_del" ); if($(this).is(':checked')){ input_check.prop('checked',false); input_check.prop('checked',true); }else{ input_check.prop('checked',false); } }); }); function exchangeStatusAct(earlyStat,this_id){ var toStat = ''; var csrfHash = '<?= $this->security->get_csrf_hash(); ?>'; if (earlyStat == 'ya') { toStat = 'Ya'; }else{ toStat = 'Tidak'; } $.ajax({ 'url' : "<?= base_url('admin/categories/changeStatusAct'); ?>", 'type' : 'POST', 'dataType' :'json', 'data' : { 'this_id' : this_id, 'toStat' : toStat, 'csrftestname' : csrfHash }, 'success' : function(res) { if (res.res == 'sukses') { // alert('Successfully'); location.reload(); } } }); } function refreshDisplayPriority(){ if (confirm("Are you sure?")==true) { var inp_change_priority = jQuery("input.inp_change_priority"); var csrfHash = '<?= $this->security->get_csrf_hash(); ?>'; var data = [[]]; jQuery.each(inp_change_priority,function(idx,key){ data[idx] = { id : jQuery(this).data('id'), val : jQuery(this).val(), }; }); $.ajax({ 'url' : "<?= base_url('admin/categories/refreshDisplayPriority'); ?>", 'type' : 'POST', 'dataType' :'json', 'data' : { 'this_data' : data, 'csrftestname' : csrfHash }, 'success' : function(res) { if (res.res == 'sukses') { // console.log(res.data); // alert('Successfully'); location.reload(); } } }); } } </script>