class vtigerConnector{
var $www="http://e5crm.more7.com/e5ltd/crm/sugar.php";
var $data;
var $limit;
var $where;
var $count;
var $pp=50;
var $order_by="purchaseorder.duedate";
var $sorder="asc";
function vtigerConnector(){
}
function curl_get_contents($URL){
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
function getData(){
$www=$this->www;
$this->www.="?ok=ok";
if($this->order_by){
$opts['order_by']=$this->order_by;
$opts['sorder']=$this->sorder;
$this->www.="&order_by=".$this->order_by."&sorder=".$this->sorder;
}
$opts['limit']=$this->limit;
$this->www.="&limit=".$this->limit;
if($this->where){
$opts['where']=$this->where;
$this->www.="&where=".$this->where;
}
$source=file_get_contents($www."?content=".base64_encode(serialize($opts)));
//$file=fopen($this->www,"r");
//$source = fread($file,filesize($this->www));
$this->data=unserialize(base64_decode($source));
//echo $source."
";
//echo "click
";
//print_r($this->data)."
";
}
function getCount(){
$this->count=$this->data[0]['count'];
}
function getIdByCode($code){
$r=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$code."'"));
return $r['id'];
}
function formatNumber($no){
return number_format($no,$GLOBALS['sugar_config']['default_currency_significant_digits'],$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
}
function timeDate($time){
if($time!='0000-00-00')return $GLOBALS['timedate']->to_display_date($time);
}
function sortableColumn($name,$field,$ascdesc,$width=10,$index="index"){
$img="";
if($ascdesc=="asc"){
$sorder="desc";
if($this->order_by==$field)$img="_up";
}
else {
$sorder="asc";
if($this->order_by==$field)$img="_down";
}
$str='
