Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. function getDocuments($pdfbytes) {
  2. $documents = array();
  3. $id = 1;
  4.  
  5.  
  6. $d = new Document();
  7. $d->PDFBytes = $pdfbytes;
  8. $d->Name = "Demo Document";
  9. $d->ID = $id++;;
  10. $d->FileExtension = "pdf";
  11. array_push($documents, $d);
  12.  
  13.  
  14. return $documents;
  15. }
  16.  
  17. function buildEnvelope($pdfbytes) {
  18. $envelope = new Envelope();
  19. $envelope->Subject = $_SESSION["Taskmaster"];
  20. $envelope->EmailBlurb = "Please Sign by logining ";
  21.  
  22. $envelope->AccountId = $_SESSION["AccountID"];
  23. $envelope->Recipients = constructRecipients();
  24. $envelope->Tabs = addTabs(count($envelope->Recipients));
  25. $envelope = processOptions($envelope);
  26. $envelope->Documents = getDocuments($pdfbytes);
  27. return $envelope;
  28. }
  29.  
  30. function constructRecipients() {
  31. $recipients = array();
  32.  
  33.  
  34.  
  35. $r = new Recipient();
  36.  
  37. $r->UserName =$_SESSION["Secretaryname"];
  38. $r->Email = $_SESSION["Secretaryemail"];
  39. $r->RequireIDLookup = false;
  40.  
  41.  
  42. $r->ID = 1;
  43. $r->Type = RecipientTypeCode::Signer;
  44. $r->RoutingOrder = "2";
  45.  
  46. // if(!isset($_POST['RecipientInviteToggle'][$i])){
  47. $r->CaptiveInfo = new RecipientCaptiveInfo();
  48. $r->CaptiveInfo->ClientUserId = 2;
  49. $r->CaptiveInfo->embeddedRecipientStartURL=SIGN_AT_DOCUSIGN;
  50. // }
  51.  
  52. array_push($recipients, $r);
  53.  
  54.  
  55. if(empty($recipients)){
  56. $_SESSION["errorMessage"] = "You must include at least 1 Recipient";
  57. //header("Location: error.php");
  58. exit;
  59. }
  60.  
  61. return $recipients;
  62. }
  63.  
  64. function sendNow($envelope) {
  65. $api = getAPI();
  66.  
  67.  
  68.  
  69. $csParams = new CreateAndSendEnvelope();
  70. $csParams->Envelope = $envelope;
  71. //print_r($csParams);
  72. try {
  73. $status = $api->CreateAndSendEnvelope($csParams)->CreateAndSendEnvelopeResult;
  74. //echo "Result for Create and Send <br>";
  75. //print_r($status);
  76.  
  77. if ($status->Status == EnvelopeStatusCode::Sent) {
  78. addEnvelopeID($status->EnvelopeID);
  79. $correct = new Correction;
  80.  
  81. $correct->EnvelopeID = $status->EnvelopeID;
  82. $correct->RecipientCorrections = addRecipientCorrection();
  83. $correctparams = new CorrectAndResendEnvelope();
  84. $correctparams->Correction = $correct;
  85.  
  86. //print_r($correctparams);
  87. //Send
  88. $response = $api->CorrectAndResendEnvelope($correctparams);
  89. //print_r($response);
  90. //exit;
  91. $_SESSION["EnvelopeID"]=null;
  92. $_SESSION["Direct"]="Yes";
  93. header("Location: getstatusanddocs.php?envelopid=" . $status->EnvelopeID .
  94. "&accountID=" . $envelope->AccountId . "&source=Document");
  95. }
  96. } catch (SoapFault $e) {
  97. $_SESSION["errorMessage"] = $e;
  98. header("Location: error.php");
  99. }
  100. }
  101.  
  102. function addRecipientCorrection(){
  103. $correction = new RecipientCorrection();
  104.  
  105. $correction->PreviousUserName = "xxxxxx";
  106. $correction->PreviousEmail = "xxxxxxx";
  107. $correction->PreviousSignerName = $correction->PreviousUserName;
  108. $correction->PreviousRoutingOrder = "2";
  109. $correction->CorrectedUserName = $_SESSION["Secretaryname"];
  110. $correction->CorrectedEmail = $_SESSION["Secretaryemail"];
  111. $correction->CorrectedSignerName = $correction->CorrectedUserName;
  112.  
  113. return $correction;
  114. }
  115.  
  116. //========================================================================
  117. // Main
  118. //========================================================================
  119. loginCheck();
  120.  
  121. if($_SESSION["Taskmaster"]=="xxxxx"){
  122. $api = getAPI();
  123. $RequestPDFParam = new RequestPDF();
  124. $RequestPDFParam->EnvelopeID = $_SESSION["EnvelopeID"];
  125. $result = $api->RequestPDF($RequestPDFParam);
  126. $envPDF = $result->RequestPDFResult;
  127. //file_put_contents("./Cert/".$_SESSION["EnvelopeID"].".pdf", $envPDF->PDFBytes);
  128. //echo "Stop here";
  129. //exit;
  130.  
  131.  
  132. $envelope = buildEnvelope($envPDF->PDFBytes);
  133.  
  134. sendNow($envelope);
  135.  
  136. }else{
  137. echo "You have no power";
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement