Month: November 2013

Social buttons Linkedin recommend,facebook like,google+

Social button sample

{“parsetags”: “explicit”}

function renderPlusone() {
gapi.plusone.render(“plusone-div”, {“size”: “medium”, “annotation”: “inline”, “href”: “http://www.voicent.com” });
}

function renderInRecommend() {
var parent = document.getElementById(‘inrecdiv’);
var child = document.getElementById(‘inrecimg’);
parent.removeChild(child);

var e = document.createElement(‘script’);
e.type=”text/javascript”;
e.src = ‘http://platform.linkedin.com/in.js’;
document.getElementsByTagName(‘head’)[0].appendChild(e);
}

function renderFbLike() {
var parent = document.getElementById(‘fblikediv’);
var child = document.getElementById(‘fblikeimg’);
parent.removeChild(child);

var html2 = “”;
document.getElementById(‘fblikediv’).innerHTML = html2;
}

Recurring booking,finding the start datetime and end datetime and Outlook configuration

function bookroom($id=”null”)
{
$this->set(‘reso’,$this->Resource->find(‘all’,array(‘conditions’=>array(‘Resource.req_book’=>1,’Resource.status’=>0))));
if(@$this->data[‘timein’] && @$this->data[‘roomid’])
{
$this->set(‘roomdetail’,$this->Booking->find(‘first’,array(‘conditions’=>array(‘Booking.r_number’=>$this->data[‘roomid’]))));
$this->set(‘srchtime’,$this->data);
}
else
{
$this->set(‘roomdetail’,$this->Booking->find(‘first’,array(‘conditions’=>array(‘Booking.r_number’=>$id))));

if($this->data)
{
if($this->data[‘Booking’][‘repeat’]==”1″)
{
/***********save here repeating events********************/
$this->request->data[‘Recurring’][‘repeat_type’]=$this->data[‘Booking’][‘repeat_type’];
$this->request->data[‘Recurring’][‘starts’]=$this->data[‘Booking’][‘start’];
$this->request->data[‘Recurring’][‘repeat_type’]=$this->data[‘Booking’][‘repeat_type’];
// $this->Recurring->save($this->data[‘Recurring’]);
if(!empty($this->data[‘book’]))
{
$bk=implode(‘,’,$this->data[‘book’]);
$this->request->data[‘Room’][‘resource’]=$bk;
}

$uid=$this->Session->read(‘uid’);
$this->request->data[‘Room’][‘status’]=”1″;
$this->request->data[‘Recurring’][‘ends’]=$this->data[‘occrnum’];
$this->request->data[‘Room’][‘fname’]=$this->data[‘Booking’][‘fname’];
$this->request->data[‘Room’][‘ename’]=$this->data[‘Booking’][‘ename’];
$this->request->data[‘Room’][‘lname’]=$this->data[‘Booking’][‘lname’];
$this->request->data[‘Room’][‘phone’]=$this->data[‘Booking’][‘phone’];
$this->request->data[‘Room’][’email’]=$this->data[‘Booking’][’email’];
$this->request->data[‘Room’][‘room_no’]=$this->data[‘Booking’][‘room_no’];
$this->request->data[‘Room’][‘r_name’]=$this->data[‘Booking’][‘r_name’];
$this->request->data[‘Room’][‘user_id’]=$uid;
if($this->data[‘Booking’][‘repeat_type’]==”1″ || $this->data[‘Booking’][‘repeat_type’]==”2″)
{

if(is_numeric($this->data[‘occrnum’]))
{
$date1 =$this->data[‘Booking’][‘date’];
for($i=0;$idata[‘occrnum’];$i++)
{
$tomorrow = date(‘y-m-d’,strtotime($date1 . “+”.$i.” days”));
$this->request->data[‘Room’][‘datein’]=$tomorrow.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$tomorrow.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}
}
else
{
$a=date_diff($this->data[‘Booking’][‘date’],$this->data[‘occrnum’]);
$date1 =$this->data[‘Booking’][‘date’];
for($i=0;$irequest->data[‘Room’][‘datein’]=$tomorrow.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$tomorrow.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}
}
}
else if($this->data[‘Booking’][‘repeat_type’]==”6”)
{

$incrementmnth=$this->data[‘Booking’][‘repeat_every_month’] + 1;
if(is_numeric($this->data[‘occrnum’]))
{
$final = date(‘y-m-d’,strtotime($this->data[‘Booking’][‘date’]));
for($i=0;$idata[‘occrnum’];$i++)
{
if($i!=0)
{
$final = date(‘y-m-d’,strtotime($final . “+”.$this->data[‘Booking’][‘repeat_every_month’].” months”));
}
$this->request->data[‘Room’][‘datein’]=$final.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$final.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}

}
else
{
$diff = abs(strtotime($this->data[‘occrnum’]) – strtotime($this->data[‘Booking’][‘date’]));
$months = floor($diff/(60*60*24*30));
$mn=$months/$incrementmnth;
$final = date(‘y-m-d’,strtotime($this->data[‘Booking’][‘date’]));
for($i=0;$idata[‘Booking’][‘repeat_every_month’].” months”));
}
$this->request->data[‘Room’][‘datein’]=$final.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$final.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}

}
}
else if($this->data[‘Booking’][‘repeat_type’]==”7”)
{
$incrementyr=$this->data[‘Booking’][‘repeat_every_year’] + 1;
$tdate = strtotime($this->data[‘Booking’][‘date’]);
if(is_numeric($this->data[‘occrnum’]))
{
$final = date(‘y-m-d’,strtotime($this->data[‘Booking’][‘date’]));
for($i=0;$idata[‘occrnum’];$i++)
{
if($i!=0)
{
$final = date(‘y-m-d’,strtotime($final . “+”.$incrementyr.” years”));
}
$this->request->data[‘Room’][‘datein’]=$final.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$final.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}

}
else
{
$diff = abs(strtotime($this->data[‘occrnum’]) – strtotime($this->data[‘Booking’][‘date’]));
$years = floor($diff / (365*60*60*24));
$incrementyr=$this->data[‘Booking’][‘repeat_every_year’] + 1;
$yr=$years/$incrementyr;
$final = date(‘y-m-d’,strtotime($this->data[‘Booking’][‘date’]));
for($i=0;$irequest->data[‘Room’][‘datein’]=$final.” “.$this->data[‘Booking’][‘inhrs’].”00″;
$this->request->data[‘Room’][‘dateout’]=$final.” “.$this->data[‘Booking’][‘outhrs’].”00″;
$this->Room->saveAll($this->data[‘Room’]);
}

}
}
else if($this->data[‘Booking’][‘repeat_type’]==”5”)
{

if(is_numeric($this->data[‘occrnum’]))
{
$day=$this->data[‘day’];
foreach($this->data[‘day’] as $b)
{
$dow = $b;
$step = $this->data[‘Booking’][‘repeat_every_week’] + 1;
$unit = ‘W’;
$date=$this->data[‘Booking’][‘date’];
$start = new DateTime($date);
$start->modify($dow); // Move to first occurence
$a=$this->data[‘occrnum’];
$dayz= 7*$step*$a;
$pass= “P”.$dayz.”D”;
$end = new DateTime($this->data[‘Booking’][‘date’]);
$end->add(new DateInterval($pass));
$interval = new DateInterval(“P{$step}{$unit}”);

$pe = new DatePeriod($start, $interval, $end);
foreach($pe as $pe){

$this->request->data[‘Room’][‘datein’]= $pe->format(‘Y-m-d’);
$this->request->data[‘Room’][‘dateout’]= $pe->format(‘Y-m-d’);
$this->Room->saveAll($this->data[‘Room’]);
}
}

}
else
{
$day=$this->data[‘day’];
foreach($this->data[‘day’] as $b)
{
$dow = $b;
$step = $this->data[‘Booking’][‘repeat_every_week’] + 1;
$unit = ‘W’;
$date=$this->data[‘Booking’][‘date’];
$start = new DateTime($date);
$end = new DateTime($this->data[‘occrnum’]);
$start->modify($dow); // Move to first occurence

$interval = new DateInterval(“P{$step}{$unit}”);
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $date) {

$this->request->data[‘Room’][‘datein’]= $date->format(‘Y-m-d’);
$this->request->data[‘Room’][‘dateout’]= $date->format(‘Y-m-d’);
$this->Room->saveAll($this->data[‘Room’]);
}
}

}
}

$this->Session->setFlash(‘Room Booked Successfully !’,’success’);
$this->redirect(array(‘action’=>’records’,’controller’=>’bookings’));

}
else
{
/***********save here non-repeating events********************/
if(!empty($this->data[‘book’]))
{
$bk=implode(‘,’,$this->data[‘book’]);
$this->request->data[‘Room’][‘resource’]=$bk;
}
$uid=$this->Session->read(‘uid’);
$this->request->data[‘Room’][‘status’]=”1″;
$this->request->data[‘Room’][‘fname’]=$this->data[‘Booking’][‘fname’];
$this->request->data[‘Room’][‘ename’]=$this->data[‘Booking’][‘ename’];
$this->request->data[‘Room’][‘lname’]=$this->data[‘Booking’][‘lname’];
$this->request->data[‘Room’][‘phone’]=$this->data[‘Booking’][‘phone’];
$this->request->data[‘Room’][’email’]=$this->data[‘Booking’][’email’];
$this->request->data[‘Room’][‘room_no’]=$this->data[‘Booking’][‘room_no’];
$this->request->data[‘Room’][‘r_name’]=$this->data[‘Booking’][‘r_name’];
$this->request->data[‘Room’][‘datein’] =$this->data[‘Booking’][‘date’].” “.$this->data[‘Booking’][‘inhrs’];
$this->request->data[‘Room’][‘dateout’]=$this->data[‘Booking’][‘date1’].” “.$this->data[‘Booking’][‘outhrs’];
$a=$this->request->data[‘Room’][‘datein’];
$b=$this->request->data[‘Room’][‘dateout’];
$this->request->data[‘Room’][‘user_id’]=$uid;
//$a='”$a”‘;
//$b='”$b”‘;
$q=”SELECT room_no FROM rooms WHERE NOT(((datein <= '$a' AND dateout = ‘$a’ AND dateout >= ‘$b’))
AND (( datein >= ‘$a’ AND datein >= ‘$b’ ) OR ( dateout <= '$a' AND dateout Room->query($q);
$b=0;
foreach($rm as $a)
{
$b=in_array($this->data[‘Room’][‘room_no’],$a[‘rooms’]);

}
if($b==”1”)
{
$this->Session->setFlash(‘Sorry! Room has already been booked! View Details‘);
$this->set(‘bookings’,$this->Room->find(‘all’,array(‘conditions’=>array(‘Room.room_no’=>$this->request->data[‘Room’][‘room_no’]))));
}
else
{
$this->Room->save($this->data[‘Room’]);

/********add event to outlook***********/
$d1=date(“Ymd”, strtotime($this->data[‘Booking’][‘date’]));
$d2=date(“Ymd”, strtotime($this->data[‘Booking’][‘date1’]));
$t1=date(“Gis”, strtotime($this->data[‘Booking’][‘inhrs’]));
$t2=date(“Gis”, strtotime($this->data[‘Booking’][‘outhrs’]));
$message=”BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:”.$d1.”T”.$t1.”00Z
DTEND:”.$d2.”T”.$t2.”00Z
DTSTAMP:20131025T075116Z
ORGANIZER;CN=Poria:tallent35@netsetsoftware.com:poriapardeep@gmail.com
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Poria:tallent35@netsetsoftware.com:poriapardeep@gmail.com
DESCRIPTION:This is an event invitation.
LOCATION: HospitalBook
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Event Invitation
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR”;

$headers = “From: Admin \n”;
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-Type: text/calendar; method=REQUEST;\n”;
$headers .= ‘ charset=”UTF-8″‘;
$headers .= “\n”;
$headers .= “Content-Transfer-Encoding: 7bit”;

$sendto=$this->data[‘Booking’][’email’];
$subject = “Meeting Subject”;
$subject = html_entity_decode($subject, ENT_QUOTES, ‘UTF-8’);

mail($sendto, $subject, $message, $headers);

/*******added event to outlook***********/
$this->Session->setFlash(“Room Booked Successfully”,”success”);
$this->redirect(array(‘action’=>’records’));
}

}
}
}
}