14 if (!defined(
'IN_PEEL')) {
18 include(
$GLOBALS[
'dirroot'] .
'/lib/fonctions/fonctions_admin.php');
27 $query =
query(
'SELECT o.id_utilisateur AS customers_id, count(*) AS this_count, IF( o_timestamp <"' . date(
'Y-m-d 00:00:00', time()-3600 * 24 * 365) .
'",1,0) AS old
29 INNER JOIN peel_statut_paiement sp ON sp.id=o.id_statut_paiement
30 WHERE sp.technical_code IN ("being_checked","completed")
31 GROUP BY o.id_utilisateur, IF(o.o_timestamp < "' . date(
'Y-m-d 00:00:00', time()-3600 * 24 * 365) .
'",1,0)
32 ORDER BY o.id_utilisateur ASC');
35 $recent_buys[
$result[
'customers_id']] = $result[
'this_count'];
37 $old_buys[
$result[
'customers_id']] = $result[
'this_count'];
39 $users[] =
$result[
'customers_id'];
41 foreach($users as $user_id) {
43 if (!empty($old_buys[$user_id])) {
44 $buys += $old_buys[$user_id];
46 if (!empty($recent_buys[$user_id])) {
47 $buys += $recent_buys[$user_id];
49 if ($buys >= 2 && !empty($recent_buys[$user_id])) {
50 $users_seg_buy[
'multi_recent'][$user_id] =
true;
51 }
elseif (!empty($recent_buys[$user_id])) {
52 $users_seg_buy[
'one_recent'][$user_id] =
true;
54 $users_seg_buy[
'multi_old'][$user_id] =
true;
56 $users_seg_buy[
'one_old'][$user_id] =
true;
62 query(
'UPDATE peel_utilisateurs SET seg_buy="no"');
64 foreach($users_seg_buy as $this_value => $ids_as_keys) {
65 query(
'UPDATE peel_utilisateurs
69 $GLOBALS[
'contentMail'] .=
'MAJ des valeurs de segmentation achat : OK' .
"\n";
80 $query =
query(
'SELECT UNIX_TIMESTAMP(expiration_date) AS paid_until_timestamp, user_id
83 $gold_ads_renewals_timestamps[
$result[
'user_id']][] = $result[
'paid_until_timestamp'];
87 FROM peel_admins_contacts_planified
88 WHERE timestamp >= UNIX_TIMESTAMP(NOW())
89 ORDER BY timestamp ASC');
91 $planified_contact_timestamps[$contact[
'user_id']][] = $contact[
'timestamp'];
93 $query =
query(
'SELECT id_membre, UNIX_TIMESTAMP(MAX(date)) AS last_contact_timestamp, COUNT(*) AS contacts_count
94 FROM peel_admins_actions
95 WHERE action IN ("PHONE_EMITTED", "PHONE_RECEIVED", "SEND_EMAIL") AND ' .
get_filter_site_cond(
'admins_actions') .
'
98 $last_contact_timestamps[$contact[
'id_membre']] = $contact[
'last_contact_timestamp'];
99 $contacts_counts[$contact[
'id_membre']] = $contact[
'contacts_count'];
101 $query =
query(
'SELECT *, TO_DAYS(now())-TO_DAYS(GREATEST(date_insert,"2008-01-01 00:00:00")) AS followed_days
102 FROM peel_utilisateurs
105 $user_id = $user[
'id_utilisateur'];
107 $is_actif = ($user[
'etat'] !==
'0');
110 if (!empty($contacts_counts) && !empty($contacts_counts[$user_id])) {
111 $frequence_followed = $contacts_counts[$user_id] * 365 / $user[
'followed_days'];
113 $frequence_followed = 0;
115 if ($frequence_followed == 0) {
116 $seg_followed =
'no';
117 }
elseif ($frequence_followed < 3) {
118 $seg_followed =
'poor';
120 $seg_followed =
'correct';
124 if (!empty($last_contact_timestamps[$user_id])) {
125 $contact_time_basis = $last_contact_timestamps[$user_id];
127 $contact_time_basis = strtotime($user[
'date_insert']);
129 if (!empty($seg_note)) {
131 if ($seg_note < 38) {
132 $seg_contact_days_frequence = 365;
133 }
elseif ($seg_note < 45) {
134 $seg_contact_days_frequence = 182;
135 }
elseif ($seg_note < 60) {
136 $seg_contact_days_frequence = 91;
138 $seg_contact_days_frequence = 30;
141 $next_contact_time[
'usual'] = $contact_time_basis + $seg_contact_days_frequence * 3600 * 24;
144 if (!empty($user[
'supramembre'])) {
147 $next_contact_time_subscription_renewal_expected_array[] = $user[
'supramembre']-7 * 24 * 3600;
149 if (!empty($user[
'platinum_until'])) {
152 $next_contact_time_subscription_renewal_expected_array[] = $user[
'platinum_until']-7 * 24 * 3600;
154 if (!empty($user[
'diamond_until'])) {
157 $next_contact_time_subscription_renewal_expected_array[] = $user[
'diamond_until']-7 * 24 * 3600;
159 if (!empty($next_contact_time_subscription_renewal_expected_array) && max($next_contact_time_subscription_renewal_expected_array) > $contact_time_basis + 7 * 24 * 3600) {
162 $next_contact_time[
'renewal_expected'] = max($next_contact_time_subscription_renewal_expected_array);
163 unset($next_contact_time_subscription_renewal_expected_array);
165 if (!empty($gold_ads_renewals_timestamps) && !empty($gold_ads_renewals_timestamps[$user_id])) {
167 foreach($gold_ads_renewals_timestamps[$user_id] as $this_timestamp) {
168 if ((empty($next_contact_time[
'renewal_expected']) || $this_timestamp-7 * 24 * 3600 < $next_contact_time[
'renewal_expected']) && $this_timestamp-7 * 24 * 3600 > $contact_time_basis + 7 * 24 * 3600) {
171 $next_contact_time[
'renewal_expected'] = $this_timestamp-7 * 24 * 3600;
176 if (!empty($planified_contact_timestamps) && !empty($planified_contact_timestamps[$user_id])) {
178 foreach($planified_contact_timestamps[$user_id] as $this_timestamp) {
179 if ((empty($next_contact_time[
'already_planified']) || $this_timestamp < $next_contact_time[
'already_planified']) && $this_timestamp > $contact_time_basis) {
182 $next_contact_time[
'already_planified'] = $this_timestamp;
188 if (!empty($next_contact_time)) {
190 asort($next_contact_time);
192 $next_contact_reason = key($next_contact_time);
193 if($next_contact_reason !=
'already_planified') {
194 $next_contact_timestamp = $next_contact_time[$next_contact_reason];
196 query(
'INSERT INTO peel_admins_contacts_planified (`user_id`, `timestamp`, `reason`)
198 ' . intval($user[
'id_utilisateur']) .
',
203 $next_contact_reason =
'';
204 $next_contact_timestamp = 0;
206 if ($seg_followed != $user[
'seg_followed']) {
208 query(
'UPDATE peel_utilisateurs
210 WHERE id_utilisateur=' . intval($user_id));
212 unset($next_contact_time);
214 $GLOBALS[
'contentMail'] .=
'MAJ des dates de contact : OK' .
"\n";
217 $contentMail =
'Traitement des segmentations client et des dates de contact
updateClientsContactDates()
updateClientsContactDates()
getClientNote(&$user_infos)
Renvoie la note d'un client en fonction de l'intérêt qu'on souhaite lui porter.
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
real_escape_string($value)
real_escape_string()
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
updateClientsSegBuy()
updateClientsSegBuy()
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
fetch_assoc($query_result)
fetch_assoc()
$GLOBALS['page_columns_count']
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...