mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 08:20:54 -04:00
Bootstrapify date_input for reports (#116). Form alignment to be
improved, basic version working Move common jquery validation settings to base object
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
class DateFormatter {
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Matches each symbol of PHP date format standard
|
||||
* with jQuery equivalent codeword
|
||||
@@ -67,6 +71,50 @@ function dateformat_jquery($php_format)
|
||||
return $jqueryui_format;
|
||||
}
|
||||
|
||||
function dateformat_momentjs($php_format)
|
||||
{
|
||||
$SYMBOLS_MATCHING = array(
|
||||
'd' => 'DD',
|
||||
'D' => 'ddd',
|
||||
'j' => 'D',
|
||||
'l' => 'dddd',
|
||||
'N' => 'E',
|
||||
'S' => 'o',
|
||||
'w' => 'e',
|
||||
'z' => 'DDD',
|
||||
'W' => 'W',
|
||||
'F' => 'MMMM',
|
||||
'm' => 'MM',
|
||||
'M' => 'MMM',
|
||||
'n' => 'M',
|
||||
't' => '', // no equivalent
|
||||
'L' => '', // no equivalent
|
||||
'o' => 'YYYY',
|
||||
'Y' => 'YYYY',
|
||||
'y' => 'YY',
|
||||
'a' => 'a',
|
||||
'A' => 'A',
|
||||
'B' => '', // no equivalent
|
||||
'g' => 'h',
|
||||
'G' => 'H',
|
||||
'h' => 'hh',
|
||||
'H' => 'HH',
|
||||
'i' => 'mm',
|
||||
's' => 'ss',
|
||||
'u' => 'SSS',
|
||||
'e' => 'zz', // deprecated since version $1.6.0 of moment.js
|
||||
'I' => '', // no equivalent
|
||||
'O' => '', // no equivalent
|
||||
'P' => '', // no equivalent
|
||||
'T' => '', // no equivalent
|
||||
'Z' => '', // no equivalent
|
||||
'c' => '', // no equivalent
|
||||
'r' => '', // no equivalent
|
||||
'U' => 'X'
|
||||
);
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
}
|
||||
|
||||
function dateformat_bootstrap($php_format)
|
||||
{
|
||||
$SYMBOLS_MATCHING = array(
|
||||
|
||||
@@ -74,9 +74,7 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
first_name: "required",
|
||||
last_name: "required",
|
||||
|
||||
@@ -168,9 +168,7 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
first_name: "required",
|
||||
last_name: "required",
|
||||
|
||||
@@ -87,8 +87,6 @@ $(document).ready(function()
|
||||
selected_person_id && autocompleter.val(selected_person_id);
|
||||
submit_form.call(form, selected_person);
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
{
|
||||
giftcard_number:
|
||||
|
||||
@@ -109,8 +109,6 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
{
|
||||
name:"required",
|
||||
|
||||
@@ -333,9 +333,6 @@
|
||||
});
|
||||
event.preventDefault();
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
errorClass: "has-error",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
{
|
||||
name:"required",
|
||||
|
||||
@@ -182,10 +182,7 @@ $(document).ready(function()
|
||||
}
|
||||
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
errorClass: "has-error",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
unit_price:
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=f940457590"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=38ca46b12e" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3bf78bd284" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -156,9 +156,7 @@ $(document).ready(function()
|
||||
selected_supplier_id && autocompleter.val(selected_supplier_id);
|
||||
submit_form.call(form, selected_supplier);
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
invoice_number: {
|
||||
invoice_number: true
|
||||
|
||||
@@ -6,74 +6,67 @@ if(isset($error))
|
||||
echo "<div class='alert alert-dismissible alert-danger'>".$error."</div>";
|
||||
}
|
||||
?>
|
||||
<?php echo form_label($this->lang->line('reports_date_range'), 'report_date_range_label', array('class'=>'required')); ?>
|
||||
<div id='report_date_range_simple'>
|
||||
<input type="radio" name="report_type" id="simple_radio" value='simple' checked='checked'/>
|
||||
<?php echo form_dropdown('report_date_range_simple',$report_date_range_simple, '', 'id="report_date_range_simple"'); ?>
|
||||
</div>
|
||||
|
||||
<div id='report_date_range_complex'>
|
||||
<input type="radio" name="report_type" id="complex_radio" value='complex' />
|
||||
<span>
|
||||
<?php echo form_dropdown('start_month',$months, $selected_month, 'id="start_month"'); ?>
|
||||
<?php echo form_dropdown('start_day',$days, $selected_day, 'id="start_day"'); ?>
|
||||
<?php echo form_dropdown('start_year',$years, $selected_year, 'id="start_year"'); ?>
|
||||
-
|
||||
<?php echo form_dropdown('end_month',$months, $selected_month, 'id="end_month"'); ?>
|
||||
<?php echo form_dropdown('end_day',$days, $selected_day, 'id="end_day"'); ?>
|
||||
<?php echo form_dropdown('end_year',$years, $selected_year, 'id="end_year"'); ?>
|
||||
</span>
|
||||
<?php
|
||||
if (isset($discount_input)) {
|
||||
?>
|
||||
<div>
|
||||
<span>
|
||||
<?php echo $this->lang->line('reports_discount_prefix') .' ' .form_input(array(
|
||||
'name'=>'selected_discount',
|
||||
'id'=>'selected_discount',
|
||||
'value'=>'0')). ' '. $this->lang->line('reports_discount_suffix')
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if($mode == 'sale')
|
||||
{
|
||||
?>
|
||||
<?php echo form_label($this->lang->line('reports_sale_type'), 'reports_sale_type_label', array('class'=>'required')); ?>
|
||||
<div id='report_sale_type'>
|
||||
<?php echo form_dropdown('sale_type', array('all' => $this->lang->line('reports_all'),
|
||||
'sales' => $this->lang->line('reports_sales'),
|
||||
'returns' => $this->lang->line('reports_returns')), 'all', 'id="input_type"'); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
elseif($mode == 'receiving')
|
||||
{
|
||||
?>
|
||||
<?php echo form_label($this->lang->line('reports_receiving_type'), 'reports_receiving_type_label', array('class'=>'required')); ?>
|
||||
<div id='report_receiving_type'>
|
||||
<?php echo form_dropdown('receiving_type', array('all' => $this->lang->line('reports_all'),
|
||||
'receiving' => $this->lang->line('reports_receivings'),
|
||||
'returns' => $this->lang->line('reports_returns'),
|
||||
'requisitions' => $this->lang->line('reports_requisitions')), 'all', 'id="input_type"'); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if (!empty($stock_locations) && count($stock_locations) > 1)
|
||||
{
|
||||
?>
|
||||
<?php echo form_label($this->lang->line('reports_stock_location'), 'reports_stock_location_label', array('class'=>'required')); ?>
|
||||
<div id='report_stock_location'>
|
||||
<?php echo form_dropdown('stock_location',$stock_locations,'all','id="location_id"'); ?>
|
||||
<?php echo form_open('#', array('id'=>'item_form', 'enctype'=>'multipart/form-data', 'class' => 'form-horizontal')); ?>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_date_range'), 'report_date_range_label', array('class'=>'control-label col-xs-1 required')); ?>
|
||||
|
||||
<div class="col-xs-4">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="report_type" id="simple_radio" value='simple' checked='checked'/>
|
||||
<?php echo form_dropdown('report_date_range_simple',$report_date_range_simple, '', 'id="report_date_range_simple" class="form-control"'); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="report_type" id="complex_radio" value='complex' />
|
||||
<?php echo form_input(array('name'=>'daterangepicker', 'class'=>'form-control input-sm', 'id'=>'daterangepicker')); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if($mode == 'sale')
|
||||
{
|
||||
?>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_sale_type'), 'reports_sale_type_label', array('class'=>'required control-label col-xs-1')); ?>
|
||||
<div id='report_sale_type' class="col-xs-4">
|
||||
<?php echo form_dropdown('sale_type', array('all' => $this->lang->line('reports_all'),
|
||||
'sales' => $this->lang->line('reports_sales'),
|
||||
'returns' => $this->lang->line('reports_returns')), 'all', 'id="input_type" class="form-control"'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
elseif($mode == 'receiving')
|
||||
{
|
||||
?>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_receiving_type'), 'reports_receiving_type_label', array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div id='report_receiving_type' class="col-xs-4">
|
||||
<?php echo form_dropdown('receiving_type', array('all' => $this->lang->line('reports_all'),
|
||||
'receiving' => $this->lang->line('reports_receivings'),
|
||||
'returns' => $this->lang->line('reports_returns'),
|
||||
'requisitions' => $this->lang->line('reports_requisitions')), 'all', 'id="input_type" class="form-control"'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if (!empty($stock_locations) && count($stock_locations) > 1)
|
||||
{
|
||||
?>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_stock_location'), 'reports_stock_location_label', array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div id='report_stock_location' class="col-xs-4">
|
||||
<?php echo form_dropdown('stock_location',$stock_locations,'all','id="location_id" class="form-control"'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo form_button(array(
|
||||
'name'=>'generate_report',
|
||||
@@ -83,11 +76,25 @@ echo form_button(array(
|
||||
);
|
||||
?>
|
||||
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<?php $this->load->view("partial/footer"); ?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
var start_date, end_date;
|
||||
$('#daterangepicker').daterangepicker({
|
||||
locale: {
|
||||
format: '<?php echo dateformat_momentjs($this->config->item("dateformat"))?>'
|
||||
},
|
||||
startDate: "<?php echo date($this->config->item('dateformat'), time());?>",
|
||||
endDate: "<?php echo date($this->config->item('dateformat'), time());?>"
|
||||
}).on('apply.daterangepicker', function(ev, picker) {
|
||||
start_date = picker.startDate.format('MM-DD-YYYY');
|
||||
end_date = picker.endDate.format('MM-DD-YYYY');
|
||||
});
|
||||
|
||||
$("#generate_report").click(function()
|
||||
{
|
||||
var input_type = $("#input_type").val();
|
||||
@@ -99,8 +106,6 @@ $(document).ready(function()
|
||||
}
|
||||
else
|
||||
{
|
||||
var start_date = $("#start_year").val()+'-'+$("#start_month").val()+'-'+$('#start_day').val();
|
||||
var end_date = $("#end_year").val()+'-'+$("#end_month").val()+'-'+$('#end_day').val();
|
||||
if(!input_type)
|
||||
{
|
||||
location += '/'+start_date + '/'+ end_date;
|
||||
|
||||
@@ -170,9 +170,7 @@ $(document).ready(function()
|
||||
selected_customer_id && autocompleter.val(selected_customer_id);
|
||||
submit_form.call(form, selected_customer);
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
invoice_number:
|
||||
{
|
||||
|
||||
@@ -61,10 +61,7 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
},
|
||||
errorLabelContainer: "#error_message_box",
|
||||
errorClass: "has-error",
|
||||
wrapper: "li",
|
||||
rules:
|
||||
rules:
|
||||
{
|
||||
company_name: "required",
|
||||
first_name: "required",
|
||||
|
||||
3
dist/opensourcepos.js
vendored
3
dist/opensourcepos.js
vendored
@@ -52202,6 +52202,9 @@ dialog_support = (function() {
|
||||
init: init,
|
||||
submit: submit,
|
||||
error: {
|
||||
errorClass: "has-error",
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
highlight: function (e)
|
||||
{
|
||||
$(e).closest('.form-group').addClass('has-error');
|
||||
|
||||
2
dist/opensourcepos.min.js
vendored
2
dist/opensourcepos.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -465,6 +465,9 @@ dialog_support = (function() {
|
||||
init: init,
|
||||
submit: submit,
|
||||
error: {
|
||||
errorClass: "has-error",
|
||||
errorLabelContainer: "#error_message_box",
|
||||
wrapper: "li",
|
||||
highlight: function (e)
|
||||
{
|
||||
$(e).closest('.form-group').addClass('has-error');
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<!-- end mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=38ca46b12e" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3bf78bd284" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user