Commit b2eeb1bb by Tobin

dc

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