コード例 #1
0
    case 'year':
        $mysql_date_format = '%Y';
        $php_date_format = '\\1';
        break;
    default:
        CAppUI::stepAjax('common-error-Invalid parameter', UI_MSG_ERROR);
}
$order_by[] = "DATE_FORMAT(`{$patient->_spec->table}`.`naissance`, '{$mysql_date_format}')";
$order_by[] = "`{$patient->_spec->table}`.`nom`, `{$patient->_spec->table}`.`prenom`";
$request = new CRequest();
$request->addSelect('`cs`.*');
$request->addTable("{$consult->_spec->table} AS `cs`");
$request->addLJoin($ljoin);
$request->addWhere($where);
$request->addOrder($order_by);
$consultations = $consult->loadQueryList($request->makeSelect());
CStoredObject::massLoadFwdRef($consultations, 'plageconsult_id');
$patients = CStoredObject::massLoadFwdRef($consultations, 'patient_id');
if ($_print_ipp) {
    CPatient::massLoadIPP($patients);
}
$sorted_consults = array();
/** @var CConsultation $_consult */
foreach ($consultations as $_consult) {
    // Implicit loadRefPlageConsult()
    $_consult->loadRefPraticien();
    $_consult->loadRefPatient();
    $period = preg_replace('/(\\d{4})-(\\d{2})-(\\d{2})/', $php_date_format, $_consult->_ref_patient->naissance);
    if (!isset($sorted_consults[$period])) {
        $sorted_consults[$period] = array();
    }