Commit 9204878f by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !3
parents cfa05614 41655434
......@@ -7,6 +7,7 @@ application/logs/*
!application/logs/index.html
!application/*/.htaccess
application/config/database.php
composer.lock
......
......@@ -50,6 +50,31 @@ class Handlerequest extends CI_Controller {
}
}
public function wishPost() {
if($this->validate_headers() == true){
if(isset($_POST)) {
$data = $_POST;
if(isset($_FILES)){
$images = $this->handle_model->image_upload($_FILES);
$data = $_POST;
$data = $this->handle_model->wish_post($data, $images);
if($data['status'] == 1){
$data = $this->encrypted(json_encode($data['data']));
$this->response($data);
} else {
$this->errorResponse($data['code'],$data['message']);
}
} else {
$this->errorResponse('023','Wish media is missing');
}
} else {
$this->errorResponse('002','Invalid request');
}
} else {
$this->errorResponse('001','Authentication failed');
}
}
public function validate_headers() {
if($this->headers['x-api-key'] == $this->secret_key) {
return true;
......
......@@ -50,12 +50,14 @@ class Handle_model extends CI_Model {
'address'=>$data['address'],
'assist_name'=>$data['assist_name'],
'assist_phone_no'=>$data['assist_phone_no'],
'assist_email_id'=>$data['assist_email_id']
'assist_email_id'=>$data['assist_email_id'],
'code'=>$data['code'],
'assist_code'=>$data['assist_code']
);
$rs = $this->db->insert('customer', $userData);
if($rs) {
$insert_id = $this->db->insert_id();
$this->db->where('user_id',$insert_id)->where('user_type',1)->update('users',array('pin'=>md5($data['pin']), 'status'=>1));
$this->db->where('user_id',$insert_id)->where('user_type',1)->update('users',array('password'=>md5($data['pin']), 'status'=>1));
$user = $this->db->where('id', $insert_id)->get('customer')->row();
$res = array('status'=>1, 'message'=>'Registration Successfully', 'data'=>$user);
} else {
......@@ -104,6 +106,162 @@ class Handle_model extends CI_Model {
return $res;
}
function get_country($data) {
if(isset($data['id'])) {
$this->db->where('id',$data['id']);
}
$data_rs = $this->db->select('id,country_name,symbol,rate,code,flag')->where('status', 1)->get('currency');
if($data_rs->num_rows() > 0){
if($data_rs->num_rows() > 1){
$data = $data_rs->result();
} else {
$data = $data_rs->row();
}
$res = array('status'=>1, 'message'=>'Country List List', 'data'=>$data);
} else {
$res = array('status'=>0,'message'=>'No Country found!','code'=>'024');
}
return $res;
}
function image_upload($file) {
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 2000;
$config['max_width'] = 1500;
$config['max_height'] = 1500;
$this->load->library('upload');
$count = count($file['media']['name']);
for($i = 0; $i < $count; $i++) {
$_FILES['userfile']['name']= $file['media']['name'][$i];
$_FILES['userfile']['type']= $file['media']['type'][$i];
$_FILES['userfile']['tmp_name']= $file['media']['tmp_name'][$i];
$_FILES['userfile']['error']= $file['media']['error'][$i];
$_FILES['userfile']['size']= $file['media']['size'][$i];
$name = explode('.',$_FILES['userfile']['name']);
$length = count($name);
$ext = $name[$length-1];
$new_name = 'post_'.rand(111111,999999).'.'.$ext;
$config['file_name'] = $new_name;
$this->upload->initialize($config);
$this->upload->do_upload();
$dataInfo[] = 'assets/uploads/'.$new_name;
}
return $dataInfo;
}
function wish_post($data, $images) {
$wish = array(
'cust_id'=>$data['cust_id'],
'cat_id'=>$data['cat_id'],
'sub_cat_id'=>$data['sub_cat_id'],
'description'=>$data['description'],
'prod_name'=>$data['prod_name'],
'post_date'=>date('Y-m-d')
);
$rs = $this->db->insert('wish', $wish);
if($rs) {
$insert_id = $this->db->insert_id();
$data_image = array();
foreach($images as $image) {
$image_array = array(
'wish_id'=>$insert_id,
'url'=>$image
);
array_push($data_image,$image_array);
}
$this->db->insert_batch('wish_media', $data_image);
$res = array('status'=>1, 'message'=>'Wish posted successfully', 'data'=>array('wish_id'=>$insert_id));
} else {
$res = array('status'=>0,'message'=>'Something Went Wrong! Wish post Failed','code'=>'012');
}
return $res;
}
function wish_list($data) {
$state = 0;
if(isset($data['id'])) {
$this->db->where('wish.id',$data['id']);
$state = 1;
}
if(isset($data['cust_id'])) {
$this->db->where('wish.cust_id',$data['cust_id']);
}
if(isset($data['cat_id'])) {
$this->db->where('wish.cat_id',$data['cat_id']);
$state = 1;
}
if(isset($data['cat_id'])) {
$this->db->where('wish.cat_id',$data['cat_id']);
$state = 1;
}
if(isset($data['post_date'])) {
$this->db->where('wish.post_date',$data['post_date']);
$state = 1;
}
if($state == 0) {
$total = $this->db->where('status', 1)->select('id')->get('wish')->num_rows();
$per_page = 10;
if(isset($data['page'])) {
$page = $data['page'];
} else {
$page = 1;
}
$total_page = ceil($total / $per_page);
$start = ($page-1) * $per_page;
$this->db->limit($per_page, $start);
$meta = array(
'total'=>$total,
'per_page'=>$per_page,
'total_page'=>$total_page,
'curr_page'=>$page
);
}
if(isset($data['cust_id'])) {
$this->db->where('wish.cust_id',$data['cust_id']);
}
$this->db->select('wish.id,wish.post_date,wish.prod_name, wish.description, category.cat_name, sub_category.sub_cat_name,GROUP_CONCAT(DISTINCT wish_media.url SEPARATOR "\n") AS images');
$this->db->from('wish');
$this->db->join('wish_media','wish.id = wish_media.wish_id', 'LEFT');
$this->db->join('category','wish.cat_id = category.id', 'LEFT');
$this->db->join('sub_category','wish.sub_cat_id = sub_category.id', 'LEFT');
$this->db->where('wish.status', 1);
$this->db->group_by('wish.id');
$this->db->order_by('id', 'DESC');
$data_rs = $this->db->get();
if($data_rs->num_rows() > 0){
if($data_rs->num_rows() > 1){
$data = $data_rs->result();
} else {
$data = $data_rs->row();
}
if($state == 0) {
$rs = array('data'=>$data, 'meta'=>$meta);
$res = array('status'=>1, 'message'=>'Wish List', 'data'=>$rs);
} else {
$res = array('status'=>1, 'message'=>'Wish List', 'data'=>$data);
}
} else {
$res = array('status'=>0,'message'=>'No Wish posts found!','code'=>'025');
}
return $res;
}
......
......@@ -7,7 +7,7 @@ class Validation_model extends CI_Model {
'email'=>array('code'=>'005', 'message'=>'Invalid Email id')
),
'password'=>array('required'=>array('code'=>'006', 'message'=>'Password is null or empty'),
'min_4'=>array('code'=>'007', 'message'=>'Password length is minimum 6')
'min_4'=>array('code'=>'007', 'message'=>'Password length is minimum 4')
)
),
'registration'=> array('email_id'=>array('required'=>array('code'=>'004', 'message'=>'Email id is null or empty'),
......@@ -17,7 +17,7 @@ class Validation_model extends CI_Model {
'phone'=>array('code'=>'015', 'message'=>'Invalid Phone no'),
),
'pin'=>array('required'=>array('code'=>'006', 'message'=>'Password is null or empty'),
'min_4'=>array('code'=>'007', 'message'=>'Password length is minimum 6')
'min_4'=>array('code'=>'007', 'message'=>'Password length is minimum 4')
),
'name'=>array('event_id'=>array('required'=>array('code'=>'016', 'message'=>'Name is null or empty')
)
......@@ -37,6 +37,8 @@ class Validation_model extends CI_Model {
),
'categories'=>array(),
'sub_categories'=>array(),
'get_country'=>array(),
'wish_list'=>array(),
'forgot'=> array('email_id'=>array('required'=>array('code'=>'ER02', 'message'=>'Email id is null or empty'),
'email'=>array('code'=>'ER03', 'message'=>'Invalid Email id')
)
......
......@@ -4,208 +4,8 @@
<script src="<?php echo base_url('assets/js/jquery.matchHeight.min.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/main.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/parsley.min.js'); ?>"></script>
<?php
if(isset($datatable)) {
include 'datatable.php';
}
?>
<!--Local Stuff-->
<script>
jQuery(document).ready(function($) {
"use strict";
// Pie chart flotPie1
var piedata = [
{ label: "Desktop visits", data: [[1,32]], color: '#5c6bc0'},
{ label: "Tab visits", data: [[1,33]], color: '#ef5350'},
{ label: "Mobile visits", data: [[1,35]], color: '#66bb6a'}
];
$.plot('#flotPie1', piedata, {
series: {
pie: {
show: true,
radius: 1,
innerRadius: 0.65,
label: {
show: true,
radius: 2/3,
threshold: 1
},
stroke: {
width: 0
}
}
},
grid: {
hoverable: true,
clickable: true
}
});
// Pie chart flotPie1 End
// cellPaiChart
var cellPaiChart = [
{ label: "Direct Sell", data: [[1,65]], color: '#5b83de'},
{ label: "Channel Sell", data: [[1,35]], color: '#00bfa5'}
];
$.plot('#cellPaiChart', cellPaiChart, {
series: {
pie: {
show: true,
stroke: {
width: 0
}
}
},
legend: {
show: false
},grid: {
hoverable: true,
clickable: true
}
});
// cellPaiChart End
// Line Chart #flotLine5
var newCust = [[0, 3], [1, 5], [2,4], [3, 7], [4, 9], [5, 3], [6, 6], [7, 4], [8, 10]];
var plot = $.plot($('#flotLine5'),[{
data: newCust,
label: 'New Data Flow',
color: '#fff'
}],
{
series: {
lines: {
show: true,
lineColor: '#fff',
lineWidth: 2
},
points: {
show: true,
fill: true,
fillColor: "#ffffff",
symbol: "circle",
radius: 3
},
shadowSize: 0
},
points: {
show: true,
},
legend: {
show: false
},
grid: {
show: false
}
});
// Line Chart #flotLine5 End
// Traffic Chart using chartist
if ($('#traffic-chart').length) {
var chart = new Chartist.Line('#traffic-chart', {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
[0, 18000, 35000, 25000, 22000, 0],
[0, 33000, 15000, 20000, 15000, 300],
[0, 15000, 28000, 15000, 30000, 5000]
]
}, {
low: 0,
showArea: true,
showLine: false,
showPoint: false,
fullWidth: true,
axisX: {
showGrid: true
}
});
chart.on('draw', function(data) {
if(data.type === 'line' || data.type === 'area') {
data.element.animate({
d: {
begin: 2000 * data.index,
dur: 2000,
from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
to: data.path.clone().stringify(),
easing: Chartist.Svg.Easing.easeOutQuint
}
});
}
});
}
// Traffic Chart using chartist End
//Traffic chart chart-js
if ($('#TrafficChart').length) {
var ctx = document.getElementById( "TrafficChart" );
ctx.height = 150;
var myChart = new Chart( ctx, {
type: 'line',
data: {
labels: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul" ],
datasets: [
{
label: "Visit",
borderColor: "rgba(4, 73, 203,.09)",
borderWidth: "1",
backgroundColor: "rgba(4, 73, 203,.5)",
data: [ 0, 2900, 5000, 3300, 6000, 3250, 0 ]
},
{
label: "Bounce",
borderColor: "rgba(245, 23, 66, 0.9)",
borderWidth: "1",
backgroundColor: "rgba(245, 23, 66,.5)",
pointHighlightStroke: "rgba(245, 23, 66,.5)",
data: [ 0, 4200, 4500, 1600, 4200, 1500, 4000 ]
},
{
label: "Targeted",
borderColor: "rgba(40, 169, 46, 0.9)",
borderWidth: "1",
backgroundColor: "rgba(40, 169, 46, .5)",
pointHighlightStroke: "rgba(40, 169, 46,.5)",
data: [1000, 5200, 3600, 2600, 4200, 5300, 0 ]
}
]
},
options: {
responsive: true,
tooltips: {
mode: 'index',
intersect: false
},
hover: {
mode: 'nearest',
intersect: true
}
}
} );
}
//Traffic chart chart-js End
// Bar Chart #flotBarChart
$.plot("#flotBarChart", [{
data: [[0, 18], [2, 8], [4, 5], [6, 13],[8,5], [10,7],[12,4], [14,6],[16,15], [18, 9],[20,17], [22,7],[24,4], [26,9],[28,11]],
bars: {
show: true,
lineWidth: 0,
fillColor: '#ffffff8a'
}
}], {
grid: {
show: false
}
});
// Bar Chart #flotBarChart End
});
</script>
\ No newline at end of file
<?php
if(isset($datatable)) {
include 'datatable.php';
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment