Jump to content

Anton Qcl

Members
  • Posts

    70
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Anton Qcl

  1. Forgot to share the code but I actually did it Note: this code is extremely dirty and should not be used in production. I hope, Smart Search will be really customizable some day ssbp-20210730.zip
  2. Solution: In components/invoice_delivery/invoice_delivery.php around line 745 add a few more lines 'postalmethods_apikey', 'postalmethods_colored', 'postalmethods_return_address1', 'postalmethods_return_address2', 'postalmethods_return_city', 'postalmethods_return_state', 'postalmethods_return_zip', 'postalmethods_return_country', 'postalmethods_replyenvelope', 'postalmethods_doublesided',
  3. Solution: In components/invoice_delivery/invoice_delivery.php around line 745 add a few more lines 'postalmethods_apikey', 'postalmethods_colored', 'postalmethods_return_address1', 'postalmethods_return_address2', 'postalmethods_return_city', 'postalmethods_return_state', 'postalmethods_return_zip', 'postalmethods_return_country', 'postalmethods_replyenvelope', 'postalmethods_doublesided',
  4. Hello. When we try to send invoice through Postal Methods, we receive error "Unauthorized User". We checked API Keys few times and sure that they correct. I created the video: https://monosnap.com/file/NUjscl3xEDJDFRhtKKs3Axq2LPWtPg Please, let me know if I'm doing something wrong.
  5. Hello. We found in logs a lot of errors like this in the file general-warning-cron-2021-07-14.log: [2021-07-14T22:46:17.164596+00:00] general.WARNING: E_WARNING: array_merge(): Expected parameter 1 to be an array, null given {"code":2,"message":"array_merge(): Expected parameter 1 to be an array, null given","file":"/var/www/vhosts/hdzona.tv/public_html/components/delivery/postal_methods/postal_methods.php","line":298} Looks like system expects that address is set but it is not. Can you, please, check it from your side? Since the error pops up in the cron log we are not able to determine which exactly action cause it. Let me know if you need any additional information. Blesta: 5.1.0 PHP: 7.4 OS: centos-release-7-9.2009.1.el7.centos.x86_64
  6. @Paul Thank you very much! I'd suggest little improvement in this case - when user choose to use Postal Method, check that company invoice page size is compatible with Postal Methods
  7. @Paul, hi! Updated version to 5.0.3. Invoices go to the PostalMethods but they are marked as "Invalid" in Postal Methods admin panel. Error: "Invalid Page Size" (http://prntscr.com/106zp92) Can you check it, please? Upd: got information from PostalMethods: Can you, please, create PDF's in LETTER format for them?
  8. @Jono, @Paul, great. Thank you for your work, guys!
  9. @Paul, Works good without that option. @Jono, the error generated by PostalMethods, so there is nothing in blesta logs. However, if you need to, I can temporary modify file postal_methods.php to collect any debug information you can use. Let me know which information you want to get from me
  10. @Paul thank you for fix, but, unfortunately, no changes after applying Still get the error "An internal error occurred during your request!" Our settings: http://prntscr.com/zsgyak OS: centos7 PHP: php7.4 Blesta: 5.0.2 + patch Key Type: Dev Let me know if you need any additional information from me
  11. We tested version 5.0.2 which includes API Adapter for new Postal Methods API but, unfortunately, it does not work. We set dev api key and tried to send invoice using Postal Methods and got next error: {"code":0,"message":"An internal error occurred during your request!","details":null,"validationErrors":null} We also see next information in Postal Methods Dashboard (http://prntscr.com/z5x4oi? Object reference not set to an instance of an object. Please, check it. PS I found minor bug in the components/delivery/postal_methods.php. I fixed it for my instance but it hasn't changed the API response (line 225) $filename = tempnam(sys_get_temp_dir(), 'tmp_') // This will generate file like "/tmp/tmp_XbKJsv" without ".tmp" extension ... // This block is completely useless because filename does not contain ".tmp" $new_filename = str_replace('.tmp', '.pdf', $filename); rename($filename, $new_filename); My Fix: $filename = tempnam(sys_get_temp_dir(), 'tmp_') . '.pdf'; // TODO: remove it // $new_filename = str_replace('.tmp', '.pdf', $filename); // rename($filename, $new_filename);
  12. SOLVED: some of required entries in cron_task_runs were missing. List: process_service_changes for all companies backups_sftp for company 0 backups_amazons3 for company 0 license_validation for company 0 SQL commands. For process_service_changes. Note (use your own company ids): INSERT INTO `blesta`.`cron_task_runs` (`id`, `task_id`, `company_id`, `time`, `interval`, `enabled`, `date_enabled`) VALUES (NULL, '29', '2', NULL, '5', '1', NOW()); INSERT INTO `blesta`.`cron_task_runs` (`id`, `task_id`, `company_id`, `time`, `interval`, `enabled`, `date_enabled`) VALUES (NULL, '29', '3', NULL, '5', '1', NOW()); For other tasks: INSERT INTO `blesta`.`cron_task_runs` (`id`, `task_id`, `company_id`, `time`, `interval`, `enabled`, `date_enabled`) VALUES (NULL, '9', '0', NULL, '5', '1', NOW()); INSERT INTO `blesta`.`cron_task_runs` (`id`, `task_id`, `company_id`, `time`, `interval`, `enabled`, `date_enabled`) VALUES (NULL, '14', '0', NULL, '5', '1', NOW()); INSERT INTO `blesta`.`cron_task_runs` (`id`, `task_id`, `company_id`, `time`, `interval`, `enabled`, `date_enabled`) VALUES (NULL, '17', '0', NULL, '5', '1', NOW());
  13. @Paul "Task last run" for all tasks is 2021-01-27 (day before update) No, there was php5.4
  14. [2021-01-28T07:15:01.624512+00:00] general.ERROR: Uncaught Exception TypeError: "Argument 1 passed to Blesta\Core\Automation\TaskFactory::cronTask() must be an instance of stdClass, bool given, called in /var/www/vhosts/hdzona.tv/public_html/app/controllers/cron.php on line 486" at /var/www/vhosts/hdzona.tv/public_html/core/Automation/TaskFactory.php line 74 {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Blesta\\Core\\Automation\\TaskFactory::cronTask() must be an instance of stdClass, bool given, called in /var/www/vhosts/hdzona.tv/public_html/app/controllers/cron.php on line 486 at /var/www/vhosts/hdzona.tv/public_html/core/Automation/TaskFactory.php:74)"} We have only standard plugins but this error appears every cron run since upgrade to 5.0.2 ENV: centos7, php7.4, mariadb10.4
  15. If you edit payment account and click "Show Card" right away, the popup window appears correctly, with the field for password. More than that, if you change any information after showing the card and try to save, system will allow you to do so. But, if you initially try to edit information and save it, system will show you the error. More that that, if you try to press "Show Card" after that, you'll get get an empty popup window. Video of the second scenario: https://monosnap.com/file/aI6IxxDDis0CuXqrBQHKNaqDw9MCDc I was able to reproduce the bug on the 4 different Blesta installs (2 of them 4.12.3, 2 of them 4.8)
  16. Paul, I mentioned that if I press link "Show Card", system just opens empty popup window: http://prntscr.com/vxzmom
  17. New version of the API will be supported by Blesta: https://dev.blesta.com/browse/CORE-4044
  18. Hello, We faced an error during payment account: if we try to change data and save, we get error: "The card type is invalid or could not be determined". Important, that we do not change any credit card information, including card number - we only try to change field "Zip Code". PS Also we've noticed weird system behaviour if we press link "Show Card": system just opens empty popup window: http://prntscr.com/vxzmom Blesta version: 4.12.3 Server OS: Centos7 PHP Version: 5.4
  19. Postal Methods introduced the new versions of API: https://documenter.getpostman.com/view/10877655/TVKD3dba http://prntscr.com/vumgnb Do you have plan to support that version? PS Postal Method's support confirmed that they are not gonna support SOAP version of API after January 1st (http://prntscr.com/vun4af)
  20. @Abdy, like I said earlier, this option is completely unacceptable by my client: * He needs to do two additional actions every search (click to open menu, another click to change the search) * If custom search was unsuccessful, system will not automatically use Smart Search after that. Both of these problems are solved in my solution. @Paul, ok, I'll publish the code after I finish the tests
  21. @Abdy, @Paul, I also found crutchy way to handle the case if we found few clients: Store results in session Handle event AppController.strucrure: Encode results and publish them as JS var inject JS script for handling result And then in JS script: Check if we are on the search results page Check if we have additional results Create html for row and append rows to the table. Create table if table does not exist. I can publish the code if you or somebody else need it.
  22. @Abdy, good idea but in this case client need to do two additional actions every time he wants to use custom search. It is not acceptable. Probably I could've try to go this way if there was an option to change default search. Right now it is 'Smart Search' and I did not find the way to change it. Is it possible? However, I like the idea of using events, so I did it. Following code monitor event Appcontroller.preAction and fire custom search function if detect that url is /admin/search. If clients are found, function will redirect user to the first client's page. It is crutchy but, unfortunately, I did not find the way to get the controller in my function interceptAdminSearch - I could possible use only var $event which does not contain any useful information. <?php class AtnSmartsearchPlugin extends Plugin { public function __construct() { $this->loadConfig(dirname(__FILE__) . DS . "config.json"); } public function getEvents() { return [ [ 'event' => "Appcontroller.preAction", 'callback' => ["this", "interceptAdminSearch"] ] ]; } public function interceptAdminSearch() { if ( strpos($_SERVER['REQUEST_URI'], "/admin/search") === 0 && $_SERVER['REQUEST_METHOD'] === "POST" ) { $this->searchClients(); } } public function searchClients() { $this->requireLogin(); $value = htmlentities(strip_tags($_POST['search'])); $clients = $this->myFunctionToSearchClients($value); if (!empty($clients)) { $client = array_pop($clients); $this->redirect($client->url); } } // Just an example, not a real function private function myFunctionToSearchClients($value) { if ($value == "example") { return [ (object)['url'=>"/admin/clients/view/1/", 'name'=>"Test Client1"], (object)['url'=>"/admin/clients/view/2/", 'name'=>" TestClient2"], ]; } } private function requireLogin() { if (empty($_SESSION['blesta_staff_id'])) { $this->redirect("/admin/login"); } } private function redirect($url) { header("Location: {$url}"); die(); } } Technically, this approach solves my problem but I would like to show information about other found clients somehow. It would be ok if I could add it in a flash message, but method flashMessage() is protected and defined in AppController. I tried to create custom controller inside my plugin but it did not work - no errors, but no flash messages after using it: <?php class CustomSearch extends AppController { public function setFlashMessage($message) { $this->flashMessage("message", $message, ['preserve_tags'=>true], false); } } <?php class AtnSmartsearchPlugin extends Plugin { public function searchClients() { ... if (!empty($clients)) { $client = array_pop($clients); if (count($clients) > 0) { $this->addClientsInfoToFlashMessages($clients,); } ... } } private function addClientsInfoToFlashMessages($clients,) { $clientsInfo = array_map(function($client) { return "<a href='{$client->url}'>{$client->name}</a>"; }, $clients); $clientsInfo = implode(nl2br(PHP_EOL), $clientsInfo); $message = "Also found clients:<br>{$clientsInfo}"; $controller = $this->loadCustomSearchController(); $controller->setFlashMessage($message); } private function loadCustomSearchController() { require __DIR__ . "/controllers/custom_search.php"; $controller = new \CustomSearch(null, null, false); return $controller; } }
  23. Paul, I actually tried to implement your idea. Action I took: 1. Added row into config/routes.php Router::route('^' . $admin_loc . '/search/?$', 'atn_smartsearch/atn_admin_search'); 2. Created plugin atn_smartsearch with controller atn_admin_search.php. Code of the AtnAdminSearch Controller: <?php class AtnAdminSearch extends AdminSearch { public function preAction() { // do nothing } public function index() { die('cathced index'); } } Please, take a look at this code. I expected that I can extend AdminSearch and redefine function index() to implement my own algo of search. This code works but, as you can see, I also redefined function preAction(). I did not want to do it but without it system just redirect me to the main admin page. I'm little bit confused because I did not find any errors in the logs which would indicate what I have done wrong. Can you, please, give me some advises? PS I've also added a video 2020-07-23 19-09-30.mp4
  24. Paul, thank you for answer. I also think I can implement much more dirty but convinient for customers solution: add some js on the page which intercept smart search form submitting, then do necessary search thru ajax. I'll share the code here if somebody will face the same requirement
×
×
  • Create New...