Jump to content

Anton Qcl

  • Content Count

  • Joined

  • Last visited

About Anton Qcl

  • Rank
    Advanced Member
  • Birthday 09/26/1989

Profile Information

  • Gender
  • Location

Contact Methods

  • Skype

Recent Profile Visitors

4,877 profile views
  1. @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
  2. @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.
  3. @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; } }
  4. 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
  5. 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
  6. Anton Qcl

    Custom Smart Search

    Hi, Is there a way to extend custom search the way I need? For example, in some plugins I have additional information attached to client and I want to be able to find clients thru Smart Search using only this information.
  7. Paul, I'm using SMTP. Blesta Version: 3.6.2 I have access to logs. OS is CentOS 7. I've checked /var/log/maillog but there is no entries about failed emails. Do you have any idea about other files to check? Unfortunately, it is not easy procedure in my case cause some of .pdt files was modified and some of third-party plugins can be incompatible with new version. I'll try to avoid this procedure as long as possible. It looks like fortune telling. Yes, problems could be caused by plenty of reasons and I want to find these reasons. However "the guessing" is not the way I want to use. So, I'm asking you, how can I find real source of the problems? Do you have instrument for debug this kind of problems (like extended logging to the file)? Maybe I can temporarily place some snippet for debug purposes somewhere? Please, tell me about variants of diagnostic. What would you do to find cause of this problem?
  8. Licensecart, SMTP. Paul, Some emails go out but not all of them. Fortunately I was able to repeat problem using test user. From the over side, I have no idea how to find the reason of the problem. Mail settings is ok - I'm able to send mail from the other software using same credentials. Moreover, I have several companies in my Blesta (with unique email for each) and from time to time I face with mail problems at each of them. Regretfully, I can't find any useful information about reasons of the errors - I can only see status "Unsent" and message "The email failed to send due to a configuration issue". Please, recommend my some way to investigate the problems. Perhaps I can find some logs somewhere?
  9. Hello. I tried to send email to test user (url: /admin/clients/email/{USERID}/) and received next error: "The email failed to send due to a configuration issue". Please, tell me how can I figure out the reason of this problem? Apache log has no errors. Screenshot of the error: http://prntscr.com/f909xh
  10. Paul, in this case, please, change text of the error. Also, I will be very appreciate if you describe allowed and disallowed clauses in documentation(https://docs.blesta.com/display/user/Generating+Reports) more.
  11. Hello, I'm trying to create a custom report, but I receive error: "Only one query allowed, and it must be a SELECT query." Problem occurs when I trying to add next string in my query: GROUP_CONCAT(CONCAT(`client_notes`.`title`, `client_notes`.`description`) SEPARATOR '; ') AS 'Notes' Full text of my query: SELECT `users`.`date_added` AS 'Memeber Since', `clients`.`status` AS 'Client Status', `clients`.`id_value` AS 'CRM #', `contacts`.`first_name` AS 'First Name', `contacts`.`last_name` AS 'Last Name', `contacts`.`company` AS 'Company/Org.', `contacts`.`address1` AS 'Address', `contacts`.`city` AS 'City', `contacts`.`country` AS 'Country', `contacts`.`state` AS 'State/Province', `contacts`.`zip` AS 'Zip/Postal Code', `contacts`.`email` AS 'Email', GROUP_CONCAT(CONCAT(`client_notes`.`title`, `client_notes`.`description`) SEPARATOR '; ') AS 'Notes' FROM `clients` JOIN `users` ON (`users`.`id`=`clients`.`user_id`) LEFT JOIN `contacts` ON (`contacts`.`client_id`=`clients`.`id` AND `contacts`.`contact_type`='primary') LEFT JOIN `contact_numbers` ON (`contact_numbers`.`contact_id`=`contacts`.`id`) LEFT JOIN `client_notes` ON (`client_notes`.`client_id`=`clients`.`id`) GROUP BY `clients`.`id`
  12. Tested in: OS: Microsoft Windows 8.1 Browser: Firefox 26.0 OS: Linux Browser: Firefox 24.0
  13. Did you try to use browser Mozilla Firefox? It is very important to duplicate this error. I mean browser "Mozilla Firefox" is sending wrong form to the handler.
  14. Blesta version: 3.1.1 Url: https://my.blesta.site/admin/clients/edit/765/ Browser: Mozilla Firefox. Steps: Go to a client in the admin interface. Click "Edit". (Click "Add additional number"). Type number Click "Modify Client". Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'type' cannot be null on line 124 in /var/www/vhosts/my.blesta.site/public_html/lib/model.php Printing Stack Trace: #0 /var/www/vhosts/my.blesta.site/public_html/lib/model.php(124): PDOStatement->execute(Array) #1 /var/www/vhosts/my.blesta.site/public_html/components/record/record.php(216): Model->query('INSERT INTO `co...', Array) #2 /var/www/vhosts/my.blesta.site/public_html/app/models/contacts.php(475): Record->insert('contact_numbers', Array, Array) #3 /var/www/vhosts/my.blesta.site/public_html/app/models/contacts.php(188): Contacts->addNumber('503', Array) #4 /var/www/vhosts/my.blesta.site/public_html/app/controllers/admin_clients.php(991): Contacts->edit('503', Array) #5 /var/www/vhosts/my.blesta.site/public_html/lib/dispatcher.php(111): AdminClients->edit() #6 /var/www/vhosts/my.blesta.site/public_html/index.php(21): Dispatcher::dispatch('/admin/clients/...') #7 {main}
  15. Incorrect url in settings of one company was original reason of the problem. Solved. Thank you for help.
  • Create New...