Add tracking icon and popup in Listview

Add tracking icon and popup in Listview

May 29, 2018 PHP SugarCRM 0

'TRACKING_CODE' =>

 array (

   'type' => 'varchar',

   'label' => 'LBL_TRACKING_CODE',

   'width' => '10%',

   'default' => true,

'customCode' => '{$TRACKING_CODE} <a href="tracking_orders.php?trackcode={$TRACKING_CODE}" target="_blank"><img src="themes/default/images/tracking.png" border="0" style="cursor:pointer" width="25" height="25" ></a> ',

 ),

 

Tracking_orders.php::::::::::::::::
<?php
 $track=$_REQUEST['trackcode'];
 if($track)
 {
 $track=preg_replace('/\s+/', '', $track);
if(startsWith($track, "JC")==true)
{
$link = "<script>window.open('https://www.roylmail.com/track-your-item?trackNumber=".$track."', 'width=710,height=555,left=160,top=170')</script>";
}
else
{
$link = "<script>window.open('http://www.parceforce.com/track-trace?trackNumber=".$track."', 'width=710,height=555,left=160,top=170')</script>";
}
echo $link;
echo "<script type=\"text/javascript\" charset=\"utf-8\">window.self.close()</script>";
 }
 else
 {
echo "Invalid Tracking Code";
}
function startsWith($haystack, $needle) {
    // search backwards starting from haystack length characters from the end
    return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
}
function endsWith($haystack, $needle) {
    // search forward starting from end minus needle length characters
    return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
}
?>

 

Leave a Reply

Your email address will not be published. Required fields are marked *