Ejemplo n.º 1
0
 public function getGoodsinfo()
 {
     $goodsinfos = array();
     $db = new Core();
     $query = "SELECT g.*,\n                  gv.field as gvkey,\n                  gv.value as gvvalue,\n                  o.telphone as mobile,\n                  o.order_quantity as goods_number,\n                  o.goods_value as goods_value\n                  FROM " . DB_PREFIX . "goodslist g\n                  LEFT JOIN  " . DB_PREFIX . "order o \n                  ON g.order_id=o.id\n                  LEFT JOIN  " . DB_PREFIX . "goodsextensionvalue gv \n                  ON g.order_id=gv.id\n                  WHERE \n                  1\n                  and o.order_id='" . $this->order_id . "'";
     $mresult = $db->query($query);
     if (!$mresult) {
         $this->BundleGoods = $goodsinfos;
         return;
     }
     foreach ($mresult as $result) {
         $goods = json_decode(urldecode($result['extensions']), 1);
         $goods['goods_number'] = $result['goods_number'];
         $goods['goods_value'] = $result['goods_value'];
         //$goods['mobile'] = $result['mobile'];
         if ($result['gvkey'] == 'session') {
             $goods['session'] = $result['gvvalue'];
         }
         $goodsinfos[$result['bundle_id']]['goods'][] = $goods;
     }
     //file_put_contents('./cache/mobile.txt',var_export($result,1));
     $query = "SELECT *\n                  FROM " . DB_PREFIX . "order \n                  \n                  WHERE \n                  1\n                  and order_id='" . $this->order_id . "'";
     $re = $db->query($query, '');
     $this->mobile = $re[0]['telphone'];
     // = '18021806556';
     $this->BundleGoods = $goodsinfos;
 }
Ejemplo n.º 2
0
 public function overdueproceess()
 {
     $time = 2100;
     //过期时间
     $db = new Core();
     /**
      * 查询与订单号相关的商品,订单中相关信息如积分等
      */
     $query = "SELECT \n    \t          g.*,\n    \t          o.order_id as new_order_id,\n    \t          o.pay_credits as pay_credits,\n    \t          o.user_id as user_id,\n    \t\t      o.integral_status as integral_status\n    \t          FROM " . DB_PREFIX . "goodslist g\n                  LEFT JOIN " . DB_PREFIX . "order o\n                  ON g.order_id=o.id\n                  WHERE o.pay_status = 1 \n                  and o.create_time<" . (time() - $time) . " limit 0,100";
     $goodses = $db->query($query);
     if (!$goodses) {
         return;
     }
     $ids = array();
     $newgoodses = array();
     foreach ($goodses as $goods) {
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['id'] = $goods['goods_id'];
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['goods_number'] += $goods['goods_number'];
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['bundle_id'] = $goods['bundle_id'];
         $ids[] = $goods['order_id'];
         $credits[$goods['user_id']]['id'] = $goods['order_id'];
         $credits[$goods['user_id']]['order_id'] = $goods['new_order_id'];
         $credits[$goods['user_id']]['credit'] = $goods['pay_credits'];
         $credits[$goods['user_id']]['integral_status'] = $goods['integral_status'];
         //积分的状态
     }
     $this->BundleGoods = $newgoodses;
     foreach ($newgoodses as $bundle_id => $bundlegoodses) {
         $curl = $bundle_id . "curl";
         $this->{$curl} = $this->create_curl_obj($bundle_id);
         $this->init_curl($bundle_id);
         //$Re_Minus_updateStores = $this -> opBundle('updateStore', array('operation' => 'plus'));
     }
     $Re_Minus_updateStores = $this->opBundle('updateStore', array('operation' => 'plus'));
     $orderids = implode(",", $ids);
     if (!$orderids) {
         return false;
     }
     require_once CUR_CONF_PATH . 'lib/sms.class.php';
     require_once ROOT_PATH . 'lib/class/members.class.php';
     $members = new members();
     foreach ($credits as $user => $v) {
         if (!$v['credit']) {
             continue;
         }
         $re = $members->return_credit($user, $v['credit'], $v['order_id'], 'payments', 'OrderUpdate', 'cancle', '订单:' . $v['order_id'] . '被系统取消:' . $v['title'], $v['integral_status'], '取消订单');
         if (!$re['logid']) {
             return false;
         }
     }
     $query = "UPDATE " . DB_PREFIX . "order \n                  SET order_status=24,pay_status=3,is_completed=23\n                  WHERE pay_status=1 and id in(" . $orderids . ")";
     $result = $db->query_update($query);
 }
Ejemplo n.º 3
0
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <*****@*****.**>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On lance la création de la campagne
if (isset($_GET)) {
    // On récupère les données
    $user = User::ID();
    // On crée la nouvelle mission en récupérant l'identifiant créé
    $campagne = Campaign::create("email");
    // On tâche de récupérer la liste des contacts concernés par l'envoi
    $var = $_GET;
    // On retraite les critères complexes
    $var['criteres'] = trim($var['criteres'], ';');
    // On charge les identifiants des fiches correspondantes
    $contacts = People::listing($var, 0, false);
    // On prépare la requête d'ajout des destinataires
    $query = Core::query('campagne-destinataires');
    // On enregistre les contacts concernés
    foreach ($contacts as $contact) {
        $query->bindParam(':campagne', $campagne, PDO::PARAM_INT);
        $query->bindParam(':contact', $contact, PDO::PARAM_INT);
        $query->execute();
    }
    echo $campagne;
} else {
    http_response_code(403);
}
Ejemplo n.º 4
0
 /**
  * Tasks to come, by deadline
  *
  * @param integer $user User ID related, if asked
  *
  * @return array
  */
 public static function tasks($user = null)
 {
     if (is_null($user)) {
         $query = Core::query('tasks-all');
         $query->execute();
     } else {
         $query = Core::query('tasks');
         $query->bindValue(':user', $user, PDO::PARAM_INT);
         $query->execute();
     }
     if ($query->rowCount()) {
         return $query->fetchAll(PDO::FETCH_ASSOC);
     } else {
         return false;
     }
 }
Ejemplo n.º 5
0
 /**
  * List of all folders
  *
  * @param integer $status Status of asked folders (1 open 0 close)
  *
  * @return array
  * @static
  **/
 public static function all($status = 1)
 {
     $query = Core::query('folder-all');
     $query->bindValue(':status', $status, PDO::PARAM_INT);
     $query->execute();
     return $query->fetchAll(PDO::FETCH_ASSOC);
 }
Ejemplo n.º 6
0
 /**
  * Email sending method
  *
  * @param integer $campaign Campaign ID
  * @param string  $email    Recipient's email
  *
  * @return void
  * @static
  **/
 public static function sending(int $campaign, string $email)
 {
     // campaign data
     $campaign = new Campaign($campaign);
     // recipient data
     $query = Core::query('contact-by-email');
     $query->bindValue(':coord', $email);
     $query->execute();
     $data = $query->fetch(PDO::FETCH_NUM);
     $person = new People($data[0]);
     unset($data);
     $mail = $campaign->get('mail');
     $replace = array('mail-optout.php?test' => 'mail-optout.php?email=' . md5($email));
     $mail = strtr($mail, $replace);
     $to = array(array('email' => $email, 'name' => $person->display_name(), 'type' => 'to'));
     $message = array('html' => $mail, 'subject' => $campaign->get('objet'), 'from_email' => Configuration::read('mail.sender.mail'), 'from_name' => Configuration::read('mail.sender.name'), 'headers' => array('Reply-To' => Configuration::read('mail.replyto')), 'to' => $to, 'track_opens' => true, 'auto_text' => true, 'subaccount' => Configuration::read('client'));
     $async = true;
     $mandrill = Configuration::read('mail');
     $result = $mandrill->messages->send($message, $async);
     // we parse mail sending result
     $result = $result[0];
     // we save result data
     $query = Core::query('tracking-update');
     $query->bindValue(':campaign', $campaign->get('id'), PDO::PARAM_INT);
     $query->bindValue(':email', $result['email']);
     $query->bindValue(':id', $result['_id']);
     $query->bindValue(':status', $result['status']);
     $query->bindValue(':reject', $result['reject_reason']);
     $query->execute();
 }
