/** * log into database an access * * @param int $user_id CMediusers_id * @param string $object_class Object_class * @param int $object_id Object_id * @param string $datetime datetime * @param int $group_id group where access has been done * * @return bool the status of executed request. */ static function logintoDb($user_id, $object_class, $object_id, $datetime, $group_id) { $object = new self(); $ds = $object->getDS(); $sql = "INSERT IGNORE INTO " . $object->_spec->table . " (`access_id`, `user_id`, `datetime`, `object_class`, `object_id`, `group_id`)\n VALUES ('', '{$user_id}', '{$datetime}', '{$object_class}', '{$object_id}', '{$group_id}');"; return $ds->exec($sql); }
static function getFirstMailDate($account_id) { $mail = new self(); $ds = $mail->getDS(); $query = "SELECT MIN(`date_inbox`) FROM `user_mail` WHERE `account_id` = '{$account_id}' AND `account_class` = 'CSourcePOP'"; $date = $ds->loadResult($query); $date = $date ? $date : CMbDT::dateTime(); return $date; }
/** * @param array $user_ids list of user's id * @param date $date date targeted * @return CPlageConge[] */ static function loadForIdsForDate($user_ids, $date) { $plage = new self(); $ds = $plage->getDS(); $where = array(); $where["user_id"] = $ds->prepareIn($user_ids); $where[] = " '{$date}' BETWEEN date_debut AND date_fin "; $plages = $plage->loadList($where); return $plages; }
/** * count the number of consultations asking to be * * @param array() $chir_ids list of chir ids * @param Date|null $day date targeted, default = today * * @return int number of result */ static function countDesistementsForDay($chir_ids, $day = null) { $date = CMbDT::date($day); $consultation = new self(); $ds = $consultation->getDS(); $where = array("plageconsult.date" => " > '{$date}'", "consultation.si_desistement" => "= '1'", "consultation.annule" => "= '0'"); $where[] = "plageconsult.chir_id " . $ds->prepareIn($chir_ids) . " OR plageconsult.remplacant_id " . $ds->prepareIn($chir_ids); $ljoin = array("plageconsult" => "plageconsult.plageconsult_id = consultation.plageconsult_id"); return $consultation->countList($where, null, $ljoin); }
/** * * * @param null|int $user_id * @param null|string $date_start * @param null|string $date_end * @param array $object_classes * * @return CBrisDeGlace[] $briss */ static function loadBrisForUser($user_id = null, $date_start = null, $date_end = null, $object_classes = array()) { $date_start = $date_start ? $date_start : CMbDT::date(); $date_end = $date_end ? $date_end : $date_start; $bris = new self(); $ds = $bris->getDS(); $where = array(); $where["date"] = " BETWEEN '{$date_start} 00:00:00' AND '{$date_end} 23:59:59' "; if (count($object_classes)) { $where["object_class"] = $ds->prepareIn($object_classes); } if ($user_id) { $where["user_id"] = " = '{$user_id}'"; } /** @var CBrisDeGlace[] $briss */ $briss = $bris->loadList($where, "date DESC"); return $briss; }