コード例 #1
0
/**
 * import the csv firstname file
 *
 * @param string $targetPath filepath
 * @param int    $start      start from
 * @param int    $count      step of import
 *
 * @return void
 */
function importFile($targetPath, $start, $count)
{
    $fp = fopen($targetPath, 'r');
    //0 = first line
    if ($start == 0) {
        $start++;
    }
    $line_nb = 0;
    while ($line = fgetcsv($fp, null, ";")) {
        if ($line_nb >= $start && $line_nb < $start + $count) {
            $found = false;
            $fn = CMbString::removeDiacritics(trim($line[0]));
            $sex = trim($line[1]);
            $language = CMbString::removeDiacritics(trim($line[2]));
            if ($sex == "m,f" || $sex == "f,m") {
                $sex = "u";
            }
            $firstname = new CFirstNameAssociativeSex();
            $firstname->firstname = $fn;
            $firstname->language = $language;
            $firstname->loadMatchingObjectEsc();
            if ($firstname->_id) {
                // found
                $found = true;
                if ($sex != $firstname->sex) {
                    $firstname->sex = "u";
                }
            } else {
                // not found
                $firstname->sex = $sex;
            }
            // store & message
            if ($msg = $firstname->store()) {
                CAppUI::stepAjax($msg, UI_MSG_WARNING);
            } else {
                if ($found == true) {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, mis à jour <strong>[{$firstname->sex}]</strong>");
                } else {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, ajouté <strong>[{$firstname->sex}]</strong>");
                }
            }
        }
        $line_nb++;
    }
    return;
}
コード例 #2
0
/**
 * $Id$
 *  
 * @category System
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkEdit();
$page = CValue::get('page', 0);
$name = trim(CValue::get('name'));
$type = CValue::get('type');
$first = new CFirstNameAssociativeSex();
$where = array();
if (trim($name)) {
    $where['firstname'] = " LIKE '%{$name}%' ";
}
if ($type) {
    $where['sex'] = " = '{$type}' ";
}
$nb_firsts = $first->countList($where);
$hundred_firsts = $first->loadList($where, "firstname", "{$page},100");
// smarty
$smarty = new CSmartyDP();
$smarty->assign("list", $hundred_firsts);
$smarty->assign("total", $nb_firsts);
$smarty->assign("page", $page);
$smarty->display("inc_list_firstnames.tpl");
コード例 #3
0
 /**
  * guess sexe by firstname
  *
  * @return boolean true if sexe found, false if sexe not found
  */
 function guessSex()
 {
     $sex_found = CFirstNameAssociativeSex::getSexFor($this->prenom);
     if ($sex_found && $sex_found != "u") {
         $this->sex = $sex_found;
         return true;
     }
     return false;
 }
コード例 #4
0
<?php

/**
 * $Id$
 *  
 * @category System
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkEdit();
$fs = new CFirstNameAssociativeSex();
$fs_id = CValue::get('fs_id');
$fs->load($fs_id);
//smarty
$smarty = new CSmartyDP();
$smarty->assign("object", $fs);
$smarty->display("inc_edit_firstname.tpl");
コード例 #5
0
/**
 * $Id$
 *  
 * @category Patients
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$class = CValue::post("target_class");
$reset = CValue::post("reset", 0);
$callback = CValue::post("callback", 0);
$limit = 500;
$use_callback = true;
if (!CFirstNameAssociativeSex::countData()) {
    CAppUI::stepAjax("CFirstNameAssociativeSex-msg-no_data_in_db", UI_MSG_WARNING);
    CApp::rip();
}
if (is_subclass_of($class, 'CPerson')) {
    /** @var CPerson $_class */
    $_class = new $class();
    $field_sex = $_class->getSexFieldName();
    if (!$field_sex) {
        CAppUI::stepAjax("class %s does not contain sex field", UI_MSG_ERROR, $class);
    }
    $idex = new CIdSante400();
    $idex->object_class = $class;
    $idex->tag = "sex_guess_last_id";
    $idex->loadMatchingObject();
    $idex->id400 = CMbDT::dateTime();