Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getDocuments($pdfbytes) {
- $documents = array();
- $id = 1;
- $d = new Document();
- $d->PDFBytes = $pdfbytes;
- $d->Name = "Demo Document";
- $d->ID = $id++;;
- $d->FileExtension = "pdf";
- array_push($documents, $d);
- return $documents;
- }
- function buildEnvelope($pdfbytes) {
- $envelope = new Envelope();
- $envelope->Subject = $_SESSION["Taskmaster"];
- $envelope->EmailBlurb = "Please Sign by logining ";
- $envelope->AccountId = $_SESSION["AccountID"];
- $envelope->Recipients = constructRecipients();
- $envelope->Tabs = addTabs(count($envelope->Recipients));
- $envelope = processOptions($envelope);
- $envelope->Documents = getDocuments($pdfbytes);
- return $envelope;
- }
- function constructRecipients() {
- $recipients = array();
- $r = new Recipient();
- $r->UserName =$_SESSION["Secretaryname"];
- $r->Email = $_SESSION["Secretaryemail"];
- $r->RequireIDLookup = false;
- $r->ID = 1;
- $r->Type = RecipientTypeCode::Signer;
- $r->RoutingOrder = "2";
- // if(!isset($_POST['RecipientInviteToggle'][$i])){
- $r->CaptiveInfo = new RecipientCaptiveInfo();
- $r->CaptiveInfo->ClientUserId = 2;
- $r->CaptiveInfo->embeddedRecipientStartURL=SIGN_AT_DOCUSIGN;
- // }
- array_push($recipients, $r);
- if(empty($recipients)){
- $_SESSION["errorMessage"] = "You must include at least 1 Recipient";
- //header("Location: error.php");
- exit;
- }
- return $recipients;
- }
- function sendNow($envelope) {
- $api = getAPI();
- $csParams = new CreateAndSendEnvelope();
- $csParams->Envelope = $envelope;
- //print_r($csParams);
- try {
- $status = $api->CreateAndSendEnvelope($csParams)->CreateAndSendEnvelopeResult;
- //echo "Result for Create and Send <br>";
- //print_r($status);
- if ($status->Status == EnvelopeStatusCode::Sent) {
- addEnvelopeID($status->EnvelopeID);
- $correct = new Correction;
- $correct->EnvelopeID = $status->EnvelopeID;
- $correct->RecipientCorrections = addRecipientCorrection();
- $correctparams = new CorrectAndResendEnvelope();
- $correctparams->Correction = $correct;
- //print_r($correctparams);
- //Send
- $response = $api->CorrectAndResendEnvelope($correctparams);
- //print_r($response);
- //exit;
- $_SESSION["EnvelopeID"]=null;
- $_SESSION["Direct"]="Yes";
- header("Location: getstatusanddocs.php?envelopid=" . $status->EnvelopeID .
- "&accountID=" . $envelope->AccountId . "&source=Document");
- }
- } catch (SoapFault $e) {
- $_SESSION["errorMessage"] = $e;
- header("Location: error.php");
- }
- }
- function addRecipientCorrection(){
- $correction = new RecipientCorrection();
- $correction->PreviousUserName = "xxxxxx";
- $correction->PreviousEmail = "xxxxxxx";
- $correction->PreviousSignerName = $correction->PreviousUserName;
- $correction->PreviousRoutingOrder = "2";
- $correction->CorrectedUserName = $_SESSION["Secretaryname"];
- $correction->CorrectedEmail = $_SESSION["Secretaryemail"];
- $correction->CorrectedSignerName = $correction->CorrectedUserName;
- return $correction;
- }
- //========================================================================
- // Main
- //========================================================================
- loginCheck();
- if($_SESSION["Taskmaster"]=="xxxxx"){
- $api = getAPI();
- $RequestPDFParam = new RequestPDF();
- $RequestPDFParam->EnvelopeID = $_SESSION["EnvelopeID"];
- $result = $api->RequestPDF($RequestPDFParam);
- $envPDF = $result->RequestPDFResult;
- //file_put_contents("./Cert/".$_SESSION["EnvelopeID"].".pdf", $envPDF->PDFBytes);
- //echo "Stop here";
- //exit;
- $envelope = buildEnvelope($envPDF->PDFBytes);
- sendNow($envelope);
- }else{
- echo "You have no power";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement