Bootstrapify item edit form (#116)

Use bootstrap-dialog in items inventory and inventory details (#328)
This commit is contained in:
jekkos
2016-02-16 23:42:20 +01:00
parent a97929f239
commit c99ef3f315
12 changed files with 208 additions and 206 deletions

View File

@@ -358,9 +358,9 @@ function get_item_data_row($item,$controller)
}
}
$table_data_row.='<td align="center" width="55px">' . $image . '</td>';
$table_data_row.='<td width="5%"><a onclick="item_details(\''.$controller_name.'/view/'. $item->item_id . '/width:' . $width . '\')">'. $CI->lang->line('common_edit').'</a></td>';
$table_data_row.='<td width="10%">'.anchor($controller_name."/inventory/$item->item_id/width:$width", $CI->lang->line('common_inv'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_count')))./*'</td>';//inventory count
$table_data_row.='<td width="5%">'*/'&nbsp;&nbsp;&nbsp;&nbsp;'.anchor($controller_name."/count_details/$item->item_id/width:$width", $CI->lang->line('common_det'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_details_count'))).'</td>';//inventory details
$table_data_row.='<td width="5%"><a onclick="item_details(\''.$controller_name.'/view/'. $item->item_id . '/width:' . $width . '\',\''.$CI->lang->line("items_basic_information").'\')">'. $CI->lang->line('common_edit').'</a>';
$table_data_row.='<td width="10%"><a onclick="item_details(\''.$controller_name.'/inventory/' . $item->item_id . '/width:' . $width . '\', \''.$CI->lang->line("items_count"). '\')">'. $CI->lang->line('common_inv'). '</a>'.
'&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="item_details(\''.$controller_name.'/count_details/'. $item->item_id. '/width:' . $width . '\', \''. $CI->lang->line('items_details_count') . '\')">' . $CI->lang->line('common_det'). '</a></td>';//inventory detail_
$table_data_row.='</tr>';

View File

@@ -1,11 +1,9 @@
<?php echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_form')); ?>
<fieldset id="inv_item_basic_info">
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<table align="center" border="0" bgcolor="#CCCCCC">
<table border="0" bgcolor="#CCCCCC">
<div class="field_row clearfix">
<tr>
<td>
<td>
<?php echo form_label($this->lang->line('items_item_number').':', 'name',array('class'=>'wide')); ?>
</td>
<td>
@@ -22,10 +20,10 @@
</td>
</tr>
<tr>
<td>
<td>
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'wide')); ?>
</td>
<td>
<td>
<?php $iname = array (
'name'=>'name',
'id'=>'name',
@@ -38,10 +36,10 @@
</td>
</tr>
<tr>
<td>
<td>
<?php echo form_label($this->lang->line('items_category').':', 'category',array('class'=>'wide')); ?>
</td>
<td>
<td>
<?php $cat = array (
'name'=>'category',
@@ -86,13 +84,7 @@
</div>
</table>
<div class="field_row clearfix">
<div class='form_field'></div>
</div>
<div class="field_row clearfix">
<div class='form_field'></div>
</div>
</fieldset>
<?php echo form_close(); ?>
@@ -106,9 +98,9 @@ foreach( $inventory_array as $row)
array_push($employee_name, $employee->first_name." ".$employee->last_name);
}
?>
<table id="inventory_result" border="0" align="center">
<table id="inventory_result" style="width:100%;">
<tr bgcolor="#FF0033" align="center" style="font-weight:bold"><td colspan="4">Inventory Data Tracking</td></tr>
<tr align="center" style="font-weight:bold"><td width="15%">Date</td><td width="25%">Employee</td><td width="15%">In/Out Qty</td><td width="45%">Remarks</td></tr>
<tr style="font-weight:bold"><td width="30%">Date</td><td width="25%">Employee</td><td width="15%">In/Out Qty</td><td width="45%">Remarks</td></tr>
</table>
<script type='text/javascript'>
@@ -141,8 +133,7 @@ function display_stock(location_id)
{
var tr = document.createElement('TR');
tr.setAttribute("bgColor","#CCCCCC");
tr.setAttribute("align","#center");
var td = document.createElement('TD');
td.appendChild(document.createTextNode(data['trans_date']));
tr.appendChild(td);
@@ -152,7 +143,6 @@ function display_stock(location_id)
tr.appendChild(td);
td = document.createElement('TD');
td.setAttribute("align","right");
td.appendChild(document.createTextNode(data['trans_inventory']));
tr.appendChild(td);

View File

@@ -1,113 +1,124 @@
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="error_message_box" class="error_message_box"></ul>
<?php echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'enctype'=>'multipart/form-data')); ?>
<fieldset id="item_basic_info">
<?php echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'enctype'=>'multipart/form-data', 'class' => 'form-horizontal')); ?>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_item_number').':', 'item_number',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_item_number'), 'item_number',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_input(array(
'name'=>'item_number',
'class'=>'item_number',
'id'=>'item_number',
'class'=>'form-control',
'value'=>$item_info->item_number)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'required wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_name'), 'name',array('class'=>'required control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_input(array(
'name'=>'name',
'id'=>'name',
'class'=>'form-control',
'value'=>$item_info->name)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_category').':', 'category',array('class'=>'required wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_category'), 'category',array('class'=>'required control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_input(array(
'name'=>'category',
'id'=>'category',
'class'=>'form-control',
'value'=>$item_info->category)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_supplier').':', 'supplier',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_dropdown('supplier_id', $suppliers, $selected_supplier);?>
<div class="form-group">
<?php echo form_label($this->lang->line('items_supplier'), 'supplier',array('class'=>'required control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_dropdown('supplier_id', $suppliers, $selected_supplier, 'class="form-control"');?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_cost_price').':', 'cost_price',array('class'=>'required wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_cost_price'), 'cost_price',array('class'=>'required control-label col-xs-3')); ?>
<div class="col-xs-3">
<div class="input-group">
<span class="input-group-addon">$</span>
<?php echo form_input(array(
'name'=>'cost_price',
'size'=>'8',
'id'=>'cost_price',
'class'=>'form-control',
'value'=>$item_info->cost_price)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_unit_price').':', 'unit_price',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'unit_price',
'size'=>'8',
'id'=>'unit_price',
'value'=>$item_info->unit_price)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_tax_1').':', 'tax_percent_1',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_unit_price'), 'unit_price',array('class'=>'required control-label col-xs-3')); ?>
<div class='col-xs-3'>
<div class="input-group">
<span class="input-group-addon"><?php echo $this->config->item('currency_symbol'); ?></span>
<?php echo form_input(array(
'name'=>'unit_price',
'id'=>'unit_price',
'class'=>'form-control',
'value'=>$item_info->unit_price)
);?>
</div>
</div>
</div>
<div class="form-group">
<?php echo form_label($this->lang->line('items_tax_1'), 'tax_percent_1',array('class'=>'wide control-label col-xs-3')); ?>
<div class='col-sm-3'>
<?php echo form_input(array(
'name'=>'tax_names[]',
'id'=>'tax_name_1',
'size'=>'8',
'class'=>'form-control',
'value'=> isset($item_tax_info[0]['name']) ? $item_tax_info[0]['name'] : $this->config->item('default_tax_1_name'))
);?>
</div>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_1',
'size'=>'3',
'value'=> isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : $default_tax_1_rate)
);?>
%
</div>
<div class="col-sm-2 input-group">
<?php echo form_input(array(
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_1',
'class'=>'form-control',
'value'=> isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : $default_tax_1_rate)
);?>
<span class="input-group-addon">%</span>
</div>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_tax_2').':', 'tax_percent_2',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_tax_2'), 'tax_percent_2',array('class'=>'wide control-label col-xs-3')); ?>
<div class='col-sm-3'>
<?php echo form_input(array(
'name'=>'tax_names[]',
'id'=>'tax_name_2',
'size'=>'8',
'class'=>'form-control',
'value'=> isset($item_tax_info[1]['name']) ? $item_tax_info[1]['name'] : $this->config->item('default_tax_2_name'))
);?>
</div>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_2',
'size'=>'3',
'value'=> isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : $default_tax_2_rate)
);?>
%
</div>
<div class="col-sm-2 input-group">
<?php echo form_input(array(
'name'=>'tax_percents[]',
'class'=>'form-control',
'id'=>'tax_percent_name_2',
'value'=> isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : $default_tax_2_rate)
);?>
<span class="input-group-addon">%</span>
</div>
</div>
</div>
@@ -115,16 +126,15 @@
foreach($stock_locations as $key=>$location_detail)
{
?>
<div class="field_row clearfix">
<div class="form-group">
<?php echo form_label($this->lang->line('items_quantity').' '.$location_detail['location_name'] .':',
$key.'_quantity',
array('class'=>'required wide')); ?>
<div class='form_field'>
array('class'=>'required wide control-label col-xs-3')); ?>
<div class='col-xs-2'>
<?php echo form_input(array(
'name'=>$key.'_quantity',
'id'=>$key.'_quantity',
'class'=>'quantity',
'size'=>'8',
'class'=>'quantity form-control',
'value'=>isset($item_info->item_id)?$location_detail['quantity']:0)
);?>
</div>
@@ -133,80 +143,82 @@
}
?>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_receiving_quantity').':', 'receiving_quantity',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_receiving_quantity'), 'receiving_quantity',array('class'=>'wide control-label col-xs-3')); ?>
<div class='col-xs-2'>
<?php echo form_input(array(
'name'=>'receiving_quantity',
'id'=>'receiving_quantity',
'size'=>'8',
'class'=>'form-control',
'value'=>$item_info->receiving_quantity)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_reorder_level').':', 'reorder_level',array('class'=>'required wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_reorder_level'), 'reorder_level',array('class'=>'required control-label col-xs-3')); ?>
<div class='col-xs-2'>
<?php echo form_input(array(
'name'=>'reorder_level',
'id'=>'reorder_level',
'size'=>'8',
'class'=>'form-control',
'value'=>!isset($item_info->item_id)?0:$item_info->reorder_level)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_description').':', 'description',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_description'), 'description',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_textarea(array(
'name'=>'description',
'id'=>'description',
'value'=>$item_info->description,
'rows'=>'5',
'cols'=>'17')
'class'=>'form-control',
'value'=>$item_info->description)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_image').':', 'item_image',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_image').':', 'item_image',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_upload('item_image');?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_allow_alt_description').':', 'allow_alt_description',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_allow_alt_description').':', 'allow_alt_description',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-1'>
<?php echo form_checkbox(array(
'name'=>'allow_alt_description',
'id'=>'allow_alt_description',
'class'=>'form-control',
'value'=>1,
'checked'=>($item_info->allow_alt_description)? 1 :0)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_is_serialized').':', 'is_serialized',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_is_serialized').':', 'is_serialized',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-1'>
<?php echo form_checkbox(array(
'name'=>'is_serialized',
'id'=>'is_serialized',
'class'=>'form-control',
'value'=>1,
'checked'=>($item_info->is_serialized)? 1 : 0)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_is_deleted').':', 'is_deleted',array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->lang->line('items_is_deleted').':', 'is_deleted',array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-1'>
<?php echo form_checkbox(array(
'name'=>'is_deleted',
'id'=>'is_deleted',
'class'=>'form-control',
'value'=>1,
'checked'=>($item_info->deleted)? 1 : 0)
);?>
@@ -221,12 +233,13 @@
{
$item_arr = (array)$item_info;
?>
<div class="field_row clearfix">
<?php echo form_label($this->config->item('custom'.$i.'_name').':', 'custom'.$i,array('class'=>'wide')); ?>
<div class='form_field'>
<div class="form-group">
<?php echo form_label($this->config->item('custom'.$i.'_name').':', 'custom'.$i,array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-6'>
<?php echo form_input(array(
'name'=>'custom'.$i,
'id'=>'custom'.$i,
'class'=>'form-control',
'value'=>$item_arr['custom'.$i])
);?>
</div>
@@ -235,7 +248,6 @@
}
}
?>
</fieldset>
<?php echo form_close(); ?>
<script type='text/javascript'>

View File

@@ -3,15 +3,10 @@
<?php echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_form')); ?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<table align="center" border="0" bgcolor="#CCCCCC">
<div class="field_row clearfix">
<tr>
<td>
<?php echo form_label($this->lang->line('items_item_number').':', 'name',array('class'=>'wide')); ?>
</td>
<td>
<div class="form_field">
<?php $inumber = array (
'name'=>'item_number',
'id'=>'item_number',
@@ -19,16 +14,14 @@
'style' => 'border:none',
'readonly' => 'readonly'
);
echo form_input($inumber);
?>
</td>
</tr>
<tr>
<td>
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'wide')); ?>
</td>
<td>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'wide')); ?>
<div class='form_field'>
<?php $iname = array (
'name'=>'name',
'id'=>'name',
@@ -36,60 +29,53 @@
'style' => 'border:none',
'readonly' => 'readonly'
);
echo form_input($iname);
?>
</td>
</tr>
<tr>
<td>
<?php echo form_label($this->lang->line('items_category').':', 'category',array('class'=>'wide')); ?>
</td>
<td>
echo form_input($iname);
?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_category').':', 'category',array('class'=>'wide')); ?>
<div class='form_field'>
<?php $cat = array (
'name'=>'category',
'id'=>'category',
'value'=>$item_info->category,
'style' => 'border:none',
'readonly' => 'readonly'
);
echo form_input($cat);
?>
</td>
</tr>
<tr>
<td>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_stock_location').':', 'stock_location',array('class'=>'wide')); ?>
</td>
<td>
<?php
echo form_dropdown('stock_location',$stock_locations,current($stock_locations),'onchange="fill_quantity(this.value)"');
?>
</td>
</tr>
<tr>
<td>
<div class='form_field'>
<?php
echo form_dropdown('stock_location',$stock_locations,current($stock_locations),'onchange="fill_quantity(this.value)"');
?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_current_quantity').':', 'quantity',array('class'=>'wide')); ?>
</td>
<td>
<div class='form_field'>
<?php $qty = array (
'name'=>'quantity',
'id'=>'quantity',
'value'=>current($item_quantities),
'style' => 'border:none',
'readonly' => 'readonly'
);
echo form_input($qty);
?>
</td>
</tr>
</div>
</table>
</div>
</div>
<div class="field_row clearfix">
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_add_minus').':', 'quantity',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
@@ -100,25 +86,17 @@
</div>
</div>
<div class="field_row clearfix">
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_inventory_comments').':', 'description',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_textarea(array(
'name'=>'trans_comment',
'id'=>'trans_comment',
'rows'=>'3',
'cols'=>'17')
'cols'=>'17')
);?>
</div>
</div>
<?php
echo form_submit(array(
'name'=>'submit',
'id'=>'submit',
'value'=>$this->lang->line('common_submit'),
'class'=>'btn btn-primary btn-sm pull-right')
);
?>
</fieldset>
<?php echo form_close(); ?>
@@ -133,7 +111,7 @@ $(document).ready(function()
$(form).ajaxSubmit({
success:function(response)
{
tb_remove();
dialog_support.hide();
post_item_form_submit(response);
},
dataType:'json'

View File

@@ -109,32 +109,19 @@ function init_table_sorting()
}
}
var item_details = function(url) {
dialog_support = { hide: function () {}, clicked_button : undefined };
var submit_form = function(button_id) {
return function(dialog_ref)
{
dialog_support.clicked_button = button_id;
$('#item_form').submit();
dialog_support.hide_dialog = function() {
dialog_ref.close();
};
}
};
var item_details = function(url, title) {
return BootstrapDialog.show({
title: '<?php echo $this->lang->line("items_basic_information"); ?>',
title: title,
message: $('<div></div>').load(url),
buttons: [{
id: 'submit',
label: '<?php echo $this->lang->line('common_submit'); ?>',
action: submit_form('submit')
action: dialog_support.submit('submit')
}, {
id: 'new',
label: '<?php echo $this->lang->line('common_new'); ?>',
action: submit_form('new')
action: dialog_support.submit('new')
}]
});
};

View File

@@ -43,7 +43,7 @@
<!-- end js template tags -->
<?php else : ?>
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=76a0f9124b" language="javascript"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=be80220783" language="javascript"></script>
<!-- end minjs template tags -->
<?php endif; ?>

View File

@@ -1,19 +1,13 @@
.field_row
{
margin: 0 0 10px 0;
}
.field_row label
.field_row label
{
float:left;
width:100px;
width:20%;
text-align:left;
line-height:2.3;
}
.field_row label.wide
{
width:150px;
width:30%;
}
label.required
@@ -25,12 +19,10 @@ label.required
{
float:left;
padding: 3px;
background-color: #f2f2f2;
}
.form_field input, .form_field textarea
{
border: 1px solid #ccc;
padding: 4px;
}
@@ -49,7 +41,7 @@ input
padding: 3px;
}
.clearfix:after
.clearfix:after
{
content: ".";
display: block;

View File

@@ -201,8 +201,7 @@ a.rollover img
}
}
.modal .modal-body
{
max-height: 420px;
.modal-body {
max-height: calc(100vh - 212px);
overflow-y: auto;
}

22
dist/opensourcepos.js vendored
View File

@@ -44816,6 +44816,28 @@ function get_visible_checkbox_ids()
});
return row_ids;
}
dialog_support = (function() {
var submit_form = function(button_id) {
return function(dialog_ref)
{
dialog_support.clicked_button = button_id;
$('#item_form').submit();
dialog_support.hide_dialog = function() {
dialog_ref.close();
};
}
};
return {
hide: function () {},
clicked_button : undefined,
submit: submit_form
};
})();
;(function($) {
function http_s(url)

View File

File diff suppressed because one or more lines are too long

View File

@@ -387,3 +387,25 @@ function get_visible_checkbox_ids()
});
return row_ids;
}
dialog_support = (function() {
var submit_form = function(button_id) {
return function(dialog_ref)
{
dialog_support.clicked_button = button_id;
$('#item_form').submit();
dialog_support.hide_dialog = function() {
dialog_ref.close();
};
}
};
return {
hide: function () {},
clicked_button : undefined,
submit: submit_form
};
})();

View File

@@ -38,7 +38,7 @@
<!-- end js template tags -->
<?php else : ?>
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=76a0f9124b" language="javascript"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=be80220783" language="javascript"></script>
<!-- end minjs template tags -->
<?php endif; ?>