Advertisement
fadlyshafa

Untitled

Mar 19th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 19.30 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. $p = array('1', '21', '22', '31', '32','61','62');
  4. if (!(in_array($this->session->userdata('type'), $p))) {
  5.   redirect('auth/dashboard');
  6. }
  7. $this->load->view('layout/header');
  8. ?>
  9. <!-- Content Wrapper. Contains page content -->
  10. <div class="content-wrapper">
  11.   <!-- Content Header (Page header) -->
  12.   <section class="content-header">
  13.     <h5>
  14.       <ol class="breadcrumb">
  15.         <li><a href="<?php echo base_url('auth/dashboard'); ?>"><i class="fa fa-dashboard"></i> <?php echo $this->lang->line('header_dashboard'); ?></a></li>
  16.         <li><a href="<?php echo base_url('product'); ?>"><?php echo $this->lang->line('header_product'); ?></a></li>
  17.         <li class="active"><?php echo $this->lang->line('product_add_product'); ?></li>
  18.       </ol>
  19.     </h5>
  20.   </section>
  21.   <!-- Main content -->
  22.   <section class="content">
  23.     <div class="row">
  24.       <!-- right column -->
  25.       <div class="col-md-12">
  26.         <div class="box">
  27.           <div class="box-header with-border">
  28.             <div class="row">
  29.               <div class="col-md-4">
  30.                 <p>
  31.                 <h3 class="box-title"><?php echo $this->lang->line('product_add_new_product'); ?></h3>
  32.               <!-- </div> -->
  33.  
  34.               <!-- <div class="col-md-3"> -->
  35.               <form role="form" id="form" method="post" action="<?php echo base_url('product/addProduct'); ?>" encType="multipart/form-data">
  36.                
  37.                 <div class="form-group">
  38.                     <label for="kategori">Product Type : </label>
  39.                     <select class="form-control select2" id="product_type" name="product_type" style="width: 100%;">
  40.                       <option value="" selected="" disabled="">Product Type Select</option>
  41.                       <option value="1">Raw Material</option>
  42.                       <option value="2">Finish Good</option>
  43.                     </select>
  44.                   </div>
  45.                   </p>
  46.               </div>
  47.             </div>
  48.  
  49.            
  50.  
  51.           </div>
  52.           <!-- /.box-header -->
  53.           <div class="detail-product">
  54.             <div class="box-body">
  55.             <div class="row">
  56.  
  57.                  <div class="col-md-4">
  58.                   <div class="form-group">
  59.                     <label for="max_qty">Code : </label>
  60.                     <input type="text" class="form-control" id="codep" name="codep" value="<?php echo set_value('max_qty'); ?>">
  61.                   </div>
  62.                 </div>
  63.                 <div class="col-md-4">
  64.                   <div class="form-group">
  65.                     <label for="kategori">Category : </label>
  66.                     <select class="form-control select2" id="category" name="category" style="width: 100%;">
  67.                       <option value="">Category Select</option>
  68.                       <?php
  69.                      foreach ($category as $value) {
  70.                        echo "<option value='$value->category_id'" . set_select('category', $value->category_code) . ">$value->category_name</option>";
  71.                       }
  72.                       ?>
  73.                     </select>
  74.                   </div>
  75.                 </div>
  76.                 <div class="col-md-4">
  77.                   <div class="form-group">
  78.                     <label for="kategori">Sub Category : </label>
  79.                     <select class="form-control select2" id="sub_category" name="sub_category" style="width: 100%;">
  80.                       <option value="">Sub Category Select</option>
  81.                     </select>
  82.                   </div>
  83.                 </div>
  84.                 <div class="col-md-4">
  85.                   <div class="form-group">
  86.                     <label for="kategori">Sub Category1 : </label>
  87.                     <select class="form-control select2" id="sub_category1" name="sub_category1" style="width: 100%;">
  88.                       <option value="">Sub Category1 Select</option>
  89.                     </select>
  90.                   </div>
  91.                 </div>
  92.                
  93.                 <div class="col-md-4">
  94.                   <div class="form-group">
  95.                     <label for="code">Product Number : <span class="validation-color">*</span></label>
  96.                     <input type="text" class="form-control" id="code" name="code" value="<?php echo set_value('code', $code); ?>" readonly>
  97.                     <input type="hidden" class="form-control" id="pnumber" name="pnumber" value="<?php echo sprintf("%04s", $pnumber); ?>" readonly>
  98.                     <span class="validation-color" id="err_code"><?php echo form_error('part_number'); ?></span>
  99.                   </div>
  100.                 </div>
  101.                 <div class="col-md-4">
  102.                   <div class="form-group">
  103.                     <label for="name">Item Name : <span class="validation-color">*</span></label>
  104.                     <input type="text" class="form-control" id="name" name="name" value="<?php echo set_value('name'); ?>">
  105.                     <span class="validation-color" id="err_name"><?php echo form_error('name'); ?></span>
  106.                   </div>
  107.                 </div>
  108.                 <div class="col-md-4">
  109.                   <div class="form-group">
  110.                     <label for="name">Item Name By suppliers : </label>
  111.                     <input type="text" class="form-control" id="item_namebyp" name="item_namebyp" value="<?php echo set_value('item_namebyp'); ?>">
  112.                   </div>
  113.                 </div>
  114.                 <div class="col-md-4">
  115.                   <div class="form-group">
  116.                     <label for="size">Supplier/Vendor : <span class="validation-color">*</span></label>
  117.                     <select class="form-control select2" id="principal" name="principal" style="width: 100%;">
  118.                       <option value=""><?php echo $this->lang->line('product_select').' Supplier'; ?>
  119.                       </option>
  120.                       <?php
  121.                      foreach ($supplier as $row) {
  122.                        echo "<option value='$row->supplier_id'" . set_select('supplier', $row->supplier_id) . ">$row->supplier_name</option>";
  123.                       }
  124.                       ?>
  125.                     </select>
  126.                     <span class="validation-color" id="err_principal"><?php echo form_error('principal'); ?></span>
  127.                   </div>
  128.                 </div>
  129.                 <div class="col-md-4">
  130.                   <div class="form-group">
  131.                     <label for="subcategory">Brand : </label>
  132.                     <select class="form-control select2" id="brand" name="brand" style="width: 100%;">
  133.                       <option value=""><?php echo $this->lang->line('product_select').' Brand'; ?>
  134.                       </option>
  135.                       <?php
  136.                      foreach ($brand as $value) {
  137.                        echo "<option value='$value->id'" . set_select('brand', $value->id) . ">$value->brand_name</option>";
  138.                       }
  139.                       ?>
  140.                     </select>
  141.                   </div>
  142.  
  143.                  
  144.                 </div>
  145.                 <div class="col-md-4">
  146.                   <div class="form-group">
  147.                     <label for="size">Country Origin : </label>
  148.                     <select class="form-control select2" id="origin" name="origin" style="width: 100%;">
  149.                       <option value="">Select Country</option>
  150.                       <?php
  151.                      foreach ($country as $value) {
  152.                        echo "<option value='$value->id'" . set_select('country', $value->id) . ">$value->name</option>";
  153.                       }
  154.                       ?>
  155.                     </select>
  156.                   </div>
  157.                 </div>
  158.                    <!-- <div class="form-group">
  159.                    <label for="date">Expired Date : </label>
  160.                    <input type="date" class="form-control" id="expired" name="expired" value="<?php echo set_value('expired_date'); ?>">
  161.                  </div> -->
  162.                   <div class="col-md-4">
  163.                     <div class="form-group">
  164.                       <label for="size">Purchase Unit : </label>
  165.                       <select class="form-control select2" id="principal" name="unit" style="width: 100%;">
  166.                         <option value=""><?php echo $this->lang->line('product_select').' Unit'; ?>
  167.                           <?php
  168.                          foreach ($unit as $row) {
  169.                            echo "<option value='$row->unit'" . set_select('unit', $row->id) . ">$row->unit</option>";
  170.                           }
  171.                           ?>
  172.                         </select>
  173.                     </div>
  174.                   </div>
  175.                   <div class="col-md-4">
  176.                     <div class="form-group">
  177.                       <label for="name">Selling Unit : </label>
  178.                       <select class="form-control select2" id="principal" name="sku" style="width: 100%;">
  179.                         <option value=""><?php echo $this->lang->line('product_select').' Unit'; ?>
  180.                           <?php
  181.                          foreach ($unit as $row) {
  182.                            echo "<option value='$row->unit'" . set_select('unit', $row->id) . ">$row->unit</option>";
  183.                           }
  184.                           ?>
  185.                         </select>
  186.                     </div>
  187.                   </div>
  188.                
  189.                
  190.                
  191.                
  192.                   <!-- <div class="form-group">
  193.                    <label for="tax">Tax : </label>
  194.                    <input type="text" class="form-control" id="tax" name="tax" value="<?php echo set_value('tax'); ?>">
  195.                  </div>
  196.  
  197.                  <div class="form-group">
  198.                    <label for="sales_tax">Sales Tax : </label>
  199.                    <input type="text" class="form-control" id="sales_tax" name="sales_tax" value="<?php echo set_value('sales_tax'); ?>">
  200.                  </div> -->
  201.                 <div class="col-md-6" style="margin-left: 25%;">
  202.                   <div class="form-group">
  203.                     <label for="p_detail">Product Detail :</label>
  204.                     <textarea class="form-control" id="p_detail" name="p_detail"><?php echo set_value('p_detail'); ?></textarea>
  205.                   </div>
  206.                 </div>
  207.               </div>
  208.           </div>
  209.           </div>
  210.           <!-- /.box-body -->
  211.         </div>
  212.         <!--/.col (right) -->
  213.       </div>
  214.       <!-- /.row -->
  215.     </section>
  216.    
  217.     <div class="detail-product">
  218.       <section class="content">
  219.     <div class="row">
  220.       <!-- right column -->
  221.       <div class="col-md-12">
  222.         <div class="box">
  223.           <div class="box-header with-border">
  224.             <h3 class="box-title"><?php echo $this->lang->line('product_add_new_product'); ?></h3>
  225.  
  226.           </div>
  227.           <!-- /.box-header -->
  228.           <div class="box-body">
  229.             <div class="row">
  230.                 <div class="col-md-3">
  231.                   <div class="form-group">
  232.                     <label for="max_qty">Maksimum Qty : </label>
  233.                     <input type="text" class="form-control" id="max_qty" name="max_qty" value="<?php echo set_value('max_qty'); ?>">
  234.                   </div>
  235.                 </div>
  236.                 <div class="col-md-3">
  237.                   <div class="form-group">
  238.                     <label for="price">Selling Price :</label>
  239.                     <div class="input-group">
  240.                       <div class="input-group-addon">Rp.</div>
  241.                       <input type="text" class="form-control" id="cost" name="cost" value="<?php echo set_value('cost'); ?>">
  242.                       <div class="input-group-addon">.00</div>
  243.                     </div>
  244.                   </div>
  245.                 </div>
  246.                 <div class="col-md-3">
  247.                   <div class="form-group">
  248.                     <label for="pprice">Purchase Price : </label>
  249.                     <div class="input-group">
  250.                       <div class="input-group-addon">Rp.</div>
  251.                       <input type="text" class="form-control" id="price" name="price" value="<?php echo set_value('price'); ?>">
  252.                       <div class="input-group-addon">.00</div>
  253.                     </div>
  254.                   </div>
  255.                 </div>
  256.                 <div class="col-md-3">
  257.                   <div class="form-group">
  258.                     <label for="qty">Opening Stock Qty :</label>
  259.                     <input type="text" class="form-control" id="qty" name="qty" value="<?php echo set_value('qty'); ?>">
  260.                   </div>
  261.                 </div>
  262.                 <div class="col-md-6">
  263.                   <div class="form-group">
  264.                     <label for="open_stock">Opening Stock Value / Unit : </label>
  265.                     <div class="input-group">
  266.                       <div class="input-group-addon">Rp.</div>
  267.                       <input type="text" class="form-control" id="open_stock" name="open_stock" value="<?php echo set_value('open_stock'); ?>">
  268.                       <div class="input-group-addon">.00</div>
  269.                     </div>
  270.                   </div>
  271.                 </div>
  272.                 <div class="col-md-3">
  273.                   <div class="form-group">
  274.                     <label for="min_quantity">Minimum Qty : </label>
  275.                     <input type="text" class="form-control" id="min_quantity" name="min_quantity" value="<?php echo set_value('min_quantity'); ?>">
  276.                   </div>
  277.                 </div>
  278.                 <div class="col-md-3">
  279.                   <div class="form-group">
  280.                     <label for="image"><?php echo $this->lang->line('product_product_image'); ?> </label>
  281.                     <input type="file" class="" id="image" name="image" value="<?php echo set_value('image'); ?>">
  282.                   </div>
  283.                 </div>
  284.                 <div class="col-md-6">
  285.                   <div class="form-group">
  286.                     <label for="salesinfo">Sales Information : </label>
  287.                     <textarea class="form-control" id="salesinfo" name="salesinfo"><?php echo set_value('salesinfo'); ?></textarea>
  288.                   </div>
  289.                 </div>
  290.                 <div class="col-md-6">
  291.                   <div class="form-group">
  292.                     <label for="purchaseinfo">Purchase Information : </label>
  293.                     <textarea class="form-control" id="note" name="purchaseinfo"><?php echo set_value('purchaseinfo'); ?></textarea>
  294.                   </div>
  295.                 </div>  
  296.                 <div class="col-sm-12">
  297.                   <div class="box-footer">
  298.                     <button type="submit" id="submit" class="btn btn-info">&nbsp;&nbsp;&nbsp;<?php echo $this->lang->line('product_add'); ?>&nbsp;&nbsp;&nbsp;</button>
  299.                     <span class="btn btn-default" id="cancel" style="margin-left: 2%" onclick="cancel('product')"><?php echo $this->lang->line('product_cancel'); ?></span>
  300.                   </div>
  301.                 </div>
  302.               </div>
  303.                 </form>
  304.             </div>
  305.           </div>
  306.         </div>
  307.       </div>
  308.     </div>
  309.     </section>
  310.     </div>
  311.  
  312.   <!-- /.content-wrapper -->
  313.  
  314.   <?php
  315.  $this->load->view('layout/product_footer');
  316.   ?>
  317.   <script>
  318.     $(document).ready(function () {
  319.       $('.detail-product').hide();
  320.  
  321.       $("select[name='product_type']").change(function(){
  322.         $('.detail-product').show('slow');
  323.       })
  324.  
  325.       $("#submit").click(function (event) {
  326.         var name_regex = /^[-a-zA-Z\s]+$/;
  327.         var p_name_regex = /^[-a-zA-Z0-9\s]+$/;
  328.         var sname_regex = /^[a-zA-Z0-9]+$/;
  329.         var num_regex = /^\$?[0-9]+(\.[0-9][0-9])?$/;
  330.         var snum_regex = /^[0-9]+$/;
  331.         var code = $('#code').val(); //
  332.         var name = $('#name').val(); //
  333.         var principal = $('#principal').val(); //
  334.  
  335.  
  336.         if (code == null || code == "") {
  337.           $("#err_code").text("Please Enter Part Number.");
  338.           return false;
  339.         } else {
  340.           $("#err_code").text("");
  341.         }
  342.  
  343.         if (name == null || name == "") {
  344.           $("#err_name").text("Please Enter Item Name.");
  345.           return false;
  346.         } else {
  347.           $("#err_name").text("");
  348.         }
  349.  
  350.         if (principal == "") {
  351.           $("#err_principal").text("Select the Principal.");
  352.           return false;
  353.         } else {
  354.           $("#err_principal").text("");
  355.         }
  356.         // Principal validation complite.
  357.  
  358.       });
  359.  
  360.       $("#code").on("blur keyup", function (event) {
  361.         var code = $('#code').val();
  362.         if (code == null || code == "") {
  363.           $("#err_code").text("Please Enter Part Number.");
  364.           return false;
  365.         } else {
  366.           $("#err_code").text("");
  367.         }
  368.       });
  369.  
  370.       $("#name").on("blur keyup", function (event) {
  371.         var name = $('#name').val();
  372.         if (name == null || name == "") {
  373.           $("#err_name").text("Please Enter Item Name.");
  374.           return false;
  375.         } else {
  376.           $("#err_name").text("");
  377.         }
  378.       });
  379.      
  380.       $("#principal").change(function (event) {
  381.         var category = $('#principal').val();
  382.         if (category == "") {
  383.           $("#err_principal").text("Select the Principal.");
  384.           return false;
  385.         } else {
  386.           $("#err_principal").text("");
  387.         }
  388.       });
  389.  
  390.     });
  391.   </script>
  392.  
  393.   <script>
  394.     $(document).ready(function(){
  395.     var i = 0;
  396.     var product_data = new Array();
  397.     var counter = 1;
  398.  
  399.     $('#category').change(function () {
  400.       $('#sub_category').html('');
  401.       $('#sub_category').html('<option value="">Select Sub Category</option>');
  402.       var category_id = $(this).val();
  403.       console.log(category_id);
  404.       $.ajax({
  405.         url: "<?php echo base_url('product/getSub_Category') ?>/" + category_id,
  406.         type: "GET",
  407.         dataType: "JSON",
  408.         data: {
  409.           '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
  410.         },
  411.         success: function (data) {
  412.           console.log(data);
  413.           for (a = 0; a < data.length; a++) {
  414.            $('#sub_category').append('<option value="' + data[a].sub_category_id + '">' + data[a].sub_category_name + '</option>');
  415.           }
  416.         }
  417.       });
  418.     });
  419.  
  420.     $('#sub_category').change(function () {
  421.       $('#sub_category1').html('');
  422.       $('#sub_category1').html('<option value="">Select Sub Category</option>');
  423.       var sub_category_id = $(this).val();
  424.       $.ajax({
  425.         url: "<?php echo base_url('product/getSub_Category1') ?>/" + sub_category_id,
  426.         type: "GET",
  427.         dataType: "JSON",
  428.         data: {
  429.           '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
  430.         },
  431.         success: function (data) {
  432.           console.log(data);
  433.           for (a = 0; a < data.length; a++) {
  434.            $('#sub_category1').append('<option value="' + data[a].sub_category_code + '">' + data[a].sub_category_name + '</option>');
  435.           }
  436.         }
  437.       });
  438.     });
  439.  
  440.     $('#sub_category1').change(function () {
  441.  
  442.  
  443.       $('#code').val($("#category").val() + "-" + $("#sub_category").val() + $("#sub_category1").val() + "-" + $("#codep").val());
  444.  
  445.     });
  446.   });
  447.  
  448.   </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement