mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-06 14:54:32 -04:00
Fix last stock_locations config quirks
This commit is contained in:
@@ -80,31 +80,26 @@ class Stock_locations extends CI_Model
|
||||
{
|
||||
if (!$this->exists($location_id))
|
||||
{
|
||||
if($this->db->insert('stock_locations',$location_data))
|
||||
{
|
||||
$location_name = $location_data['location_name'];
|
||||
$this->db->trans_start();
|
||||
$location_data = array('location_name'=>$location_name,'deleted'=>0);
|
||||
$this->db->insert('stock_locations',$location_data);
|
||||
$location_id = $this->db->insert_id();
|
||||
|
||||
$this->_insert_new_permission('items', $location_id, $location_name);
|
||||
$this->_insert_new_permission('sales', $location_id, $location_name);
|
||||
$this->_insert_new_permission('receivings', $location_id, $location_name);
|
||||
$location_name = $location_data['location_name'];
|
||||
$this->db->trans_start();
|
||||
$location_data = array('location_name'=>$location_name,'deleted'=>0);
|
||||
$this->db->insert('stock_locations',$location_data);
|
||||
$location_id = $this->db->insert_id();
|
||||
|
||||
$this->_insert_new_permission('items', $location_id, $location_name);
|
||||
$this->_insert_new_permission('sales', $location_id, $location_name);
|
||||
$this->_insert_new_permission('receivings', $location_id, $location_name);
|
||||
|
||||
|
||||
// insert quantities for existing items
|
||||
$items = $this->Item->get_all();
|
||||
foreach ($items->result_array() as $item)
|
||||
{
|
||||
$quantity_data = array('item_id' => $item['item_id'], 'location_id' => $location_id, 'quantity' => 0);
|
||||
$this->db->insert('item_quantities', $quantity_data);
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
// insert quantities for existing items
|
||||
$items = $this->Item->get_all();
|
||||
foreach ($items->result_array() as $item)
|
||||
{
|
||||
$quantity_data = array('item_id' => $item['item_id'], 'location_id' => $location_id, 'quantity' => 0);
|
||||
$this->db->insert('item_quantities', $quantity_data);
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->where('location_id', $location_id);
|
||||
@@ -125,8 +120,6 @@ class Stock_locations extends CI_Model
|
||||
{
|
||||
$grants_data = array('permission_id' => $permission_id, 'person_id' => $employee['person_id']);
|
||||
$this->db->insert('grants', $grants_data);
|
||||
|
||||
$this->db->delete('permissions', array('permission_id' => 'items_'.$location_name));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,8 +129,14 @@ class Stock_locations extends CI_Model
|
||||
*/
|
||||
function delete($location_id)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->where('location_id', $location_id);
|
||||
return $this->db->update('stock_locations', array('deleted' => 1));
|
||||
$this->db->update('stock_locations', array('deleted' => 1));
|
||||
|
||||
// should delete permissions and grants as well?
|
||||
$this->db->where('location_id', $location_id);
|
||||
$this->db->delete('permissions');
|
||||
$this->db->trans_complete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -259,7 +259,9 @@ echo form_open('config/save/',array('id'=>'config_form'));
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('partial/stock_locations', array('stock_locations' => $stock_locations)); ?>
|
||||
<div id="stock_locations">
|
||||
<?php $this->load->view('partial/stock_locations', array('stock_locations' => $stock_locations)); ?>
|
||||
</div>
|
||||
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('config_sales_invoice_format').':', 'sales_invoice_format',array('class'=>'wide')); ?>
|
||||
|
||||
@@ -161,7 +161,8 @@ $(document).ready(function()
|
||||
{
|
||||
equalTo: "#password"
|
||||
},
|
||||
email: "email", "grants[]" : {
|
||||
email: "email",
|
||||
"grants[]" : {
|
||||
required : function(element) {
|
||||
var checked = false;
|
||||
$("ul#permission_list > li > input:checkbox").each(function()
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<div id="stock_locations">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach($stock_locations as $location => $location_data ) { ?>
|
||||
<?php $location_id = $location_data['location_id']; ?>
|
||||
<?php $location_name = $location_data['location_name']; ?>
|
||||
<div class="field_row clearfix" style="<? echo $location_data['deleted'] ? ';display:none;' : 'display:block;' ?>">
|
||||
<?php echo form_label($this->lang->line('config_stock_location').' ' .++$i. ':', 'stock_location_'.$i ,array('class'=>'required wide')); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_input(array(
|
||||
'name'=>'stock_location_'.$location_id,
|
||||
'id'=>'stock_location_'.$location_id,
|
||||
'class'=>'stock_location required',
|
||||
'value'=>$location_name)); ?>
|
||||
</div>
|
||||
<img class="add_stock_location" src="<?php echo base_url('images/plus.png'); ?>" />
|
||||
<img class="remove_stock_location" src="<?php echo base_url('images/minus.png'); ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach($stock_locations as $location => $location_data ) { ?>
|
||||
<?php $location_id = $location_data['location_id']; ?>
|
||||
<?php $location_name = $location_data['location_name']; ?>
|
||||
<div class="field_row clearfix" style="<? echo $location_data['deleted'] ? ';display:none;' : 'display:block;' ?>">
|
||||
<?php echo form_label($this->lang->line('config_stock_location').' ' .++$i. ':', 'stock_location_'.$i ,array('class'=>'required wide')); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_input(array(
|
||||
'name'=>'stock_location_'.$location_id,
|
||||
'id'=>'stock_location_'.$location_id,
|
||||
'class'=>'stock_location required',
|
||||
'value'=>$location_name)); ?>
|
||||
</div>
|
||||
<img class="add_stock_location" src="<?php echo base_url('images/plus.png'); ?>" />
|
||||
<img class="remove_stock_location" src="<?php echo base_url('images/minus.png'); ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
@@ -737,8 +737,8 @@ ALTER TABLE `ospos_permissions`
|
||||
-- Constraints for table `ospos_grants`
|
||||
--
|
||||
ALTER TABLE `ospos_grants`
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`),
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_receivings`
|
||||
|
||||
Reference in New Issue
Block a user