....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 107.180.102.13  /  Your IP : 216.73.216.161
Web Server : Apache
System : Linux ip-107-180-102-13.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : nobody ( 99)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/egdeals/public_html/admin/controller/extension/openbay/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/egdeals/public_html/admin/controller/extension/openbay/fba.php
<?php
class ControllerExtensionOpenbayFba extends Controller {
    public function install() {
        $this->load->model('extension/openbay/fba');
        $this->load->model('setting/setting');
        $this->load->model('setting/extension');
        $this->load->model('user/user_group');

        $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/openbay/fba');
        $this->model_user_user_group->addPermission($this->user->getGroupId(), 'modify', 'extension/openbay/fba');

        $this->model_extension_openbay_fba->install();
    }

    public function uninstall() {
        $this->load->model('extension/openbay/fba');
        $this->load->model('setting/setting');
        $this->load->model('setting/extension');

        $this->model_extension_openbay_fba->uninstall();
        $this->model_setting_extension->uninstall('openbay', $this->request->get['extension']);
        $this->model_setting_setting->deleteSetting($this->request->get['extension']);
    }

    public function index() {
        $this->load->language('extension/openbay/fba');

        $data = $this->language->all();

        $this->load->model('setting/setting');
        $this->load->model('localisation/order_status');
        $this->load->model('extension/openbay/fba');

        $this->document->setTitle($this->language->get('text_dashboard'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        $data['breadcrumbs'] = array();
        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_home'),
        );
        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_openbay'),
        );
        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_dashboard'),
        );

