Esempio n. 1
0
// Open CSV File
if (null == ($csvfile = @fopen($csvpath, "r"))) {
    CAppUI::stepAjax("Fichier '{$csvpath}' non disponible", UI_MSG_ERROR);
}
$cols = fgetcsv($csvfile);
// Each line
$medecins = array();
$mode_import = CValue::get("mode_import");
while ($line = fgetcsv($csvfile)) {
    // Load from CSV
    $medecin = new CMedecin();
    foreach ($cols as $index => $field) {
        $medecin->{$field} = $line[$index];
    }
    // Recherche des siblings
    $siblings = $medecin->loadExactSiblings();
    if ($medecin->_has_siblings = count($siblings)) {
        $sibling = reset($siblings);
        switch ($mode_import) {
            case "comp":
                $medecin->_id = $sibling->_id;
                break;
            case "rpps":
                $rpps = $medecin->rpps;
                $medecin = $sibling;
                $medecin->rpps = $rpps;
        }
        $updates++;
    }
    // Sauvegarde
    $medecin->repair();