Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16769 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16769 Rev 16971
Línea 26... Línea 26...
26
use LeadersLinked\Mapper\DiscoveryContactInteractionTypeMapper;
26
use LeadersLinked\Mapper\DiscoveryContactInteractionTypeMapper;
27
use LeadersLinked\Model\DiscoveryContactInteraction;
27
use LeadersLinked\Model\DiscoveryContactInteraction;
28
use LeadersLinked\Model\DiscoveryContactInteractionType;
28
use LeadersLinked\Model\DiscoveryContactInteractionType;
29
use LeadersLinked\Cache\CacheInterface;
29
use LeadersLinked\Cache\CacheInterface;
30
use LeadersLinked\Cache\CacheImpl;
30
use LeadersLinked\Cache\CacheImpl;
-
 
31
use LeadersLinked\Mapper\DiscoveryContactBlackListMapper;
Línea 31... Línea 32...
31
 
32
 
32
 
33
 
33
class DiscoveryContactController extends AbstractActionController
34
class DiscoveryContactController extends AbstractActionController
Línea 112... Línea 113...
112
            if ($isJson) {
113
            if ($isJson) {
113
                $search = $this->params()->fromQuery('search');
114
                $search = $this->params()->fromQuery('search');
114
                $search = empty($search['value']) ? '' :  Functions::sanitizeFilterString($search['value']);
115
                $search = empty($search['value']) ? '' :  Functions::sanitizeFilterString($search['value']);
Línea -... Línea 116...
-
 
116
 
-
 
117
 
Línea 115... Línea 118...
115
 
118
                
116
 
119
                
117
 
120
 
118
                $page               = intval($this->params()->fromQuery('start', 1), 10);
121
                $page               = intval($this->params()->fromQuery('start', 1), 10);
Línea 126... Línea 129...
126
 
129
 
127
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
130
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
128
                    $order_direction = 'ASC';
131
                    $order_direction = 'ASC';
Línea -... Línea 132...
-
 
132
                }
-
 
133
 
Línea 129... Línea 134...
129
                }
134
                $discoveryContactBackListMapper = DiscoveryContactBlackListMapper::getInstance($this->adapter);
130
 
135
                $contact_ids = $discoveryContactBackListMapper->fetchAllContactIdsByCompanyId($currentCompany->id);
Línea 131... Línea 136...
131
 
136
 
132
 
137
 
133
                $discoveryContactMapper = DiscoveryContactMapper::getInstance($this->adapter);
138
                $discoveryContactMapper = DiscoveryContactMapper::getInstance($this->adapter);
Línea 832... Línea 837...
832
                    return new JsonModel([
837
                    return new JsonModel([
833
                        'success' => false,
838
                        'success' => false,
834
                        'data' => 'ERROR_CACHE_INVALID'
839
                        'data' => 'ERROR_CACHE_INVALID'
835
                    ]);
840
                    ]);
836
                }
841
                }
-
 
842
                
-
 
843
                
-
 
844
                $csv = "EMAIL|STATUS\r\n";
Línea 837... Línea 845...
837
 
845
 
838
 
846
 
Línea 854... Línea 862...
854
 
862
 
855
 
863
 
856
                $new_contacts  = 0;
864
                $new_contacts  = 0;
857
                $duplicate_contacts = 0;
865
                $duplicate_contacts = 0;
-
 
866
                $error_contacts = 0;
858
                $error_contacts = 0;
867
                foreach ($records as $record) 
859
                foreach ($records as $record) {
868
                {
860
                    $first_name =   $record['first_name'];
869
                    $first_name =   $record['first_name'];
861
                    $last_name = $record['last_name'];
870
                    $last_name = $record['last_name'];
862
                    $email_personal = $record['email_personal'];
871
                    $email_personal = $record['email_personal'];
Línea 875... Línea 884...
875
                    $scholarship = $record['scholarship'];
884
                    $scholarship = $record['scholarship'];
Línea 876... Línea 885...
876
                    
885
                    
877
                    
886
                    
-
 
887
                    $discoveryContact = $discoveryContactMapper->fetchOneByCorporateEmail($email_company);
-
 
888
                    if ($discoveryContact) {
878
                    $discoveryContact = $discoveryContactMapper->fetchOneByCorporateEmail($email_company);
889
                        
879
                    if ($discoveryContact) {
890
                        $csv .= "$email_company|DUPLICATE\r\n";
Línea 880... Línea 891...
880
                        $duplicate_contacts++;
891
                        $duplicate_contacts++;
881
                    } else {
892
                    } else {
Línea 901... Línea 912...
901
                      
912
                      
902
                        
913
                        
Línea -... Línea 914...
-
 
914
                        if($discoveryContactMapper->insert($discoveryContact)) {
903
                        if($discoveryContactMapper->insert($discoveryContact)) {
915
                            $new_contacts++; 
Línea 904... Línea 916...
904
                            $new_contacts++; 
916
                            
905
                            
917
                            
906
                            if($discoveryContactInteractionTypeDefault) {
918
                            if($discoveryContactInteractionTypeDefault) {
Línea 954... Línea 966...
954
                            if ($discoveryContact->scholarship) {
966
                            if ($discoveryContact->scholarship) {
955
                                $discoveryContactLog->details .= 'LABEL_SCHOLARSHIP : ' . $discoveryContact->scholarship  . PHP_EOL;
967
                                $discoveryContactLog->details .= 'LABEL_SCHOLARSHIP : ' . $discoveryContact->scholarship  . PHP_EOL;
956
                            }
968
                            }
Línea 957... Línea 969...
957
                            
969
                            
-
 
970
                            
-
 
971
                            if($discoveryContactLogMapper->insert($discoveryContactLog)) {
-
 
972
                                $csv .= "$email_company|NEW\r\n";
-
 
973
                            } else {
Línea 958... Línea 974...
958
                            
974
                                $csv .= "$email_company|ERROR\r\n";
-
 
975
                            }
959
                            $discoveryContactLogMapper->insert($discoveryContactLog);
976
                            
960
                            
977
                            
961
                            
978
                            
962
                            
979
                        } else {
-
 
980
                            $csv .= "$email_company|ERROR\r\n";
-
 
981
                            $error_contacts++;
-
 
982
                        }
Línea 963... Línea 983...
963
                        } else {
983
                    }
964
                            $error_contacts++;
984
                }
965
                        }
985
                
966
                    }
986
                $csv_filename = 'discovery-contact-' . date('Y-m-d H:i') . '.csv';
967
                }
987
                $csv_filename = str_replace(' ', '-', $csv_filename);
968
 
988
 
-
 
989
 
-
 
990
                return new JsonModel([
969
 
991
                    'success' => true,
970
                return new JsonModel([
992
                    'data' => [
971
                    'success' => true,
993
                        'new_contacts' => $new_contacts,
972
                    'data' => [
994
                        'error_contacts' => $error_contacts,
973
                        'new_contacts' => $new_contacts,
995
                        'duplicate_contacts' => $duplicate_contacts,