So I have integrated 7 shifts into SambaPOS and using it along the time clock Emre had built recently. It works really well I will share it with you here.
For those wondering about the time clock here it is: Time Clock.zip (10.4 KB)
This is a configuration task you will import using DB Tools in Settings. Once imported you go to Settings > Configuration Tasks and click on Time Clock.
First thing you will need is the script:
You can ignore Method 2 they removed that method from their api because they want it for internal use only (Bastards) anyway.
var apikey = 'YOUR API KEY HERE';
var method1 = 'locations';
var method2 = 'time_punches/punch';
var method3 = 'time_punches';
var method4 = 'users';
function getuser(pincode) {
var getusers = web.PostData('https://api.7shifts.com/v1/'+method4+'/','',''+apikey+'','');
var user = JSON.parse(getusers);
for(var i=0; i<user.data.length; i++){
if(user.data[i].user.employee_id == pincode)
return user.data[i].user.id;
}
}
function getlocation() {
var location = web.PostData('https://api.7shifts.com/v1/locations','',''+apikey+'','');
var getlocations = JSON.parse(location);
return getlocations.data[0].location.id;
}
function punch(pincode,timein,timeout) {
var eid = getuser(pincode);
var loc = getlocation();
var execpunch = web.PostJson('https://api.7shifts.com/v1/'+method3+'/','{ "time_punch": { "user_id": '+eid+', "location_id": '+loc+', "clocked_in": "'+timein+'", "clocked_out": "'+timeout+'" } }',''+apikey+'','');
var getpid = JSON.parse(execpunch);
return getpid.data.time_punch.id;
}
7shiftcreate.punch('{REPORT SQL DETAILS:SELECT PinCode FROM Users WHERE Name ='{SETTING:CURRENTUSER}':F.PinCode}','[=FD(ADS('{REPORT OPEN TASK DETAILS:=FD([T.StartDate],'yyyy-MM-dd'),T.StartTime,:(TSC.User={SETTING:CURRENTUSER}) and (TST=Punch):{0} {1}}',+18000),'yyyy-MM-dd HH:mm:ss')]','[=FD(ADS('{DATE:yyyy-MM-dd HH:mm:ss}',+18000),'yyyy-MM-dd HH:mm:ss')]')
Now what is important is in that script call you have to offset the timezone difference with yours and 7shifts servers they refuse to fix that issue. In my case i had a +5 hour difference so you will see I added 18000 seconds. Just replace the 18000 with whatever offset you need from their servers.
What this does is it records the punch when the user clocks out for the day. The reason for this is because of how the Create method in 7shifts API works. You want to do the punch in and out at the same time or else its even more complicated with needing to use 2 calls one to create and one to update.
It uses the task from the SambaPOS time clock for the punch in time and then just uses current date/time for punch out.
Eventually I will spend the time to completely integrate it where SambaPOS reads punches from 7shifts for reports etc and it will be fully synced even when editing punches from inside SambaPOS. I would also like to fully sync the scheduling portion of it so we can do some cool automation in SambaPOS based on employee schedules. Like not allowing someone to clock in or use the pos if they are not scheduled etc.
I have made some changes to this integration. I will post them tomorrow. I also have integrated Sales to 7shifts so we can track labor %. I need a few features to complete time punching though so maybe @VehbiEmiroglu can help me with that eventually. I specifically need the ability to use PUT method to update punches vs POST method.
@VehbiEmiroglu Before I share that I want to clarify. I need the PUT method for JSON something like web.PutJson to execute Punch Updates on the 7shifts API. web.PostJson does not want to work.
Ok getting my sales integration script ill post it here…
@Jesse wouldnt opening a past ticket from ticket list to reprint bill or something submit it a second time?
You want some form of mark on submitted tickets? My PMS intergration I set a state with the carge ids returned from the API and use this as an extra validation to ensure it never gets double posted.
No it would not. It has ticket id assigned and it only allows it to post once via that ticket id. The ticket id is the unique identifier. I mean on their API side I used TICKET ID as the unique identifier so it will only allow the receipt with that ID once. There is a different API command for updating existing tickets. I need PUT capability for that as well. POST wont work.
So as of right now my sales integration is missing the capability to update returns or refunds etc.