init
This commit is contained in:
148
modules/EcmPriceBooks/ListHelper.php
Executable file
148
modules/EcmPriceBooks/ListHelper.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?
|
||||
function dy($text) {
|
||||
$text=str_replace("ą","1",$text);
|
||||
$text=str_replace("ć","a",$text);
|
||||
$text=str_replace("ę","e",$text);
|
||||
$text=str_replace("A<EFBFBD>","3",$text);
|
||||
$text=str_replace("A<EFBFBD>","n",$text);
|
||||
$text=str_replace("A3","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","o",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
$text=str_replace("Ao","Y",$text);
|
||||
$text=str_replace("Ą","Y",$text);
|
||||
$text=str_replace("Ć","A",$text);
|
||||
$text=str_replace("<EFBFBD>~","E",$text);
|
||||
$text=str_replace("A<EFBFBD>","L",$text);
|
||||
$text=str_replace("Af","N",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","O",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
return plc($text);
|
||||
}
|
||||
function plc($string, $type = UTF8_TO_WIN1250)
|
||||
{
|
||||
$win2utf = array(
|
||||
"\xb9" => "\xc4\x85", "\xa5" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\x9c" => "\xc5\x9b", "\x8c" => "\xc5\x9a",
|
||||
"\xbf" => "\xc5\xbc", "\x8f" => "\xc5\xbb",
|
||||
"\x9f" => "\xc5\xba", "\xaf" => "\xc5\xb9",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
$iso2utf = array(
|
||||
"\xb1" => "\xc4\x85", "\xa1" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\xb6" => "\xc5\x9b", "\xa6" => "\xc5\x9a",
|
||||
"\xbc" => "\xc5\xba", "\xac" => "\xc5\xb9",
|
||||
"\xbf" => "\xc5\xbc", "\xaf" => "\xc5\xbb",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
|
||||
if ($type == ISO88592_TO_UTF8)
|
||||
return strtr($string, $iso2utf);
|
||||
if ($type == UTF8_TO_ISO88592)
|
||||
return strtr($string, array_flip($iso2utf));
|
||||
if ($type == WIN1250_TO_UTF8)
|
||||
return strtr($string, $win2utf);
|
||||
if ($type == UTF8_TO_WIN1250)
|
||||
return strtr($string, array_flip($win2utf));
|
||||
if ($type == ISO88592_TO_WIN1250)
|
||||
return strtr($string, "\xa1\xa6\xac\xb1\xb6\xbc",
|
||||
"\xa5\x8c\x8f\xb9\x9c\x9f");
|
||||
if ($type == WIN1250_TO_ISO88592)
|
||||
return strtr($string, "\xa5\x8c\x8f\xb9\x9c\x9f",
|
||||
"\xa1\xa6\xac\xb1\xb6\xbc");
|
||||
}
|
||||
function imgType($name){
|
||||
if(substr($name, -4, 4) == '.jpg' || substr($name, -4, 4) == 'jpeg')return "IMAGETYPE_JPEG";
|
||||
elseif(substr($name, -4, 4) == '.gif')return "IMAGETYPE_GIF";
|
||||
elseif(substr($name, -4, 4) == '.png') return "IMAGETYPE_PNG";
|
||||
}
|
||||
|
||||
function resizeImage($source, $max_x, $max_y, $save_image, $jpeg_quality = 100){
|
||||
if(imgType($source) == "IMAGETYPE_JPEG")$img_src = imagecreatefromjpeg($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_GIF")$img_src = imagecreatefromgif($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_PNG")$img_src = imagecreatefrompng($source);
|
||||
else die('Wrong filetype! Accepted images: JPG/JPEG, GIF, PNG');
|
||||
|
||||
$image_x = imagesx($img_src);
|
||||
$image_y = imagesy($img_src);
|
||||
if($image_x > $image_y){
|
||||
$ratio_x = ($image_x > $max_x) ? $max_x/$image_x : 1;
|
||||
$ratio_y = $ratio_x;
|
||||
$move = 'y';
|
||||
}
|
||||
else{
|
||||
$ratio_y = ($image_y > $max_y) ? $max_y/$image_y : 1;
|
||||
$ratio_x = $ratio_y;
|
||||
$move = 'x';
|
||||
}
|
||||
$new_x = $image_x*$ratio_x;
|
||||
$new_y = $image_y*$ratio_y;
|
||||
|
||||
$move_x = ($move == "x") ? ($max_x-$new_x)/2 : 0;
|
||||
$move_y = ($move == "y") ? ($max_y-$new_y)/2 : 0;
|
||||
|
||||
$new_img = imagecreatetruecolor($max_x, $max_y);
|
||||
$background = imagecolorallocate($new_img, 255, 255, 255);
|
||||
$black = imagecolorallocate($new_img,0,0,0);
|
||||
imagefill($new_img, 0, 0, $background);
|
||||
imagecopyresampled($new_img, $img_src, $move_x, $move_y, 0, 0, $new_x, $new_y, $image_x, $image_y);
|
||||
|
||||
$ix=ceil($max_x/90);
|
||||
$iy=ceil($max_y/90);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$i,0,$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$i,$max_x,$i,$background);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$max_x-$i,0,$max_x-$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$max_y-$i,$max_x,$max_y-$i,$background);
|
||||
|
||||
if(imgType($save_image) == "IMAGETYPE_JPEG")imagejpeg($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_GIF")imagegif($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_PNG") imagepng($new_img, $save_image,100);
|
||||
}
|
||||
function addExchangeRateValue($value,$field,$er,$n=false)
|
||||
{
|
||||
$tabs=array("fob_price","purchase_price","ems_price","srp_price","srp_promo_price","price","list_price");
|
||||
foreach($tabs as $tab)
|
||||
{
|
||||
if($tab==$field)
|
||||
{
|
||||
if(!$n)$value=number_format($value/$er,2,",",".");
|
||||
else $value=$value/$er;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function sortLink($order_by,$sorder,$title)
|
||||
{
|
||||
if($order_by==$_REQUEST['order_by'])
|
||||
{
|
||||
if($sorder=="desc")
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_down.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="asc";
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_up.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="desc";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s=$sorder;
|
||||
}
|
||||
|
||||
return '<a style="cursor:pointer;" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id='.$_GET['customview_id'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&order_by='.$order_by.'&sorder='.$s.'\',\'products\');">'.$title.' '.$img.'</a>';
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user