EnvelopeID Changed after correction? - soap

I have 2 signature document and the first signer already signed. The document is still in process. So I went to correct the second signer. I realised the envelopeID changed after the correction.
What will it happen to the old envelope? Voided?
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";
}

EnvelopeId does not change after correction. The envelopeID never changes. New envelopes can be created, but the original GUID that was used will keep living in the system.

Related

Woocommerce Custom Place Order API not working cart empty

public function RetriveCart($request){
global $woocommerce;
$woocommerce->frontend_includes();
$user_id = $request['user_id'];
wp_set_current_user( $user_id );
add_action('woocommerce_cart_calculate_fees', array($this,'woo_cart_fee_update'));
$woocommerce->session = new WC_Session_Handler();
$woocommerce->session->init();
$woocommerce->customer = new WC_Customer( get_current_user_id(), true );
$woocommerce->cart = new WC_Cart();
$items = $woocommerce->cart->get_cart();
if(empty($items)){
$response['status'] = 0;
$response['message'] = __("Cart is empty", self::domainText);
$response['data'] = new stdClass();
return new WP_REST_Response($response, 200);
}
foreach($items as $item => $values) {
$_product = wc_get_product( $values['product_id']);
$cart[] = array('key'=>$item,
'product_id'=>$values['product_id'],
'title'=>$_product->get_title(),
'quantity'=>$values['quantity'],
'price'=>$_product->get_price(),
'subtotal'=> strval(($_product->get_price()+$addons_price) * $values['quantity']),
'currency_symbol'=>get_woocommerce_currency_symbol(),
);
}
WC()->cart->calculate_totals();
$shipping = $woocommerce->cart->fee_total;
$cart_summary = array('sub_total'=>$woocommerce->cart->subtotal,
'shipping_amount'=>$shipping,
'order_type'=>$order_type,
'is_deliverable'=>$is_deliverable,
'discount_amount'=>$woocommerce->cart->get_cart_discount_total(),
'tax_amount'=>$woocommerce->cart->tax_total,
'total_amount'=>$woocommerce->cart->total,
'currency_symbol'=>get_woocommerce_currency_symbol(),
);
$output['cart_summary'] = $cart_summary;
$output['items'] = $cart;
$response['status'] = 1;
$response['message'] = __("Cart Items found", self::domainText);
$response['data'] = $output;
return new WP_REST_Response($response, 200);
}
public function newOrder($request){
global $wpdb,$woocommerce;
$woocommerce->frontend_includes();
$orderRequest = $request['order'];
$user_id = $orderRequest['user_id'];
wp_set_current_user( $user_id );
$woocommerce->session = new WC_Session_Handler();
$woocommerce->session->init();
$woocommerce->customer = new WC_Customer( get_current_user_id(), true );
$woocommerce->cart = new WC_Cart();
if ($woocommerce->cart->get_cart_contents_count() == 0) {
$response['status'] = 0;
$response['message'] = __('Cart is empty', self::domainText);
$response['data'] = new stdClass();
return new WP_REST_Response($response, 200);
}
$cart = $woocommerce->cart->get_cart();
$order = wc_create_order(array('customer_id' => get_current_user_id()));
$order_id = $order->id;
foreach($cart as $item => $values) {
$product = wc_get_product($values['product_id']);
$quantity = (int)$values['quantity'];
if(wc_prices_include_tax()){
$product_price = wc_get_price_including_tax($product);
}else{
$product_price = wc_get_price_excluding_tax($product);
}
$variationsArray = array();
$order->add_product($product, $quantity, $variationsArray);
}
$order->set_address( $orderRequest['billing_address'], 'billing' );
$order->set_address( $orderRequest['shipping_address'], 'shipping' );
$order->set_payment_method($orderRequest['payment_method']['id']);
$get_fees = $woocommerce->cart->get_fees();
foreach($get_fees as $fee_data){
$item_fee = new WC_Order_Item_Fee();
$item_fee->set_name($fee_data->name);
$item_fee->set_amount($fee_data->amount);
$item_fee->set_tax_class( '' );
$item_fee->set_tax_status( 'none' );
$item_fee->set_total($fee_data->total);
$item_fee->save();
$order->add_item($item_fee);
}
if(!empty($coupon)){
$order->apply_coupon($coupon[0]);
}
$order->update_status('created');
$order->calculate_totals();
$woocommerce->cart->empty_cart();
$customer_id = $order->get_user_id();
$response['status'] = 1;
$response['message'] = __("Order $order_id is successfully placed", self::domainText);
$response['order_id'] = $order_id;
return new WP_REST_Response($response, 200);
}
In RetriveCart() all datas are there when I try place order. Its give me an empty cart and fees not added.

Update controller method not rendering json data in Laravel

I have a simple form with some text inputs and uploading photos with that form. Store method working very well but I'm doing something wrong in update method.
This is my store method which works fine:
public function store(Request $request)
{
dd($request);
$post = new Post;
$post->title = $request->title;
$post->user_id = $request->user()->id;
$post->who = $request->who;
$post->when = $request->when;
$post->where = $request->where;
$post->body_text = $request->body;
$post->embed = $request->embed;
$post->status = "4";
$post->tags = $request->tags;
$post->slug = "asdasd";
$post->ip = request()->ip();
if($request->hasfile('photo'))
{
foreach($request->file('photo') as $image)
{
$name= time()."".$this->photo_san($image->getClientOriginalName());
$image->move(public_path().'/uploads/', $name);
$data[] = $name;
}
$post->photo = json_encode($data);
}
$post->save();
$post->slug = $post->id."-".$this->make_slug($request->title);
$post->save();
Session::flash('success', 'Well done.');
return redirect()->route('archive');
}
And this is my update method which saves everything but photos:
public function update(Request $request, $id)
{
if(Auth::user()->role == 3 || Auth::user()->id == Post::find($id)->user_id){
$post = Post::find($id);
$post->title = $request->title;
$post->user_id = $request->user()->id;
$post->who = $request->who;
$post->when = $request->when;
$post->where = $request->where;
$post->body_text = $request->body;
$post->embed = $request->embed;
$post->status = "4";
$post->tags = $request->tags;
$post->slug = $id."-".$this->make_slug($request->title);
$post->ip = request()->ip();
if($request->hasFile('photo'))
{
foreach($request->file('photo') as $image)
{
$name= time()."-edit-".$this->photo_san($image->getClientOriginalName());
$image->move(public_path().'/uploads/', $name);
$data[] = $name;
}
$post->photo = json_encode($data);
}
$post->save();
Session::flash('success', 'Well done.');
return redirect()->route('new');
}
else
Session::flash('error', 'Shame on you :( ');
return redirect()->route('new');
}
When I'm updating any post, everything updating but photos and I don't have any idea what's wrong.
I don't know if it differs but I'm using Laravel 5,8

make a custom error message and prevent duplicate mail id from inserting in db

I have checked email unique in codeigniter. In else past I diplayed error. But the system error is not convenient. how to customise error...
i have tried giveng javascript alert instead of that error message... but after that alert the data are storing in database.. Actually the data should not store in database if the email is not unique..
public function add_applicants() {
// $field_name=$this->input->post('photo');
$data = $this->input->post();
$mobile = $this->db->get_where('applicants',array('mobile_number'=>$this->input->post('mobile_number')));
if($mobile->num_rows()>0)
{
throw new Exception("Mobile Number Already Registered");
}
$email = $this->db->get_where('applicants',array('email_id'=>$this->input->post('email_id')));
if($email->num_rows()>0)
{
throw new Exception("Email_id Already Registered");
}
$school_id= $this->input->post('school_code');
$name_of_exam= $this->input->post('name_of_exam');
$name= $this->input->post('name_candiadte');
switch($name_of_exam){
case '1':
$exam='NMMS';
break;
case '2':
$exam='NTS';
break;
}
$school_code = $this->Welcome_Model->getschoolData($school_id);
if (isset($_FILES['photo']) == 1) {
$config['upload_path'] = FCPATH . 'uploads/'. $school_code->name_of_the_school.'/'. $exam ;
$this->upload_path = $config['upload_path'];
if ($this->validate_upload_path() == TRUE) {
$config['upload_path'] = $this->upload_path;
// print_r($this->upload_path) ;
// die();
}
$config['allowed_types'] = 'jpg';
$config['max_size'] = 2000;
$config['remove_spaces'] = TRUE;
$config['overwrite'] = true;
$config['file_name'] = $name.'-'.date('Ymdhis') . '.jpg';
$file_name = $config['file_name'];
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('photo')) {
$this->upload->display_errors();
}
}
$data['photo'] = $file_name;
$insetapplicants = $this->Welcome_Model->insertApplicants($data);
if ($insetapplicants == 'Success') {
echo "<script>
alert('New Applicants Added Successfully');
// window.location.href='dashboard';
</script>";
}
}

SugarCRM 6.5 How to print php template?

I am newly SugarCRM 6.5 developer, I have write view.detail.php file and controller file. How to print template controller action json data php template. please help me. I have create controller and view.details code below.
Controller
protected function action_printinvoice(){
global $current_user, $db, $region;
$db = DBManagerFactory::getInstance();
$id = $_POST['record'];
$sql = "select gn.client_name, gn.client_address, gn.client_address_city, gn.client_address_state, gn.client_address_country, gn.client_address_postalcode, gn.id, gn.recipient_name, gn.recipient_address_city, gn.recipient_address_state, gn.recipient_address_country, gn.recipient_address_postalcode, gn.recipient_address, gn.recipient_vat_id, gn.recipient_tax_no, gn.recipient_name, gn.invoice_number as ginvo_client_invoice_id, "
. " gcstm.* "
. "from ginvo_client_invoice as gn "
. " inner join ginvo_client_invoice_cstm as gcstm on gn.id=gcstm.id_c "
. "where "
. " gn.deleted=0 and gn.id='".$id."' limit 1 ";
$result = $db->query($sql);
$ginv_invoice_ary=array();
while($row = $db->fetchByAssoc($result) ) {
$ginv_invoice_ary[]=$row;
}
if ($ginv_invoice_ary[0]['region_c'] == 'non_eu_client_and_freelancer_provider') {
$region = 'Non EU client and freelancer provider';
}else if($ginv_invoice_ary[0]['region_c'] == 'non_eu_client_and_employed_provider'){
$region = 'Non EU client and employed provider';
}else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_freelancer_provider'){
$region = 'German client and freelancer provider';
}else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_employed_provider'){
$region = 'German client and employed provider';
}else if($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_freelancer_provider'){
$region = 'EU client and freelancer provider';
}else if ($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_employed_provider') {
$region = 'EU client and employed provider';
}else {
$region = '';
}
echo json_encode($ginv_invoice_ary);
$this->view = 'invoiceprint';
//$this->view = 'custom/modules/ginvo_client_invoice/metadata/ClientInvoice.php';
exit;
}
View.detail.php
<?php
require_once('include/MVC/View/views/view.detail.php');
// require_once('modules/ginvo_client_invoice/view/invoice.php');
class ginvo_client_invoiceViewDetail extends ViewDetail {
function ginvo_client_invoiceViewDetail(){
parent::ViewDetail();
}
function display(){
echo $ginv_invoice_ary;
//$this->populateQuoteTemplates();
$this->displayPopupHtml();
parent::display();
}
function populateQuoteTemplates(){
global $app_list_strings, $current_user;
$inv_id = $this->bean->id;
$sql = "SELECT * FROM ginvo_client_invoice WHERE deleted=0 AND id='$inv_id'";
$res = $this->bean->db->query($sql);
$app_list_strings[] = array();
while($row = $this->bean->db->fetchByAssoc($res)){
if($row){
$app_list_strings[$row] = $row;
}
}
}
function displayPopupHtml(){
global $app_list_strings,$app_strings, $mod_strings;
$templates = array_keys($app_list_strings);
if($templates){
echo '
<script>
function showPopup(task){
var record = \''.$this->bean->id.'\';
var fdata = {\'record\':record};
var params = jQuery.param(fdata);
$.ajax({
type:\'post\',
data: fdata,
// dataType: "json",
// url:\'custom/client_invoice.php?\'+params,
//url:\'custom/modules/ginvo_client_invoice/ClientInvoice.php?\'+params,
url:\'index.php?module=ginvo_client_invoice&action=printinvoice\',
error:function(resp){},
success:function(resp){
console.log(resp);
// location.reload(true);
}
});
// var w = window.open(\'custom/ClientInvoice.php\');
//
// $(w).ready(function(){
// w.print();
// });
}
</script>';
}
else{
echo '<script>
function showPopup(task){
alert(\''.$current_user.'\');
}
</script>';
}
}
}
?>

How to get my zend script picture filename into a hidden field

OK, I am stumped here. I'm using a Zend script that helps me to upload pictures. It works great, but I am trying to capture the pictures name into a hidden field for a form. I'd like to note that the name changes, so I'd need to get whichever it ends up being put into the hidden field. Here is the Zend script:
<?php
if (isset($_POST['upload'])) {
require_once('scripts/library.php');
try {
$destination = 'xxxxxxxx';
$uploader = new Zend_File_Transfer_Adapter_Http();
$uploader->setDestination($destination);
$filename = $uploader->getFileName(NULL, FALSE);
$uploader->addValidator('Size', FALSE, '90kB');
$uploader->addValidator('ImageSize', FALSE, array('minheight' => 100, 'minwidth' => 100));
if (!$uploader->isValid()) {
$messages = $uploader->getMessages();
} else {
$no_spaces = str_replace(' ', '_', $filename, $renamed);
$uploader->addValidator('Extension', FALSE, 'gif, png, jpg');
$recognized = FALSE;
if ($uploader->isValid()) {
$recognized = TRUE;
} else {
$mime = $uploader->getMimeType();
$acceptable = array('jpg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif');
$key = array_search($mime, $acceptable);
if (!$key) {
$messages[] = 'Unrecognized image type';
} else {
$no_spaces = "$no_spaces.$key";
$recognized = TRUE;
$renamed = TRUE;
}
}
$uploader->clearValidators();
if ($recognized) {
$existing = scandir($destination);
if (in_array($no_spaces, $existing)) {
$dot = strrpos($no_spaces, '.');
$base = substr($no_spaces, 0, $dot);
$extension = substr($no_spaces, $dot);
$i = 1;
do {
$no_spaces = $base . '_' . $i++ . $extension;
} while (in_array($no_spaces, $existing));
$renamed = TRUE;
}
$uploader->addFilter('Rename', array('target' => $no_spaces));
$success = $uploader->receive();
if (!$success) {
$messages = $uploader->getMessages();
} else {
$uploaded = "$filename uploaded successfully";
$pic = $filename;
if ($renamed) {
$uploaded .= " and renamed $no_spaces";
}
$messages[] = "$uploaded";
}
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
Here I am trying to make the $pic variable not to throw an error for now (on the form page)
if (isset($_POST['upload'])) { } else { $pic = "unknown";}
The $pic variable is what I was trying to have the filename from the zend script copied into. Any feedback is greaaaatly appreciated :)