Skip to content

Commit

Permalink
Code Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
bandel committed Jun 26, 2014
1 parent 5f40bae commit aa3f107
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 173 deletions.
5 changes: 4 additions & 1 deletion application/libraries/Posnic.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Posnic{
private $CI;

Expand Down Expand Up @@ -429,3 +429,6 @@ function posnic_master_increment_max($key){
return $data;
}
}

/* End of file Posnic.php */
/* Location: ./application/libraries/Posnic.php */
5 changes: 3 additions & 2 deletions application/models/aclpermissionmodel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Aclpermissionmodel extends CI_Model
{
function __construct() {
Expand Down Expand Up @@ -168,4 +168,5 @@ function sales_permission($did,$bid)
}
}
}
?>
/* End of file aclpermissionmodel.php */
/* Location: ./application/models/aclpermissionmodel.php */
156 changes: 78 additions & 78 deletions application/models/core_model.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Core_model extends CI_Model{
function __construct() {
parent::__construct();
}

function item_setting($guid,$branch){
$data=array('item_id'=>$guid,
'branch_id'=>$branch);
'branch_id'=>$branch
);
$this->db->insert('items_setting',$data);
$id=$this->db->insert_id();
$orderid=md5($id.'items_setting');
Expand All @@ -16,120 +18,118 @@ function item_setting($guid,$branch){
$this->db->update('items_setting',$value);
}


function delete_item_setting($guid,$bid){
$data=array('active_status'=>0,'delete_status'=>1);
$this->db->where('item_id',$guid);
$this->db->where('branch_id',$bid);
$this->db->update('items_setting',$data);


}
$this->db->update('items_setting',$data);
}

function restore_item_setting($guid,$bid){
$data=array('active_status'=>1,'delete_status'=>0);
$this->db->where('item_id',$guid);
$this->db->where('barnch_id',$bid);
$this->db->update('items_setting',$data);



}
$this->db->update('items_setting',$data);
}

