delete( 'globelus_proposed_candidates', [ 'date_add[<=]' => date( 'Y-m-d', strtotime( '-30 days', time() ) ) ] ); // pobierz wszystkie aktywne ogłoszenia z przypisanymi kandydatami i przypisanem krajem $adverts = $mdb -> query( 'SELECT ga.id, id_position, country_id, title FROM globelus_adverts AS ga WHERE visible = 1 AND id_position IS NOT NULL AND country_id IS NOT NULL AND ( ga.proposed_candidates_date IS NULL OR ga.proposed_candidates_date <= \'' . date( 'Y-m-d H:i:s', strtotime( '-1 days', time() ) ) . '\' ) ORDER BY proposed_candidates_date ASC, id ASC LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $adverts ) ) foreach ( $adverts as $advert ) { $candidates_ids = $mdb -> select( 'globelus_candidates_positions', 'user_id', [ 'id_position' => $advert['id_position'] ] ); $candidates_ids = $mdb -> query( 'SELECT gu.id FROM globelus_users AS gu WHERE type = 0 AND status = 1 AND visible = 1 AND active_to >= \'' . date( "Y-m-d" ) . '\' AND gu.id IN ( ' . implode( ',', array_merge( [0], $candidates_ids ) ) . ')' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $candidates_ids ) ) foreach ( $candidates_ids as $candidate ) { if ( !$mdb -> count( 'globelus_proposed_candidates', [ 'AND' => [ 'advert_id' => $advert['id'], 'candidate_id' => $candidate['id'] ] ] ) ) { if ( $mdb -> count( 'globelus_candidates_countries', [ 'AND' => [ 'user_id' => $candidate['id'], 'country_id' => $advert['country_id'] ] ] ) ) $mdb -> insert( 'globelus_proposed_candidates', [ 'advert_id' => $advert['id'], 'candidate_id' => $candidate['id'], 'date_add' => date( 'Y-m-d H:i:s' ) ] ); } } $mdb -> update( 'globelus_adverts', [ 'proposed_candidates_date' => date( 'Y-m-d H:i:s' ) ], [ 'id' => $advert['id'] ] ); echo( '
Wyszukuję proponowanych kandydatów dla ogłoszenia: ' . $advert['title'] . ' #' . $advert['id'] . '
' ); } exit; } public static function disable_cv_access() { global $mdb, $settings; $results = $mdb -> query( 'SELECT ' . 'gu.id ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'gu.cv_access_date < \'' . date( 'Y-m-d' ) . '\' ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_users', [ 'cv_access' => 0, 'cv_access_date' => null ], [ 'id' => $row['id'] ] ); $mdb -> delete( 'globelus_firms_categories', [ 'user_id' => $row['id'] ] ); echo( 'Wyłączam dostęp do CV.
' ); } } public static function nopl() { global $mdb; $results = $mdb -> query( 'SELECT id, title FROM globelus_adverts WHERE title_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_adverts', [ 'title_nopl' => \S::seo( $row['title'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - ogłoszenia.
' ); } $results = $mdb -> query( 'SELECT id, firm_name_profile FROM globelus_firms_data WHERE firm_name_profile_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_firms_data', [ 'firm_name_profile_nopl' => \S::seo( $row['firm_name_profile'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - firmy.
' ); } $results = $mdb -> query( 'SELECT id, text FROM globelus_adverts WHERE text_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_adverts', [ 'text_nopl' => \S::seo( $row['text'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - ogłoszenia.
' ); } $results = $mdb -> query( 'SELECT id, name FROM globelus_countries WHERE name_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_countries', [ 'name_nopl' => \S::seo( $row['name'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - kraje.
' ); } $results = $mdb -> query( 'SELECT id, city FROM globelus_adverts WHERE city_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_adverts', [ 'city_nopl' => \S::seo( $row['city'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - miasta.
' ); } $results = $mdb -> query( 'SELECT id, name FROM globelus_adverts_categories WHERE name_seo IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_adverts_categories', [ 'name_seo' => \S::seo( $row['name'], true ) ], [ 'id' => $row['id'] ] ); echo( 'Generuje wartość nopl - kategorie.
' ); } } public static function disable_old_adverts() { global $mdb, $settings; $results = $mdb -> query( 'SELECT ' . 'ga.id, gu.email, ga.title, ga.date_add ' . 'FROM ' . 'globelus_adverts AS ga ' . 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id ' . 'WHERE ' . 'ga.active_to < \'' . date( "Y-m-d" ) . '\' ' . 'AND ' . '( old = 0 OR ga.visible = 1 )' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_adverts', [ 'visible' => 0, 'active_to' => null, 'highlight' => 0, 'highlight_to' => null, 'main_page' => 0, 'main_page_to' => null, 'old' => 1, 'last_refresh' => null ], [ 'id' => $row['id'] ] ); echo( 'Wyłączam stare ogłoszenia.
' ); } } public static function disable_adverts_main_page() { global $mdb, $lang, $settings; $results = $mdb -> query( 'SELECT ' . 'ga.id, gu.email, ga.title ' . 'FROM ' . 'globelus_adverts AS ga ' . 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id ' . 'WHERE ' . 'ga.main_page_to < \'' . date( 'Y-m-d' ) . '\' ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#koniec-polecania-ogloszenia' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o końcu polecania ogłoszenia.
' ); } } public static function disable_adverts_highlights() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'ga.id, gu.email, ga.title ' . 'FROM ' . 'globelus_adverts AS ga ' . 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id ' . 'WHERE ' . 'ga.highlight_to < \'' . date( 'Y-m-d' ) . '\' ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#koniec-wyroznienia-ogloszenia' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o końcu wyróżnienia ogłoszenia.
' ); } } public static function disable_profile_highlights() { global $mdb, $lang, $settings; $results = $mdb -> query( 'SELECT ' . 'gu.id, gu.email ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'gu.highlight_to < \'' . date( 'Y-m-d' ) . '\' ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $mdb -> update( 'globelus_users', [ 'highlight' => 0, 'highlight_to' => null ], [ 'id' => $row['id'] ] ); echo( 'Wyłączam wyróżnione profile.
' ); } } public static function email_advert_expired() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'ga.id, ga.active_to, gu.email, ga.title ' . 'FROM ' . 'globelus_adverts AS ga ' . 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id ' . 'WHERE ' . 'ga.visible = 1 ' . 'AND ' . 'ga.active_to IS NOT NULL ' . 'AND ' . 'ga.active_to < \'' . date( 'Y-m-d' ) . '\' ' . 'AND ' . 'ga.mail_expired = 0 ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#ogloszenie-wygaslo' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o wygaśnięciu ogłoszenia.
' ); } } public static function delete_inactive_profiles() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'gu.id, gu.email ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'gu.type = 0 ' . 'AND ' . 'gu.mail_delete_date < \'' . date( 'Y-m-d', strtotime( '-14 days', time() ) ) . '\' ' . 'AND ' . 'gu.mail_delete = 1 ' . 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#kandydat-usuniecie-konta-kandydata' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $text = str_replace( '[LINK]', $base . "://" . $_SERVER['SERVER_NAME'] . "/login-as/" . $row['hash'] . "?return_url=" . urlencode( '/panel-pracodawcy/ogloszenia' ), $text ); $regex = "-(Usuwanie nieaktywnych kont.
' ); } } public static function email_advert_expiration() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'ga.id, ga.active_to, gu.email, ga.title, gu.hash ' . 'FROM ' . 'globelus_adverts AS ga ' . 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id ' . 'WHERE ' . 'ga.visible = 1 ' . 'AND ' . 'ga.active_to IS NOT NULL ' . 'AND ' . 'ga.active_to <= \'' . date( 'Y-m-d', strtotime( '+3 days', time() ) ) . '\' ' . 'AND ' . 'ga.mail_expiration = 0 ' . 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#przedluz-swoje-ogloszenie' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $text = str_replace( '[LINK]', $base . "://" . $_SERVER['SERVER_NAME'] . "/login-as/" . $row['hash'] . "?return_url=" . urlencode( '/panel-pracodawcy/ogloszenia' ), $text ); $regex = "-(Wysyłam powiadomienie o wygasaniu ogłoszenia.
' ); } } static public function email_profile_delete() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'gu.id, gu.email, active_to ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'type = 0 ' . 'AND ' . 'DATE_ADD( active_to, INTERVAL 180 day ) < \'' . date( 'Y-m-d' ) . '\' ' . 'AND ' . 'mail_delete = 0 ' . 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-usunieciu-konta' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o usuniętym profilu.
' ); } } public static function email_profile_expired() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'gu.id, gu.email, active_to ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'type = 0 ' . 'AND ' . 'active_to < \'' . date( 'Y-m-d' ) . '\' ' . 'AND ' . 'mail_expired = 0 ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-wygasnieciu-profilu' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o wygaśniętym profilu.
' ); } } public static function email_profile_expiration() { global $mdb, $lang, $settings, $globelus_settings; $results = $mdb -> query( 'SELECT ' . 'gu.id, gu.email, active_to ' . 'FROM ' . 'globelus_users AS gu ' . 'WHERE ' . 'type = 0 ' . 'AND ' . 'active_to <= \'' . date( 'Y-m-d', strtotime( '+7 days', time() ) ) . '\' ' . 'AND ' . 'mail_expiration = 0 ' . 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC ); if ( is_array( $results ) ) foreach ( $results as $row ) { $days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 ); $text = $settings['newsletter_header']; $text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-wygasaniu-profilu' ); $text .= $settings['newsletter_footer_1']; $settings['ssl'] ? $base = 'https' : $base = 'http'; $regex = "-(Wysyłam powiadomienie o wygasaniu profilu.
' ); } } }