Commit b2eeb1bb by Tobin

dc

parent 2503af97
...@@ -96,26 +96,30 @@ ...@@ -96,26 +96,30 @@
return $unique; return $unique;
} }
function genQRcode($data){ function genQRcode($qr_id='',$url='',$custmLogo=''){
if(empty($qr_id)){
return '';
}
include 'qr_code/autoload.php'; include 'qr_code/autoload.php';
$logo = 'assets/images/qr-cod-icon.png'; $qr_id = urlencode($qr_id);
$QR = imagecreatefrompng('https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs=500x500&chl='.urlencode($data)); $logo = (!empty($custmLogo))?$custmLogo:'assets/images/qr-cod-icon.png';
$savePath = (!empty($url))?$url:"assets/uploads/qrcode/bookCode_".time().".png";
$logo = imagecreatefromstring(file_get_contents($logo)); $QR = imagecreatefrompng('https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs=500x500&chl='.$qr_id);
$QR_width = imagesx($QR);
$QR_height = imagesy($QR);
$logo_width = imagesx($logo); $logo = imagecreatefromstring(file_get_contents($logo));
$logo_height = imagesy($logo); $qrWidth = imagesx($QR)/3;
$qrHeight = imagesy($QR)/3;
$logo_qr_width = $QR_width/3; $logoWidth = imagesx($logo);
$scale = $logo_width/$logo_qr_width; $logoHeight = imagesy($logo);
$logo_qr_height = $logo_height/$scale;
imagecopyresampled($QR, $logo, $QR_width/3, $QR_height/3, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); $scale = $logoWidth/$qrWidth;
$imgWidth = $qrWidth;
$imgHeight = $logoHeight/$scale;
$savePath = "assets/uploads/qrcode/bookCode_".time().".png"; imagecopyresampled($QR,$logo,$imgWidth,$qrHeight,0,0,$imgWidth,$imgHeight,$logoWidth,$logoHeight);
imagepng($QR, $savePath); imagepng($QR, $savePath);
return $savePath; return $savePath;
......
...@@ -509,16 +509,34 @@ class Api_model extends CI_Model { ...@@ -509,16 +509,34 @@ class Api_model extends CI_Model {
unset($post_data['city']); unset($post_data['city']);
} }
if(isset($data['file'])){ if(isset($data['file'])){
$img=$data['file']['name']; $imgName = $data['file']['name'];
$expbanner = explode('.',$img); $imgNameArr = explode('.',$imgName);
$img_ext = strtolower($expbanner[1]); $imgExt = strtolower($imgNameArr[1]);
$rand = rand(10000,99999);
$encname = time().$rand; if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){
if($img_ext=='png' || $img_ext=='jpeg' || $img_ext == 'jpg' || $img_ext == 'gif'){ $imgPath = 'assets/uploads/user/CUST_'.$user_id.'.png';
$bannername = $encname.'.'.$img_ext; $imgQRPath = 'assets/uploads/user/CUST_QR_'.$user_id.'.png';
$imagePath="./assets/uploads/".$bannername; $bagImagePath = 'assets/uploads/user/bitmoji_back.png';
$post_data['profile_image'] = "assets/uploads/".$bannername; move_uploaded_file($data['file']["tmp_name"],"./".$imgPath);
move_uploaded_file($data['file']["tmp_name"],$imagePath);
$imgSrc = imagecreatefrompng($imgPath);
$bagSrc = imagecreatefrompng($bagImagePath);
$bagW = imagesx($bagSrc)/3;
$bagH = imagesy($bagSrc)/3;
$imgW = imagesx($imgSrc);
$imgH = imagesy($imgSrc);
$scale = $imgW/$bagW;
$iWidth = $bagW;
$iHeight = $imgH/$scale;
imagecopyresampled($bagSrc,$imgSrc,$iWidth,$bagH,0,0,$iWidth,$iHeight,$imgW,$imgH);
imagepng($bagSrc,$imgPath);
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); $state=$this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){ if($state){
$img_error = 1; $img_error = 1;
......
...@@ -444,7 +444,6 @@ class Webservice_model extends CI_Model { ...@@ -444,7 +444,6 @@ class Webservice_model extends CI_Model {
'is_favorite'=>$rs->is_favorite === 'true'? true: false, 'is_favorite'=>$rs->is_favorite === 'true'? true: false,
'latitude'=>$rs->latitude, 'latitude'=>$rs->latitude,
'longitude'=>$rs->longitude, 'longitude'=>$rs->longitude,
'currency'=>$countryData['currency'],
'currency_symbol'=>$countryData['currency_symbol'] 'currency_symbol'=>$countryData['currency_symbol']
); );
array_push($response, $resData); array_push($response, $resData);
...@@ -623,7 +622,8 @@ class Webservice_model extends CI_Model { ...@@ -623,7 +622,8 @@ class Webservice_model extends CI_Model {
'latitude'=>$rs->lat, 'latitude'=>$rs->lat,
'address_name'=>$transData['venue'], 'address_name'=>$transData['venue'],
'address'=>$rs->address, 'address'=>$rs->address,
'longitude'=>$rs->lng 'longitude'=>$rs->lng,
'currency_symbol'=>$countryData['currency_symbol']
); );
$res = array('status'=>1,'data'=>$resData); $res = array('status'=>1,'data'=>$resData);
} else { } else {
...@@ -1258,7 +1258,8 @@ class Webservice_model extends CI_Model { ...@@ -1258,7 +1258,8 @@ class Webservice_model extends CI_Model {
'rate'=>$price, 'rate'=>$price,
'location'=>$rs->location, 'location'=>$rs->location,
'is_favorite'=>$rs->is_favorite === 'true'? true: false, 'is_favorite'=>$rs->is_favorite === 'true'? true: false,
'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false 'is_editors_choice'=>$rs->is_editors_choice === 'true'? true: false,
'currency_symbol'=>$countryData['currency_symbol']
); );
array_push($response, $resData); array_push($response, $resData);
} }
......
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