'', 'success' => '' ]; protected $_flash_error = [ 'error' => '', 'success' => '' ]; public function __construct() { parent::__construct(); $this->load->database(); // load services $this->load->library('helpers_service'); $this->load->library('stripe_helper_service'); // $this->load->library('stevesie_api_helper_service'); // $this->load->library('sale_detail_api_service'); $this->load->model('school_model'); $this->load->model('content_model'); $this->load->model('professor_model'); $this->load->model('textbook_model'); $this->load->model('classes_model'); $this->load->model('inventory_model'); // $this->load->library('helpers_service'); $this->_data['layout_clean_mode'] = FALSE; /** * social links */ $facebook_link = '#'; $twitter_link = '#'; $instagram_link = '#'; $this->_data['facebook_link'] = $facebook_link; $this->_data['twitter_link'] = $twitter_link; $this->_data['instagram_link'] = $instagram_link; } public function index($offset = 0) { $content = $this->content_model->get_all(['status'=>1]); $this->_data['content'] = []; if($content ){ $data = []; foreach ($content as $key => $value) { $data[$value->content_name]= $value; } $this->_data['content'] = $data; } $meta_data = $this->db->select('content,content_name')->from('content')->where('content_name','home_page_meta_title') ->or_where('content_name','home_page_meta_description')->get()->result_array(); if($meta_data){ $meta_data = array_column($meta_data,'content','content_name'); $this->_data['meta']['title']= $meta_data['home_page_meta_title']; $this->_data['meta']['desc']= $meta_data['home_page_meta_description']; } $this->_data['active'] = 'home'; $this->_render('Guest/Home', $this->_data); } public function get_all_categories() { $data = $this->school_model->get_all(['status' => 1]); if ($data) { echo json_encode($data); exit(); } echo json_encode(FALSE); exit(); } public function load_items_by_school_select() { $school_id = $this->input->get('school_id'); if ($school_id == 0) { $output = [ 'error' => TRUE, 'status' => 0, 'msg' => 'all' ]; echo json_encode($output); exit(); } $items = $this->inventory_model->get_all(['school_id' => $school_id]); $school_data = $this->school_model->get($school_id); if (!empty($items)) { $output = [ 'success' => TRUE, 'status' => 200, 'data' => $items, 'school_name' => $school_data->name ]; echo json_encode($output); exit(); } else { $output = [ 'error' => TRUE, 'status' => 0, 'msg' => 'No items found for: ' . $school_data->name . ' school.' ]; echo json_encode($output); exit(); } } public function item_details($id) { $item_details = $this->inventory_model->get_item_details_fe($id); if (!empty($item_details)) { $this->_data['item_details'] = $item_details; } $school_id = $item_details->school_id; $related_items = $this->inventory_model->get_all(['school_id' => $school_id]); if (!empty($related_items)) { $this->_data['related_items'] = $related_items; } // echo '
';print_r($related_items);die();
$this->_data['active'] = 'item_details';
$this->_render('Guest/Item_details', $this->_data);
}
public function about()
{
$this->_data['active'] = 'about';
$this->_render('Guest/About', $this->_data);
}
public function contact()
{
if($this->input->post('submit_btn')){
if($this->input->post('email') && $this->input->post('message') ){
$email = htmlentities($this->input->post('email'));
// $name = htmlentities($this->input->post('name'));
$message = htmlentities($this->input->post('message'));
$regex = '/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/';
if (!preg_match($regex, $email)) {
$this->_data['status_'] = 'error';
$this->_data['status_msg'] = 'Invalid Email';
}else{
$data = array(
'name'=>'',
'email'=>$email,
'message'=>$message,
'created_at'=>date('Y-m-d')
);
$this->db->insert('contact_us',$data);
$this->load->model('email_model');
$this->load->library('mail_service');
$this->mail_service->set_adapter('smtp');
$from_email = $this->config->item('from_email');
$this->mail_service->send($from_email, $from_email, "Contact Us", $message, $email);
$this->_data['status_'] = 'success';
$this->_data['status_msg'] = 'Form submitted successfully.';
}
}else{
$this->_data['status_'] = 'error';
$this->_data['status_msg'] = 'Fill All required Fields';
}
}
$this->_data['meta'] = [
'title'=>'',
'desc'=>'',
];
$meta_data = $this->db->select('content,content_name')->from('content')->where('content_name','contact_page_meta_title')
->or_where('content_name','contact_page_meta_description')->get()->result_array();
if($meta_data){
$meta_data = array_column($meta_data,'content','content_name');
$this->_data['meta']['title']= $meta_data['contact_page_meta_title'];
$this->_data['meta']['desc']= $meta_data['contact_page_meta_description'];
}
$this->_data['active'] = 'contact';
$this->_render('Guest/Contact', $this->_data);
}
public function privacy_policy()
{
$this->_data['active'] = 'privacy_policy';
$this->_data['data'] = $this->db->select('*')->from('content')->where('content_name','privacy_policy')->get()->row_array();
$this->_render('Guest/Privacy_policy', $this->_data);
}
public function buy($offset = 0)
{
// if($this->session->userdata('user_id'))
// {
// //create setup intent used in js
// $stripe = new \Stripe\StripeClient(
// $this->config->item('stripe_secret_key')
// );
// $this->_data['clientSecret'] = $stripe->setupIntents->create([
// 'payment_method_types' => ['card'],
// ])->client_secret;
// }
$this->_data['stripe_client'] = $this->config->item('stripe_publish_key');
//get all school data
if ($this->input->get('school_id', TRUE))
{
$this->_data['school_data'] = $this->school_model->get_all(['status' => 1, 'id' => $this->input->get('school_id') ]);
}
if ($this->input->get('professor_id', TRUE))
{
$this->_data['professor_data'] = $this->professor_model->get_all(['status' => 1, 'id' => $this->input->get('professor_id') ]);
}
if ($this->input->get('class_id', TRUE))
{
$this->_data['classes_data'] = $this->classes_model->get_all(['status' => 1, 'id' => $this->input->get('class_id') ]);
}
if ($this->input->get('isbn', TRUE))
{
$this->_data['textbook_data'] = $this->db->select('distinct(isbn)')->from('inventory')->where('isbn', $this->input->get('isbn', TRUE))->get()->result_array();
}
$search_term = $this->input->get('search_term', TRUE);
$school_id = $this->input->get('school_id', TRUE);
$professor_id = $this->input->get('professor_id', TRUE);
$textbook_id = $this->input->get('textbook_id', TRUE);
$isbn = $this->input->get('isbn', TRUE);
$class_id = $this->input->get('class_id', TRUE);
$order_by = $this->input->get('order_by', TRUE);
$direction = $this->input->get('direction', TRUE);
// if($school_id || $professor_id || $textbook_id || $class_id || $search_term)
// {
// for pagination
$this->load->library('pagination');
$rows_data = $this->inventory_model->get_all_active_items_list_fe($search_term, $school_id, $professor_id, $textbook_id, $class_id,$isbn,$order_by,$direction);
$total_rows = 0;
if (!empty($rows_data))
{
$total_rows = count($rows_data);
}
$limit = 10;
// $offset = $offset * $limit ;
if ($offset != 0 OR $offset != "")
{
$offset = ($offset - 1) * $limit;
}
$this->pagination->initialize([
'reuse_query_string' => TRUE,
'base_url' => base_url().'/buy',
'total_rows' => $total_rows,
'per_page' => $limit,
'num_links' => 2,
'full_tag_open' => '";
print_r($output);
die();
}
public function get_review(){
if( isset($_POST['id']) )
{
$data = $this->db->select('r.*,u.image,u.first_name')->from('review r')->join('user u','r.user_id=u.id')->where('inventory_id',$_POST['id'])->where('r.status',1)->order_by('r.created_at')->get()->result_array();
echo json_encode(['status'=>true,'data'=>$data]);
exit;
}
echo json_encode(['status'=>false]);
exit;
}
}