Merge pull request #2319 from opensourcepos/fix-attribute-datetime

Fix attribute datetime formatting
This commit is contained in:
FrancescoUK
2019-06-15 10:32:22 +01:00
committed by GitHub
29 changed files with 159 additions and 116 deletions

View File

@@ -484,19 +484,6 @@ class Items extends Secure_Controller
}
$default_pack_name = $this->lang->line('items_default_pack_name');
if ($item_id == -1)
{
// Set low_sell_item_id to -1 for a new item so that when it is saved the item will point to itself for the
// low sell item.
$low_sell_item_id = $this->input->post('low_sell_item_id') == NULL ? -1 : $this->input->post('low_sell_item_id');
}
else
{
// On an existing item where the low sell item is not prompted for always force the item_id as the low sell item Id
$low_sell_item_id = $this->input->post('low_sell_item_id') == NULL ? $item_id : $this->input->post('low_sell_item_id');
}
//Save item data
$item_data = array(
'name' => $this->input->post('name'),
@@ -514,7 +501,7 @@ class Items extends Secure_Controller
'is_serialized' => $this->input->post('is_serialized') != NULL,
'qty_per_pack' => $this->input->post('qty_per_pack') == NULL ? 1 : $this->input->post('qty_per_pack'),
'pack_name' => $this->input->post('pack_name') == NULL ? $default_pack_name : $this->input->post('pack_name'),
'low_sell_item_id' => $low_sell_item_id,
'low_sell_item_id' => $this->input->post('low_sell_item_id') == NULL ? $item_id : $this->input->post('low_sell_item_id'),
'deleted' => $this->input->post('is_deleted') != NULL,
'hsn_code' => $this->input->post('hsn_code') == NULL ? '' : $this->input->post('hsn_code')
);

View File

@@ -1345,6 +1345,7 @@ class Reports extends Secure_Controller
}
$attribute_values = (isset($drow['attribute_values'])) ? $drow['attribute_values'] : '';
$attribute_values = (isset($drow['attribute_dtvalues'])) ? $attribute_values . '|' . $drow['attribute_dtvalues'] : $attribute_values;
$attribute_values = expand_attribute_values($definition_names, $attribute_values);
$details_data[$row['sale_id']][] = $this->xss_clean(array_merge(array(
@@ -1462,6 +1463,8 @@ class Reports extends Secure_Controller
}
$attribute_values = (isset($drow['attribute_values'])) ? $drow['attribute_values'] : '';
$attribute_values = (isset($drow['attribute_dtvalues'])) ? $attribute_values . '|' . $drow['attribute_dtvalues'] : $attribute_values;
$attribute_values = expand_attribute_values($definition_names, $attribute_values);
$details_data[$row['receiving_id']][] = $this->xss_clean(array_merge(array(
@@ -1471,7 +1474,6 @@ class Reports extends Secure_Controller
$quantity_purchased,
to_currency($drow['total']),
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])), $attribute_values));
}
}

View File

@@ -3,7 +3,7 @@
const DEFAULT_LANGUAGE = 'english';
const DEFAULT_LANGUAGE_CODE = 'en-US';
define('DEFAULT_DATETIME', mktime(0, 0, 0, 1, 1, 2010));
define('DEFAULT_DATE', mktime(0, 0, 0, 1, 1, 2010));
/**
* Currency locale helper
@@ -310,11 +310,11 @@ function tax_decimals()
return $config->item('tax_decimals') ? $config->item('tax_decimals') : 0;
}
function to_datetime($datetime)
function to_date($date)
{
$config = get_instance()->config;
return date($config->item('dateformat') . ' ' . $config->item('timeformat'), $datetime);
return date($config->item('dateformat'), $date);
}
function to_currency($number)
@@ -457,6 +457,50 @@ function dateformat_momentjs($php_format)
return strtr($php_format, $SYMBOLS_MATCHING);
}
function dateformat_mysql()
{
$config = get_instance()->config;
$php_format = $config->item('dateformat');
$SYMBOLS_MATCHING = array(
// Day
'd' => '%d',
'D' => '%a',
'j' => '%e',
'l' => '%W',
'N' => '',
'S' => '',
'w' => '',
'z' => '',
// Week
'W' => '',
// Month
'F' => '',
'm' => '%m',
'M' => '%b',
'n' => '%c',
't' => '',
// Year
'L' => '',
'o' => '',
'Y' => '%Y',
'y' => '%y',
// Time
'a' => '',
'A' => '%p',
'B' => '',
'g' => '%l',
'G' => '%k',
'h' => '%H',
'H' => '%k',
'i' => '%i',
's' => '%S',
'u' => '%f'
);
return strtr($php_format, $SYMBOLS_MATCHING);
}
function dateformat_bootstrap($php_format)
{
$SYMBOLS_MATCHING = array(
@@ -498,11 +542,6 @@ function dateformat_bootstrap($php_format)
return strtr($php_format, $SYMBOLS_MATCHING);
}
function valid_datetime($datetime)
{
return preg_match('/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])(?:( [0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/', $datetime);
}
function valid_decimal($decimal)
{
return preg_match('/^(\d*\.)?\d+$/', $decimal);

View File

@@ -90,7 +90,7 @@ function get_sale_data_row($sale)
$row = array (
'sale_id' => $sale->sale_id,
'sale_time' => date($CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($sale->sale_time)),
'sale_time' => to_date(strtotime($sale->sale_time)),
'customer_name' => $sale->customer_name,
'amount_due' => to_currency($sale->amount_due),
'amount_tendered' => to_currency($sale->amount_tendered),
@@ -444,6 +444,7 @@ function get_item_data_row($item)
);
$attribute_values = (property_exists($item, 'attribute_values')) ? $item->attribute_values : "";
$attribute_values = (property_exists($item, 'attribute_dtvalues')) ? $attribute_values . '|' . $item->attribute_dtvalues : $attribute_values;
return $columns + expand_attribute_values($definition_names, $attribute_values) + $icons;
}
@@ -529,15 +530,22 @@ function expand_attribute_values($definition_names, $attribute_values)
$indexed_values = array();
foreach($values as $attribute_value)
{
$exploded_value = explode(':', $attribute_value);
$indexed_values[$exploded_value[0]] = isset($exploded_value[1]) ? $exploded_value[1] : '-';
$exploded_value = explode('_', $attribute_value);
if (sizeof($exploded_value) > 1)
{
$indexed_values[$exploded_value[0]] = $exploded_value[1];
}
}
$attribute_values = array();
foreach($definition_names as $definition_id => $definition_name)
{
$attribute_value = isset($indexed_values[$definition_id]) ? $indexed_values[$definition_id] : '-';
$attribute_values["$definition_id"] = $attribute_value;
if (isset($indexed_values[$definition_id]))
{
$attribute_value = $indexed_values[$definition_id];
$attribute_values["$definition_id"] = $attribute_value;
}
}
return $attribute_values;
}
@@ -651,7 +659,7 @@ function get_expenses_data_row($expense)
$controller_name = strtolower(get_class($CI));
return array (
'expense_id' => $expense->expense_id,
'date' => date($CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($expense->date)),
'date' => to_date(strtotime($expense->date)),
'supplier_name' => $expense->supplier_name,
'supplier_tax_code' => $expense->supplier_tax_code,
'amount' => to_currency($expense->amount),
@@ -742,11 +750,11 @@ function get_cash_up_data_row($cash_up)
$controller_name = strtolower(get_class($CI));
return array (
'cashup_id' => $cash_up->cashup_id,
'open_date' => date($CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($cash_up->open_date)),
'open_date' => to_date(strtotime($cash_up->open_date)),
'open_employee_id' => $cash_up->open_first_name . ' ' . $cash_up->open_last_name,
'open_amount_cash' => to_currency($cash_up->open_amount_cash),
'transfer_amount_cash' => to_currency($cash_up->transfer_amount_cash),
'close_date' => date($CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($cash_up->close_date)),
'close_date' => to_date(strtotime($cash_up->close_date)),
'close_employee_id' => $cash_up->close_first_name . ' ' . $cash_up->close_last_name,
'closed_amount_cash' => to_currency($cash_up->closed_amount_cash),
'note' => $cash_up->note ? '<span class="glyphicon glyphicon-ok"></span>' : '<span class="glyphicon glyphicon-remove"></span>',

View File

@@ -231,6 +231,8 @@ class Receiving_lib
$receiving_quantity = $item_info->receiving_quantity;
}
$attribute_links = $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS)->row_object();
$item = array($insertkey => array(
'item_id' => $item_id,
'item_location' => $item_location,
@@ -240,7 +242,8 @@ class Receiving_lib
'name' => $item_info->name,
'description' => $description != NULL ? $description: $item_info->description,
'serialnumber' => $serialnumber != NULL ? $serialnumber: '',
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS),
'attribute_values' => $attribute_links->attribute_values,
'attribute_dtvalues' => $attribute_links->attribute_dtvalues,
'allow_alt_description' => $item_info->allow_alt_description,
'is_serialized' => $item_info->is_serialized,
'quantity' => $quantity,

View File

@@ -719,6 +719,8 @@ class Sale_lib
return FALSE;
}
$price = 0.00;
$cost_price = 0.00;
$item_id = $item_info->item_id;
$item_type = $item_info->item_type;
$stock_type = $item_info->stock_type;
@@ -745,16 +747,7 @@ class Sale_lib
$price = $item_info->unit_price;
$cost_price = $item_info->cost_price;
}
else
{
$price = 0.00;
$cost_price = 0.00;
}
}
else
{
$price= 0.00;
$cost_price = 0.00;
}
if($price_override != NULL)
@@ -840,6 +833,7 @@ class Sale_lib
$item_info->name .= NAME_SEPARATOR . $item_info->pack_name;
}
$attribute_links = $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES)->row_object();
//Item already exists and is not serialized, add to quantity
if(!$itemalreadyinsale || $item_info->is_serialized)
@@ -851,7 +845,8 @@ class Sale_lib
'line' => $insertkey,
'name' => $item_info->name,
'item_number' => $item_info->item_number,
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES),
'attribute_values' => $attribute_links->attribute_values,
'attribute_dtvalues' => $attribute_links->attribute_dtvalues,
'description' => $description != NULL ? $description : $item_info->description,
'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
'allow_alt_description' => $item_info->allow_alt_description,

View File

@@ -1,6 +1,6 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'libraries/tokens/Token.php');
require_once(APPPATH . 'models/tokens/Token.php');
/**
* Token library

View File

@@ -0,0 +1,20 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Migration_fix_attribute_datetime extends CI_Migration
{
public function __construct()
{
parent::__construct();
}
public function up()
{
execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_fix_attribute_datetime.sql');
}
public function down()
{
}
}
?>

View File

@@ -0,0 +1 @@
ALTER TABLE `ospos_attribute_values` CHANGE `attribute_datetime` `attribute_date` DATE DEFAULT NULL;

View File

@@ -3,10 +3,10 @@
define('GROUP', 'GROUP');
define('DROPDOWN', 'DROPDOWN');
define('DECIMAL', 'DECIMAL');
define('DATETIME', 'DATETIME');
define('DATE', 'DATE');
define('TEXT', 'TEXT');
const DEFINITION_TYPES = [GROUP, DROPDOWN, DECIMAL, TEXT, DATETIME];
const DEFINITION_TYPES = [GROUP, DROPDOWN, DECIMAL, TEXT, DATE];
/**
* Attribute class
@@ -105,9 +105,9 @@ class Attribute extends CI_Model
*/
public function search($search, $rows = 0, $limit_from = 0, $sort = 'definition.definition_name', $order = 'asc')
{
$this->db->select('definition_group.definition_name AS definition_group, definition.*');
$this->db->select('parent_definition.definition_name AS definition_group, definition.*');
$this->db->from('attribute_definitions AS definition');
$this->db->join('attribute_definitions AS definition_group', 'definition_group.definition_id = definition.definition_fk', 'left');
$this->db->join('attribute_definitions AS parent_definition', 'parent_definition.definition_id = definition.definition_fk', 'left');
$this->db->group_start();
$this->db->like('definition.definition_name', $search);
@@ -270,11 +270,11 @@ class Attribute extends CI_Model
$this->db->where('definition_id',$definition);
$success = TRUE;
if($to === DATETIME)
if($to === DATE)
{
foreach($this->db->get()->result_array() as $row)
{
if(valid_datetime($row['attribute_value']) === FALSE)
if(valid_date($row['attribute_value']) === FALSE)
{
log_message('ERROR', 'item_id: ' . $row['item_id'] . ' with attribute_value: ' . $row['attribute_value'] . ' cannot be converted to datetime');
$success = FALSE;
@@ -303,9 +303,9 @@ class Attribute extends CI_Model
//From TEXT to DATETIME
if($from_type === TEXT)
{
if($to_type === DATETIME || $to_type === DECIMAL)
if($to_type === DATE || $to_type === DECIMAL)
{
$field = ($to_type === DATETIME ? 'attribute_datetime' : 'attribute_decimal');
$field = ($to_type === DATETIME ? 'attribute_date' : 'attribute_decimal');
if($this->check_data_validity($definition_id, $from_type, $to_type))
{
@@ -452,7 +452,9 @@ class Attribute extends CI_Model
public function get_link_values($item_id, $sale_receiving_fk, $id, $definition_flags)
{
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR ", ") AS attribute_values, GROUP_CONCAT(attribute_datetime SEPARATOR ", ") AS attribute_datetimevalues');
$format = $this->db->escape(dateformat_mysql());
$this->db->select("GROUP_CONCAT(attribute_value SEPARATOR ', ') AS attribute_values");
$this->db->select("GROUP_CONCAT(DATE_FORMAT(attribute_date, $format) SEPARATOR ', ') AS attribute_dtvalues");
$this->db->from('attribute_links');
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id');
$this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id');
@@ -471,23 +473,7 @@ class Attribute extends CI_Model
$this->db->where('item_id', (int) $item_id);
$this->db->where('definition_flags & ', $definition_flags);
$results = $this->db->get();
if ($results->num_rows() > 0)
{
$row_object = $results->row_object();
$datetime_values = explode(', ', $row_object->attribute_datetimevalues);
$attribute_values = array();
foreach (array_filter($datetime_values) as $datetime_value)
{
$attribute_values[] = to_datetime(strtotime($datetime_value));
}
return implode(',', $attribute_values) . $row_object->attribute_values;
}
return "";
return $this->db->get();
}
public function get_attribute_value($item_id, $definition_id)
@@ -541,38 +527,29 @@ class Attribute extends CI_Model
{
if($definition_type == TEXT || $definition_type == DROPDOWN)
{
$attribute_id_check = $this->value_exists($attribute_value);
if(empty($attribute_id_check))
$attribute_id = $this->value_exists($attribute_value);
if(empty($attribute_id))
{
$this->db->insert('attribute_values', array('attribute_value' => $attribute_value));
$attribute_id = $this->db->insert_id();
}
else
{
$attribute_id = $attribute_id_check;
}
}
else if($definition_type == DECIMAL)
{
$this->db->insert('attribute_values', array('attribute_decimal' => $attribute_value));
$attribute_id = $this->db->insert_id();
}
else
{
$this->db->insert('attribute_values', array('attribute_datetime' => date('Y-m-d H:i:s', strtotime($attribute_value))));
$attribute_id = $this->db->insert_id();
$this->db->insert('attribute_values', array('attribute_date' => date('Y-m-d', strtotime($attribute_value))));
}
$attribute_id = $attribute_id ? $attribute_id : $this->db->insert_id();
$this->db->insert('attribute_links', array(
'attribute_id' => empty($attribute_id) ? NULL : $attribute_id,
'item_id' => empty($item_id) ? NULL : $item_id,
'definition_id' => $definition_id));
}
else
{
$this->db->where('attribute_id', $attribute_id);
$this->db->update('attribute_values', array('attribute_value' => $attribute_value));
}
$this->db->trans_complete();

View File

@@ -192,7 +192,9 @@ class Item extends CI_Model
if ($attributes_enabled)
{
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$format = $this->db->escape(dateformat_mysql());
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\'_\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_date, $format)) SEPARATOR '|') AS attribute_dtvalues");
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id IS NULL AND attribute_links.sale_id IS NULL AND definition_id IN (' . implode(',', $filters['definition_ids']) . ')', 'left');
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
}
@@ -279,6 +281,7 @@ class Item extends CI_Model
{
$this->db->select('items.*');
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR \'|\') AS attribute_values');
$this->db->select('GROUP_CONCAT(attribute_date SEPARATOR \'|\') AS attribute_dtvalues');
$this->db->select('suppliers.company_name');
$this->db->from('items');
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
@@ -376,8 +379,8 @@ class Item extends CI_Model
{
$this->db->select('items.*');
$this->db->select('company_name');
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$this->db->select('items.category');
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\'_\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\'_\', definition_id, attribute_date) ORDER BY definition_id SEPARATOR \'|\') AS attribute_dtvalues');
$this->db->select('quantity');
$this->db->from('items');
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');

View File

@@ -102,7 +102,9 @@ class Detailed_receivings extends Report
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
if (count($inputs['definition_ids']) > 0)
{
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$format = $this->db->escape(dateformat_mysql());
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, attribute_value) ORDER BY definition_id SEPARATOR '|') AS attribute_values");
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_date, $format)) SEPARATOR '|') AS attribute_dtvalues");
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id = receivings_items_temp.receiving_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
$this->db->group_by('receivings_items_temp.receiving_id, receivings_items_temp.item_id');

View File

@@ -148,7 +148,9 @@ class Detailed_sales extends Report
$this->db->from('sales_items_temp');
if (count($inputs['definition_ids']) > 0)
{
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
$format = $this->db->escape(dateformat_mysql());
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, attribute_value) ORDER BY definition_id SEPARATOR '|') AS attribute_values");
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_date, $format)) SEPARATOR '|') AS attribute_dtvalues");
$this->db->join('attribute_links', 'attribute_links.item_id = sales_items_temp.item_id AND attribute_links.sale_id = sales_items_temp.sale_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
$this->db->group_by('sales_items_temp.sale_id, sales_items_temp.item_id');

View File

@@ -1,13 +1,13 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'libraries/tokens/Token.php');
require_once(APPPATH . 'libraries/tokens/Token_customer.php');
require_once(APPPATH . 'libraries/tokens/Token_invoice_count.php');
require_once(APPPATH . 'libraries/tokens/Token_invoice_sequence.php');
require_once(APPPATH . 'libraries/tokens/Token_quote_sequence.php');
require_once(APPPATH . 'libraries/tokens/Token_work_order_sequence.php');
require_once(APPPATH . 'libraries/tokens/Token_suspended_invoice_count.php');
require_once(APPPATH . 'libraries/tokens/Token_year_invoice_count.php');
require_once(APPPATH . 'models/tokens/Token.php');
require_once(APPPATH . 'models/tokens/Token_customer.php');
require_once(APPPATH . 'models/tokens/Token_invoice_count.php');
require_once(APPPATH . 'models/tokens/Token_invoice_sequence.php');
require_once(APPPATH . 'models/tokens/Token_quote_sequence.php');
require_once(APPPATH . 'models/tokens/Token_work_order_sequence.php');
require_once(APPPATH . 'models/tokens/Token_suspended_invoice_count.php');
require_once(APPPATH . 'models/tokens/Token_year_invoice_count.php');
/**
* Token class

View File

@@ -82,14 +82,14 @@ $(document).ready(function()
{
var definition_type = $("#definition_type option:selected").text();
if(definition_type == "DATETIME" || (definition_type == "GROUP" && !is_new) || definition_type == "DECIMAL")
if(definition_type == "DATE" || (definition_type == "GROUP" && !is_new) || definition_type == "DECIMAL")
{
$('#definition_type').prop("disabled",true);
}
else if(definition_type == "DROPDOWN")
{
$("#definition_type option:contains('GROUP')").hide();
$("#definition_type option:contains('DATETIME')").hide();
$("#definition_type option:contains('DATE')").hide();
$("#definition_type option:contains('DECIMAL')").hide();
}
else
@@ -181,9 +181,13 @@ $(document).ready(function()
});
$.validator.addMethod('valid_chars', function(value, element) {
return value.match(/(\||:)/g) == null;
return value.match(/(\||_)/g) == null;
}, "<?php echo $this->lang->line('attributes_attribute_value_invalid_chars'); ?>");
$('form').bind('submit', function () {
$(this).find(':input').prop('disabled', false);
});
$('#attribute_form').validate($.extend({
submitHandler: function(form)
{
@@ -217,4 +221,4 @@ $(document).ready(function()
}
}, form_support.error));
});
</script>
</script>

View File

@@ -22,12 +22,12 @@ foreach($definition_values as $definition_id => $definition_value)
echo form_hidden("attribute_ids[$definition_id]", $definition_value['attribute_id']);
$attribute_value = $definition_value['attribute_value'];
if ($definition_value['definition_type'] == DATETIME)
if ($definition_value['definition_type'] == DATE)
{
$value = (empty($attribute_value) || empty($attribute_value->attribute_datetime)) ? DEFAULT_DATETIME : strtotime($attribute_value->attribute_datetime);
$value = (empty($attribute_value) || empty($attribute_value->attribute_date)) ? DEFAULT_DATE : strtotime($attribute_value->attribute_date);
echo form_input(array(
'name' => "attribute_links[$definition_id]",
'value' => to_datetime($value),
'value' => to_date($value),
'class' => 'form-control input-sm datetime',
'data-definition-id' => $definition_id,
'readonly' => 'true'));
@@ -59,7 +59,7 @@ foreach($definition_values as $definition_id => $definition_value)
<script type="text/javascript">
(function() {
<?php $this->load->view('partial/datepicker_locale'); ?>
<?php $this->load->view('partial/datepicker_locale', array('config' => '{ minView: 2, format: "'.dateformat_bootstrap($this->config->item('dateformat') . '"}'))); ?>
var enable_delete = function() {
$('.remove_attribute_btn').click(function() {

View File

@@ -176,7 +176,7 @@
'name'=>'date',
'id'=>'datetime',
'class'=>'form-control input-sm',
'value'=>to_datetime(strtotime($person_info->date)),
'value'=>to_date(strtotime($person_info->date)),
'readonly'=>'true')
); ?>
</div>

View File

@@ -17,7 +17,7 @@
<?php echo form_input(array(
'name'=>'date',
'class'=>'form-control input-sm datetime',
'value'=>to_datetime(strtotime($expenses_info->date)),
'value'=>to_date(strtotime($expenses_info->date)),
'readonly'=>'readonly')
);?>
</div>

View File

@@ -1,9 +1,9 @@
<?php $this->lang->load('calendar'); $this->lang->load('date'); ?>
var pickerconfig = function(start) {
return {
format: "<?php echo dateformat_bootstrap($this->config->item('dateformat')) . ' ' . dateformat_bootstrap($this->config->item('timeformat'));?>",
startDate: start || "<?php echo to_datetime(DEFAULT_DATETIME); ?>",
var pickerconfig = function(config) {
return $.extend({
format: "<?php echo dateformat_bootstrap($this->config->item('dateformat'));?>",
startDate: "<?php echo to_date(DEFAULT_DATE); ?>",
<?php
$t = $this->config->item('timeformat');
$m = $t[strlen($t)-1];
@@ -26,7 +26,7 @@ var pickerconfig = function(start) {
todayHighlight: true,
bootcssVer: 3,
language: "<?php echo current_language_code(); ?>"
};
}, <?php echo isset($config) ? $config : '{}' ?>);
};
$.fn.datetimepicker.dates['<?php echo $this->config->item("language"); ?>'] = {

View File

@@ -136,7 +136,7 @@ if (isset($success))
<td><?php echo anchor($controller_name."/delete_item/$line", '<span class="glyphicon glyphicon-trash"></span>');?></td>
<td><?php echo $item['item_number']; ?></td>
<td style="align:center;">
<?php echo $item['name'] . ' ' . $item['attribute_values']; ?><br /> <?php echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; ?>
<?php echo $item['name'] . ' '. implode(' ', array($item['attribute_values'], $item['attribute_dtvalues'])); ?><br /> <?php echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; ?>
<?php echo form_hidden('location', $item['item_location']); ?>
</td>

View File

@@ -12,7 +12,7 @@
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('sales_date'), 'date', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<?php echo form_input(array('name'=>'date','value'=>to_datetime(strtotime($sale_info['sale_time'])), 'class'=>'datetime form-control input-sm'));?>
<?php echo form_input(array('name'=>'date','value'=>to_date(strtotime($sale_info['sale_time'])), 'class'=>'datetime form-control input-sm'));?>
</div>
</div>

View File

@@ -156,7 +156,7 @@ if(isset($success))
?>
<td><?php echo $item['item_number']; ?></td>
<td style="align: center;">
<?php echo $item['name'] . ' ' . $item['attribute_values']; ?>
<?php echo $item['name'] . ' '. implode(' ', array($item['attribute_values'], $item['attribute_dtvalues'])); ?>
<br/>
<?php if ($item['stock_type'] == '0'): echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; endif; ?>
</td>