        $data['success'] = '';
        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];
            unset($this->session->data['success']);
        } else {
            $data['success'] = '';
        }

        $data['validation'] = $this->openbay->fba->validate();
        $data['link_settings'] = $this->url->link('extension/openbay/fba/settings', 'user_token=' . $this->session->data['user_token'], true);
        $data['link_account'] = 'https://account.openbaypro.com/fba/index/';
        $data['link_fulfillments'] = $this->url->link('extension/openbay/fba/fulfillmentlist', 'user_token=' . $this->session->data['user_token'], true);
        $data['link_orders'] = $this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true);
		$data['link_signup'] = 'https://account.openbaypro.com/fba/apiRegister/?endpoint=2&utm_source=opencart_install&utm_medium=dashboard&utm_campaign=fba';

        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba', $data));
    }

    public function settings() {
        $this->load->language('extension/openbay/fba_settings');

        $data = $this->language->all();

        $this->document->setTitle($this->language->get('heading_title'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        $this->load->model('setting/setting');
        $this->load->model('extension/openbay/fba');
        $this->load->model('localisation/order_status');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
            $this->model_setting_setting->editSetting('openbay_fba', $this->request->post);
            $this->session->data['success'] = $this->language->get('text_success');
            $this->response->redirect($this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true));
        }

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_home'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_openbay'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_fba'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba/settings', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('heading_title'),
        );

        $data['action'] = $this->url->link('extension/openbay/fba/settings', 'user_token=' . $this->session->data['user_token'], true);
        $data['cancel'] = $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true);
        $data['link_signup'] = 'https://account.openbaypro.com/fba/apiRegister/?endpoint=2&utm_source=opencart_install&utm_medium=settings&utm_campaign=fba';

        $data['user_token'] = $this->session->data['user_token'];

        if (isset($this->error['warning'])) {
            $data['error_warning'] = $this->error['warning'];
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->request->post['openbay_fba_status'])) {
            $data['openbay_fba_status'] = $this->request->post['openbay_fba_status'];
        } else {
            $data['openbay_fba_status'] = $this->config->get('openbay_fba_status');
        }

        if (isset($this->request->post['openbay_fba_api_key'])) {
            $data['openbay_fba_api_key'] = trim($this->request->post['openbay_fba_api_key']);
        } else {
            $data['openbay_fba_api_key'] = trim($this->config->get('openbay_fba_api_key'));
        }

        if (isset($this->request->post['openbay_fba_encryption_key'])) {
            $data['openbay_fba_encryption_key'] = trim($this->request->post['openbay_fba_encryption_key']);
        } else {
            $data['openbay_fba_encryption_key'] = trim($this->config->get('openbay_fba_encryption_key'));
        }

        if (isset($this->request->post['openbay_fba_encryption_iv'])) {
            $data['openbay_fba_encryption_iv'] = trim($this->request->post['openbay_fba_encryption_iv']);
        } else {
            $data['openbay_fba_encryption_iv'] = trim($this->config->get('openbay_fba_encryption_iv'));
        }

        if (isset($this->request->post['openbay_fba_api_account_id'])) {
            $data['openbay_fba_api_account_id'] = trim($this->request->post['openbay_fba_api_account_id']);
        } else {
            $data['openbay_fba_api_account_id'] = trim($this->config->get('openbay_fba_api_account_id'));
        }

        if (isset($this->request->post['openbay_fba_send_orders'])) {
            $data['openbay_fba_send_orders'] = $this->request->post['openbay_fba_send_orders'];
        } else {
            $data['openbay_fba_send_orders'] = $this->config->get('openbay_fba_send_orders');
        }

        if (isset($this->request->post['openbay_fba_debug_log'])) {
            $data['openbay_fba_debug_log'] = $this->request->post['openbay_fba_debug_log'];
        } else {
            $data['openbay_fba_debug_log'] = $this->config->get('openbay_fba_debug_log');
        }

        $order_total = $this->model_extension_openbay_fba->countFbaOrders();

        if ($order_total > 0) {
            $data['prefix_can_edit'] = false;
        } else {
            $data['prefix_can_edit'] = true;
        }

        if (isset($this->request->post['openbay_fba_order_prefix'])) {
            $data['openbay_fba_order_prefix'] = $this->request->post['openbay_fba_order_prefix'];
        } else {
            $data['openbay_fba_order_prefix'] = $this->config->get('openbay_fba_order_prefix');
        }

        if (isset($this->request->post['openbay_fba_order_trigger_status'])) {
            $data['openbay_fba_order_trigger_status'] = $this->request->post['openbay_fba_order_trigger_status'];
        } else {
            $data['openbay_fba_order_trigger_status'] = $this->config->get('openbay_fba_order_trigger_status');
        }

        if (isset($this->request->post['openbay_fba_only_fill_complete'])) {
            $data['openbay_fba_only_fill_complete'] = $this->request->post['openbay_fba_only_fill_complete'];
        } else {
            $data['openbay_fba_only_fill_complete'] = $this->config->get('openbay_fba_only_fill_complete');
        }

        $data['fulfillment_policy'] = array(
            'FillOrKill' => $this->language->get('text_fillorkill'),
            'FillAll' => $this->language->get('text_fillall'),
            'FillAllAvailable' => $this->language->get('text_fillallavailable'),
        );

        if (isset($this->request->post['openbay_fba_fulfill_policy'])) {
            $data['openbay_fba_fulfill_policy'] = $this->request->post['openbay_fba_fulfill_policy'];
        } else {
            $data['openbay_fba_fulfill_policy'] = $this->config->get('openbay_fba_fulfill_policy');
        }

        $data['shipping_speed'] = array(
            'Standard' => $this->language->get('text_standard'),
            'Expedited' => $this->language->get('text_expedited'),
            'Priority' => $this->language->get('text_priority'),
        );

        if (isset($this->request->post['openbay_fba_shipping_speed'])) {
            $data['openbay_fba_shipping_speed'] = $this->request->post['openbay_fba_shipping_speed'];
        } else {
            $data['openbay_fba_shipping_speed'] = $this->config->get('openbay_fba_shipping_speed');
        }

        $data['api_server'] = $this->openbay->fba->getServerUrl();
        $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba_settings', $data));
    }

    public function verifyCredentials() {
        $this->load->language('extension/openbay/fba_settings');

        $errors = array();

        if (!isset($this->request->post['openbay_fba_api_key']) || empty($this->request->post['openbay_fba_api_key'])) {
            $errors[] = array('message' => $this->language->get('error_api_key'));
        }

        if (!isset($this->request->post['openbay_fba_api_account_id']) || empty($this->request->post['openbay_fba_api_account_id'])) {
            $errors[] = array('message' => $this->language->get('error_api_account_id'));
        }

        if (!isset($this->request->post['openbay_fba_encryption_key']) || empty($this->request->post['openbay_fba_encryption_key'])) {
            $errors[] = array('message' => $this->language->get('error_encryption_key'));
        }

        if (!isset($this->request->post['openbay_fba_encryption_iv']) || empty($this->request->post['openbay_fba_encryption_iv'])) {
            $errors[] = array('message' => $this->language->get('error_encryption_iv'));
        }

        if (!$errors) {
            $this->openbay->fba->setApiKey($this->request->post['openbay_fba_api_key']);
            $this->openbay->fba->setAccountId($this->request->post['openbay_fba_api_account_id']);
            $this->openbay->fba->setEncryptionKey($this->request->post['openbay_fba_encryption_key']);
            $this->openbay->fba->setEncryptionIv($this->request->post['openbay_fba_encryption_iv']);

            $response = $this->openbay->fba->call("v1/fba/status/", array(), 'GET');
        } else {
            $response = array(
                "result" => null,
                "error" => true,
                "error_messages" => $errors,
            );
        }

        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($response));
    }

    protected function validate() {
        if (!$this->user->hasPermission('modify', 'extension/openbay/fba')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        if (!$this->request->post['openbay_fba_api_key']) {
            $this->error['api_key'] = $this->language->get('error_api_key');
        }

        if (!$this->request->post['openbay_fba_api_account_id']) {
            $this->error['api_account_id'] = $this->language->get('error_api_account_id');
        }

        return !$this->error;
    }

    public function fulfillment() {
        $this->load->language('extension/openbay/fba_fulfillment');

        $data = $this->language->all();

        $this->document->setTitle($this->language->get('heading_title'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        if (!isset($this->request->get['fulfillment_id'])) {
            $this->response->redirect($this->url->link('extension/openbay/fba/fulfillmentlist', 'user_token=' . $this->session->data['user_token'] . (!empty($this->request->get['filter_date']) ? '&filter_date=' . $this->request->get['filter_date'] : ''), true));
        }

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_home'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_openbay'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['text_fba'],
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba/fulfillmentlist', 'user_token=' . $this->session->data['user_token'] . (!empty($this->request->get['filter_date']) ? '&filter_date=' . $this->request->get['filter_date'] : ''), true),
            'text' => $data['heading_title'],
        );

        $response = $this->openbay->fba->call("v1/fba/fulfillments/" . $this->request->get['fulfillment_id'] . "/", array());
        $data['response'] = $response['body'];

        if ($response['error'] == true || $response['response_http'] != 200) {
            $this->session->data['error'] = $this->language->get('error_loading_fulfillment');

            $this->response->redirect($this->url->link('extension/openbay/fba/fulfillmentlist', 'user_token=' . $this->session->data['user_token'], true));
        }

        $data['user_token'] = $this->session->data['user_token'];

        if (isset($this->session->data['error'])) {
            $data['error_warning'] = $this->session->data['error'];
            unset($this->session->data['error']);
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];

            unset($this->session->data['success']);
        } else {
            $data['success'] = '';
        }

        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba_fulfillment_form', $data));
    }

    public function fulfillmentList() {
        $this->load->language('extension/openbay/fba_fulfillment_list');

        $data = $this->language->all();

        $this->document->setTitle($this->language->get('heading_title'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_home'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_openbay'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['text_fba'],
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['heading_title'],
        );

        if (isset($this->request->get['filter_date'])) {
            $data['filter_date'] = $this->request->get['filter_date'];
            $request_url = "?query_start_date_time=".urlencode($this->request->get['filter_date'] . "T00:00:00Z");
        } else {
            $data['filter_date'] = '';
            $request_url = "";
        }

        $data['fulfillments'] = array();

        $response = $this->openbay->fba->call("v1/fba/fulfillments/".$request_url, array(), 'GET');

        if (isset($response['body']) && is_array($response['body'])) {
            foreach ($response['body'] as $fulfillment_order) {
                $data['fulfillments'][] = array(
                    'seller_fulfillment_order_id' => $fulfillment_order['seller_fulfillment_order_id'],
                    'displayable_order_id' => $fulfillment_order['displayable_order_id'],
                    'displayable_order_date_time' => $fulfillment_order['displayable_order_date_time'],
                    'shipping_speed_category' => $fulfillment_order['shipping_speed_category'],
                    'fulfillment_order_status' => $fulfillment_order['fulfillment_order_status'],
                    'edit' => $this->url->link('extension/openbay/fba/fulfillment', 'user_token=' . $this->session->data['user_token'] . '&fulfillment_id=' . $fulfillment_order['seller_fulfillment_order_id'] . (!empty($data['filter_date']) ? '&filter_date=' . $data['filter_date'] : ''), true),
                );
            }
        }

        $data['cancel'] = $this->url->link('extension/openbay/fba/index', 'user_token=' . $this->session->data['user_token'], true);
        $data['user_token'] = $this->session->data['user_token'];

        if (isset($this->session->data['error'])) {
            $data['error_warning'] = $this->session->data['error'];
            unset($this->session->data['error']);
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];

            unset($this->session->data['success']);
        } else {
            $data['success'] = '';
        }

        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba_fulfillment_list', $data));
    }

    public function shipFulfillment() {
        $this->load->language('extension/openbay/fba_fulfillment');

        $errors = array();

        if (empty($this->request->get['order_id']) || empty($this->request->get['fba_order_fulfillment_id'])) {
            $this->session->data['error'] = $this->language->get('error_missing_id');

            $this->response->redirect($this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true));
        } else {
            $order_id = (int)$this->request->get['order_id'];
            $fba_order_fulfillment_id = (int)$this->request->get['fba_order_fulfillment_id'];

            $this->openbay->fba->log('shipFulfillment request for order ID: ' . $order_id . ', Fulfillment ID: ' . $fba_order_fulfillment_id);

            $fba_fulfillment_id = $this->openbay->fba->createFBAFulfillmentID($order_id, 1);

            $response = $this->openbay->fba->call("v1/fba/fulfillments/" . $this->config->get('openbay_fba_order_prefix') . $order_id . '-' . $fba_order_fulfillment_id . "/ship/", array(), 'GET');



            if (!isset($response['response_http']) || $response['response_http'] != 200) {
                /**
                 * @todo notify the admin about any errors
                 */
                $errors[] = $this->language->get('error_amazon_request');

                //$this->openbay->fba->updateFBAOrderStatus($order_id, 1);
            } else {
                $this->openbay->fba->populateFBAFulfillment(json_encode(array()), json_encode($response), $response['response_http'], $fba_fulfillment_id);

                $this->openbay->fba->updateFBAOrderStatus($order_id, 3);

                $this->session->data['success'] = $this->language->get('text_fulfillment_shipped');
            }
        }

        if ($errors) {
            $this->session->data['error'] = $errors;
        }

        $this->response->redirect($this->url->link('extension/openbay/fba/order', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true));
    }

    public function cancelFulfillment() {
        $this->load->language('extension/openbay/fba_fulfillment');

        $errors = array();

        if (empty($this->request->get['order_id']) || empty($this->request->get['fba_order_fulfillment_id'])) {
            $this->session->data['error'] = $this->language->get('error_missing_id');

            $this->response->redirect($this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true));
        } else {
            $order_id = (int)$this->request->get['order_id'];
            $fba_order_fulfillment_id = (int)$this->request->get['fba_order_fulfillment_id'];

            $this->openbay->fba->log('cancelFulfillment request for order ID: ' . $order_id . ', Fulfillment ID: ' . $fba_order_fulfillment_id);

            $fba_fulfillment_id = $this->openbay->fba->createFBAFulfillmentID($order_id, 2);

            $response = $this->openbay->fba->call("v1/fba/fulfillments/" . $this->config->get('openbay_fba_order_prefix') . $order_id . '-' . $fba_order_fulfillment_id . "/cancel/", array(), 'POST');

            if (!isset($response['response_http']) || $response['response_http'] != 200) {
                /**
                 * @todo notify the admin about any errors
                 */
                $errors[] = $this->language->get('error_amazon_request');
            } else {
                $this->openbay->fba->populateFBAFulfillment(json_encode(array()), json_encode($response), $response['response_http'], $fba_fulfillment_id);

                $this->openbay->fba->updateFBAOrderStatus($order_id, 4);

                $this->session->data['success'] = $this->language->get('text_fulfillment_cancelled');
            }
        }

        if ($errors) {
            $this->session->data['error'] = $errors;
        }

        $this->response->redirect($this->url->link('extension/openbay/fba/order', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true));
    }

    public function resendFulfillment() {
        $this->load->language('extension/openbay/fba_fulfillment');

        $errors = array();

        if (empty($this->request->get['order_id'])) {
            $this->session->data['error'] = $this->language->get('error_missing_id');

            $this->response->redirect($this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true));
        } else {
            $order_id = (int)$this->request->get['order_id'];

            $this->openbay->fba->log('resendFulfillment request for order ID: ' . $order_id);

            $this->load->model('sale/order');
            $this->load->model('catalog/product');

            $order = $this->model_sale_order->getOrder($order_id);

            if ($order['shipping_method']) {
                if ($this->config->get('openbay_fba_order_trigger_status') == $order['order_status_id']) {
                    $fba_fulfillment_id = $this->openbay->fba->createFBAFulfillmentID($order_id, 1);

                    $order_products = $this->model_sale_order->getOrderProducts($order_id);

                    $fulfillment_items = array();

                    foreach ($order_products as $order_product) {
                        $product = $this->model_catalog_product->getProduct($order_product['product_id']);

                        if ($product['location'] == 'FBA') {
                            $fulfillment_items[] = array(
                                'seller_sku' => $product['sku'],
                                'quantity' => $order_product['quantity'],
                                'seller_fulfillment_order_item_id' => $this->config->get('openbay_fba_order_prefix') . $fba_fulfillment_id . '-' . $order_product['order_product_id'],
                                'per_unit_declared_value' => array(
                                    'currency_code' => $order['currency_code'],
                                    'value' => number_format($order_product['price'], 2)
                                ),
                            );
                        }
                    }

                    $total_fulfillment_items = count($fulfillment_items);

                    if (!empty($fulfillment_items)) {
                        $request = array();

                        $datetime = new DateTime($order['date_added']);
                        $request['displayable_order_datetime'] = $datetime->format(DateTime::ISO8601);

                        $request['seller_fulfillment_order_id'] = $this->config->get('openbay_fba_order_prefix') . $order_id . '-' . $fba_fulfillment_id;
                        $request['displayable_order_id'] = $order_id;
                        $request['displayable_order_comment'] = 'none';
                        $request['shipping_speed_category'] = $this->config->get('openbay_fba_shipping_speed');
                        $request['fulfillment_action'] = ($this->config->get('openbay_fba_send_orders') == 1 ? 'Ship' : 'Hold');
                        $request['fulfillment_policy'] = $this->config->get('openbay_fba_fulfill_policy');

                        $request['destination_address'] = array(
                            'name' => $order['shipping_firstname'] . ' ' . $order['shipping_lastname'],
                            'line_1' => (!empty($order['shipping_company']) ? $order['shipping_company'] : $order['shipping_address_1']),
                            'line_2' => (!empty($order['shipping_company']) ? $order['shipping_address_1'] : $order['shipping_address_2']),
                            'line_3' => (!empty($order['shipping_company']) ? $order['shipping_address_2'] : ''),
                            'state_or_province_code' => $order['shipping_zone'],
                            'city' => $order['shipping_city'],
                            'country_code' => $order['shipping_iso_code_2'],
                            'postal_code' => $order['shipping_postcode'],
                        );

                        $request['items'] = $fulfillment_items;

                        $response = $this->openbay->fba->call("v1/fba/fulfillments/", $request, 'POST');

                        if ($response['response_http'] != 201) {
                            /**
                             * @todo notify the admin about any errors
                             */
                            $errors[] = $this->language->get('error_amazon_request');

                            $this->openbay->fba->updateFBAOrderStatus($order_id, 1);
                        } else {
                            if ($this->config->get('openbay_fba_send_orders') == 1) {
                                $this->openbay->fba->updateFBAOrderStatus($order_id, 3);
                            } else {
                                $this->openbay->fba->updateFBAOrderStatus($order_id, 2);
                            }

                            $this->openbay->fba->updateFBAOrderRef($order_id, $this->config->get('openbay_fba_order_prefix') . $order_id . '-' . $fba_fulfillment_id);

                            $this->session->data['success'] = $this->language->get('text_fulfillment_sent');
                        }

                        $this->openbay->fba->populateFBAFulfillment(json_encode($request), json_encode($response), $response['response_http'], $fba_fulfillment_id);
                        $this->openbay->fba->updateFBAOrderFulfillmentID($order_id, $fba_fulfillment_id);
                    } else {
                        $errors[] = $this->language->get('error_no_items');
                    }
                }
            } else {
                $errors[] = $this->language->get('error_no_shipping');
            }
        }

        if ($errors) {
            $this->session->data['error'] = $errors;
        }

        $this->response->redirect($this->url->link('extension/openbay/fba/order', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true));
    }

    public function orderList() {
        $this->load->language('extension/openbay/fba_order');

        $data = $this->language->all();

        $this->document->setTitle($this->language->get('heading_title'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_home'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_openbay'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['text_fba'],
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['heading_title'],
        );

        $filters = array();

        $url = '';

        if (isset($this->request->get['filter_start'])) {
            $filters['filter_start'] = $this->request->get['filter_start'];
            $data['filter_start'] = $this->request->get['filter_start'];
            $url .= "&filter_start=".urlencode($this->request->get['filter_start']);
        } else {
            $filters['filter_start'] = null;
            $data['filter_start'] = null;
        }

        if (isset($this->request->get['filter_end'])) {
            $filters['filter_end'] = $this->request->get['filter_end'];
            $data['filter_end'] = $this->request->get['filter_end'];
            $url .= "&filter_end=".urlencode($this->request->get['filter_end']);
        } else {
            $filters['filter_end'] = null;
            $data['filter_end'] = null;
        }

        if (isset($this->request->get['filter_status'])) {
            $filters['filter_status'] = $this->request->get['filter_status'];
            $data['filter_status'] = $this->request->get['filter_status'];
            $url .= "&filter_status=".urlencode($this->request->get['filter_status']);
        } else {
            $filters['filter_status'] = null;
            $data['filter_status'] = null;
        }

        $data['orders'] = array();

        $orders = $this->openbay->fba->getFBAOrders($filters);

        if (!empty($orders)) {
            foreach ($orders as $order) {
                $data['orders'][] = array(
                    'order_id' => $order['order_id'],
                    'order_link' => $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order['order_id'] . $url, true),
                    'status' => $order['status'],
                    'created' => $order['created'],
                    'fba_item_count' => $this->openbay->fba->hasOrderFBAItems($order['order_id']),
                    'view' => $this->url->link('extension/openbay/fba/order', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order['order_id'] . $url, true)
                );
            }
        }

        $data['cancel'] = $this->url->link('extension/openbay/fba/index', 'user_token=' . $this->session->data['user_token'], true);
        $data['user_token'] = $this->session->data['user_token'];

        $data['status_options'] = array(
            0 => $this->language->get('text_option_new'),
            1 => $this->language->get('text_option_error'),
            2 => $this->language->get('text_option_held'),
            3 => $this->language->get('text_option_shipped'),
        );

        if (isset($this->session->data['error'])) {
            $data['error_warning'] = $this->session->data['error'];
            unset($this->session->data['error']);
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];

            unset($this->session->data['success']);
        } else {
            $data['success'] = '';
        }
		
        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba_order_list', $data));
    }

    public function order() {
        $this->load->language('extension/openbay/fba_order');

        $data = $this->language->all();

        $this->document->setTitle($this->language->get('heading_title'));
        $this->document->addScript('view/javascript/openbay/js/faq.js');

        $this->load->model('sale/order');
        $this->load->model('catalog/product');

        if (!isset($this->request->get['order_id'])) {
            $this->response->redirect($this->url->link('extension/openbay/fba/orderList', 'user_token=' . $this->session->data['user_token'], true));
        }

        $order_id = (int)$this->request->get['order_id'];
        $order_fba = $this->openbay->fba->getFBAOrder($order_id);
        $order_info = $this->model_sale_order->getOrder($order_id);

        if ($order_fba['status'] == 2 || $order_fba['status'] == 3 || $order_fba['status'] == 4) {
            $data['fulfillment_id'] = $order_fba['fba_order_fulfillment_ref'];
            $data['fulfillment_link'] = $this->url->link('extension/openbay/fba/fulfillment', 'user_token=' . $this->session->data['user_token'] . '&fulfillment_id=' . $data['fulfillment_id'], true);
        } else {
            $data['fulfillment_id'] = '';
            $data['fulfillment_link'] = '';
        }

        $data['fba_order_status'] = $order_fba['status'];
        $data['order_id'] = $order_id;
        $data['order_link'] = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true);
        $data['resend_link'] = $this->url->link('extension/openbay/fba/resendfulfillment', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true);
        $data['ship_link'] = $this->url->link('extension/openbay/fba/shipfulfillment', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id . '&fba_order_fulfillment_id=' . $order_fba['fba_order_fulfillment_id'], true);
        $data['cancel_link'] = $this->url->link('extension/openbay/fba/cancelfulfillment', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id . '&fba_order_fulfillment_id=' . $order_fba['fba_order_fulfillment_id'], true);

        $data['cancel'] = $this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true);

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'href'      => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
            'text'      => $this->language->get('text_home'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $this->language->get('text_openbay'),
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['text_fba'],
        );

        $data['breadcrumbs'][] = array(
            'href' => $this->url->link('extension/openbay/fba/orderlist', 'user_token=' . $this->session->data['user_token'], true),
            'text' => $data['heading_title'],
        );

        $data['fulfillments'] = array();

        if (is_array($order_fba['fulfillments'])) {
            foreach ($order_fba['fulfillments'] as $fulfillment) {
                $response_body = json_decode($fulfillment['response_body'], true);

                $fulfillment_errors = array();

                if (isset($response_body['error']) && $response_body['error'] == true) {
                    if (is_array($response_body['error_messages']) && !empty($response_body['error_messages'])) {
                        $fulfillment_errors = $response_body['error_messages'];
                    }
                }

                $data['fulfillments'][] = array(
                    'fba_order_fulfillment_id' => $fulfillment['fba_order_fulfillment_id'],
                    'created' => $fulfillment['created'],
                    'request_body' => json_decode($fulfillment['request_body']),
                    'request_body_output' => print_r(json_decode($fulfillment['request_body']), true),
                    'response_body' => json_decode($fulfillment['response_body']),
                    'response_body_output' => print_r(json_decode($fulfillment['response_body']), true),
                    'response_header_code' => $fulfillment['response_header_code'],
                    'errors' => $fulfillment_errors,
                    'type' => $fulfillment['type'],
                );
            }
        }

        // Shipping Address
        if ($order_info['shipping_address_format']) {
            $format = $order_info['shipping_address_format'];
        } else {
            $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
        }

        $find = array(
            '{firstname}',
            '{lastname}',
            '{company}',
            '{address_1}',
            '{address_2}',
            '{city}',
            '{postcode}',
            '{zone}',
            '{zone_code}',
            '{country}'
        );

        $replace = array(
            'firstname' => $order_info['shipping_firstname'],
            'lastname'  => $order_info['shipping_lastname'],
            'company'   => $order_info['shipping_company'],
            'address_1' => $order_info['shipping_address_1'],
            'address_2' => $order_info['shipping_address_2'],
            'city'      => $order_info['shipping_city'],
            'postcode'  => $order_info['shipping_postcode'],
            'zone'      => $order_info['shipping_zone'],
            'zone_code' => $order_info['shipping_zone_code'],
            'country'   => $order_info['shipping_country']
        );

        $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));

        $data['status_options'] = array(
            0 => $this->language->get('text_option_new'),
            1 => $this->language->get('text_option_error'),
            2 => $this->language->get('text_option_held'),
            3 => $this->language->get('text_option_shipped'),
            4 => $this->language->get('text_option_cancelled'),
        );

        $data['type_options'] = array(
            0 => $this->language->get('text_type_new'),
            1 => $this->language->get('text_type_ship'),
            2 => $this->language->get('text_type_cancel'),
        );

        $data['products'] = array();

        $products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']);

        foreach ($products as $product) {
            $option_data = array();

            $product_info = $this->model_catalog_product->getProduct($product['product_id']);

            $options = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);

            foreach ($options as $option) {
                if ($option['type'] != 'file') {
                    $option_data[] = array(
                        'name'  => $option['name'],
                        'value' => $option['value'],
                        'type'  => $option['type']
                    );
                }
            }

            $data['products'][] = array(
                'order_product_id' => $product['order_product_id'],
                'product_id'       => $product['product_id'],
                'name'    	 	   => $product['name'],
                'sku'    		   => $product_info['sku'],
                'option'   		   => $option_data,
                'quantity'		   => $product['quantity'],
                'fba'		       => ($product_info['location'] == 'FBA' ? 1 : 0),
                'href'     		   => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $product['product_id'], true),
            );
        }

        if (isset($this->session->data['error'])) {
            $data['error_warning'] = $this->session->data['error'];
            unset($this->session->data['error']);
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];
            unset($this->session->data['success']);
        } else {
            $data['success'] = '';
        }


        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

        $this->response->setOutput($this->load->view('extension/openbay/fba_order_info', $data));
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit