为数据库中的每个现有员工创建唯一链接

时间:2016-05-20 19:12:12

标签: php mysql database

因此,我们有一个网站,雇主可以登录并添加他们刚刚雇用的新员工。当你点击“提交”#39;在要求提供员工信息的表单上,创建一个唯一的链接,如果他们点击,它将带他们到一个页面查看手册(入职)并以电子方式签名。我们最近有一个新的雇主,想看看我们是否可以将他现有的300名员工加入到网站中,并让每个人都查看并签署手册。我能够通过MySQL将所有300名员工愚弄到数据库中,但现在的问题是,从未为所有人创建过唯一链接,因为他们提交了'按钮从来没有推过每一个。 你们认为解决这个问题的最佳方法是什么?我不确定如何创建唯一链接,但我想我找到了创建它的代码。我只想创建一个可以创建链接的按钮,但我必须告诉它为300名员工中的每一个做这件事。我似乎无法想到更好的方法。

<?php
ob_start();

//-------------------PAGE SETUP------------------------------------------------------
// Connect to the database
include( "db/connect.php" );
include( "db/dbFunctions.php" );
//-----------------------------------------------------------------------------------

//Restrict Users who do not have the Onboarding service
if (!hasService($USERID,'Onboarding')) {header( 'Location: home.php' ,true,301) ;}

//Check to see if the user has access to this functionality
checkAccessToFunctionality($USERID,$USERTYPE,'ADDEMPLOYEE',true);

$client = getClient($_POST['clientid'],$USERID);
$clientID = $client->id;
$locationID = $_POST['locationid'];
$templateID = $_POST['templateid'];

//Update the data fields
if ($clientID)
{


    //Create the account and add data 
    $newuserID = createOnboardingEmployee();


    setData($newuserID,'tblonboardingemployees','locationid',$_POST['locationid']);
    setData($newuserID,'tblonboardingemployees','firstname',$_POST['firstname']);
    setData($newuserID,'tblonboardingemployees','lastname',$_POST['lastname']);
    setData($newuserID,'tblonboardingemployees','middleinitial',$_POST['middleinitial']);

    setData($newuserID,'tblonboardingemployees','ssn',$_POST['ssn']);
    setData($newuserID,'tblonboardingemployees','phone',$_POST['phone']);
    setData($newuserID,'tblonboardingemployees','hiredate',$_POST['dateofhire_year'].'-'.$_POST['dateofhire_month'].'-'.$_POST['dateofhire_day']);
    setData($newuserID,'tblonboardingemployees','startdate',$_POST['startdate_year'].'-'.$_POST['startdate_month'].'-'.$_POST['startdate_day']);
    setData($newuserID,'tblonboardingemployees','hourlyrate',$_POST['hourlyrate']);
    setData($newuserID,'tblonboardingemployees','addedby',$USERID);

    setData($newuserID,'tblonboardingemployees','customfield1',$_POST['customfield1']);
    setData($newuserID,'tblonboardingemployees','customfield2',$_POST['customfield2']);
    setData($newuserID,'tblonboardingemployees','customfield3',$_POST['customfield3']);
    setData($newuserID,'tblonboardingemployees','customfield4',$_POST['customfield4']);
    setData($newuserID,'tblonboardingemployees','customfield5',$_POST['customfield5']);

    if (isset($_POST['noemail']))
        {
        setData($newuserID,'tblonboardingemployees','noemail','1');
        }   
    else{
        setData($newuserID,'tblonboardingemployees','emailaddress',$_POST['email']);    
    }



    //Set the employee's onboarding link
    setData($newuserID,'tblonboardingemployees','onboardinglink',$newuserID . '-' . GUID());

    //Set the onboarding template to use for the employee
    assignOnboardingTemplateToEmployee($templateID,$locationID,$newuserID,$USERID);


    //Send the onboarding link to the user
    sendOnboardingIntroEmail($USERID,$newuserID,$templateID);


    //auditaction($USERID,'USER',$newuserID,'User Added','UserType='.$_POST['usertype'],null);

    //Assign permission to all client data and locations
    //$permission = createUserPermission($newuserID,4,1,$clientID);

    //Assign the master user ID to the client record
    //setData($clientID,'tblclients','masteruserid',$newuserID);


}
else

{
    echo 'A location ID was not found. Had to stop. Sorry about that!.';
    ob_flush();
    exit(0);
}
header( 'Location: onboarding_addemployee_complete.php?id='. $newuserID  ) ;

ob_flush();

0 个答案:

没有答案