Пример #1
0
<?php

require_once 'includes.php';
$link = Configuration::read('db.link');
$query = $link->prepare('SELECT * FROM `TABLE 47` LIMIT 0, 50');
$query->execute();
$contacts = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($contacts as $contact) {
    // On regarde si un contact correspodant existe déjà
    $nomPrenom = $contact['Prénom'] . ' ' . $contact['Nom'];
    $search = People::search($nomPrenom);
    if (count($search)) {
        if (count($search) == 1) {
            $person = new People($search[0]['id']);
        } else {
            $person = People::create();
            $person = new People($person);
            $person->update('nom', $contact['Nom']);
            $person->update('prenoms', $contact['Prénom']);
        }
    } else {
        $person = People::create();
        $person = new People($person);
        $person->update('nom', $contact['Nom']);
        $person->update('prenoms', $contact['Prénom']);
    }
    // On met à jour l'organisation si elle existe
    if (!empty($contact['Société'])) {
        $person->update('organisme', $contact['Société']);
    }
    // On met à jour le titre
Пример #2
0
<?php

// On protège la page
User::protection(5);
// On commence par vérifier qu'une recherche a été lancée
if (!isset($_POST['recherche']) || empty($_POST['recherche'])) {
    Core::goPage('contacts', true);
}
// On récupère cette recherche
$terme = $_POST['recherche'];
// On effectue la recherche
$resultats = People::search($terme);
// On regarde le nombre de réponses trouvées
$nombre = count($resultats);
// S'il n'y a qu'une réponse, on redirige directement vers la réponse
if ($nombre == 1) {
    $reponse = $resultats[0];
    Core::goPage('contact', array('contact' => $reponse[0]), true);
}
// Quand tout est bon, on affiche le template
Core::loadHeader();
?>
<h2>Résultats de la recherche &laquo;&nbsp;<?php 
echo $terme;
?>
&nbsp;&raquo;</h2>

<?php 
if ($nombre == 0) {
    ?>
Пример #3
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new People('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['People'])) {
         $model->attributes = $_GET['People'];
     }
     if (isset($_GET['export'])) {
         header("Content-Type: application/vnd.ms-excel; charset=utf-8");
         header("Content-Disposition: inline; filename=\"people-report.xls\"");
         $dataProvider = $model->search();
         $dataProvider->pagination = false;
         $fields = array('id', 'fname', 'lname', 'dob', 'mobile');
         $labels = $model->attributeLabels();
         $fval = array();
         foreach ($fields as $field) {
             array_push($fval, $labels[$field]);
         }
         echo implode("\t", $fval) . "\n";
         foreach ($dataProvider->data as $data) {
             $fval = array();
             foreach ($fields as $field) {
                 array_push($fval, $data->{$field});
             }
             echo implode("\t", $fval) . "\n";
         }
         Yii::app()->end();
     }
     $ac = People::getAutoCompleteFields();
     $this->render('admin', array('model' => $model, 'ac' => $ac));
 }