Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section class="content">
- <div class="box" id="print-section">
- <div class="box-header">
- <h3 class="box-title purchase-top-header"><i class="fa fa-wpforms" aria-hidden="true"></i> Work Order Form
- </h3>
- <div class="pull pull-right purchase-top-header">
- <a type="button" class="btn btn-danger btn-flat btn-sm" href="<?php echo base_url('work-order');?>" ><i class="fa fa-times" aria-hidden="true"></i> Batalkan
- </a>
- </div>
- </div>
- <div class="box-body ">
- <?php echo form_open('work-order/edit/'. $mp_work_order['id'], array("class" => "form-horizontal", "autocomplete" => "off")); ?>
- <div class="row">
- <div class="col-md-12 form-wo">
- <fieldset class="informasi_formula">
- <legend>
- <div class="row">
- <div class="col-lg-12">
- Informasi Formula Produk
- <p class="small" style="font-size:70%"><em>Silakan pilih formula</em></p>
- </div>
- </div>
- </legend>
- <div class="form-group col-md-6">
- <label for="id_product_formula" class="col-md-4 control-label">Product Formula</label>
- <div class="col-md-8">
- <select name="id_product_formula" class="form-control" onchange="this.options[this.selectedIndex].value && (window.location = '<?php echo base_url('work-order/add/'); ?>' + this.options[this.selectedIndex].value);">
- <option value="">Pilih Formula Produk</option>
- <?php
- foreach ($all_mp_product_formula as $mp_product_formula) {
- $selected = ($mp_product_formula['id'] == $idProductFormula) ? ' selected="selected"' : "";
- echo '<option value="' . $mp_product_formula['id'] . '" ' . $selected . '>' . $mp_product_formula['no_formula'] . ' - ' . $mp_product_formula['description'] . '</option>';
- }
- ?>
- </select>
- </div>
- </div>
- <div class="form-group col-md-6">
- <label for="description_formula" class="col-md-4 control-label">Deskripsi Formula Pekerjaan</label>
- <div class="col-md-8">
- <input type="text" name="description_formula" value="<?php if ($selectedProductFormula) { echo $this->input->post('description_formula') ? $this->input->post('description_formula') : $selectedProductFormula->description; }?>" class="form-control description_formula" id="description_formula" readonly/>
- </div>
- </div>
- <div class="form-group col-md-6">
- <label for="quantity_wo" class="col-md-4 control-label">Jumlah Produksi</label>
- <div class="col-md-8">
- <input type="text" name="quantity_wo" value="<?php if ($selectedProductFormula) { echo $this->input->post('quantity_wo') ? $this->input->post('quantity_wo'): $selectedProductFormula->quantity; }?>" class="form-control quantity_wo" id="quantity_wo" required/>
- <input type="hidden" name="quantity_wo_shadow" value="<?php if ($selectedProductFormula) { echo $this->input->post('quantity_wo') ? $this->input->post('quantity_wo'): $selectedProductFormula->quantity; }?>" class="quantity_wo_shadow" id="quantity_wo_shadow"/>
- </div>
- </div>
- </fieldset>
- <br>
- <fieldset class="rincian_wo">
- <legend>
- <div class="row">
- <div class="col-lg-12">
- Rincian Work Order
- <p class="small" style="font-size:70%"><em>Silakan isi rincian work order</em></p>
- </div>
- </div>
- </legend>
- <div class="form-group col-md-6">
- <label for="no_wo" class="col-md-4 control-label">Nomor Work Order</label>
- <div class="col-md-8">
- <input type="text" name="no_wo" value="<?php echo ($this->input->post('no_wo') ? $this->input->post('no_wo') : $mp_work_order['no_wo']); ?>" class="form-control" id="no_wo" />
- </div>
- </div>
- <div class="form-group col-md-6">
- <label for="start_date" class="col-md-4 control-label">Start Date</label>
- <div class="col-md-8">
- <input type="text" name="start_date" value="<?php
- if ($mp_work_order) {
- $start_date = date_create($mp_work_order['start_date']);
- }
- echo $this->input->post('start_date') ? $this->input->post('start_date') : date_format($start_date, 'd-m-Y'); ?>" class="form-control datepicker" id="start_date" />
- </div>
- </div>
- <div class="form-group col-md-6">
- <label for="end_date" class="col-md-4 control-label">End Date</label>
- <div class="col-md-8">
- <input type="text" name="end_date" value="<?php
- if ($mp_work_order) {
- $end_date = date_create($mp_work_order['end_date']);
- }
- echo $this->input->post('end_date') ? $this->input->post('end_date'): date_format($end_date, 'd-m-Y'); ?>" class="form-control datepicker" id="end_date" />
- </div>
- </div>
- <!-- <div class="form-group col-md-6">
- <label for="progress_unit" class="col-md-4 control-label">Progress Unit</label>
- <div class="col-md-8">
- <input type="text" name="progress_unit" value="<?php echo $this->input->post('progress_unit'); ?>" class="form-control" id="progress_unit" />
- </div>
- </div>
- <div class="form-group col-md-6">
- <label for="progress_percent" class="col-md-4 control-label">Progress Percent</label>
- <div class="col-md-8">
- <input type="text" name="progress_percent" value="<?php echo $this->input->post('progress_percent'); ?>" class="form-control" id="progress_percent" />
- </div>
- </div> -->
- <div class="form-group col-md-6">
- <label for="description" class="col-md-4 control-label">Description</label>
- <div class="col-md-8">
- <textarea name="description" class="form-control" id="description"><?php echo $this->input->post('description') ? $this->input->post('description') : $mp_work_order['description']; ?></textarea>
- </div>
- </div>
- </fieldset>
- <div class="row">
- <div class="col-md-12">
- <div class="form-group pull-left row_save_wo">
- <div class="col-sm-4">
- <button type="button" class="btn btn-info process_wo">Proses</button>
- <button type="submit" class="btn btn-success save_wo hidden">Simpan</button>
- </div>
- <div class="col-sm-4">
- <a type="button" class="btn btn-default btn-flat" href="<?php echo base_url('work-order');?>" >Kembali
- </a>
- </div>
- </div>
- </div>
- </div>
- <hr>
- <div class="row">
- <div class="col-md-12">
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active"><a href="#produkRaw" aria-controls="produkRaw" role="tab" data-toggle="tab">Bahan Baku</a></li>
- <li role="presentation"><a href="#prodCost" aria-controls="prodCost" role="tab" data-toggle="tab">Biaya Produksi</a></li>
- </ul>
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane fade in active" id="produkRaw">
- <table class="table table-striped table-bordered tableProdukRaw">
- <tr>
- <th>No</th>
- <th>Nama Produk</th>
- <th>Jumlah</th>
- <th>Harga Satuan</th>
- <th>Total Biaya</th>
- <th>Deskripsi</th>
- </tr>
- <?php $no=1; foreach ($mp_product_formula_raw_material as $m) {?>
- <tr>
- <td class='hidden'><input name='woProductRaw[id][]' value='<?php echo $m['id']; ?>' class='form-control'></td>
- <td class='hidden'><input name='woProductRaw[id_raw_product][]' value='<?php echo $m['id_product']; ?>' class='form-control'></td>
- <td class='hidden'><input name='woProductRaw[work_order_raw_material_id][]' value='<?php echo $m['mworm_id']; ?>' class='form-control'></td>
- <td><?php echo $no++; ?></td>
- <td><?php echo $m['product_name']; ?></td>
- <td><input name='woProductRaw[quantity][]' value='<?php echo $m['qty_mworm']; ?>' class='form-control quantity'></td>
- <td><input name='woProductRaw[cost][]' value='<?php echo $m['cost_mworm']; ?>' class='form-control cost'></td>
- <td><input name='woProductRaw[total_cost][]' value='<?php echo $m['totalCost_mworm']; ?>' class='form-control total_cost' readonly="readonly"></td>
- <td><input name='woProductRaw[description][]' value='<?php echo $m['description_mworm']; ?>' class='form-control description'></td>
- </tr>
- <?php }?>
- </table>
- </div>
- <div role="tabpanel" class="tab-pane fade" id="prodCost">
- <table class="table table-striped table-bordered tableProdCost">
- <tr>
- <th>No</th>
- <th>Kode Produk</th>
- <th>Jam</th>
- <th>Harga Satuan</th>
- <th>Total Biaya</th>
- <th>Deskripsi</th>
- </tr>
- <?php $no=1; foreach($mp_product_formula_production_costs as $m) { ?>
- <tr>
- <td class='hidden'><input name='woDetailProductionCost[mpfpc_id][]' value='<?php echo $m['mpfpc_id']; ?>' class='form-control'></td>
- <td class='hidden'><input name='woDetailProductionCost[pc_id][]' value='<?php echo $m['pc_id']; ?>' class='form-control'></td>
- <td class='hidden'><input name='woDetailProductionCost[mp_work_order_production_costs_id][]' value='<?php echo $m['mwopc_id']; ?>' class='form-control'></td>
- <td><?php echo $no++; ?></td>
- <td><?php echo $m['code']; ?></td>
- <td><input name='woDetailProductionCost[hour][]' value='<?php echo $m['mwopc_hour']; ?>' class='form-control hour'></td>
- <td><input name='woDetailProductionCost[cost][]' value='<?php echo $m['mwopc_cost']; ?>' class='form-control cost'></td>
- <td><input name='woDetailProductionCost[total_cost][]' value='<?php echo $m['mwopc_totalCost']; ?>' class='form-control total_cost' readonly="readonly"></td>
- <td><input name='woDetailProductionCost[description][]' value='<?php echo $m['mwopc_description']; ?>' class='form-control description'></td>
- </tr>
- <?php } ?>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php echo form_close(); ?>
- <script>
- $('#myTabs a').click(function (e) {
- e.preventDefault()
- $(this).tab('show')
- })
- $(document).ready(function() {
- // calculate qty price in raw product
- $("#produkRaw table").on("change", "input", function () {
- var tableRow = $(this).closest("tr");
- var quantity = Number(tableRow.find(".quantity").val());
- var cost = Number(tableRow.find(".cost").val());
- var total_cost = quantity * cost;
- // set total cost
- tableRow.find('.total_cost').val(total_cost);
- });
- // calculate qty price in raw product
- $("#prodCost table").on("change", "input", function () {
- var tableRow = $(this).closest("tr");
- var quantity = Number(tableRow.find(".hour").val());
- var cost = Number(tableRow.find(".cost").val());
- var total_cost = quantity * cost;
- // set total cost
- tableRow.find('.total_cost').val(total_cost);
- });
- // change to cost raw to decription
- $("#produkRaw table").on("change", "input.cost", function () {
- var tableRow = $(this).closest("tr");
- var description = tableRow.find(".description").val('Biaya Input Manual');
- });
- // disable first all input except product formula
- $('.form-wo .informasi_formula').find('input.description_formula').attr('disabled', 'disabled');
- // change product formula
- $(document).on('change', '.no_wo', function () {
- $('.form-wo').find('input').removeAttr('disabled', 'disabled');
- $('.form-wo').find('textarea').removeAttr('readonly');
- });
- // change product raw and cost product child
- $(document).on('change', '.quantity_wo', function () {
- // table raw product
- var tableProdukRawTr = $('.tableProdukRaw tr');
- var tableProdCostTr = $('.tableProdCost tr');
- var quantity_wo = $(this).val();
- var quantity_wo_shadow_val = $('.informasi_formula').find('input.quantity_wo_shadow').val();
- // set to raw product
- for (let i = 1; i < tableProdukRawTr.length; i++) {
- var row = $('.tableProdukRaw').find('tr[id=row-raw-product-'+i+']');
- row_input_quantity_shadow = row.find('input.quantity_shadow').val();
- row_input_cost = row.find('input.cost').val();
- increaseQuantity = Number( (row_input_quantity_shadow / quantity_wo_shadow_val) * quantity_wo);
- newTotalCost = Number(increaseQuantity * row_input_cost);
- localStorage.setItem("qty", row_input_quantity_shadow);
- // set new quantity
- row.find('input.quantity').val(increaseQuantity);
- // set new total total cost
- row.find('input.total_cost').val(newTotalCost);
- }
- // set to cost production
- for (let i = 1; i < tableProdCostTr.length; i++) {
- var row = $('.tableProdCost').find('tr[id=row-cost-production-'+i+']');
- row_input_hour_shadow = row.find('input.hour_shadow').val();
- row_input_cost = row.find('input.cost').val();quantity_wo
- increaseQuantity = Number( (row_input_hour_shadow / quantity_wo_shadow_val ) * quantity_wo);
- newTotalCost = Number(increaseQuantity * row_input_cost);
- // set new quantity
- row.find('input.hour').val(increaseQuantity);
- // set new total total cost
- row.find('input.total_cost').val(newTotalCost);
- }
- });
- $(document).on('click', '.process_wo', function () {
- var tableProdukRawTr = $('.tableProdukRaw tr');
- var tableProdCostTr = $('.tableProdCost tr');
- var mp_work_order_raw_material_history = new Object();
- var mp_work_order_production_costs_history = new Object();
- // release button save
- $('.save_wo').removeClass('hidden');
- $('.process_wo').addClass('hidden');
- // set to raw product history
- for (let i = 1; i < tableProdukRawTr.length; i++) {
- var row = $('.tableProdukRaw').find('tr[id=row-raw-product-'+i+']');
- mp_work_order_raw_material_history[i] =
- {
- 'id_product' : row.find('input.id_raw_product ').val(),
- 'quantity' : row.find('input.quantity ').val(),
- 'cost' : row.find('input.cost ').val(),
- 'total_cost' : row.find('input.total_cost ').val(),
- 'description': row.find('input.description ').val(),
- 'added_by' : row.find('input.added_by ').val(),
- 'created_at' : row.find('input.created_at ').val(),
- 'updated_at' : row.find('input.updated_at ').val(),
- }
- }
- // set to cost production history
- for (let i = 1; i < tableProdCostTr.length; i++) {
- var row = $('.tableProdCost').find('tr[id=row-cost-production-'+i+']');
- mp_work_order_production_costs_history[i] =
- {
- 'id_work_order' : row.find('input.id_work_order').val(),
- 'id_production_cost': row.find('input.id_production_cost').val(),
- 'hour' : row.find('input.hour').val(),
- 'cost' : row.find('input.cost').val(),
- 'total_cost' : row.find('input.total_cost').val(),
- 'description' : row.find('input.description').val(),
- 'added_by' : row.find('input.added_by').val(),
- 'created_at' : row.find('input.created_at').val(),
- 'updated_at' : row.find('input.updated_at').val(),
- }
- }
- var data = {
- 'mp_work_order' : {
- 'id_product_formula': $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'qty' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'start_date' : $('.start_date').val() ? $('.start_date').val() : "",
- 'end_date' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'description' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'progress_unit' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'progress_percent' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'created_at' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- 'added_by' : $('.id_product_formula').val() ? $('.id_product_formula').val() : "",
- },
- mp_work_order_raw_material_history,
- mp_work_order_production_costs_history
- }
- var a = JSON.stringify(data);
- $('#history_wo').val(a);
- })
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement