当前位置: 首页>>代码示例>>PHP>>正文


PHP MY_Controller::_switch_brand方法代码示例

本文整理汇总了PHP中MY_Controller::_switch_brand方法的典型用法代码示例。如果您正苦于以下问题:PHP MY_Controller::_switch_brand方法的具体用法?PHP MY_Controller::_switch_brand怎么用?PHP MY_Controller::_switch_brand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MY_Controller的用法示例。


在下文中一共展示了MY_Controller::_switch_brand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_brand

 /**
  * Handle form submission of add store (brand) form.
  * 
  * @author unknown, Christophe
  */
 public function add_brand()
 {
     $this->load->library('Vision_users');
     $rules = array(array('field' => 'store_name', 'label' => 'Store Name', 'rules' => 'trim|required'), array('field' => 'man_id', 'label' => 'Manufacturer ID', 'rules' => 'trim|numeric|min_length[5]|max_length[9]'));
     $this->form_validation->set_rules($rules);
     $this->form_validation->set_fields();
     $store_name = $this->input->post('store_name');
     $man_id = $this->input->post('man_id');
     // this is to handle failed file uploads so as not to duplicated the store name
     $new_store_id = $this->input->post('new_store_id');
     if ($this->form_validation->run()) {
         $store_info['user_id'] = $this->user_id;
         $store_info['store_name'] = $store_name;
         $store_info['store_enable'] = '1';
         $store_info['created_at'] = date("Y-m-d H:i:s");
         $store_info['man_id'] = $man_id;
         if (!empty($new_store_id)) {
             // if store already exists, then connect user to store
             $store_info['id'] = $new_store_id;
             $this->store_id = $new_store_id;
             $this->Store->update_store_info($store_info);
             // send notification to TrackStreet staff about store being added
             $email = $this->config->item('environment') == 'production' ? 'christophe@trackstreet.com, chris@trackstreet.com' : 'christophe@trackstreet.com';
             $subject = '[TrackStreet] New Store Added: ' . $store_name;
             $html_message = "<p>A new store (brand) has been added: {$store_name} (ID: {$this->store_id})</p>";
             $html_message .= "<p>User who added store: {$this->user['first_name']} {$this->user['last_name']} (ID: {$this->user_id})</p>";
             $text_message = strip_tags($html_message);
             $this->vision_users->sendSESEmail($email, $subject, $html_message, $text_message);
         } else {
             // create new store
             $this->store_id = $this->Store->add_store($store_info);
             $this->User->add_team_member($this->store_id, $this->user_id);
             // send notification to TrackStreet staff about new store being added
             $email = $this->config->item('environment') == 'production' ? 'christophe@trackstreet.com, chris@trackstreet.com' : 'christophe@trackstreet.com';
             $subject = '[TrackStreet] New Store Added: ' . $store_name;
             $html_message = "<p>A new store (brand) has been added: {$store_name} (ID: {$this->store_id})</p>";
             $html_message .= "<p>User who added store: {$this->user['first_name']} {$this->user['last_name']} (ID: {$this->user_id})</p>";
             $text_message = strip_tags($html_message);
             $this->vision_users->sendSESEmail($email, $subject, $html_message, $text_message);
             parent::_switch_brand($this->store_id);
         }
         $this->store_id = $this->data->new_store_id = $this->store_id;
         if ($_FILES['brand_logo']['error'] != 4) {
             $upload = $this->upload_logo();
             if (!$upload) {
                 $this->data->store_name = $store_name;
                 $this->data->man_id = $man_id;
                 $this->data->message = $this->file_upload_error;
                 $this->session->set_flashdata('error_msg', 'Error: Logo could not be uploaded. Please try again, or contact support for help.');
                 redirect('/settings/add_store');
                 exit;
             } else {
                 $this->db->where('id', $this->store_id);
                 $this->db->update($this->_table_store, array('brand_logo' => $this->uploaded_file));
                 redirect(base_url() . 'settings/products');
             }
         } else {
             redirect(base_url() . 'settings/products');
         }
     } else {
         $this->data->store_name = $store_name;
         $this->data->man_id = $man_id;
         $this->data->new_store_id = '';
         $this->data->message = validation_errors();
     }
     $this->javascript('views/settings.js.php');
     $this->_view = $this->_controller . '/index';
 }
开发者ID:kostya1017,项目名称:our,代码行数:73,代码来源:settings.php


注:本文中的MY_Controller::_switch_brand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。