Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- $p = array('1', '21', '22', '31', '32','61','62');
- if (!(in_array($this->session->userdata('type'), $p))) {
- redirect('auth/dashboard');
- }
- $this->load->view('layout/header');
- ?>
- <!-- Content Wrapper. Contains page content -->
- <div class="content-wrapper">
- <!-- Content Header (Page header) -->
- <section class="content-header">
- <h5>
- <ol class="breadcrumb">
- <li><a href="<?php echo base_url('auth/dashboard'); ?>"><i class="fa fa-dashboard"></i> <?php echo $this->lang->line('header_dashboard'); ?></a></li>
- <li><a href="<?php echo base_url('product'); ?>"><?php echo $this->lang->line('header_product'); ?></a></li>
- <li class="active"><?php echo $this->lang->line('product_add_product'); ?></li>
- </ol>
- </h5>
- </section>
- <!-- Main content -->
- <section class="content">
- <div class="row">
- <!-- right column -->
- <div class="col-md-12">
- <div class="box">
- <div class="box-header with-border">
- <div class="row">
- <div class="col-md-4">
- <p>
- <h3 class="box-title"><?php echo $this->lang->line('product_add_new_product'); ?></h3>
- <!-- </div> -->
- <!-- <div class="col-md-3"> -->
- <form role="form" id="form" method="post" action="<?php echo base_url('product/addProduct'); ?>" encType="multipart/form-data">
- <div class="form-group">
- <label for="kategori">Product Type : </label>
- <select class="form-control select2" id="product_type" name="product_type" style="width: 100%;">
- <option value="" selected="" disabled="">Product Type Select</option>
- <option value="1">Raw Material</option>
- <option value="2">Finish Good</option>
- </select>
- </div>
- </p>
- </div>
- </div>
- </div>
- <!-- /.box-header -->
- <div class="detail-product">
- <div class="box-body">
- <div class="row">
- <div class="col-md-4">
- <div class="form-group">
- <label for="max_qty">Code : </label>
- <input type="text" class="form-control" id="codep" name="codep" value="<?php echo set_value('max_qty'); ?>">
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="kategori">Category : </label>
- <select class="form-control select2" id="category" name="category" style="width: 100%;">
- <option value="">Category Select</option>
- <?php
- foreach ($category as $value) {
- echo "<option value='$value->category_id'" . set_select('category', $value->category_code) . ">$value->category_name</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="kategori">Sub Category : </label>
- <select class="form-control select2" id="sub_category" name="sub_category" style="width: 100%;">
- <option value="">Sub Category Select</option>
- </select>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="kategori">Sub Category1 : </label>
- <select class="form-control select2" id="sub_category1" name="sub_category1" style="width: 100%;">
- <option value="">Sub Category1 Select</option>
- </select>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="code">Product Number : <span class="validation-color">*</span></label>
- <input type="text" class="form-control" id="code" name="code" value="<?php echo set_value('code', $code); ?>" readonly>
- <input type="hidden" class="form-control" id="pnumber" name="pnumber" value="<?php echo sprintf("%04s", $pnumber); ?>" readonly>
- <span class="validation-color" id="err_code"><?php echo form_error('part_number'); ?></span>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">Item Name : <span class="validation-color">*</span></label>
- <input type="text" class="form-control" id="name" name="name" value="<?php echo set_value('name'); ?>">
- <span class="validation-color" id="err_name"><?php echo form_error('name'); ?></span>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">Item Name By suppliers : </label>
- <input type="text" class="form-control" id="item_namebyp" name="item_namebyp" value="<?php echo set_value('item_namebyp'); ?>">
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="size">Supplier/Vendor : <span class="validation-color">*</span></label>
- <select class="form-control select2" id="principal" name="principal" style="width: 100%;">
- <option value=""><?php echo $this->lang->line('product_select').' Supplier'; ?>
- </option>
- <?php
- foreach ($supplier as $row) {
- echo "<option value='$row->supplier_id'" . set_select('supplier', $row->supplier_id) . ">$row->supplier_name</option>";
- }
- ?>
- </select>
- <span class="validation-color" id="err_principal"><?php echo form_error('principal'); ?></span>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="subcategory">Brand : </label>
- <select class="form-control select2" id="brand" name="brand" style="width: 100%;">
- <option value=""><?php echo $this->lang->line('product_select').' Brand'; ?>
- </option>
- <?php
- foreach ($brand as $value) {
- echo "<option value='$value->id'" . set_select('brand', $value->id) . ">$value->brand_name</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="size">Country Origin : </label>
- <select class="form-control select2" id="origin" name="origin" style="width: 100%;">
- <option value="">Select Country</option>
- <?php
- foreach ($country as $value) {
- echo "<option value='$value->id'" . set_select('country', $value->id) . ">$value->name</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <!-- <div class="form-group">
- <label for="date">Expired Date : </label>
- <input type="date" class="form-control" id="expired" name="expired" value="<?php echo set_value('expired_date'); ?>">
- </div> -->
- <div class="col-md-4">
- <div class="form-group">
- <label for="size">Purchase Unit : </label>
- <select class="form-control select2" id="principal" name="unit" style="width: 100%;">
- <option value=""><?php echo $this->lang->line('product_select').' Unit'; ?>
- <?php
- foreach ($unit as $row) {
- echo "<option value='$row->unit'" . set_select('unit', $row->id) . ">$row->unit</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-4">
- <div class="form-group">
- <label for="name">Selling Unit : </label>
- <select class="form-control select2" id="principal" name="sku" style="width: 100%;">
- <option value=""><?php echo $this->lang->line('product_select').' Unit'; ?>
- <?php
- foreach ($unit as $row) {
- echo "<option value='$row->unit'" . set_select('unit', $row->id) . ">$row->unit</option>";
- }
- ?>
- </select>
- </div>
- </div>
- <!-- <div class="form-group">
- <label for="tax">Tax : </label>
- <input type="text" class="form-control" id="tax" name="tax" value="<?php echo set_value('tax'); ?>">
- </div>
- <div class="form-group">
- <label for="sales_tax">Sales Tax : </label>
- <input type="text" class="form-control" id="sales_tax" name="sales_tax" value="<?php echo set_value('sales_tax'); ?>">
- </div> -->
- <div class="col-md-6" style="margin-left: 25%;">
- <div class="form-group">
- <label for="p_detail">Product Detail :</label>
- <textarea class="form-control" id="p_detail" name="p_detail"><?php echo set_value('p_detail'); ?></textarea>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- /.box-body -->
- </div>
- <!--/.col (right) -->
- </div>
- <!-- /.row -->
- </section>
- <div class="detail-product">
- <section class="content">
- <div class="row">
- <!-- right column -->
- <div class="col-md-12">
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title"><?php echo $this->lang->line('product_add_new_product'); ?></h3>
- </div>
- <!-- /.box-header -->
- <div class="box-body">
- <div class="row">
- <div class="col-md-3">
- <div class="form-group">
- <label for="max_qty">Maksimum Qty : </label>
- <input type="text" class="form-control" id="max_qty" name="max_qty" value="<?php echo set_value('max_qty'); ?>">
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <label for="price">Selling Price :</label>
- <div class="input-group">
- <div class="input-group-addon">Rp.</div>
- <input type="text" class="form-control" id="cost" name="cost" value="<?php echo set_value('cost'); ?>">
- <div class="input-group-addon">.00</div>
- </div>
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <label for="pprice">Purchase Price : </label>
- <div class="input-group">
- <div class="input-group-addon">Rp.</div>
- <input type="text" class="form-control" id="price" name="price" value="<?php echo set_value('price'); ?>">
- <div class="input-group-addon">.00</div>
- </div>
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <label for="qty">Opening Stock Qty :</label>
- <input type="text" class="form-control" id="qty" name="qty" value="<?php echo set_value('qty'); ?>">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="open_stock">Opening Stock Value / Unit : </label>
- <div class="input-group">
- <div class="input-group-addon">Rp.</div>
- <input type="text" class="form-control" id="open_stock" name="open_stock" value="<?php echo set_value('open_stock'); ?>">
- <div class="input-group-addon">.00</div>
- </div>
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <label for="min_quantity">Minimum Qty : </label>
- <input type="text" class="form-control" id="min_quantity" name="min_quantity" value="<?php echo set_value('min_quantity'); ?>">
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-group">
- <label for="image"><?php echo $this->lang->line('product_product_image'); ?> </label>
- <input type="file" class="" id="image" name="image" value="<?php echo set_value('image'); ?>">
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="salesinfo">Sales Information : </label>
- <textarea class="form-control" id="salesinfo" name="salesinfo"><?php echo set_value('salesinfo'); ?></textarea>
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <label for="purchaseinfo">Purchase Information : </label>
- <textarea class="form-control" id="note" name="purchaseinfo"><?php echo set_value('purchaseinfo'); ?></textarea>
- </div>
- </div>
- <div class="col-sm-12">
- <div class="box-footer">
- <button type="submit" id="submit" class="btn btn-info"> <?php echo $this->lang->line('product_add'); ?> </button>
- <span class="btn btn-default" id="cancel" style="margin-left: 2%" onclick="cancel('product')"><?php echo $this->lang->line('product_cancel'); ?></span>
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </section>
- </div>
- <!-- /.content-wrapper -->
- <?php
- $this->load->view('layout/product_footer');
- ?>
- <script>
- $(document).ready(function () {
- $('.detail-product').hide();
- $("select[name='product_type']").change(function(){
- $('.detail-product').show('slow');
- })
- $("#submit").click(function (event) {
- var name_regex = /^[-a-zA-Z\s]+$/;
- var p_name_regex = /^[-a-zA-Z0-9\s]+$/;
- var sname_regex = /^[a-zA-Z0-9]+$/;
- var num_regex = /^\$?[0-9]+(\.[0-9][0-9])?$/;
- var snum_regex = /^[0-9]+$/;
- var code = $('#code').val(); //
- var name = $('#name').val(); //
- var principal = $('#principal').val(); //
- if (code == null || code == "") {
- $("#err_code").text("Please Enter Part Number.");
- return false;
- } else {
- $("#err_code").text("");
- }
- if (name == null || name == "") {
- $("#err_name").text("Please Enter Item Name.");
- return false;
- } else {
- $("#err_name").text("");
- }
- if (principal == "") {
- $("#err_principal").text("Select the Principal.");
- return false;
- } else {
- $("#err_principal").text("");
- }
- // Principal validation complite.
- });
- $("#code").on("blur keyup", function (event) {
- var code = $('#code').val();
- if (code == null || code == "") {
- $("#err_code").text("Please Enter Part Number.");
- return false;
- } else {
- $("#err_code").text("");
- }
- });
- $("#name").on("blur keyup", function (event) {
- var name = $('#name').val();
- if (name == null || name == "") {
- $("#err_name").text("Please Enter Item Name.");
- return false;
- } else {
- $("#err_name").text("");
- }
- });
- $("#principal").change(function (event) {
- var category = $('#principal').val();
- if (category == "") {
- $("#err_principal").text("Select the Principal.");
- return false;
- } else {
- $("#err_principal").text("");
- }
- });
- });
- </script>
- <script>
- $(document).ready(function(){
- var i = 0;
- var product_data = new Array();
- var counter = 1;
- $('#category').change(function () {
- $('#sub_category').html('');
- $('#sub_category').html('<option value="">Select Sub Category</option>');
- var category_id = $(this).val();
- console.log(category_id);
- $.ajax({
- url: "<?php echo base_url('product/getSub_Category') ?>/" + category_id,
- type: "GET",
- dataType: "JSON",
- data: {
- '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
- },
- success: function (data) {
- console.log(data);
- for (a = 0; a < data.length; a++) {
- $('#sub_category').append('<option value="' + data[a].sub_category_id + '">' + data[a].sub_category_name + '</option>');
- }
- }
- });
- });
- $('#sub_category').change(function () {
- $('#sub_category1').html('');
- $('#sub_category1').html('<option value="">Select Sub Category</option>');
- var sub_category_id = $(this).val();
- $.ajax({
- url: "<?php echo base_url('product/getSub_Category1') ?>/" + sub_category_id,
- type: "GET",
- dataType: "JSON",
- data: {
- '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
- },
- success: function (data) {
- console.log(data);
- for (a = 0; a < data.length; a++) {
- $('#sub_category1').append('<option value="' + data[a].sub_category_code + '">' + data[a].sub_category_name + '</option>');
- }
- }
- });
- });
- $('#sub_category1').change(function () {
- $('#code').val($("#category").val() + "-" + $("#sub_category").val() + $("#sub_category1").val() + "-" + $("#codep").val());
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement