Generate Pdf File From A Thread Attached To An Order

Hello,

I’m currently doing some changes in one of the add-ons that we have to generate a PDF file from a thread that was attached to an order.

As shown in the screenshot, currently we do that by clicking on 'Generate file from threads' then a popup will show, and we enter the name of the PDF file and the threads that we want to generate.

What we want to do is to basically make this happened automatically when the order status changes from paid to complete.

I'm wondering if it's possible to have a background function that runs when we click on the order details and basically check if the status is complete and generate the PDF file, which is basically a contract in our case between the vendor and the customer.

The add-on uses the popupbox.tpl :

{include file="common/popupbox.tpl" act="link" link_text=__('ss_order_threads_gen_from_threads') id="ss_order_threads_generate_new_file_`$order_info.order_id`"
	text=__('ss_order_threads_generate_new_file') link_class="btn cm-dialog-auto-size"   href="ss_order_threads.generate_file?order_id=`$order_info.order_id`"}

The strange thing is that : app/addons/ss_order_threads/func.php is written in a way that I have never seen before.

 0)) { goto OCOiL; } goto saWL8; bL07V: if (!$count) { goto ct17P; } goto eILe9; l_XZx: $status = false; goto CcZLe; Bv1Oj: OCOiL: goto PRs25; saWL8: $count = db_get_field("\123\105\x4c\105\x43\124\40\103\x4f\x55\x4e\124\x28\52\51\x20\x46\122\117\x4d\x20\77\x3a\166\145\156\x64\x6f\162\137\143\x6f\x6d\155\165\x6e\x69\143\x61\164\x69\x6f\x6e\x73\40\127\110\x45\122\x45\x20\x74\150\x72\145\141\x64\137\x69\144\40\75\40\x3f\x69\x20\101\116\104\40\x6f\x62\152\145\x63\164\137\x74\x79\x70\x65\40\75\x20\77\163", $thread_id, "\x50"); goto bL07V; CRydD: ct17P: goto Bv1Oj; eILe9: $status = true; goto CRydD; Mmh_n: } goto kYz9K; NoYFl: die("\x41\143\x63\x65\163\163\x20\144\x65\x6e\x69\x65\x64"); goto s3NkZ; s3NkZ: VKTM1: goto Op20A; GyIDY: require_once "\150\157\x6f\x6b\x73\x2e\x70\x68\160"; goto amObX; B9XV7: function fn_ss_order_threads_generate_order($thread_id) { goto O1CKg; dSo3A: if (!(!isset($addon_params["\163\163\x5f\157\162\x64\x65\x72\x5f\164\150\x72\x65\x61\x64\x73\137\144\145\x66\x61\165\x6c\164\x5f\x73\x68\151\x70\x70\x69\x6e\x67\137\x69\144"]) || empty($addon_params["\x73\x73\x5f\157\x72\144\145\x72\x5f\x74\150\162\x65\x61\x64\163\137\144\145\146\141\x75\x6c\164\137\163\x68\151\160\x70\151\x6e\147\137\151\x64"]) || !isset($addon_params["\163\163\x5f\x6f\x72\x64\x65\162\x5f\164\x68\162\x65\x61\144\163\137\144\145\146\x61\x75\x6c\x74\137\x70\141\x79\x6d\x65\x6e\x74\x5f\x69\x64"]) || empty($addon_params["\x73\x73\137\x6f\162\x64\x65\162\137\x74\x68\162\145\141\x64\x73\137\x64\145\146\141\165\x6c\x74\x5f\160\141\171\155\x65\x6e\164\x5f\151\144"]))) { goto cuq2y; } goto gkYN6; OoZ68: goto O6fPD; goto MCvNM; jOBYq: $price_form["\143\141\162\x74\x5f\160\162\x6f\x64\x75\x63\164\x73"][$_id] = array("\163\x74\157\162\145\x64\137\x70\x72\x69\143\x65" => "\131", "\x70\162\x6f\144\165\x63\164\x5f\x69\x64" => $product_id, "\141\x6d\157\x75\x6e\x74" => (int) $quantity, "\160\x72\157\x64\x75\143\x74\137\157\160\x74\151\157\156\163" => array(), "\160\162\x69\x63\x65" => $price); goto STsHO; O1CKg: $addon_params = Registry::get("\141\144\x64\x6f\x6e\x73\x2e\x73\163\137\157\162\144\145\162\137\x74\150\x72\x65\x61\x64\163"); goto dSo3A; E3fSJ: goto gscIc; goto gGQ8d; y_ZJx: $shipping_id = $_REQUEST["\x73\150\x69\x70\x70\151\156\x67\137\151\144"]; goto IWcvv; wivuH: list($order_id, $action) = fn_place_order($cart, $auth, '', 0, 0); goto cLSsL; EbXmW: fn_calculate_cart_content($cart, $auth, $calculate_shipping, true, '', false); goto bUnHA; hKgqg: $cart["\164\157\164\x61\154"] = $subtotal + $_REQUEST["\163\150\151\x70\160\x69\x6e\147\x5f\x63\157\163\164"]; goto LrFVG; KkUtz: $cart = array(); goto s8ll4; eZj8H: $product_current_quantity = db_get_field("\123\x45\114\x45\x43\124\40\141\155\157\165\x6e\x74\40\106\122\x4f\115\40\x3f\x3a\160\162\157\x64\165\x63\x74\x73\x20\x57\110\105\122\x45\x20\x70\x72\157\x64\165\x63\x74\137\151\144\x20\75\40\x3f\151", $product_id); goto MEfD4; AmM4o: $cart["\143\150\157\x73\145\x6e\x5f\x73\150\x69\x70\160\x69\156\147"] = $shipping_ids; goto jJcIO; ZrI2O: if (!$storefront) { goto s8m6Q; } goto ThJtb; Wjjzr: WKb6z: goto tOLFO; S2OrY: $cart["\x63\x6f\155\x70\141\x6e\x79\137\151\x64"] = $product_data["\x63\x6f\x6d\160\x61\x6e\171\137\x69\x64"]; goto nFoW0; m00IS: if (isset($product_id) && $product_id > 0) { goto G74Ki; } goto ub8rq; qdFXm: if (!(isset($_REQUEST["\163\150\x69\160\x70\x69\x6e\147\x5f\143\x6f\163\x74"]) && $_REQUEST["\163\150\151\x70\x70\x69\x6e\147\x5f\143\x6f\163\x74"] > 0)) { goto yEf2e; } goto J8Y42; ub8rq: fn_set_notification("\x45", __("\145\162\x72\x6f\162"), __("\163\163\x5f\x6f\x72\144\145\162\137\164\150\x72\145\x61\144\163\137\x70\154\141\143\x65\x5f\157\162\x64\x65\x72\x5f\145\162\162\157\162")); goto EVw3d; IgCnn: $storefront = StorefrontProvider::getStorefront(); goto ZrI2O; pTua_: $price = $product_data["\x70\162\x69\x63\x65"]; goto E3fSJ; s8ll4: $subtotal = 0; goto ShfGo; SwTQD: return 0; goto kS37f; yS8cd: $cart["\160\x72\157\144\165\143\x74\163"][$_id] = array("\160\162\x6f\144\x75\x63\164\137\x69\144" => $product_id, "\141\x6d\x6f\x75\x6e\164" => $quantity, "\x63\x6f\155\x70\141\x6e\x79\137\151\144" => $product_data["\x63\157\155\x70\141\x6e\171\x5f\x69\x64"], "\160\162\157\x64\165\143\x74\x5f\x6f\x70\x74\x69\157\156\x73" => array(), "\x70\162\151\x63\x65" => $price, "\x73\165\142\x74\x6f\x74\x61\x6c" => $price * $quantity); goto Osg4u; GOC28: fn_change_order_status($order_id, $addon_params["\163\x73\137\157\162\x64\x65\162\x5f\x74\x68\x72\x65\141\144\163\137\157\x72\144\x65\162\x5f\163\x74\x61\x74\x75\x73"]); goto So8aY; Suzfn: O12Ff: goto TVRjx; wOQRo: if (empty($cart["\x70\x72\157\x64\165\143\x74\x5f\147\x72\157\165\x70\163"])) { goto HCXbH; } goto qpgqa; LrFVG: $calculate_shipping = "\x53"; goto M_RsY; uXqq9: if (isset($cart["\x73\164\x6f\x72\x65\146\x72\157\x6e\164\x5f\151\144"])) { goto jGmsS; } goto IgCnn; UIkQ1: if (!(!empty($_REQUEST["\165\156\x69\x74\137\x70\x72\151\x63\x65"]) && is_numeric($_REQUEST["\165\x6e\x69\164\x5f\160\x72\151\x63\x65"]))) { goto GtMRd; } goto jOBYq; csp0s: if (!(isset($_REQUEST["\x73\150\151\160\x70\x69\x6e\147\137\143\157\x73\164"]) && $_REQUEST["\x73\x68\x69\160\x70\151\156\147\x5f\143\x6f\x73\x74"] > 0)) { goto uTNGR; } goto wOQRo; STsHO: fn_update_cart_by_data($cart, $price_form, $auth); goto uLGLF; TVRjx: HCXbH: goto EbXmW; nFoW0: $cart["\x72\145\143\141\x6c\143\165\x6c\x61\164\x65"] = false; goto tDg_t; gkYN6: fn_set_notification("\105", __("\145\x72\162\x6f\162"), __("\x73\x73\x5f\157\162\144\145\x72\x5f\164\150\162\145\x61\x64\163\x5f\x6e\157\x5f\x6d\x65\x74\150\157\144\163") . "\x20" . "\x3c\x61\x20\150\x72\x65\x66\75\x22" . fn_url("\x61\x64\x64\157\156\163\56\165\x70\144\x61\164\x65\x26\141\x64\144\x6f\x6e\75\163\163\x5f\157\x72\x64\145\x72\x5f\164\150\x72\x65\141\144\x73", "\101") . "\42\x20\x74\x61\162\x67\145\164\75\x22\137\x62\x6c\141\156\x6b\x22\76" . __("\163\x73\137\x6f\x72\144\x65\162\x5f\x74\150\x72\x65\x61\x64\x73\x5f\x63\x6c\151\x63\x6b\137\150\x65\x72\x65") . "\x3c\x2f\141\76"); goto nlB1C; GdWKn: $product_id = $thread["\x6f\142\152\x65\x63\164\x5f\x69\144"]; goto zXXJ7; qDGfN: $payment_id = $_REQUEST["\x70\141\171\155\145\156\x74\137\151\144"]; goto SwbVi; juLHJ: fn_set_notification("\x4e", __("\x6e\x6f\x74\151\143\145"), __("\x73\x73\137\x6f\x72\x64\145\x72\137\x74\150\x72\145\x61\144\x73\x5f\x70\x6c\x61\143\145\137\x6f\x72\x64\145\162\x5f\143\157\162\x72\x65\143\164") . $order_link); goto FW5y1; ExbUW: $shipping_ids = (array) $shipping_id; goto GA8US; ZRK4Q: s8m6Q: goto PRcry; ObjbN: i5k41: goto qDGfN; munK5: gscIc: goto umt61; jJcIO: $calculate_shipping = "\x45"; goto qdFXm; gBfL0: $order_link = "\74\x61\40\x68\x72\x65\x66\x3d\x22" . fn_url("\x6f\162\x64\x65\x72\163\56\x64\145\x74\141\x69\154\163\x26\x6f\162\144\145\x72\137\x69\x64\75" . $order_id, "\101") . "\42\x20\164\141\162\x67\145\x74\75\x22\x5f\x62\x6c\x61\x6e\x6b\42\x3e" . $order_id . "\x3c\57\141\x3e"; goto juLHJ; ccfwT: if (!empty($_REQUEST["\x75\156\151\x74\x5f\160\x72\151\143\145"]) && is_numeric($_REQUEST["\x75\x6e\x69\x74\137\x70\162\x69\143\x65"])) { goto tiUSJ; } goto pTua_; tm90E: $cart_before = $cart; goto UIkQ1; kS37f: P13aG: goto KkUtz; SwbVi: La93r: goto eZj8H; qpgqa: foreach ($cart["\x70\162\157\x64\x75\x63\x74\137\147\x72\157\165\x70\163"] as $group_key => $group) { goto kmKst; kmKst: if (empty($group["\x63\x68\x6f\x73\145\x6e\x5f\163\x68\151\x70\x70\x69\156\x67\163"])) { goto oIOFD; } goto b7_zR; b7_zR: foreach ($group["\143\x68\157\x73\x65\x6e\x5f\x73\x68\151\x70\160\151\x6e\147\163"] as $shipping_key => $shipping) { goto KjESy; KjESy: $cart["\x73\164\157\x72\x65\x64\137\x73\x68\151\160\x70\x69\156\x67"][$group_key][$shipping_key] = (double) $_REQUEST["\163\x68\x69\x70\160\151\156\147\x5f\143\157\163\164"]; goto MESCE; MESCE: $cart["\160\x72\157\x64\165\x63\164\x5f\x67\x72\157\x75\x70\163"][$group_key]["\x63\150\x6f\163\145\156\137\x73\150\x69\x70\x70\x69\x6e\x67\163"][$shipping_key]["\162\x61\x74\x65"] = $cart["\x73\x74\x6f\x72\145\x64\137\x73\150\x69\160\x70\151\156\x67"][$group_key][$shipping_key]; goto yKLiv; yKLiv: PdU9x: goto Fcb9d; Fcb9d: } goto mFF57; ddMCJ: oIOFD: goto WFGMj; mFF57: QLeoY: goto ddMCJ; WFGMj: H1EwD: goto GFM5q; GFM5q: } goto Suzfn; fKnRE: $price = $_REQUEST["\165\156\x69\164\x5f\x70\x72\x69\x63\145"]; goto munK5; fUTvX: goto La93r; goto ObjbN; IWcvv: O6fPD: goto WkqBZ; cnL1v: goto WjsBR; goto qlChT; MzD1U: if (!empty($_REQUEST["\x73\150\x69\x70\x70\151\156\x67\x5f\x69\144"])) { goto BMfJS; } goto TLGdE; g9XN0: $order_id = 0; goto T7O8u; FW5y1: LoggerAddons::instance()->log("\117\x72\x64\x65\162\x20\43" . $order_link . "\40\147\x65\x6e\145\x72\x61\164\145\x64\x20\143\157\162\x72\145\x63\164\154\x79", "\x49\116\x46\117", $order_id, "\x6f\162\x64\x65\162\163", serialize(array("\162\x65\161\165\x65\x73\164" => $_REQUEST, "\143\x61\x72\164\x5f\142\145\146\x6f\162\145" => $cart_before, "\x63\x61\162\164" => $cart, "\141\165\164\x68" => $auth, "\160\162\157\x64\165\143\x74\137\x64\x61\x74\x61" => $product_data))); goto wsvQh; PRcry: jGmsS: goto Bcfmh; ShfGo: $_id = fn_generate_cart_id($product_id, array("\x70\162\x6f\144\x75\143\x74\137\157\x70\x74\x69\x6f\156\163" => array())); goto yS8cd; DFkwI: fn_calculate_cart_content($cart, $auth, "\x41", true, '', false); goto csp0s; J8Y42: $cart["\163\x68\x69\x70\x70\x69\x6e\147\x5f\x63\x6f\163\x74"] = $_REQUEST["\163\x68\x69\x70\160\151\x6e\147\137\143\157\163\164"]; goto QDOab; F22EX: $auth = fn_fill_auth($cart["\x75\163\x65\162\137\x64\x61\164\141"]); goto ExbUW; tDg_t: $cart["\163\150\x69\x70\x70\x69\156\147\x5f\162\145\161\165\x69\x72\145\144"] = false; goto mREt5; Bcfmh: $cart["\x75\x73\145\x72\x5f\144\141\164\x61"] = fn_get_user_info($thread["\165\163\145\162\137\151\144"]); goto F22EX; as0RV: $thread = db_get_row("\123\105\x4c\x45\103\x54\x20\52\40\106\x52\x4f\x4d\40\77\x3a\166\x65\156\x64\157\162\137\143\157\x6d\x6d\x75\x6e\151\143\141\164\x69\157\156\163\40\x57\x48\105\x52\x45\x20\164\x68\162\145\x61\x64\137\x69\x64\40\x3d\x20\77\x69\x20\x41\x4e\104\40\157\x62\152\x65\x63\x74\137\x74\x79\x70\x65\40\x3d\40\x3f\x73", $thread_id, "\x50"); goto GdWKn; umt61: if (!empty($_REQUEST["\161\165\x61\x6e\x74\151\x74\171"])) { goto U7D_h; } goto SY44Q; nlB1C: return false; goto w30sD; MEfD4: if (!($product_current_quantity < $quantity)) { goto P13aG; } goto AYc4L; GA8US: $cart["\x74\x6f\x74\x61\154"] = $subtotal; goto AmXBv; QDOab: $cart["\144\x69\x73\160\x6c\x61\x79\x5f\163\x68\x69\160\x70\151\x6e\147\137\143\x6f\163\164"] = $_REQUEST["\163\x68\151\x70\160\x69\x6e\x67\137\x63\157\x73\x74"]; goto hKgqg; nqDDQ: WjsBR: goto MzD1U; gGQ8d: tiUSJ: goto fKnRE; Osg4u: $subtotal += $price * $quantity; goto uXqq9; tOLFO: hDGev: goto NolS9; SY44Q: $quantity = 1; goto cnL1v; AYc4L: fn_set_notification("\x45", __("\x65\162\162\x6f\162"), __("\x73\x73\x5f\x6f\162\144\x65\x72\x5f\164\x68\x72\145\x61\x64\x73\137\156\x6f\x74\137\x65\x6e\157\x75\147\x68\137\x73\164\157\143\x6b")); goto SwTQD; TLGdE: $shipping_id = $addon_params["\x73\x73\x5f\x6f\x72\x64\145\162\x5f\164\x68\x72\x65\x61\x64\163\x5f\x64\145\146\x61\165\x6c\164\x5f\163\150\x69\x70\x70\151\156\147\x5f\151\x64"]; goto OoZ68; M_RsY: yEf2e: goto tm90E; WkqBZ: if (!empty($_REQUEST["\160\x61\x79\x6d\145\156\164\137\x69\x64"])) { goto i5k41; } goto jiMOz; zXXJ7: $product_data = fn_get_product_data($product_id); goto m00IS; bUnHA: uTNGR: goto wivuH; uLGLF: GtMRd: goto DFkwI; So8aY: l28HQ: goto gBfL0; w30sD: cuq2y: goto g9XN0; jiMOz: $payment_id = $addon_params["\163\163\137\157\x72\x64\145\162\137\x74\150\162\145\x61\144\163\x5f\144\x65\146\x61\x75\x6c\164\137\x70\x61\171\x6d\x65\156\164\x5f\151\x64"]; goto fUTvX; NolS9: return $order_id; goto g2B_6; jCiWp: G74Ki: goto ccfwT; wsvQh: db_query("\122\105\x50\114\101\103\105\x20\111\116\x54\117\40\x3f\x3a\163\x73\137\x6f\x72\x64\145\x72\137\x74\150\162\145\x61\x64\163\137\154\151\x6e\153\x73\x20\x3f\x65", array("\164\x68\162\145\141\x64\x5f\x69\144" => $thread_id, "\157\162\x64\x65\162\137\151\144" => $order_id)); goto Wjjzr; cLSsL: if (!(!empty($order_id) && $order_id > 0)) { goto l28HQ; } goto GOC28; qlChT: U7D_h: goto FTdF6; mREt5: $cart["\x63\141\x6c\143\165\x6c\141\x74\145\x5f\163\x68\x69\160\x70\151\x6e\147"] = false; goto AmM4o; At0RR: goto WKb6z; goto jCiWp; ThJtb: $cart["\x73\164\x6f\162\x65\x66\x72\x6f\156\x74\x5f\151\x64"] = $storefront->storefront_id; goto ZRK4Q; T7O8u: if (!(isset($thread_id) && $thread_id > 0)) { goto hDGev; } goto as0RV; EVw3d: LoggerAddons::instance()->log("\x55\156\141\x62\154\x65\x20\x74\157\40\147\145\156\145\x72\x61\x74\145\40\x6f\x72\144\x65\x72", "\x45\x52\x52\117\x52", 0, '', serialize(array("\162\145\161\165\145\x73\164" => $_REQUEST, "\143\x61\162\x74\137\142\x65\146\157\x72\x65" => $cart_before, "\x70\x72\x6f\x64\x75\x63\x74\x5f\144\141\x74\x61" => $product_data, "\x63\x61\162\164" => $cart))); goto At0RR; MCvNM: BMfJS: goto y_ZJx; AmXBv: $cart["\160\141\x79\155\x65\156\164\137\151\x64"] = $payment_id; goto S2OrY; FTdF6: $quantity = $_REQUEST["\161\x75\141\x6e\164\x69\x74\x79"]; goto nqDDQ; g2B_6: } goto DUkN3; XG1_X: function fn_ss_order_threads_get_ext($filename = '') { goto wjDwH; C1d3X: $ext = $parts[$count - 1]; goto YsecT; PS1vn: GfxgZ: goto ySnK_; JiCcN: $parts = explode("\56", $filename); goto dmGWq; wjDwH: $ext = ''; goto hj9bF; hj9bF: if (empty($filename)) { goto GfxgZ; } goto JiCcN; YsecT: CJAuw: goto PS1vn; ySnK_: return $ext; goto YLezd; dmGWq: $count = count($parts); goto aFb_J; aFb_J: if (!($count > 1)) { goto CJAuw; } goto C1d3X; YLezd: } goto spO7b; spO7b: function fn_ss_order_threads_prepare_sign($param = '', $length = '') { goto Y_Om1; gedsi: if (!(isset($length) && $length > 0)) { goto H16_2; } goto C1cWc; C1cWc: $sign = substr($sign, $length); goto kDWZ7; yVvEZ: return $sign; goto iLzwK; Y_Om1: $sign = ''; goto IbF7N; uAAlC: $str = json_encode($sign_params, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto bcwUQ; IbF7N: $sign_params = array("\x61\144\144\x6f\x6e\x5f\151\144" => LicenseAddons::instance()->getAddonID(), "\163\x61\154\164" => LicenseAddons::instance()->getSalt(), "\160\141\x72\141\155" => $param); goto uAAlC; bcwUQ: $sign = hash("\163\x68\141\63\70\64", $str); goto gedsi; kDWZ7: H16_2: goto yVvEZ; iLzwK: } goto DFsDs; njcOn: if (defined("\x42\x4f\117\124\x53\124\x52\x41\120")) { goto VKTM1; } goto NoYFl; amObX: require_once "\x70\162\157\143\56\x70\150\160"; goto r4iDC; Op20A: function fn_ss_order_threads_check_thread_exists($thread_id) { goto kaAAh; DkXbi: if (!($thread_exists == 1)) { goto D02f2; } goto XLnBR; TC26C: return false; goto cOOhu; MU2Ed: D02f2: goto TC26C; kaAAh: $thread_exists = db_get_field("\x53\105\114\x45\103\x54\x20\x43\117\125\x4e\124\50\x2a\51\x20\x46\x52\x4f\115\40\x3f\72\x76\x65\156\x64\157\x72\x5f\143\157\155\x6d\x75\156\151\143\x61\x74\151\x6f\156\163\x20\x57\110\x45\x52\x45\x20\164\150\x72\145\x61\144\x5f\151\144\40\75\x20\77\x69\40\101\116\104\x20\x73\164\141\164\165\x73\40\x21\x3d\40\77\x73", $thread_id, "\104"); goto DkXbi; XLnBR: return true; goto MU2Ed; cOOhu: } goto C2je3; DFsDs: function fn_ss_order_threads_get_stats() { goto BsCtF; kh3Lc: $stats = "\74\144\x69\x76\x20\163\x74\171\154\x65\x3d\42\146\154\157\x61\x74\72\x63\x65\x6e\164\145\162\x3b\146\157\156\x74\55\x73\x69\172\145\x3a\x31\x36\x70\170\x22\76" . __("\x73\x73\x5f\x6f\162\144\x65\x72\137\x74\x68\162\145\141\x64\163\137\x73\164\x61\164\x73\x5f\x6e\x6f\137\x61\x63\164\151\166\x69\164\171") . "\x3c\57\x64\151\x76\76"; goto BobVv; BobVv: goto Cpg61; goto eN6NP; eN6NP: w11qj: goto HAKQz; WYUII: if (class_exists("\x5c\124\171\147\x68\134\123\x6f\x66\x74\123\x6f\154\151\144\134\123\163\117\x72\x64\145\162\124\150\162\x65\141\144\x73\134\x4c\x69\143\x65\156\x73\145\101\x64\144\157\156\163")) { goto w11qj; } goto kh3Lc; uGmyp: Cpg61: goto ZiyIi; BsCtF: $stats = array(); goto WYUII; HAKQz: $stats = LicenseAddons::instance()->getStats(); goto uGmyp; ZiyIi: return $stats; goto Uwy7E; Uwy7E: } goto WyImi; fs8Hf: function fn_ss_order_threads_check_thread_assigned($thread_id) { goto rIEzN; dQh9p: E8F17: goto jLhy7; rIEzN: $thread_assigned = db_get_field("\x53\105\x4c\105\103\124\40\103\117\125\116\x54\x28\52\x29\40\106\122\x4f\x4d\x20\x3f\x3a\x73\163\137\x6f\x72\144\145\162\x5f\x74\x68\x72\145\x61\x64\163\x5f\154\151\156\x6b\163\40\127\110\x45\122\105\x20\x74\x68\162\145\x61\x64\x5f\151\x64\x20\x3d\x20\77\x69", $thread_id); goto JYDSP; jLhy7: return false; goto qoHBo; PShB4: return true; goto dQh9p; JYDSP: if (!($thread_assigned > 0)) { goto E8F17; } goto PShB4; qoHBo: } goto XLFmI; WyImi: function fn_ss_order_threads_get_threads($order_id) { goto zOrrl; KWUi3: kVhv5: goto RjMTN; RjMTN: return $threads; goto qiMGu; qRxLa: foreach ($threads as $key => $thread) { goto kRjTy; aaeEb: bGPJ0: goto lrl_n; Vr9N8: $user_name = fn_get_user_name($thread_user_id); goto SfwVU; kRjTy: $thread_user_id = db_get_field("\123\105\x4c\105\103\124\40\165\x73\145\162\137\x69\x64\x20\106\x52\x4f\x4d\x20\x3f\x3a\166\145\156\144\x6f\162\137\143\157\x6d\155\x75\156\x69\143\141\x74\x69\157\156\x73\x20\x57\110\x45\122\x45\x20\164\150\x72\x65\x61\x64\137\x69\144\x20\75\40\77\x69", $thread["\x74\150\x72\145\141\x64\137\151\x64"]); goto Vr9N8; SfwVU: $threads[$key]["\165\x73\145\162\x5f\x6e\x61\155\145"] = $user_name; goto aaeEb; lrl_n: } goto KWUi3; zOrrl: $threads = db_get_array("\123\x45\x4c\105\103\124\40\x74\x6c\x2e\x73\x73\137\x6f\x72\x64\145\162\x5f\x74\x68\162\145\x61\144\163\137\x6c\151\156\x6b\x73\x5f\x69\x64\x2c\x20\164\x6c\56\x74\150\x72\x65\x61\144\137\151\144\54\x20\166\143\56\x6c\141\x73\x74\x5f\x75\160\144\141\164\x65\144\40\x46\122\x4f\115\x20\x3f\x3a\163\163\137\157\162\144\x65\x72\137\164\150\x72\x65\x61\144\x73\137\154\x69\x6e\x6b\x73\x20\101\123\40\164\x6c\x20\114\x45\106\x54\40\x4a\117\x49\116\40\77\72\166\145\x6e\144\157\x72\137\x63\157\155\x6d\x75\156\151\x63\141\x74\x69\x6f\156\x73\x20\x41\123\40\x76\143\40\117\x4e\x20\x74\x6c\x2e\164\x68\x72\145\x61\144\x5f\151\x64\40\75\40\x76\x63\x2e\x74\150\x72\x65\x61\144\137\151\144\x20\x57\110\105\122\x45\x20\164\x6c\x2e\x6f\162\x64\x65\162\x5f\151\x64\x20\x3d\40\77\x69\40\x4f\122\x44\105\x52\40\x42\x59\40\166\143\x2e\x6c\x61\x73\164\x5f\165\160\x64\x61\164\x65\144\40\x44\105\123\x43", $order_id); goto qRxLa; qiMGu: } goto IHQTY; EOLzi: function fn_ss_order_threads_get_company_by_id($thread_id) { goto ps6Ga; ps6Ga: $company_id = db_get_field("\x53\105\x4c\105\103\124\x20\x63\157\x6d\x70\x61\x6e\171\x5f\x69\x64\40\106\122\117\115\40\x3f\72\166\x65\156\144\x6f\162\137\143\x6f\155\155\165\x6e\151\143\x61\164\151\157\x6e\x73\40\x57\x48\105\x52\x45\x20\164\x68\162\145\x61\144\137\x69\x64\x20\x3d\40\x3f\151", $thread_id); goto ur6np; ur6np: $company_name = fn_get_company_name($company_id); goto ytwXN; ytwXN: return $company_name; goto hOwK6; hOwK6: } goto fs8Hf; kYz9K: function fn_ss_order_threads_get_thread_product_unit($thread_id) { goto ECxNp; N2NBq: if (!($unit_id > 0)) { goto zHSz8; } goto JqKVr; J0sr7: $unit_addon_active = db_get_field("\x53\105\x4c\105\x43\124\40\x73\164\x61\164\165\x73\x20\x46\122\x4f\x4d\40\x3f\72\x61\x64\x64\157\x6e\x73\40\127\110\105\122\x45\40\x61\144\x64\157\x6e\x20\75\x20\77\163", "\141\154\164\x74\x65\x61\x6d\x5f\x70\x72\151\143\145\137\x75\156\151\x74\163"); goto KdVQJ; zQyPU: $product_id = db_get_field("\x53\105\x4c\105\103\x54\40\x6f\142\152\145\x63\x74\x5f\151\x64\x20\x46\122\x4f\115\40\x3f\72\x76\145\x6e\144\157\162\137\143\x6f\x6d\155\x75\x6e\x69\143\x61\x74\x69\x6f\x6e\x73\40\127\x48\x45\122\x45\40\x74\150\x72\x65\141\x64\137\x69\x64\x20\75\x20\77\x69\40\101\x4e\104\40\157\142\152\145\143\164\x5f\164\x79\x70\x65\x20\75\x20\x3f\163", $thread_id, "\120"); goto iYmsR; JqKVr: $unit = db_get_field("\123\x45\114\105\x43\x54\x20\164\x69\164\x6c\x65\40\x46\122\117\115\40\x3f\x3a\160\x72\151\143\145\x5f\x75\x6e\x69\x74\163\x20\x57\110\x45\122\105\x20\x70\162\151\x63\x65\x5f\x75\x6e\x69\164\137\x69\x64\40\x3d\x20\77\x69", $unit_id); goto JruL8; ECxNp: $unit = ''; goto J0sr7; NlwYw: return $unit; goto rJ4vG; KdVQJ: if (!($unit_addon_active == "\x41")) { goto hse0G; } goto zQyPU; iYmsR: $unit_id = db_get_field("\x53\x45\x4c\105\103\x54\40\160\162\151\143\x65\137\165\x6e\x69\164\40\x46\122\117\115\40\77\x3a\x70\x72\157\144\x75\143\164\x73\40\127\x48\x45\x52\x45\x20\160\162\x6f\x64\x75\x63\x74\x5f\x69\x64\40\x3d\40\x3f\x69", $product_id); goto N2NBq; yGJlh: hse0G: goto NlwYw; JruL8: zHSz8: goto yGJlh; rJ4vG: }

I would like some assistance if possible ?


Thanks

123.png

1234.png

12345.png

123456.png

Looks like the module is encoded. So only the addon developer can help you with this modification

I have used this before with success to read encoded files

Online PHP Javascript Script Decoder | Quttera (malwaredecoder.com)

but as eComLabs suggest, you should contact the developer for assistance

I have used this before with success to read encoded files

Online PHP Javascript Script Decoder | Quttera (malwaredecoder.com)

but as eComLabs suggest, you should contact the developer for assistance

Looks like the module is encoded. So only the addon developer can help you with this modification

Thank you, I'm currently in touch with the developer.
The tool was not able to read the file, unfortunately.

Hello,

I gained access to the add-on files, but I'm still unable to find a way to also make the PDF generation fully automatic, depending on the status changing from paid to complete.

In design/backend/templates/addons/ss_order_threads :

{include file="common/popupbox.tpl" act="link" link_text=__('ss_order_threads_gen_from_threads') id="ss_order_threads_generate_new_file_`$order_info.order_id`"
	text=__('ss_order_threads_generate_new_file') link_class="btn cm-dialog-auto-size"   href="ss_order_threads.generate_file?order_id=`$order_info.order_id`"}

This calls the popup as shown in the screenshot, now when I check design/backend/templates/addons/ss_order_threads/views/ss_order_threads/generate.tpl

{if $threads}

    
    
{__('name')}{include file="common/tooltip.tpl" tooltip=__('ss_order_threads_name_tooltip')}:
{foreach from=$threads item=thread_id} {/foreach}
{else} {__("ss_order_threads_no_threads_assigned")} {/if}

I'm having a hard time understanding this line here:

 

This is the submit button that should call the function generate_pdf_file and basically send the inputs (PDF file name, selected threads to be generated), I don't see how is this done, especially with name="dispatch[ss_order_threads.generate_pdf_file]".


In app/addons/ss_order_threads/controllers/backend/ss_order_threads.php, we can check the backend logic to see both functions:

// open the popup for entering the parameters of the generated PDF file
if ($mode == 'generate_file') {
    $threads = db_get_fields("SELECT thread_id FROM ?:ss_order_threads_links WHERE order_id = ?i", $_REQUEST['order_id']);
    // Retrieve amounts that have already been refunded
    Tygh::$app['view']->assign('threads', $threads);
    Tygh::$app['view']->assign('order_id', $_REQUEST['order_id']);
    Tygh::$app['view']->display('addons/ss_order_threads/views/ss_order_threads/generate.tpl');
    exit;
} // end if
// generate and save PDF file
if ($mode == 'generate_pdf_file') {
    fn_ss_order_threads_generate_file($_REQUEST);
    return array(CONTROLLER_STATUS_OK, 'orders.details&order_id=' . $_REQUEST['order_id'] ."&selected_section=ss_order_threads_files_tab");
} // end if

The fn_ss_order_threads_generate_file is located in : app/addons/ss_order_threads/proc.php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

/**

  • Generate a PDF file, save it to disk and make an entry in the database

  • @param unknown $file_info
    */
    function fn_ss_order_threads_generate_file($file_info)
    {
    $order_info = db_get_row(“SELECT * FROM ?:orders WHERE order_id = ?i”, $file_info[‘order_id’]);
    $company_name = fn_get_company_name($order_info[‘company_id’]);
    $order_user_name = $order_info[‘firstname’] . " " . $order_info[‘lastname’];

    // The beginning of the HTML that will be used for the PDF
    $html_table = “”;
    $html_table .= “”;
    $html_table .= “Message history for order #” . $file_info[‘order_id’] . " on marketplace.bygora.com between " .$company_name . " and " . $order_user_name . “, generated at " . date(“Y-m-d H:i:s”, time()) . “

    ”;
    // For each thread
    foreach ($file_info[‘threads’][‘selected_threads’] as $thread_id => $enable) {
    if($enable[‘enable’] == “Y”) {
    // Download messages in the thread starting with the oldest
    $thread_messages = db_get_array(“SELECT * FROM ?:vendor_communication_messages WHERE thread_id = ?i ORDER BY message_id ASC”, $thread_id);
    $html_table .= “Thread #” . $thread_id . “:
    ”;
    // For each message
    foreach ($thread_messages as $message) {
    // Add it to HTML, adding the date and user who wrote it
    $user_name = fn_get_user_name($message[‘user_id’]);
    $html_table .= “[” . date(“Y-m-d H:i:s”, $message[‘timestamp’]) . “] (” . $user_name . “): " . $message[‘message’] . “
    ”;
    } // end foreach
    $html_table .= “
    ”;
    } // end if
    } // end foreach
    // end HTML
    $html_table .= “”;
    // Table with thread IDs (to be saved in the database)
    $threads_array = array();
    foreach ($file_info[‘threads’][‘selected_threads’] as $thread_id => $value) {
    $threads_array[] = $thread_id;
    } // end if
    $ext = “pdf”;
    // File name
    //$filename = $REQUEST[‘filename’]. “.” . $ext;
    $filename = 'file
    ’ . fn_ss_order_threads_prepare_sign(TIME, 32) . “.” . $ext;
    $object_id = fn_ss_order_threads_prepare_sign($file_info[‘order_id’]);
    // Generating a PDF file
    $full_html[] = $html_table;
    $output = implode(PHP_EOL, $full_html);
    $_file_path = ‘ss_order_threads/’ . $object_id . “/” . $filename;
    // Save the file in the store
    list(, $_file_path) = Storage::instance(‘custom_files’)->put($_file_path, array(“contents” => 1));
    $output = Pdf::render($full_html, Registry::get(‘config.dir.var’) . “custom_files/” . $_file_path, true);
    // Add an entry about the file to the ss_order_threads_files
    $structure = array(
    “name” => $file_info[‘name’],
    “filename” => $filename,
    “timestamp” => time(),
    “path” => Registry::get(‘config.dir.var’) . “custom_files/” . $_file_path,
    “threads” => implode(”,”, $threads_array),
    “order_id” => $file_info[‘order_id’],
    “status” => “A”
    );
    db_query(“INSERT INTO ?:ss_order_threads_files ?e”, $structure);
    LoggerAddons::instance()->log(“PDF file generated”, “INFO”, 0, “”, serialize(array(“request” => $file_info, “structure” => $structure)), “”, $file_info[‘order_id’]);

    return $html_table;
    } // end function fn_ss_order_threads_generate_file

I would appreciate some suggestions on how to do this ?


Thanks