Commit 444e9510 by Tobin

dc

parent 2f39e1d8
...@@ -12,7 +12,7 @@ class Booking extends CI_Controller { ...@@ -12,7 +12,7 @@ class Booking extends CI_Controller {
redirect(base_url()); redirect(base_url());
} }
} }
public function viewBookings(){ public function viewBookings(){
$template['page'] = 'Booking/viewBooking'; $template['page'] = 'Booking/viewBooking';
$template['menu'] = 'Booking Management'; $template['menu'] = 'Booking Management';
......
...@@ -109,8 +109,8 @@ ...@@ -109,8 +109,8 @@
$QR = imagecreatefrompng('https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs=500x500&chl='.$qr_id); $QR = imagecreatefrompng('https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs=500x500&chl='.$qr_id);
$logo = imagecreatefromstring(file_get_contents($logo)); $logo = imagecreatefromstring(file_get_contents($logo));
$qrWidth = imagesx($QR)/3; $qrWidth = imagesx($QR)/2;
$qrHeight = imagesy($QR)/3; $qrHeight = imagesy($QR)/2;
$logoWidth = imagesx($logo); $logoWidth = imagesx($logo);
$logoHeight = imagesy($logo); $logoHeight = imagesy($logo);
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
$imgWidth = $qrWidth; $imgWidth = $qrWidth;
$imgHeight = $logoHeight/$scale; $imgHeight = $logoHeight/$scale;
imagecopyresampled($QR,$logo,$imgWidth,$qrHeight,0,0,$imgWidth,$imgHeight,$logoWidth,$logoHeight); imagecopyresampled($QR,$logo,125,120,0,0,$imgWidth,$imgHeight,$logoWidth,$logoHeight);
imagepng($QR, $savePath); imagepng($QR, $savePath);
return $savePath; return $savePath;
......
...@@ -538,10 +538,23 @@ class Api_model extends CI_Model { ...@@ -538,10 +538,23 @@ class Api_model extends CI_Model {
return $res; return $res;
} }
function imageResize($path,$size){
$this->load->library('image_lib');
$config['width'] = $size['width'];
$config['height'] = $size['height'];
$config['new_image'] = $path;
$config['source_image'] = $path;
$config['create_thumb'] = FALSE;
$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
public function update_profile($data) { public function update_profile($data) {
try{ try{
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
$img_error = 0;
if($user_id > 0) { if($user_id > 0) {
$post_data = $data; $post_data = $data;
unset($post_data['file']); unset($post_data['file']);
...@@ -551,61 +564,26 @@ class Api_model extends CI_Model { ...@@ -551,61 +564,26 @@ class Api_model extends CI_Model {
$post_data['profile_city'] = $post_data['city']; $post_data['profile_city'] = $post_data['city'];
unset($post_data['city']); unset($post_data['city']);
} }
if(isset($data['file'])){
$imgName = $data['file']['name'];
$imgNameArr = explode('.',$imgName);
$imgExt = strtolower($imgNameArr[1]);
if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){
$imgPath = 'assets/uploads/user/CUST_'.$user_id.'.jpg';
$imgQRPath = 'assets/uploads/user/CUST_QR_'.$user_id.'.jpg';
$imgFramePath = 'assets/images/bitmojiFrame.jpg';
move_uploaded_file($data['file']["tmp_name"],"./".$imgPath);
$usrImage = imagecreatefrompng($imgPath);
$imgFrame = imagecreatefromjpeg($imgFramePath);
imagecopy($imgFrame,$usrImage,(imagesx($imgFrame)/2)-(imagesx($usrImage)/2),(imagesy($imgFrame)/2)-(imagesy($usrImage)/2),0,0,imagesx($usrImage),imagesy($usrImage));
imagesavealpha($imgFrame, true);
imagepng($imgFrame,$imgPath,0);
genQRcode(encode_param($user_id),$imgQRPath,$imgPath);
$post_data['profile_image'] = $imgPath;
$post_data['profile_image_qr'] = $imgQRPath;
$state=$this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){
$img_error = 1;
} else {
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
}
} else {
$res = array('status'=>0,'message'=>'Invalid Image type','code'=>'ER31');
}
} else {
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){
$img_error = 1;
} else {
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
}
}
if($img_error == 1) { $state = $this->db->where('customer_id',$user_id)->update('customer',$post_data);
$this->db->select('customer.name,customer.dob,customer.phone,customer.email, if($state){
customer.profile_image AS image,customer.gender, $this->db->select('customer.name,customer.dob,customer.phone,customer.email,
users.id AS userId, customer.profile_city AS city'); customer.profile_image AS image,customer.gender,users.id AS userId,
customer.profile_image_qr,customer.profile_city AS city');
$this->db->where('users.id',$user_id); $this->db->where('users.id',$user_id);
$this->db->from('users'); $this->db->from('users');
$this->db->join('customer','customer.customer_id = users.id'); $this->db->join('customer','customer.customer_id = users.id');
$result = $this->db->get()->row(); $result = $this->db->get()->row();
if($result){ if($result){
$result->dob = (!empty($result->dob))?date("m/d/Y", ($result->dob)/1000):''; $result->dob = (!empty($result->dob))?date("m/d/Y", ($result->dob)/1000):'';
$res = array('status'=>1,'data'=>$result); $res = array('status'=>1,'data'=>$result);
} else { } else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }
} } else {
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
}
} else { } else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }
......
...@@ -954,11 +954,11 @@ class Webservice_model extends CI_Model { ...@@ -954,11 +954,11 @@ class Webservice_model extends CI_Model {
public function update_profile($data) { public function update_profile($data) {
try{ try{
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
$img_error = 0;
if($user_id > 0) { if($user_id > 0) {
$post_data = $data; $post_data = $data;
unset($post_data['file']); unset($post_data['file']);
unset($post_data['auth_token']); unset($post_data['auth_token']);
if(isset($data['email'])){ if(isset($data['email'])){
$this->db->select('customer.email'); $this->db->select('customer.email');
$this->db->where('customer.email',$data['email']); $this->db->where('customer.email',$data['email']);
...@@ -972,44 +972,58 @@ class Webservice_model extends CI_Model { ...@@ -972,44 +972,58 @@ class Webservice_model extends CI_Model {
return $res; return $res;
} }
} }
if(isset($data['file'])){ if(isset($data['file'])){
$imgName = $data['file']['name']; $imgName = $data['file']['name'];
$imgNameArr = explode('.',$imgName); $imgNameArr = explode('.',$imgName);
$imgExt = strtolower($imgNameArr[1]); $imgExt = strtolower($imgNameArr[1]);
if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){ if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){
$imgPath = 'assets/uploads/user/CUST_'.$user_id.'.'.$imgExt;
move_uploaded_file($data['file']["tmp_name"],"./".$imgPath); $imgPath = 'assets/uploads/user/CUST_'.$user_id.'.png';
$imgQRPath = 'assets/uploads/user/CUST_QR_'.$user_id.'.png';
$imgFramePath = 'assets/images/bitmojiFrame.png';
move_uploaded_file($data['file']["tmp_name"],"./".$imgPath);
$this->imageResize($imgPath,array('width'=>'300','height'=>'300'));
$usrImage = imagecreatefrompng($imgPath);
$imgFrame = imagecreatefrompng($imgFramePath);
imagecopy($imgFrame,$usrImage,(imagesx($imgFrame)/2)-(imagesx($usrImage)/2),(imagesy($imgFrame)/2)-(imagesy($usrImage)/2),0,0,imagesx($usrImage),imagesy($usrImage));
imagesavealpha($imgFrame, true);
imagepng($imgFrame,$imgPath,0);
genQRcode(encode_param($user_id),$imgQRPath,$imgPath);
$post_data['profile_image'] = $imgPath; $post_data['profile_image'] = $imgPath;
$post_data['profile_image_qr'] = $imgQRPath;
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); $state = $this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){ if(!$state){
$img_error = 1; return array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
} else {
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
} }
} else { } else {
$res = array('status'=>0,'message'=>'Invalid Image type','code'=>'ER41'); return array('status'=>0,'message'=>'Invalid Image type','code'=>'ER41');
} }
} else { } else {
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data); $state = $this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){ if(!$state){
$img_error = 1; return array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
} else {
$res = array('status'=>0,'message'=>'Profile update failed','code'=>'ER32');
} }
} }
if($img_error == 1) {
$this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.profile_image AS image,customer.gender,users.id AS userId, customer.city'); $this->db->select('customer.name,customer.dob,customer.phone,customer.email,customer.gender,
$this->db->where('users.id',$user_id); customer.profile_image AS image,users.id AS userId, customer.city,
$this->db->from('users'); customer.profile_image_qr AS customer_qr');
$this->db->join('customer','customer.customer_id = users.id'); $this->db->where('users.id',$user_id);
$result = $this->db->get()->row(); $this->db->from('users');
if($result){ $this->db->join('customer','customer.customer_id = users.id');
$res = array('status'=>1,'data'=>$result); $result = $this->db->get()->row();
} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); if($result){
} $res = array('status'=>1,'data'=>$result);
} else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }
} else { } else {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
...@@ -1975,5 +1989,19 @@ class Webservice_model extends CI_Model { ...@@ -1975,5 +1989,19 @@ class Webservice_model extends CI_Model {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19'); $res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
} }
} }
public function imageResize($path,$size){
$this->load->library('image_lib');
$config['width'] = $size['width'];
$config['height'] = $size['height'];
$config['new_image'] = $path;
$config['source_image'] = $path;
$config['create_thumb'] = FALSE;
$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
} }
?> ?>
assets/images/qr-cod-icon.png

10.2 KB | W: | H:

assets/images/qr-cod-icon.png

11.8 KB | W: | H:

assets/images/qr-cod-icon.png
assets/images/qr-cod-icon.png
assets/images/qr-cod-icon.png
assets/images/qr-cod-icon.png
  • 2-up
  • Swipe
  • Onion skin
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