Ejemplo n.º 7
0
 /**
  * Create a new template
  *
  * @return integer
  * @static
  */
 public static function create()
 {
     $user = User::ID();
     $query = Core::query('template-create');
     $query->bindParam(':user', $user);
     $query->execute();
     return Configuration::read('db.link')->lastInsertId();
 }
Ejemplo n.º 8
0
    $query = $link->prepare($query);
    $query->bindParam(':id', $_POST['adresse']);
    $query->execute();
    $adresse = $query->fetch(PDO::FETCH_ASSOC);
    $adresse = $adresse['coordonnee_email'];
    // On ouvre la fiche du contact concerné
    $contact = new People($_POST['contact']);
    // On charge le système de mail
    $mail = Configuration::read('mail');
    // On prépare le message
    $message = array('html' => nl2br($_POST['message']), 'subject' => $_POST['objet'], 'from_email' => Configuration::read('mail.sender.mail'), 'from_name' => Configuration::read('mail.sender.name'), 'to' => array(array('email' => $adresse, 'name' => $contact->get('nom_complet'), 'type' => 'to')), 'headers' => array('Reply-To' => Configuration::read('mail.replyto')), 'track_opens' => true, 'auto_text' => true, 'subaccount' => Configuration::read('client'));
    // mode asynchrone d'envoi du mail
    $async = true;
    // on lance l'envoi du mail
    $result = $mail->messages->send($message, $async);
    // On met à jour le tracking avec les informations retournées
    $campaign = 0;
    $query = Core::query('campaign-tracking');
    $query->bindValue(':campaign', $campaign, PDO::PARAM_INT);
    $query->bindValue(':id', $result[0]['_id']);
    $query->bindValue(':email', $result[0]['email']);
    $query->bindValue(':status', $result[0]['status']);
    $query->execute();
    $event = Event::create($contact->get('id'));
    $event = new Event($event);
    $event->update('historique_type', 'courriel');
    $event->update('historique_objet', $_POST['objet']);
    $event->update('historique_notes', $_GET['message']);
} else {
    return false;
}
Ejemplo n.º 9
0
$nomFichier = 'export-' . User::ID() . '-' . uniqid() . '.csv';
$file = fopen('exports/' . $nomFichier, 'w+');
$entete = ['nom', 'nom_usage', 'prenoms', 'sexe', 'date_naissance', 'age', 'adresse declaree', 'adresse electorale', 'bureau', 'ville', 'electeur', 'electeur_europeen', 'electeur_municipales', 'organisme', 'fonction', 'tags'];
fputcsv($file, $entete, ';', '"');
foreach ($contacts as $_contact) {
    $contact = new People($_contact);
    $address = $contact->postal_address();
    $poll = Maps::pollData($contact->get('bureau'));
    $birthdate = new DateTime($contact->get('date_naissance'));
    $_fichier = array($contact->get('nom'), $contact->get('nom_usage'), $contact->get('prenoms'), $contact->get('sexe'), $birthdate->format('d/m/Y'), $contact->age(), $address['reel'], $address['officiel'], $poll['number'], $poll['city'], $contact->get('electeur'), $contact->get('electeur_europeen'), $contact->get('electeur_municipales'), $contact->get('organisme'), $contact->get('fonction'), implode(',', $contact->get('tags')));
    fputcsv($file, $_fichier, ';', '"');
}
// On retraite le nom du fichier
$f = 'exports/' . $nomFichier;
if ($f) {
    $email = file_get_contents('tpl/mail/export-reussi.tpl.html');
    $objet = '[LeQG] Votre export est prêt à être téléchargé';
    $email = strtr($email, array('{URL}' => 'http://' . Configuration::read('url') . $f));
} else {
    $email = file_get_contents('tpl/mail/export-echec.tpl.html');
    $objet = '[LeQG] Votre export a provoqué un erreur';
}
$query = Core::query('user-data', 'core');
$query->bindValue(':user', User::ID());
$query->execute();
$data = $query->fetch(PDO::FETCH_ASSOC);
$service = Configuration::read('mail');
$to = array(array('email' => $data['email'], 'name' => $data['firstname'] . ' ' . $data['lastname'], 'type' => 'to'));
$mail = array('html' => $email, 'subject' => $objet, 'from_email' => '*****@*****.**', 'from_name' => 'LeQG.info', 'to' => $to, 'headers' => array('Reply-To' => '*****@*****.**'), 'track_opens' => true, 'auto_text' => true);
$async = true;
$service->messages->send($mail, $async);
Ejemplo n.º 10
0
 /**
  * Add a street in this mission
  *
  * @param integer $rue street id
  *
  * @return boolean
  */
 public function ajoutRue(int $rue)
 {
     // On effectue une recherche de tous les immeubles contenus
     $query = Core::query('building-by-street');
     $query->bindValue(':street', $rue, PDO::PARAM_INT);
     $query->execute();
     // S'il y a des immeubles
     if ($query->rowCount()) {
         // On récupère la liste des identifiants
         $immeubles = $query->fetchAll(PDO::FETCH_NUM);
         // Si la mission est un porte à porte,
         // on cherche les électeurs concernés
         if ($this->_data['mission_type'] == 'porte') {
             // Pour chaque immeuble, on recherche tous les électeurs
             foreach ($immeubles as $immeuble) {
                 $query = Core::query('people-by-building');
                 $query->bindValue(':building', $immeuble[0], PDO::PARAM_INT);
                 $query->execute();
                 $contacts = $query->fetchAll(PDO::FETCH_NUM);
                 // Pour chaque électeur, on créé une porte à frapper
                 foreach ($contacts as $contact) {
                     $query = Core::query('item-new');
                     $query->bindParam(':mission', $this->_data['mission_id'], PDO::PARAM_INT);
                     $query->bindParam(':rue', $rue, PDO::PARAM_INT);
                     $query->bindParam(':immeuble', $immeuble[0], PDO::PARAM_INT);
                     $query->bindParam(':contact', $contact[0], PDO::PARAM_INT);
                     $query->execute();
                 }
             }
         } else {
             foreach ($immeubles as $immeuble) {
                 $query = Core::query('item-boitage-new');
                 $query->bindParam(':mission', $this->_data['mission_id'], PDO::PARAM_INT);
                 $query->bindParam(':rue', $rue, PDO::PARAM_INT);
                 $query->bindParam(':immeuble', $immeuble[0], PDO::PARAM_INT);
                 $query->execute();
             }
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 11
0
 /**
  * Create a new address for a contact
  *
  * @param integer $person   Person ID
  * @param integer $city     City ID
  * @param integer $zipcode  Zipcode ID
  * @param integer $street   Street ID
  * @param integer $building Building ID
  * @param string  $type     Address type
  *
  * @return integer
  * @static
  */
 public static function addressNew(int $person, int $city, int $zipcode, int $street, int $building, $type = 'reel')
 {
     $query = Core::query('address-new');
     $query->bindValue(':people', $person, PDO::PARAM_INT);
     $query->bindValue(':type', $type);
     $query->bindValue(':city', $city, PDO::PARAM_INT);
     $query->bindValue(':zipcode', $zipcode, PDO::PARAM_INT);
     $query->bindValue(':street', $street, PDO::PARAM_INT);
     $query->bindValue(':building', $building, PDO::PARAM_INT);
     $query->execute();
 }
Ejemplo n.º 12
0
<?php

/**
 * Sending email cron job
 *
 * PHP version 5
 *
 * @category Cron
 * @package  LeQG
 * @author   Damien Senger <*****@*****.**>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
$query = Core::query('tracking-to-send');
$query->execute();
if ($query->rowCount()) {
    $emails = $query->fetchAll(PDO::FETCH_ASSOC);
    foreach ($emails as $email) {
        Campaign::sending($email['campaign'], $email['email']);
    }
}
Ejemplo n.º 13
0
<?php

require './global.php';
require_once CUR_CONF_PATH . 'core/Core.class.php';
require_once CUR_CONF_PATH . 'lib/sms.class.php';
if (!isset($_REQUEST['out_trade_no'])) {
    return false;
}
if (!$_REQUEST['out_trade_no']) {
    return false;
}
$out_trade_no = $_REQUEST['out_trade_no'];
$db = new Core();
$query = "SELECT * FROM " . DB_PREFIX . "order \n                  WHERE \n                  pay_status=1 \n                  and order_id='" . $_REQUEST['out_trade_no'] . "'";
$query = "SELECT * FROM " . DB_PREFIX . "order \n                  WHERE \n                  order_id='" . $_REQUEST['out_trade_no'] . "'";
$result = $db->query($query, '');
if (!$result) {
    return false;
}
/**
 * 1.money 2.credits 3.money+credits
 */
$paymethod = $result[0]['paymethod'];
$payprocess = $result[0]['payprocess'];
$payprocess |= 2;
if ($payprocess == $paymethod) {
    $params['order_status'] = 25;
    //支付完成
    $params['pay_status'] = 2;
    //支付完成
    $params['integral_status'] = (int) $_REQUEST['integral_status'];
Ejemplo n.º 14
0
<?php

require_once 'includes.php';
$query = Core::query('campaign-data-md5');
$query->bindValue(':campaign', $_SERVER['QUERY_STRING']);
$query->execute();
$data = $query->fetch(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html lang="fr">
    <head>
        <meta charset="utf-8">
        <title><?php 
echo $data['objet'];
?>
</title>
    </head>
    <body style="padding: 0; margin: 0;">
        <?php 
echo $data['mail'];
?>
    </body>
</html>
Ejemplo n.º 15
0
			<ul class="formulaire">
				<li>
					<label for="rechercheCodePostalDebut" class="small">Code postal de démarrage</label>
					<span class="form-icon decalage search"><input type="text" name="rechercheCodePostalDebut" id="rechercheCodePostalDebut" placeholder="Code postal de début de la séquence recherchée"></span>
				</li>
				<li>
					<label for="rechercheCodePostalFin" class="small">Code postal final</label>
					<span class="form-icon decalage search"><input type="text" name="rechercheCodePostalFin" id="rechercheCodePostalFin" placeholder="Code postal de fin de la séquence recherchée"></span>
				</li>
				<li>
					<label for="rechercheCodePostalPays" class="small">Pays concerné</label>
					<span class="form-icon search">
						<label class="sbox" for="rechercheCodePostalPays">
							<select name="rechercheCodePostalPays" id="rechercheCodePostalPays">
								<?php 
$query = Core::query('country-approuved');
$query->execute();
$countries = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($countries as $country) {
    ?>
								<option value="<?php 
    echo $country['id'];
    ?>
"><?php 
    echo ucfirst(strtolower($country['country']));
    ?>
</option>
								<?php 
}
?>
							</select>
Ejemplo n.º 16
0
 /**
  * Création d'une campagne vierge
  *
  * @param string $type Type de campagne
  *
  * @return integer
  * @static
  */
 public static function nouvelle(string $type)
 {
     // On récupère le lien vers la base de données
     $link = Configuration::read('db.link');
     // On récupère l'identifiant de l'utilisateur connecté
     $user = User::ID();
     // On effectue la création de la campagne
     $query = Core::query('campagne-creation');
     $query->bindParam(':type', $type);
     $query->bindParam(':user', $user, PDO::PARAM_INT);
     $query->execute();
     // On retourne l'identifiant de la campagne
     return $link->lastInsertId();
 }
Ejemplo n.º 17
0
 /**
  * People listing method
  *
  * @param  array $sort   Sorting method
  * @param  int   $debut  First if int or estimation if true
  * @param  int   $nombre Number of people or all if true
  * @result array
  * */
 public static function listing(array $sort, $debut, $nombre = 5)
 {
     if (is_bool($debut) && $debut) {
         $query = 'SELECT COUNT(`id`) FROM `people`';
     } else {
         $query = 'SELECT `id` FROM `people`';
     }
     $conditionsStrictes = array();
     if (isset($sort['email']) && $sort['email'] == 1) {
         $_query = Core::query('person-with-emails');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` IN (' . implode(',', $ids) . ')';
     } elseif (isset($sort['email']) && $sort['email'] == -1) {
         $_query = Core::query('person-with-emails');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` NOT IN (' . implode(',', $ids) . ')';
     }
     if (isset($sort['mobile']) && $sort['mobile'] == 1) {
         $_query = Core::query('people-with-mobile');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` IN (' . implode(',', $ids) . ')';
     } elseif (isset($sort['mobile']) && $sort['mobile'] == -1) {
         $_query = Core::query('people-with-mobile');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` NOT IN (' . implode(',', $ids) . ')';
     }
     if (isset($sort['fixe']) && $sort['fixe'] == 1) {
         $_query = Core::query('people-with-fixe');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` IN (' . implode(',', $ids) . ')';
     } elseif (isset($sort['fixe']) && $sort['fixe'] == -1) {
         $_query = Core::query('people-with-fixe');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` NOT IN (' . implode(',', $ids) . ')';
     }
     if (isset($sort['phone']) && $sort['phone'] == 1) {
         $_query = Core::query('people-with-phone');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` IN (' . implode(',', $ids) . ')';
     } elseif (isset($sort['phone']) && $sort['phone'] == -1) {
         $_query = Core::query('people-with-phone');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` NOT IN (' . implode(',', $ids) . ')';
     }
     if (isset($sort['electeur']) && $sort['electeur'] == 1) {
         $conditionsStrictes[] = '`electeur` = 1';
     } elseif (isset($sort['electeur']) && $sort['electeur'] == -1) {
         $conditionsStrictes[] = '`electeur` = 0';
     }
     if (isset($sort['adresse']) && $sort['adresse'] == 1) {
         $_query = Core::query('people-with-address');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` IN (' . implode(',', $ids) . ')';
     } elseif (isset($sort['adresse']) && $sort['adresse'] == -1) {
         $_query = Core::query('people-with-address');
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditionsStrictes[] = '`id` NOT IN (' . implode(',', $ids) . ')';
     }
     $criteres = explode(';', $sort['criteres']);
     $conditions = array();
     $_conditions = array();
     if (!empty($criteres[0])) {
         foreach ($criteres as $critere) {
             $tri = explode(':', $critere);
             $_conditions[$tri[0]][] = $tri[1];
         }
     }
     if (isset($_conditions['bureau']) && count($_conditions['bureau'])) {
         $ids = implode(',', $_conditions['bureau']);
         $conditions[] = '`bureau` IN (' . $ids . ')';
     }
     if (isset($_conditions['rue']) && count($_conditions['rue'])) {
         $ids = implode(',', $_conditions['rue']);
         $_query = Core::query('people-from-streets');
         $_query->bindValue(':ids', $ids);
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditions[] = '`id` IN (' . implode(',', $ids) . ')';
     }
     if (isset($_conditions['ville']) && count($_conditions['ville'])) {
         $ids = implode(',', $_conditions['ville']);
         $_query = Core::query('people-from-cities');
         $_query->bindValue(':ids', $ids);
         $_query->execute();
         $ids = array();
         $result = $_query->fetchAll(PDO::FETCH_NUM);
         foreach ($result as $element) {
             $ids[] = $element[0];
         }
         $conditions[] = '`id` IN (' . implode(',', $ids) . ')';
     }
     if (isset($_conditions['thema']) && count($_conditions['thema'])) {
         $themas = array();
         foreach ($_conditions['thema'] as $tag) {
             $themas[] = '`tags` LIKE "%' . $tag . '%"';
         }
         $conditions[] = '(' . implode(' OR ', $themas) . ')';
     }
     if (isset($_conditions['zipcode']) && count($_conditions['zipcode'])) {
         $ids = array();
         foreach ($_conditions['zipcode'] as $zip) {
             $_zipcodes = explode('&', $zip);
             $_query = Core::query('zipcodes-id-by-range');
             $_query->bindValue(':begin', $_zipcodes[0]);
             $_query->bindValue(':end', $_zipcodes[1]);
             $_query->execute();
             $zipcodes_ids = array();
             $result = $_query->fetchAll(PDO::FETCH_NUM);
             foreach ($result as $element) {
                 $zipcodes_ids[] = $element[0];
             }
             foreach ($zipcodes_ids as $id) {
                 $__query = Core::query('people-by-zipcode');
                 $__query->bindValue(':zipcode', $id);
                 $__query->bindValue(':country', $_zipcodes[2]);
                 $__query->execute();
                 $result = $__query->fetchAll(PDO::FETCH_NUM);
                 foreach ($result as $element) {
                     $ids[] = $element[0];
                 }
             }
             $conditions[] = '`id` IN (' . implode(',', $ids) . ')';
         }
     }
     if (count($conditionsStrictes) || count($conditions)) {
         $query .= ' WHERE ';
     }
     if (count($conditionsStrictes)) {
         $conditionsStrictes = implode(' AND ', $conditionsStrictes);
         $query .= '( ' . $conditionsStrictes . ' )';
     }
     if (count($conditions)) {
         $conditions = implode(' AND ', $conditions);
         if (count($conditionsStrictes)) {
             $query .= ' AND ( ' . $conditions . ' )';
         } else {
             $query .= '( ' . $conditions . ' )';
         }
     }
     if (is_bool($debut) && $debut) {
         $query = Configuration::read('db.link')->prepare($query);
         $query->execute();
         $result = $query->fetch(PDO::FETCH_NUM);
         return $result[0];
     } else {
         $query .= ' ORDER BY `nom`, `nom_usage`, `prenoms` ASC';
         if (is_bool($nombre)) {
             $query = Configuration::read('db.link')->prepare($query);
             $query->execute();
             $contacts = $query->fetchAll(PDO::FETCH_NUM);
         } else {
             $query .= ' LIMIT ' . $debut . ',' . $nombre;
             $query = Configuration::read('db.link')->prepare($query);
             $query->execute();
             $contacts = $query->fetchAll(PDO::FETCH_NUM);
         }
         $ids = array();
         foreach ($contacts as $contact) {
             $ids[] = $contact[0];
         }
         return $ids;
     }
 }
Ejemplo n.º 18
0
 /**
  * List all client's user except each user asked
  *
  * @param array\string $sauf User to exclude
  *
  * @return array
  * @static
  */
 public static function sauf($sauf = '')
 {
     $user = User::data(User::ID());
     if (empty($sauf)) {
         return User::all(0);
     } else {
         $query = Core::query('user-list-except', 'core');
         $query->bindValue(':client', $user['client'], PDO::PARAM_INT);
         $query->bindValue(':exclude', implode(',', $sauf));
         $query->execute();
         return $query->fetchAll(PDO::FETCH_ASSOC);
     }
 }