Overview

Packages

  • controller
  • models
  • None

Classes

  • Ajax
  • Article
  • Cache
  • Employee
  • Firefly
  • gmreader
  • gmsite
  • Home
  • Link
  • Merchant
  • Model_article
  • Model_cache
  • Model_employee
  • Model_firefly
  • Model_gmreader
  • Model_gmsite
  • Model_link
  • Model_merchant
  • Model_reference
  • Model_user
  • Reference
  • Setting
  • User

Functions

  • check_permission
  • data_status
  • data_status_select
  • dump_html_tree
  • employee_select
  • file_get_html
  • generate_page
  • gerenate_pager_from_table
  • get_desc_asc
  • get_url_support
  • is_admin
  • is_loggedin
  • link_extractor
  • merchant_status
  • reference_reverter
  • role_select
  • siteinfo
  • str_get_html
  • yes_no
  • yesno_select
  • Overview
  • Package
  • Class
 1: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 2: 
 3: /**
 4:  * The Model_merchant class is the model used for managing Merchants associated with GMW.
 5:  *
 6:  * @package   models
 7:  * @version   0.01
 8:  * @since     2014-04-03
 9:  * @author    Rizwan Ali <riz@bitspro.com>
10:  */
11: class Model_merchant extends CI_Model{
12:     /**
13:      * Fetch list of merchants from database and return database object
14:      *
15:      * @param string $filter
16:      *
17:      * @return mixed
18:      *
19:      * @since   2014-04-03
20:      * @author  Rizwan Ali <riz@bitspro.com>
21:      */
22:     public function browse($filter = ''){
23:         if($this->input->post('action') != ''){
24:             $data = array();
25:             foreach($_POST as $key=>$val){
26:                 if($key != 'action'){
27:                     $data['merc_'.$key] = $val;
28:                 }
29:             }
30: 
31:             if($this->input->post('id')== ''){
32:                 $data['merc_created'] = time();
33:                 $this->db->insert('xenon_merchant',$data);
34:             }else{
35:                 $this->db->where('merc_id',$this->input->post('id'));
36:                 $this->db->update('xenon_merchant',$data);
37:             }
38:         }
39:         $this->db->select('*, xenon_merchant.merc_id as id');
40:         $this->db->join('xenon_merchant_store','xenon_merchant_store.merc_id = xenon_merchant.merc_id', 'left');
41:         $this->db->from('xenon_merchant');
42:         $this->db->where('xenon_merchant.is_deleted','n');
43:         if($this->input->get('page')!=''){
44:             $page = $this->input->get('page');
45:             $start = ($page * 50)-50;
46:             $end = ($page * 50);
47:             $this->db->limit(50,$start);
48:         }else{
49:             $this->db->limit(50);
50:         }
51:         return $this->db->get();
52:     }
53: 
54:     /**
55:      * Take row from merchant database and render it in to html
56:      *
57:      * @param $merchant
58:      *
59:      * @return string
60:      *
61:      * @since   2014-04-03
62:      * @author  Rizwan Ali <riz@bitspro.com>
63:      */
64:     public function render($merchant){
65:         return '
66:             <tr>
67:                 <td>'.$merchant->merc_name.'</td>
68:                 <td>'.$merchant->merc_email.'</td>
69:                 <td align="center">'.$merchant->merc_zip.'</td>
70:                 <td align="center">'.yes_no($merchant->stor_coupon).'</td>
71:                 <td align="center">'.$merchant->stor_monthly.'</td>
72:                 <td align="center">'.$merchant->stor_distribute.'</td>
73:                 <td align="center">'.$merchant->stor_sale.'</td>
74:                 <td align="center">'.date('F d, Y',$merchant->stor_created).'</td>
75:                 <td align="center">'.merchant_status($merchant->merc_status).'</td>
76:                 <td align="center"><a href="'.site_url('merchant/'.urlencode(base64_encode($merchant->id))).'">Edit</a> | <a href="?action=delete&id='.urlencode(base64_encode($merchant->id)).'">Delete</a>
77:             </tr>
78:         ';
79:     }
80: 
81:     /**
82:      * Returns error when no merchants found in database
83:      *
84:      *
85:      * @return string
86:      *
87:      * @since   2014-04-03
88:      * @author  Rizwan Ali <riz@bitspro.com>
89:      */
90:     public function error(){
91:         return '
92:             <tr>
93:                 <td colspan="5">No artciles found</td>
94:             </tr>
95:         ';
96:     }
97: }
98: ?>
API documentation generated by ApiGen