mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-14 12:02:37 -04:00
Don't lose date precision when editing sale or receiving
Extend date validator to allow timestamps as well (sale + receiving) Fix receiving edit
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +1,2 @@
|
||||
dist/ merge=ours
|
||||
application/languages/**/*.php merge=ours
|
||||
application/language/**/*.php merge=ours
|
||||
|
||||
@@ -374,7 +374,7 @@ class Receivings extends Secure_area
|
||||
function save($receiving_id)
|
||||
{
|
||||
$receiving_data = array(
|
||||
'receiving_time' => date('Y-m-d', strtotime($this->input->post('date'))),
|
||||
'receiving_time' => date('Y-m-d H:i:s', strtotime($this->input->post('date'))),
|
||||
'supplier_id' => $this->input->post('supplier_id') ? $this->input->post('supplier_id') : null,
|
||||
'employee_id' => $this->input->post('employee_id'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
|
||||
@@ -602,7 +602,7 @@ class Sales extends Secure_area
|
||||
function save($sale_id)
|
||||
{
|
||||
$sale_data = array(
|
||||
'sale_time' => date('Y-m-d', strtotime($this->input->post('date'))),
|
||||
'sale_time' => date('Y-m-d H:i:s', strtotime($this->input->post('date'))),
|
||||
'customer_id' => $this->input->post('customer_id') ? $this->input->post('customer_id') : NULL,
|
||||
'employee_id' => $this->input->post('employee_id'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<title><?php echo $this->config->item('company').' -- '.$this->lang->line('common_powered_by').' OS Point Of Sale' ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="css/ospos.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="css/ospos_print.css" media="print" />
|
||||
<?php if ($this->input->cookie('debug') == "true" || $this->input->post("debug") == "true") : ?>
|
||||
<?php if ($this->input->cookie('debug') == "true" || $this->input->get("debug") == "true") : ?>
|
||||
<!-- start js template tags -->
|
||||
<script type="text/javascript" src="js/jquery-1.8.3.js" language="javascript"></script>
|
||||
<script type="text/javascript" src="js/jquery.ajax_queue.js" language="javascript"></script>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('recvs_date').':', 'date', array('class'=>'required')); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_input(array('name'=>'date','value'=>date('m/d/Y', strtotime($receiving_info['receiving_time'])), 'id'=>'date'));?>
|
||||
<?php echo form_input(array('name'=>'date','value'=>date('Y-m-d H:i:s', strtotime($receiving_info['receiving_time'])), 'id'=>'date'));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -73,8 +73,15 @@
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$.validator.addMethod("invoice_number", function(value, element)
|
||||
{
|
||||
$.validator.addMethod("time", function (value, element) {
|
||||
var stamp = value.split(" ");
|
||||
var validDate = !/Invalid|NaN/.test(new Date(stamp[0]).toString());
|
||||
var validTime = /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(stamp[1]);
|
||||
return this.optional(element) || (validDate && validTime);
|
||||
}, '<?php echo $this->lang->line('recvs_date_type'); ?>');
|
||||
|
||||
$.validator.addMethod("invoice_number", function(value, element)
|
||||
{
|
||||
var id = $("input[name='receiving_id']").val();
|
||||
|
||||
@@ -83,16 +90,16 @@ $(document).ready(function()
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url($controller_name . "/check_invoice_number")?>',
|
||||
data: {'receiving_id' : id, 'invoice_number' : $(element).val() },
|
||||
success: function(response)
|
||||
success: function(response)
|
||||
{
|
||||
success=response.success;
|
||||
},
|
||||
async:false,
|
||||
dataType: 'json'
|
||||
}).response).success;
|
||||
}).responseText).success;
|
||||
}, '<?php echo $this->lang->line("recvs_invoice_number_duplicate"); ?>');
|
||||
|
||||
$('#date').datePicker({startDate: '<?php echo date("%Y/%M/%d");?>'});
|
||||
$('#date').datePicker({startDate: '<?php echo date("Y-m-d");?>'});
|
||||
|
||||
var format_item = function(row)
|
||||
{
|
||||
@@ -145,7 +152,7 @@ $(document).ready(function()
|
||||
{
|
||||
date: {
|
||||
required:true,
|
||||
date:true
|
||||
time:true
|
||||
},
|
||||
invoice_number: {
|
||||
invoice_number: true
|
||||
@@ -155,7 +162,7 @@ $(document).ready(function()
|
||||
{
|
||||
date: {
|
||||
required: "<?= $this->lang->line('recvs_date_required'); ?>",
|
||||
date: "<?= $this->lang->line('recvs_date_type'); ?>"
|
||||
time: "<?= $this->lang->line('recvs_date_type'); ?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('sales_date').':', 'date', array('class'=>'required')); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_input(array('name'=>'date','value'=>date('m/d/Y', strtotime($sale_info['sale_time'])), 'id'=>'date'));?>
|
||||
<?php echo form_input(array('name'=>'date','value'=>date('Y-m-d H:i:s', strtotime($sale_info['sale_time'])), 'id'=>'date'));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -93,14 +93,14 @@ $(document).ready(function()
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
$.validator.addMethod("invoice_number", function(value, element)
|
||||
$.validator.addMethod("invoice_number", function(value, element)
|
||||
{
|
||||
return JSON.parse($.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
url: '<?php echo site_url($controller_name . "/check_invoice_number")?>',
|
||||
data: {'sale_id' : <?php echo $sale_info['sale_id']; ?>, 'invoice_number' : $(element).val() },
|
||||
success: function(response)
|
||||
success: function(response)
|
||||
{
|
||||
success=response.success;
|
||||
},
|
||||
@@ -108,8 +108,16 @@ $(document).ready(function()
|
||||
dataType: 'json'
|
||||
}).responseText).success;
|
||||
}, '<?php echo $this->lang->line("sales_invoice_number_duplicate"); ?>');
|
||||
|
||||
$('#date').datePicker({startDate: '01/01/1970'});
|
||||
|
||||
$.validator.addMethod("time", function (value, element) {
|
||||
var stamp = value.split(" ");
|
||||
var validDate = !/Invalid|NaN/.test(new Date(stamp[0]).toString());
|
||||
var validTime = /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(stamp[1]);
|
||||
return this.optional(element) || (validDate && validTime);
|
||||
}, '<?php echo $this->lang->line('sales_date_type'); ?>');
|
||||
|
||||
|
||||
$('#date').datePicker({startDate: '<?php echo date('Y-m-d'); ?>'});
|
||||
|
||||
var format_item = function(row)
|
||||
{
|
||||
@@ -165,7 +173,7 @@ $(document).ready(function()
|
||||
date:
|
||||
{
|
||||
required:true,
|
||||
date:true
|
||||
time:true
|
||||
},
|
||||
invoice_number: {
|
||||
invoice_number: true
|
||||
@@ -176,7 +184,7 @@ $(document).ready(function()
|
||||
date:
|
||||
{
|
||||
required: "<?= $this->lang->line('sales_date_required'); ?>",
|
||||
date: "<?= $this->lang->line('sales_date_type'); ?>"
|
||||
time: "<?= $this->lang->line('sales_date_type'); ?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user