<?php
namespace Modules\Partners\Customers\Deduplicate; class Controller extends \App\Mvc\Controller\Window\PaginatedListing\ListingAbstract { protected $listOrderingColumns = ['score']; protected function initialize() { parent::initialize(); $this->actionsCfg['pickNextSuggestion'] = ['checkSection' => true, 'checkOption' => false,]; } protected function list_getDefaultParams() { $ret = $this->cfg['listingParams']; $model = new Model(); $id1 = $model->getTopSuggestion(0)['id1']; $dbSuggestions = $model->reorderUsingMostProbableMainSuggestion($model->getSuggestionsRelatedTo($id1)); $id1 = $dbSuggestions[0]; $ret['filters']['mainSuggestion'] = $id1; $ret['filters']['suggestedIds'] = implode(", ", $dbSuggestions); return $ret; } protected function actionIndex_preRender(\App\Mvc\ModelAbstract $model, \App\Mvc\ViewAbstract $view, Array $R) { $model = new Model(); $view->setOutputVar('progress', $model->getSuggestionsProgress()); } protected function actionPickNextSuggestion($R) { $model = new Model(); if (!$R['chosenId']) { $model->markSuggestionsAsIgnored($R['currentId']); } if ($R['chosenId']) { $pickedId = $R['chosenId']; } else { $pickedId = $model->getTopSuggestion(0)['id1']; } if ($R['chosenId']) { $relatedSuggestions = $model->getSuggestionsRelatedTo($pickedId); } else { $relatedSuggestions = $model->reorderUsingMostProbableMainSuggestion($model->getSuggestionsRelatedTo($pickedId)); $pickedId = $relatedSuggestions[0]; } $ac = new \App\Form\Input\Autocomplete_Customer(); $json = new \stdClass(); $json->value = $pickedId; $json->displayValue = $ac->determineDisplayValue($pickedId); $json->suggestedIds = implode(", ", $relatedSuggestions); $progress = $model->getSuggestionsProgress(); $json->progress = new \stdClass(); $json->progress->done = $progress['done']; $json->progress->total = $progress['total']; return new \Engine\Mvc\Response\Json($json); } protected function optionDefineParams(\App\Mvc\View\Utils\RowOptions\Option\Option $option, $selection) { switch ($option->getId()) { case 'refilter': break; case 'markDuplicate': break; } return true; } protected function optionGetEntityName($id) { return \Entity\Customer::select($id)->name; } } 