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/kanvakanva.com/public_html/application/views/admin/products/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/kanvakanva.com/public_html/application/views/admin/products/index.php
<section>
	<h2>Product Listing</h2>
    <br>
    <div class="row">
        <div class="col-sm-4">
            <?= form_open('admin/products/search_product') ?>
                <div class="form-horizontal">
                <input class="form-control" type="text" placeholder="Enter Product Name" name="product"

                <?php if (isset($product_name)): ?>
                    value="<?= ucwords($product_name) ?>"
                <?php endif; ?>

                > <input style="width:180px;" class="btn btn-primary" type="submit" name="search_product" value="SEARCH BY PRODUCT">
                </div>
            <?= form_close() ?>
        </div>
        <div class="col-sm-4">
            <?= form_open('admin/products/search_category') ?>
                <div class="form-horizontal">
                    <select name="category" class="form-control">
                    <?php
                    //get parent category id and name and parent from categories table
                    $this->db
                      ->select('id_categories, category')
                      ->from('categories')
                      ->where('parent', null)
                      ->order_by('priority', 'ASC');
                    $categories = $this->db->get()->result();
                    ?>
                    <option value="">Select Category ...</option>
                    <?php foreach ($categories as $category): ?>
                        <option value="<?= $category->id_categories ?>"

                        <?php if (isset($category_id)): ?>
                            <?php if (
                              $category->id_categories == $category_id
                            ): ?>
                                selected
                            <?php endif; ?>
                        <?php endif; ?>

                        ><?= ucwords($category->category) ?></option>

                        <?php
                        //check if the current id does have child
                        $this->db
                          ->select('*')
                          ->from('categories')
                          ->where('parent', $category->id_categories);
                        $count_child_category = $this->db->get()->num_rows();
                        ?>

                        <?php if ($count_child_category > 0): ?>

                            <?php
                            //get all existing child categories
                            $this->db
                              ->select('id_categories, category')
                              ->from('categories')
                              ->where('parent', $category->id_categories)
                              ->order_by('priority', 'ASC');
                            $child_categories = $this->db->get()->result();
                            ?>

                            <?php foreach (
                              $child_categories
                              as $child_category
                            ): ?>
                                <option style="margin-left: 10px;"value="<?= $child_category->id_categories ?>"

                                <?php if (isset($category_id)): ?>
                                    <?php if (
                                      $child_category->id_categories ==
                                      $category_id
                                    ): ?>
                                        selected
                                    <?php endif; ?>
                                <?php endif; ?>

                                >- <?= ucwords(
                                  $child_category->category
                                ) ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    <?php endforeach; ?>
                    </select>
                    <input style="width:180px;" class="btn btn-primary" type="submit" name="search_category" value="SEARCH BY CATEGORY">
                </div>
            <?= form_close() ?>
        </div>
        <div class="col-sm-4">
        <?= form_open('admin/products/search_brand') ?>

            <div class="form-horizontal">
                <select name="brand" class="form-control">

                    <?php
                    //get brands id and name from brandsa table
                    $this->db
                      ->select('id_brands, brand')
                      ->from('brands')
                      ->order_by('brand', 'ASC');
                    $brands = $this->db->get()->result();
                    ?>

                    <option value="">Select Brand ...</option>

                    <?php foreach ($brands as $brand): ?>

                        <?php if ($brand->id_brands != 0): ?>

                            <option value="<?= $brand->id_brands ?>"

                            <?php if (isset($brand_id)): ?>

                                <?php if ($brand->id_brands == $brand_id): ?>
                                selected
                            <?php endif; ?>

                            <?php endif; ?>

                            ><?= ucwords($brand->brand) ?></option>

                        <?php endif; ?>

                    <?php endforeach; ?>

                </select>

                <input style="width:180px;" class="btn btn-primary" type="submit" name="search_brand" value="SEARCH BY BRAND">
            </div>
        <?= form_close() ?>
        </div>
    </div>
    <br>
    <p><a class="btn btn-success" target="_blank" href="<?= base_url(
      'XML_export_products'
    ) ?>">SYNC PRODUCTS TO FACEBOOK</a></p>
    <br>
    <p><?= anchor(
      'admin/products/add',
      '<i class="icon-plus"></i> ADD A NEW PRODUCT'
    ) ?></p>
    <br>

	<?= $this->session->flashdata('success')
//to display success message
?>
    <?= $this->session->flashdata('result')
//to display result message
?>

    <table class="table table-striped">
    <thead>
        <tr>
            <th>Product Name</th>
            <!-- <th>Brand</th> -->
            <th>Current Stock</th>
            <th>Price (Rp)</th>
            <th>Discounted Price (Rp)</th>
            <th>Display</th>
						<th>PreOrder</th>
            <th>Ordering</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
    	<?php if (count($products)): ?>
        <?php foreach ($products as $product): ?>
        	<tr>
            	<td><?= ucfirst($product->title) ?></td>

                <!-- <td>
                    <?php if ($product->brand_id != null) {
                      $this->db
                        ->select('brand')
                        ->from('brands')
                        ->where('id_brands', $product->brand_id);
                      $brand = $this->db->get()->row();
                      echo ucfirst($brand->brand);
                    } else {
                      echo '-';
                    } ?>
                </td>  -->
                <td>
                    <?php
                    //count option where stock is not zero
                    $this->db
                      ->select('id_stocks,size_id, stock')
                      ->from('stocks')
                      ->where('product_id', $product->id_products)
                      ->where('stock !=0');
                    $stocks = $this->db->get()->result();
                    ?>
                    <?php if (count($stocks) > 0): ?>
                            <?php foreach ($stocks as $stock): ?>
                                <?php
                                //get size name
                                $this->db
                                  ->select('product_size')
                                  ->from('product_size')
                                  ->where('id_product_size', $stock->size_id);
                                $size_name = str_replace(
                                  'Size :',
                                  '',
                                  $this->db->get()->row()->product_size
                                );
                                ?>

                                    <div style="width:200px;" id="p<?= $stock->id_stocks ?>" class="form-inline" >
                                        <label for="email">  <?= str_replace(
                                          ' ',
                                          '',
                                          strtolower($size_name)
                                        ) ?>:   </label> &nbsp;
                                        <button style="border:1px solid #dee2e6" title="Edit Jumlah" type="button" id="edit_button<?= $stock->id_stocks ?>" class="btn btn-xs"><?= $stock->stock ?></button>
                                    </div>

                                    <?= form_open(
                                      'admin/products/edit_stock/' .
                                        $stock->id_stocks,
                                      'class="form-inline"'
                                    ) ?>
                                    <div id="div<?= $stock->id_stocks ?>" hidden class="form-group">
                                        <label for="email"><?= str_replace(
                                          ' ',
                                          '',
                                          strtolower($size_name)
                                        ) ?>: </label> &nbsp;

                                        <input class="form-control col-sm-3" type="number" name="stock" value="<?= $stock->stock ?>" >



                                    <?= form_close() ?>
                                    <!-- <input id="edit_button<?= $stock->id_stocks ?>" type="submit"  /> -->

                                        <button type="button" id="cancel_button<?= $stock->id_stocks ?>" class="btn btn-xs"><i class="fa fa-remove "></i></button>
                                        <button type="submit" class="btn btn-xs"><i class="fa fa-check"></i></button>
                                    </div>
                                    <script type="text/javascript">
                                        document.getElementById('edit_button<?= $stock->id_stocks ?>').onclick = function() {
                                            document.getElementById('div<?= $stock->id_stocks ?>').removeAttribute('hidden');
                                            document.getElementById('p<?= $stock->id_stocks ?>').setAttribute("hidden", true);
                                            document.getElementById('edit_button<?= $stock->id_stocks ?>').setAttribute("hidden", true);
                                        };
                                        document.getElementById('cancel_button<?= $stock->id_stocks ?>').onclick = function() {
                                            document.getElementById('div<?= $stock->id_stocks ?>').setAttribute("hidden", true);
                                            document.getElementById('p<?= $stock->id_stocks ?>').removeAttribute('hidden');
                                            document.getElementById('edit_button<?= $stock->id_stocks ?>').removeAttribute('hidden');
                                        };
                                    </script>


                            <?php endforeach; ?>
                     <?php else: ?>
                        -
                     <?php endif; ?>

                </td>
            	<td><?= number_format($product->price) ?></td>
            	<td>
                <?php if ($product->discount_price == 0) {
                  echo '-';
                } else {
                  echo number_format($product->discount_price);
                } ?>
							</td>

              <td>
                <?php if ($product->product_status == 1) {
                echo '
                    <select id="status_'.$product->id_products.'" 
                      onchange="update_data(\'product_status\',\'status\','.$product->id_products.');return false;">
                      <option value="1" selected>Yes</option>
                      <option value="0">No</option>
                    </select>';
                } else {
                  echo '
                    <select id="status_'.$product->id_products.'" 
                      onchange="update_data(\'product_status\',\'status\','.$product->id_products.');return false;">
                      <option value="1">Yes</option>
                      <option value="0" selected>No</option>
                    </select>';
                } 
                ?>
              </td>
							<td>
                <?php if ($product->preorder == 1) {
                  echo '
                    <select id="po_'.$product->id_products.'" 
                      onchange="update_data(\'preorder\',\'po\','.$product->id_products.');return false;">
                      <option value="1" selected>Yes</option>
                      <option value="0">No</option>
                    </select>';
                } else {
                  echo '
                    <select id="po_'.$product->id_products.'" 
                      onchange="update_data(\'preorder\',\'po\','.$product->id_products.');return false;">
                      <option value="1">Yes</option>
                      <option value="0" selected>No</option>
                    </select>';
                } 
                ?>
              </td>
              <td>
                <input type="text" id="priority_<?= $product->id_products ?>" value="<?= $product->priority ?>"
                 onkeyup="update_data('priority','priority','<?=$product->id_products?>');return false;"
                 style="width:60px">
                
              </td>
              <td><?= bt_edit(
                  'admin/products/edit/' . $product->id_products
                ) ?></td>
              <td><?= bt_delete(
                  'admin/products/delete/' . $product->id_products
                ) ?>
							</td>

            </tr>
        <?php endforeach; ?>
        <?php else: ?>
        	<tr>
            <td colspan="3">We could not find any product.</td>
            </tr>
        <?php endif; ?>

    </tbody>
    </table>
    <?php if (isset($pagination)) {
      //create pagination...
      echo '<p style="text-align:center;">' .
        $this->pagination->create_links() .
        '</p>';
    } ?>
</section>

<style type="text/css">
    input[readonly]{
      background-color:blue;
      border: 0;
      font-size: 1em;
      box-shadow: none;
    }
</style>

<script>
  function update_data(kolom,id,id_products){
    var value = $('#'+id+"_"+id_products).val();

    $.ajax({
        type : "POST",
        data : ({id_products,kolom,value}),
        url : "<?=base_url('admin/products/update_data');?>",
        success : function(data){
            
        },
        error: function (jqXHR, exception) {
          var msg = '';
            if (jqXHR.status === 0) {
                msg = 'Koneksi Terputus.\n Periksa Koneksi Internet Anda.';
            } else if (jqXHR.status == 404) {
                msg = 'Halaman Tidak Ditemukan';
            } else if (jqXHR.status == 500) {
                msg = 'Terjadi Kesalahan';
            } else if (exception === 'parsererror') {
                msg = 'Requested JSON parse failed.';
            } else if (exception === 'timeout') {
                msg = 'Time out error.';
            } else if (exception === 'abort') {
                msg = 'Ajax request aborted.';
            } else {
                msg = 'Uncaught Error.\n' + jqXHR.responseText;
            }
            alert(msg);
        }
    })
  }
</script>

https://t.me/RX1948 - 2025