function suppliers_x_items($id,$bid,$mrp,$supplier,$selling_price,$cost_price){
$data=array('item_id'=>$id,'mrp'=>$mrp,'supplier_id'=>$supplier,'price'=>$selling_price,'cost'=>$cost_price,'branch_id'=>$bid);
$this->db->insert('suppliers_x_items',$data);
$id= $this->db->insert_id();
$this->db->where('id',$id);
$this->db->update('suppliers_x_items',array('guid'=>md5($id.'supplier_x_items')));
}
function posnic_join_like($table,$bid){
$this->db->select()->from('suppliers_x_items');
$this->db->join('items', "$table".'.item_id=items.guid AND suppliers_x_items.active = 0','left');
$this->db->group_by("items".'.guid');
$sql= $this->db->get();
$j=0;

function posnic_join_like($table,$bid){
$this->db->select()->from('suppliers_x_items');

$this->db->join('items', "$table".'.item_id=items.guid AND suppliers_x_items.active = 0','left');
$this->db->group_by("items".'.guid');
$sql= $this->db->get();
$j=0;
$data=array();
foreach ($sql->result() as $row){
$data[$j] = array(
'label' =>$row->code ,
'desc' =>$row->description,
'cost' =>$row->cost,
'sell' =>$row->price ,
'mrp' =>$row->mrp,
'id'=>$row->guid
);
$j++;
}
return $data;
foreach ($sql->result() as $row){
$data[$j] = array(
'label' => $row->code,
'desc' => $row->description,
'cost' => $row->cost,
'sell' => $row->price,
'mrp' => $row->mrp,
'id' => $row->guid
);
$j++;
}
return $data;
}

function user_fetch_array($like,$start,$end,$sOrder){
$this->db->select();
$this->db->limit($start,$end);
$this->db->limit($start,$end);
$this->db->order_by($sOrder);
$this->db->or_like($like);



$query = $this->db->get('ajax');
return $query->result_array();

$query = $this->db->get('ajax');
return $query->result_array();
}
function posnic_data_table($start,$end,$branch,$uid,$order,$like){

function posnic_data_table($start,$end,$branch,$uid,$order,$like){
$this->db->select('users.*, users_x_branches.user_active as user_active , users_x_branches.user_id as user_id')->from('users_x_branches')->where('users_x_branches.branch_id',$branch);
$this->db->limit($start,$end);
$this->db->order_by($order);
$this->db->where('users.guid <>',$uid);
$this->db->where('users.user_type <>',2 );
// $this->db->where('users_x_branches.user_active ',0 );
// $this->db->where('users_x_branches.user_active ',0 );

$this->db->or_like($like);
$this->db->join('users', "users_x_branches.user_id=users.guid AND users.user_type!=2 ".'','left');
$query=$this->db->get();
return $query->result_array();

}

function items_data_table($end,$start,$order,$like,$branch){
$this->db->select('items.* ,items_category.guid as c_guid,items_category.category_name as c_name,brands.guid as b_guid,brands.name as b_name,items_department.department_name as d_name')->from('items')->where('items.branch_id',$branch)->where('items.delete_status',0);
$this->db->join('items_category', 'items.category_id=items_category.guid','left');
$this->db->join('brands', 'items.brand_id=brands.guid','left');
$this->db->join('items_department', 'items.depart_id=items_department.guid','left');
$this->db->limit($end,$start);
$this->db->or_like($like);
$query=$this->db->get();
return $query->result_array();
$this->db->select('items.* ,items_category.guid as c_guid,items_category.category_name as c_name,brands.guid as b_guid,brands.name as b_name,items_department.department_name as d_name')->from('items')->where('items.branch_id',$branch)->where('items.delete_status',0);
$this->db->join('items_category', 'items.category_id=items_category.guid','left');
$this->db->join('brands', 'items.brand_id=brands.guid','left');
$this->db->join('items_department', 'items.depart_id=items_department.guid','left');
$this->db->limit($end,$start);
$this->db->or_like($like);
$query=$this->db->get();
return $query->result_array();
}

function get_items_details_for_update($branch,$guid){
$this->db->select('items.* ,taxes_area.name as area_name,suppliers.first_name as s_first_name,suppliers.last_name as s_last_name,suppliers.phone as s_phone,suppliers.email as s_email,suppliers.company_name as company_name,suppliers.guid as s_guid,items_department.department_name,items_department.guid as d_guid,taxes.guid as tax_guid,tax_types.type as type,taxes.value as value, items_category.guid as c_guid,items_category.category_name as c_name,brands.guid as b_guid,brands.name as b_name')->from('items')->where('items.branch_id',$branch)->where('items.guid',$guid);
$this->db->join('items_category', 'items.category_id=items_category.guid','left');
$this->db->join('brands', 'items.brand_id=brands.guid','left');
$this->db->join('suppliers', 'items.supplier_id=suppliers.guid','left');
$this->db->join('items_department', 'items.depart_id=items_department.guid','left');
$this->db->join('taxes_area', 'items.tax_area_id=taxes_area.guid','left');
$this->db->join('taxes', 'items.tax_id=taxes.guid','left');
$this->db->join('tax_types', 'taxes.type=tax_types.guid','left');
$query=$this->db->get();
$data=array();
foreach ($query->result_array() as $row){
$row['start_date']=date('d-m-Y',$row['start_date']);
$row['end_date']=date('d-m-Y',$row['end_date']);
$data[]=$row;
}
return $data;
$this->db->select('items.* ,taxes_area.name as area_name,suppliers.first_name as s_first_name,suppliers.last_name as s_last_name,suppliers.phone as s_phone,suppliers.email as s_email,suppliers.company_name as company_name,suppliers.guid as s_guid,items_department.department_name,items_department.guid as d_guid,taxes.guid as tax_guid,tax_types.type as type,taxes.value as value, items_category.guid as c_guid,items_category.category_name as c_name,brands.guid as b_guid,brands.name as b_name')->from('items')->where('items.branch_id',$branch)->where('items.guid',$guid);
$this->db->join('items_category', 'items.category_id=items_category.guid','left');
$this->db->join('brands', 'items.brand_id=brands.guid','left');
$this->db->join('suppliers', 'items.supplier_id=suppliers.guid','left');
$this->db->join('items_department', 'items.depart_id=items_department.guid','left');
$this->db->join('taxes_area', 'items.tax_area_id=taxes_area.guid','left');
$this->db->join('taxes', 'items.tax_id=taxes.guid','left');
$this->db->join('tax_types', 'taxes.type=tax_types.guid','left');

$query=$this->db->get();
$data=array();
foreach ($query->result_array() as $row){
$row['start_date']=date('d-m-Y',$row['start_date']);
$row['end_date']=date('d-m-Y',$row['end_date']);
$data[]=$row;
}
return $data;
}

function get_items_setting_details($branch,$guid){
$this->db->select()->from('items_setting')->where('branch_id',$branch)->where('item_id',$guid);
$query=$this->db->get();
return $query->result_array();
$this->db->select()->from('items_setting')->where('branch_id',$branch)->where('item_id',$guid);
$query=$this->db->get();
return $query->result_array();
}

function get_taxes($branch,$like){
$this->db->select('taxes.* ,taxes.guid as guid,tax_types.type as name,tax_types.guid as t_guid')->from('taxes')->where('taxes.branch_id',$branch)->where('taxes.active_status',1)->where('taxes.delete_status',0);
$this->db->join('tax_types', 'taxes.type=tax_types.guid','left');
$this->db->like($like);
$query=$this->db->get();
return $query->result_array();
$this->db->select('taxes.* ,taxes.guid as guid,tax_types.type as name,tax_types.guid as t_guid')->from('taxes')->where('taxes.branch_id',$branch)->where('taxes.active_status',1)->where('taxes.delete_status',0);
$this->db->join('tax_types', 'taxes.type=tax_types.guid','left');
$this->db->like($like);
$query=$this->db->get();
return $query->result_array();
}

}
?>
/* End of file core_model.php */
/* Location: ./application/models/core_model.php */
6 changes: 4 additions & 2 deletions application/models/logindetails.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Logindetails extends CI_Model{
function __construct() {
parent::__construct();
Expand Down Expand Up @@ -66,4 +67,5 @@ function user_active_status($user_guid) {

}
}
?>
/* End of file logindetails.php */
/* Location: ./application/models/logindetails.php */
3 changes: 2 additions & 1 deletion application/models/modules_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ function get_lang(){
return $sql->result();
}
}
?>
/* End of file modules_model.php */
/* Location: ./application/models/modules.php */
Loading

0 comments on commit aa3f107

Please sign in to comment.