如何使用脚本和PHP传递数据库进行查看?

时间:2016-02-17 03:50:42

标签: javascript php json

脚本中的 getpunch 方法和 PHP 也是我想要的是通过小时:minuts in_time 当前时间

这是我的剧本:

AttendanceAdapter.method('getPunch', function(successCallBack) {
    var that = this;
    var object = {};

    object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' ');
    object['offset'] = this.getClientGMTOffset();
    var reqJson = JSON.stringify(object);
    var callBackData = [];
    callBackData['callBackData'] = [];
    callBackData['callBackSuccess'] = successCallBack;
    callBackData['callBackFail'] = 'getPunchFailCallBack';

    this.customAction('getPunch','modules=attendance',reqJson,callBackData);
});

这是我的PHP:

public function getPunch($req){
        $date = $req->date;
        $arr = explode(" ",$date);
        $date = $arr[0];

        $employee = $this->baseService->getElement('Employee',$this->getCurrentEmployeeId(),null,true);


        //Find any open punch
        $attendance = new Attendance();
        $attendance->Load("employee = ? and DATE_FORMAT( in_time,  '%Y-%m-%d' ) = ? and (out_time is NULL or out_time = '0000-00-00 00:00:00')",array($employee->id,$date));

        if($attendance->employee == $employee->id){
            //found an open punch
            return new IceResponse(IceResponse::SUCCESS,$attendance);
        }else{
            return new IceResponse(IceResponse::SUCCESS,null);
        }}

当用户尝试以 in_time 的形式 punch_out 时使用此功能,我希望在该表单中显示他们尝试使用punch_out时工作的小时数

0 个答案:

没有答案