Advertisement
ahmadtri26

xmall_mod

Mar 6th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.51 KB | None | 0 0
  1. <?php if(! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. /**
  4. * Class Xmall Model
  5. */
  6. class Xmall_model extends CI_model
  7. {
  8.  
  9.     function __construct() {
  10.  
  11.     }
  12.  
  13.     function get_item_master_category($params = null, $count=false)
  14.     {
  15.         $AGENT = 50;
  16.    
  17.     if ( $count )
  18.             $this->db->select('count(*) as many');
  19.         else
  20.             $this->db->select('a.*');
  21.  
  22.     $this->db->from('xmall_master_category a');
  23.     // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
  24.     if(isset($params['category']) && $params['category'] != ''){
  25.       $this->db->like('a.category', $params['category']);
  26.     }
  27.    
  28.     // if (isset($params['user_type_id'])) {
  29.     //         if ($params['user_type_id'] != 'ALL') {
  30.     //             $this->db->where('a.user_type_id', $params['user_type_id']);
  31.     //         }
  32.     //     } else {
  33.     //         $this->db->where('a.user_type_id', $AGENT);
  34.     //     }
  35.  
  36.     // $this->db->where('a.idelete', 0);
  37.     $this->db->order_by('a.id');
  38.  
  39.         if($count == true)
  40.         {
  41.             $result = $this->db->get();
  42.             return $result->row()->many;
  43.         }
  44.         else
  45.         {
  46.  
  47.             $this->db->limit($params['limit'], $params['offset']);
  48.  
  49.             $result = $this->db->get();
  50.             return $result->result();
  51.         }
  52.     }
  53.  
  54.     function get_seq_num_t()
  55.     {
  56.         $this->db->select_max('sort_seq');
  57.         $res = $this->db->get('xmall_master_category')->row();
  58.         return $res;
  59.     }
  60.  
  61.     public function save_master_category($data, $id = null) {
  62.  
  63.         if ($id == 'i') {
  64.             $this->db->select("*");
  65.             $this->db->where("category", $data["category"]);
  66.             $res = $this->db->get("xmall_master_category")->result();
  67.             if ( count($res) == 0 ) {
  68.                 $save = $this->db->insert('xmall_master_category', $data);
  69.                 $i_id = $this->db->insert_id();
  70.             }
  71.  
  72.         } else {
  73.             $save = $this->db->update('xmall_master_category', $data, array('id' => $id));
  74.             $i_id = $id;
  75.         }
  76.  
  77.         if ($save) {
  78.             return array(true, $i_id);
  79.         }
  80.  
  81.         return array(false, null);
  82.     }
  83.  
  84.     public function update_pic_mall_category($id, $file){
  85.  
  86.         return $this->db->update('xmall_master_category', array('img' => $file), array('id' => $id));
  87.     }
  88.  
  89.     public function delete_master_category($id) {
  90.        
  91.         $this->db->where('id', $id);
  92.        
  93.         $del = $this->db->delete('xmall_master_category');
  94.  
  95.         return $del;
  96.  
  97.     }
  98.  
  99.     public function get_master_category_data($data) {
  100.         $this->db->select('a.*');
  101.         $this->db->from('xmall_master_category a');
  102.  
  103.         if(isset($data['id']))
  104.             $this->db->where('a.id', $data['id']);
  105.        
  106.         if(isset($data['category']))
  107.             $this->db->where('a.category', $data['category']);
  108.  
  109.         return $this->db->get()->row();
  110.     }
  111.  
  112.     function get_item_master_agent($params = null, $count=false)
  113.     {
  114.         $AGENT = 50;
  115.    
  116.     if ( $count )
  117.             $this->db->select('count(*) as many');
  118.         else
  119.             $this->db->select('a.*');
  120.  
  121.     $this->db->from('xmall_master_agent_delivery a');
  122.     // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
  123.     if(isset($params['agent']) && $params['agent'] != ''){
  124.       $this->db->like('a.agent', $params['agent']);
  125.     }
  126.    
  127.     // if (isset($params['user_type_id'])) {
  128.     //         if ($params['user_type_id'] != 'ALL') {
  129.     //             $this->db->where('a.user_type_id', $params['user_type_id']);
  130.     //         }
  131.     //     } else {
  132.     //         $this->db->where('a.user_type_id', $AGENT);
  133.     //     }
  134.  
  135.     // $this->db->where('a.idelete', 0);
  136.     $this->db->order_by('a.id');
  137.  
  138.         if($count == true)
  139.         {
  140.             $result = $this->db->get();
  141.             return $result->row()->many;
  142.         }
  143.         else
  144.         {
  145.  
  146.             $this->db->limit($params['limit'], $params['offset']);
  147.  
  148.             $result = $this->db->get();
  149.             return $result->result();
  150.         }
  151.     }
  152.  
  153.  
  154.     public function get_master_agent_data($data){
  155.         $this->db->select('a.*');
  156.         $this->db->from('xmall_master_agent_delivery a');
  157.         if(isset($data['id']))
  158.             $this->db->where('a.id', $data['id']);
  159.        
  160.         if(isset($data['agent']))
  161.             $this->db->where('a.agent', $data['agent']);
  162.  
  163.         return $this->db->get()->row();
  164.     }
  165.  
  166.     function get_seq_num_agent()
  167.     {
  168.         $this->db->select_max('sort_seq');
  169.         $res = $this->db->get('xmall_master_agent_delivery')->row();
  170.         return $res;
  171.     }
  172.  
  173.     public function save_master_agent($data, $id = null) {
  174.  
  175.         if ($id == 'i') {
  176.             $this->db->select("*");
  177.             $this->db->where("agent", $data["agent"]);
  178.             $res = $this->db->get("xmall_master_agent_delivery")->result();
  179.             if ( count($res) == 0 ) {
  180.                 $save = $this->db->insert('xmall_master_agent_delivery', $data);
  181.                 $i_id = $this->db->insert_id();
  182.             }
  183.  
  184.         } else {
  185.             $save = $this->db->update('xmall_master_agent_delivery', $data, array('id' => $id));
  186.             $i_id = $id;
  187.         }
  188.  
  189.         if ($save) {
  190.             return array(true, $i_id);
  191.         }
  192.  
  193.         return array(false, null);
  194.     }
  195.  
  196.     public function update_pic_mall_agent($id, $file){
  197.  
  198.         return $this->db->update('xmall_master_agent_delivery', array('img' => $file), array('id' => $id));
  199.     }
  200.  
  201.     public function delete_master_agent($id) {
  202.        
  203.         $this->db->where('id', $id);
  204.        
  205.         $del = $this->db->delete('xmall_master_category');
  206.  
  207.         return $del;
  208.  
  209.     }
  210.  
  211.  
  212.  
  213.  
  214. }<?php if(! defined('BASEPATH')) exit('No direct script access allowed');
  215.  
  216. /**
  217. * Class Xmall Model
  218. */
  219. class Xmall_model extends CI_model
  220. {
  221.  
  222.     function __construct() {
  223.  
  224.     }
  225.  
  226.     function get_item_master_category($params = null, $count=false)
  227.     {
  228.         $AGENT = 50;
  229.    
  230.     if ( $count )
  231.             $this->db->select('count(*) as many');
  232.         else
  233.             $this->db->select('a.*');
  234.  
  235.     $this->db->from('xmall_master_category a');
  236.     // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
  237.     if(isset($params['category']) && $params['category'] != ''){
  238.       $this->db->like('a.category', $params['category']);
  239.     }
  240.    
  241.     // if (isset($params['user_type_id'])) {
  242.     //         if ($params['user_type_id'] != 'ALL') {
  243.     //             $this->db->where('a.user_type_id', $params['user_type_id']);
  244.     //         }
  245.     //     } else {
  246.     //         $this->db->where('a.user_type_id', $AGENT);
  247.     //     }
  248.  
  249.     // $this->db->where('a.idelete', 0);
  250.     $this->db->order_by('a.id');
  251.  
  252.         if($count == true)
  253.         {
  254.             $result = $this->db->get();
  255.             return $result->row()->many;
  256.         }
  257.         else
  258.         {
  259.  
  260.             $this->db->limit($params['limit'], $params['offset']);
  261.  
  262.             $result = $this->db->get();
  263.             return $result->result();
  264.         }
  265.     }
  266.  
  267.     function get_seq_num_t()
  268.     {
  269.         $this->db->select_max('sort_seq');
  270.         $res = $this->db->get('xmall_master_category')->row();
  271.         return $res;
  272.     }
  273.  
  274.     public function save_master_category($data, $id = null) {
  275.  
  276.         if ($id == 'i') {
  277.             $this->db->select("*");
  278.             $this->db->where("category", $data["category"]);
  279.             $res = $this->db->get("xmall_master_category")->result();
  280.             if ( count($res) == 0 ) {
  281.                 $save = $this->db->insert('xmall_master_category', $data);
  282.                 $i_id = $this->db->insert_id();
  283.             }
  284.  
  285.         } else {
  286.             $save = $this->db->update('xmall_master_category', $data, array('id' => $id));
  287.             $i_id = $id;
  288.         }
  289.  
  290.         if ($save) {
  291.             return array(true, $i_id);
  292.         }
  293.  
  294.         return array(false, null);
  295.     }
  296.  
  297.     public function update_pic_mall_category($id, $file){
  298.  
  299.         return $this->db->update('xmall_master_category', array('img' => $file), array('id' => $id));
  300.     }
  301.  
  302.     public function delete_master_category($id) {
  303.        
  304.         $this->db->where('id', $id);
  305.        
  306.         $del = $this->db->delete('xmall_master_category');
  307.  
  308.         return $del;
  309.  
  310.     }
  311.  
  312.     public function get_master_category_data($data) {
  313.         $this->db->select('a.*');
  314.         $this->db->from('xmall_master_category a');
  315.  
  316.         if(isset($data['id']))
  317.             $this->db->where('a.id', $data['id']);
  318.        
  319.         if(isset($data['category']))
  320.             $this->db->where('a.category', $data['category']);
  321.  
  322.         return $this->db->get()->row();
  323.     }
  324.  
  325.     function get_item_master_agent($params = null, $count=false)
  326.     {
  327.         $AGENT = 50;
  328.    
  329.     if ( $count )
  330.             $this->db->select('count(*) as many');
  331.         else
  332.             $this->db->select('a.*');
  333.  
  334.     $this->db->from('xmall_master_agent_delivery a');
  335.     // $this->db->join('user_meta b', 'b.user_id=a.id', 'left');
  336.     if(isset($params['agent']) && $params['agent'] != ''){
  337.       $this->db->like('a.agent', $params['agent']);
  338.     }
  339.    
  340.     // if (isset($params['user_type_id'])) {
  341.     //         if ($params['user_type_id'] != 'ALL') {
  342.     //             $this->db->where('a.user_type_id', $params['user_type_id']);
  343.     //         }
  344.     //     } else {
  345.     //         $this->db->where('a.user_type_id', $AGENT);
  346.     //     }
  347.  
  348.     // $this->db->where('a.idelete', 0);
  349.     $this->db->order_by('a.id');
  350.  
  351.         if($count == true)
  352.         {
  353.             $result = $this->db->get();
  354.             return $result->row()->many;
  355.         }
  356.         else
  357.         {
  358.  
  359.             $this->db->limit($params['limit'], $params['offset']);
  360.  
  361.             $result = $this->db->get();
  362.             return $result->result();
  363.         }
  364.     }
  365.  
  366.  
  367.     public function get_master_agent_data($data){
  368.         $this->db->select('a.*');
  369.         $this->db->from('xmall_master_agent_delivery a');
  370.         if(isset($data['id']))
  371.             $this->db->where('a.id', $data['id']);
  372.        
  373.         if(isset($data['agent']))
  374.             $this->db->where('a.agent', $data['agent']);
  375.  
  376.         return $this->db->get()->row();
  377.     }
  378.  
  379.     function get_seq_num_agent()
  380.     {
  381.         $this->db->select_max('sort_seq');
  382.         $res = $this->db->get('xmall_master_agent_delivery')->row();
  383.         return $res;
  384.     }
  385.  
  386.     public function save_master_agent($data, $id = null) {
  387.  
  388.         if ($id == 'i') {
  389.             $this->db->select("*");
  390.             $this->db->where("agent", $data["agent"]);
  391.             $res = $this->db->get("xmall_master_agent_delivery")->result();
  392.             if ( count($res) == 0 ) {
  393.                 $save = $this->db->insert('xmall_master_agent_delivery', $data);
  394.                 $i_id = $this->db->insert_id();
  395.             }
  396.  
  397.         } else {
  398.             $save = $this->db->update('xmall_master_agent_delivery', $data, array('id' => $id));
  399.             $i_id = $id;
  400.         }
  401.  
  402.         if ($save) {
  403.             return array(true, $i_id);
  404.         }
  405.  
  406.         return array(false, null);
  407.     }
  408.  
  409.     public function update_pic_mall_agent($id, $file){
  410.  
  411.         return $this->db->update('xmall_master_agent_delivery', array('img' => $file), array('id' => $id));
  412.     }
  413.  
  414.     public function delete_master_agent($id) {
  415.        
  416.         $this->db->where('id', $id);
  417.        
  418.         $del = $this->db->delete('xmall_master_category');
  419.  
  420.         return $del;
  421.  
  422.     }
  423.  
  424.  
  425.  
  426.  
  427. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement