mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-18 14:27:54 -05:00
Fixed customer + supplier search box width + spinner position under linux Fonts set to relative browser size Dutch language files updated (missing labels added) Conflicts: WHATS_NEW.txt application/config/autoload.php application/config/config.php application/config/migration.php application/config/routes.php application/controllers/giftcards.php application/controllers/items.php application/controllers/person_controller.php application/controllers/receivings.php application/controllers/reports.php application/controllers/sales.php application/controllers/suppliers.php application/helpers/table_helper.php application/hooks/load_config.php application/language/english/common_lang.php application/language/english/config_lang.php application/language/english/customers_lang.php application/language/english/employees_lang.php application/language/english/error_lang.php application/language/english/giftcards_lang.php application/language/english/index.html application/language/english/items_lang.php application/language/english/login_lang.php application/language/english/module_lang.php application/language/english/receivings_lang.php application/language/english/reports_lang.php application/language/english/sales_lang.php application/language/english/suppliers_lang.php application/libraries/Receiving_lib.php application/libraries/ofc-library/JSON.php application/libraries/ofc-library/README.txt application/libraries/ofc-library/dot_base.php application/libraries/ofc-library/json_format.php application/libraries/ofc-library/ofc_area_base.php application/libraries/ofc-library/ofc_area_hollow.php application/libraries/ofc-library/ofc_area_line.php application/libraries/ofc-library/ofc_arrow.php application/libraries/ofc-library/ofc_bar.php application/libraries/ofc-library/ofc_bar_3d.php application/libraries/ofc-library/ofc_bar_base.php application/libraries/ofc-library/ofc_bar_filled.php application/libraries/ofc-library/ofc_bar_glass.php application/libraries/ofc-library/ofc_bar_sketch.php application/libraries/ofc-library/ofc_bar_stack.php application/libraries/ofc-library/ofc_candle.php application/libraries/ofc-library/ofc_hbar.php application/libraries/ofc-library/ofc_line.php application/libraries/ofc-library/ofc_line_base.php application/libraries/ofc-library/ofc_line_dot.php application/libraries/ofc-library/ofc_line_hollow.php application/libraries/ofc-library/ofc_line_style.php application/libraries/ofc-library/ofc_menu.php application/libraries/ofc-library/ofc_pie.php application/libraries/ofc-library/ofc_radar_axis.php application/libraries/ofc-library/ofc_radar_axis_labels.php application/libraries/ofc-library/ofc_radar_spoke_labels.php application/libraries/ofc-library/ofc_scatter.php application/libraries/ofc-library/ofc_scatter_line.php application/libraries/ofc-library/ofc_shape.php application/libraries/ofc-library/ofc_sugar.php application/libraries/ofc-library/ofc_tags.php application/libraries/ofc-library/ofc_title.php application/libraries/ofc-library/ofc_tooltip.php application/libraries/ofc-library/ofc_x_axis.php application/libraries/ofc-library/ofc_x_axis_label.php application/libraries/ofc-library/ofc_x_axis_labels.php application/libraries/ofc-library/ofc_x_legend.php application/libraries/ofc-library/ofc_y_axis.php application/libraries/ofc-library/ofc_y_axis_base.php application/libraries/ofc-library/ofc_y_axis_label.php application/libraries/ofc-library/ofc_y_axis_labels.php application/libraries/ofc-library/ofc_y_axis_right.php application/libraries/ofc-library/ofc_y_legend.php application/libraries/ofc-library/open-flash-chart-object.php application/libraries/ofc-library/open-flash-chart.php application/models/giftcard.php application/models/item.php application/models/person.php application/models/receiving.php application/models/sale.php application/models/supplier.php application/views/config.php application/views/items/form.php application/views/items/form_bulk.php application/views/items/manage.php application/views/receivings/receiving.php application/views/reports/date_input.php application/views/reports/listing.php application/views/reports/tabular_details.php application/views/sales/edit.php application/views/sales/register.php application/views/suppliers/form.php css/reports.css css/tables.css database/database.sql import_items.csv index.php js/jquery.ajax_queue.js js/jquery.metadata.js license/license.txt
256 lines
6.4 KiB
PHP
256 lines
6.4 KiB
PHP
<?php
|
|
class Giftcard extends CI_Model
|
|
{
|
|
/*
|
|
Determines if a given giftcard_id is an giftcard
|
|
*/
|
|
function exists( $giftcard_id )
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->where('giftcard_id',$giftcard_id);
|
|
$this->db->where('deleted',0);
|
|
$query = $this->db->get();
|
|
|
|
return ($query->num_rows()==1);
|
|
}
|
|
|
|
/*
|
|
Returns all the giftcards
|
|
*/
|
|
function get_all($limit=10000, $offset=0)
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->join('people','people.person_id=giftcards.person_id');//GARRISON ADDED 4/25/2013
|
|
$this->db->where('deleted',0);
|
|
$this->db->order_by("giftcard_number", "asc");
|
|
$this->db->limit($limit);
|
|
$this->db->offset($offset);
|
|
return $this->db->get();
|
|
}
|
|
|
|
function count_all()
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->where('deleted',0);
|
|
return $this->db->count_all_results();
|
|
}
|
|
|
|
/*
|
|
Gets information about a particular giftcard
|
|
*/
|
|
function get_info($giftcard_id)
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->where('giftcard_id',$giftcard_id);
|
|
$this->db->where('deleted',0);
|
|
|
|
$query = $this->db->get();
|
|
|
|
if($query->num_rows()==1)
|
|
{
|
|
return $query->row();
|
|
}
|
|
else
|
|
{
|
|
//Get empty base parent object, as $giftcard_id is NOT an giftcard
|
|
$giftcard_obj=new stdClass();
|
|
|
|
//Get all the fields from giftcards table
|
|
$fields = $this->db->list_fields('giftcards');
|
|
|
|
foreach ($fields as $field)
|
|
{
|
|
$giftcard_obj->$field='';
|
|
}
|
|
|
|
return $giftcard_obj;
|
|
}
|
|
}
|
|
|
|
/*
|
|
Get an giftcard id given an giftcard number
|
|
*/
|
|
function get_giftcard_id($giftcard_number)
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->where('giftcard_number',$giftcard_number);
|
|
$this->db->where('deleted',0);
|
|
|
|
$query = $this->db->get();
|
|
|
|
if($query->num_rows()==1)
|
|
{
|
|
return $query->row()->giftcard_id;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
Gets information about multiple giftcards
|
|
*/
|
|
function get_multiple_info($giftcard_ids)
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->where_in('giftcard_id',$giftcard_ids);
|
|
$this->db->where('deleted',0);
|
|
$this->db->order_by("giftcard_number", "asc");
|
|
return $this->db->get();
|
|
}
|
|
|
|
/*
|
|
Inserts or updates a giftcard
|
|
*/
|
|
function save(&$giftcard_data,$giftcard_id=false)
|
|
{
|
|
if (!$giftcard_id or !$this->exists($giftcard_id))
|
|
{
|
|
if($this->db->insert('giftcards',$giftcard_data))
|
|
{
|
|
$giftcard_data['giftcard_id']=$this->db->insert_id();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
$this->db->where('giftcard_id', $giftcard_id);
|
|
return $this->db->update('giftcards',$giftcard_data);
|
|
}
|
|
|
|
/*
|
|
Updates multiple giftcards at once
|
|
*/
|
|
function update_multiple($giftcard_data,$giftcard_ids)
|
|
{
|
|
$this->db->where_in('giftcard_id',$giftcard_ids);
|
|
return $this->db->update('giftcards',$giftcard_data);
|
|
}
|
|
|
|
/*
|
|
Deletes one giftcard
|
|
*/
|
|
function delete($giftcard_id)
|
|
{
|
|
$this->db->where('giftcard_id', $giftcard_id);
|
|
return $this->db->update('giftcards', array('deleted' => 1));
|
|
}
|
|
|
|
/*
|
|
Deletes a list of giftcards
|
|
*/
|
|
function delete_list($giftcard_ids)
|
|
{
|
|
$this->db->where_in('giftcard_id',$giftcard_ids);
|
|
return $this->db->update('giftcards', array('deleted' => 1));
|
|
}
|
|
|
|
/*
|
|
Get search suggestions to find giftcards
|
|
*/
|
|
function get_search_suggestions($search,$limit=25)
|
|
{
|
|
$suggestions = array();
|
|
|
|
$this->db->from('giftcards');
|
|
$this->db->like('giftcard_number', $search);
|
|
$this->db->where('deleted',0);
|
|
$this->db->order_by("giftcard_number", "asc");
|
|
$by_number = $this->db->get();
|
|
|
|
foreach($by_number->result() as $row)
|
|
{
|
|
$suggestions[]=$row->giftcard_number;
|
|
}
|
|
|
|
/** GARRISON MODIFIED 4/24/2013 **/
|
|
$this->db->from('customers');
|
|
$this->db->join('people','customers.person_id=people.person_id');
|
|
$this->db->like("first_name",$this->db->escape_like_str($search));
|
|
$this->db->or_like("last_name",$this->db->escape_like_str($search));
|
|
$this->db->or_like("CONCAT(`first_name`,' ',`last_name`)",$this->db->escape_like_str($search));
|
|
$this->db->where("deleted","0");
|
|
$this->db->order_by("last_name", "asc");
|
|
$by_name = $this->db->get();
|
|
|
|
foreach($by_name->result() as $row)
|
|
{
|
|
$suggestions[]=$row->first_name.' '.$row->last_name;
|
|
}
|
|
/** END GARRISON MODIFIED **/
|
|
|
|
//only return $limit suggestions
|
|
if(count($suggestions > $limit))
|
|
{
|
|
$suggestions = array_slice($suggestions, 0,$limit);
|
|
}
|
|
return $suggestions;
|
|
}
|
|
|
|
/** GARRISON ADDED 5/3/2013 **/
|
|
/*
|
|
Get search suggestions to find customers
|
|
*/
|
|
function get_person_search_suggestions($search,$limit=25)
|
|
{
|
|
$suggestions = array();
|
|
|
|
$this->db->select('person_id');
|
|
$this->db->from('people');
|
|
$this->db->like('person_id',$this->db->escape_like_str($search));
|
|
$this->db->or_like('first_name',$this->db->escape_like_str($search));
|
|
$this->db->or_like('last_name',$this->db->escape_like_str($search));
|
|
$this->db->or_like("CONCAT(`first_name`,' ',`last_name`)",$this->db->escape_like_str($search));
|
|
$this->db->or_like('email',$this->db->escape_like_str($search));
|
|
$this->db->or_like('phone_number',$this->db->escape_like_str($search));
|
|
$this->db->order_by('person_id', 'asc');
|
|
$by_person_id = $this->db->get();
|
|
|
|
foreach($by_person_id->result() as $row)
|
|
{
|
|
$suggestions[]=$row->person_id;
|
|
}
|
|
|
|
//only return $limit suggestions
|
|
if(count($suggestions > $limit))
|
|
{
|
|
$suggestions = array_slice($suggestions, 0,$limit);
|
|
}
|
|
return $suggestions;
|
|
}
|
|
|
|
/** GARRISON MODIFIED 4/24/2013 **/
|
|
/*
|
|
Preform a search on giftcards
|
|
*/
|
|
function search($search)
|
|
{
|
|
$this->db->from('giftcards');
|
|
$this->db->join('people','giftcards.person_id=people.person_id');
|
|
$this->db->like("first_name",$this->db->escape_like_str($search));
|
|
$this->db->or_like("last_name",$this->db->escape_like_str($search));
|
|
$this->db->or_like("CONCAT(`first_name`,' ',`last_name`)",$this->db->escape_like_str($search));
|
|
$this->db->or_like("giftcard_number",$this->db->escape_like_str($search));
|
|
$this->db->or_like("giftcards.person_id",$this->db->escape_like_str($search));
|
|
$this->db->where('deleted',$this->db->escape('0'));
|
|
$this->db->order_by("giftcard_number", "asc");
|
|
return $this->db->get();
|
|
}
|
|
|
|
public function get_giftcard_value( $giftcard_number )
|
|
{
|
|
if ( !$this->exists( $this->get_giftcard_id($giftcard_number)))
|
|
return 0;
|
|
|
|
$this->db->from('giftcards');
|
|
$this->db->where('giftcard_number',$giftcard_number);
|
|
return $this->db->get()->row()->value;
|
|
}
|
|
|
|
function update_giftcard_value( $giftcard_number, $value )
|
|
{
|
|
$this->db->where('giftcard_number', $giftcard_number);
|
|
$this->db->update('giftcards', array('value' => $value));
|
|
}
|
|
}
|
|
?>
|