示例#1
0
$category->send_auto = "1";
foreach ($categories = $category->loadMatchingList() as $_category) {
    $_category->countDocItems();
    $_category->countUnsentDocItems();
}
// Unsent docItems
$max_load = CAppUI::conf("dPfiles CDocumentSender auto_max_load");
$where["file_category_id"] = CSQLDataSource::prepareIn(array_keys($categories));
$where["etat_envoi"] = "!= 'oui'";
$where["object_id"] = "IS NOT NULL";
$file = new CFile();
$items["CFile"] = $file->loadList($where, "file_id DESC", $max_load);
$count["CFile"] = $file->countList($where);
$document = new CCompteRendu();
$items["CCompteRendu"] = $document->loadList($where, "compte_rendu_id DESC", $max_load);
$count["CCompteRendu"] = $document->countList($where);
// Sending
$max_send = CAppUI::conf("dPfiles CDocumentSender auto_max_send");
foreach ($items as $_items) {
    $sent = 0;
    /** @var CDocumentItem[] $_items */
    foreach ($_items as $_item) {
        $_item->loadTargetObject();
        if ($do && !$_item->_send_problem) {
            // Max sent
            if (++$sent > $max_send) {
                break;
            }
            $_item->_send = "1";
            $_item->_send_problem = $_item->store();
            // To track whether sending has been tried
 if ($date_docs_min && $date_docs_max) {
     $ljoin["user_log"] = "compte_rendu.compte_rendu_id = user_log.object_id\n      AND user_log.object_class = 'CCompteRendu'\n      AND user_log.type = 'create'";
     $where["user_log.date"] = "BETWEEN '{$date_docs_min} 00:00:00' AND '{$date_docs_max} 23:59:59'";
 }
 if ($prat_docs) {
     $where["author_id"] = " = '{$prat_docs}'";
 } else {
     if ($specialite_docs) {
         if (!isset($ljoin["user_log"])) {
             $ljoin["user_log"] = "compte_rendu.compte_rendu_id = user_log.object_id\n       AND user_log.object_class = 'CCompteRendu'\n       AND user_log.type = 'create'";
         }
         $ljoin["users_mediboard"] = "user_log.user_id = users_mediboard.user_id";
         $where["users_mediboard.function_id"] = " = '{$specialite_docs}'";
     }
 }
 $total_docs = $cr->countList($where, null, $ljoin);
 /** @var CCompteRendu[] $docs */
 $docs = $cr->loadList($where, "user_log.date desc", "{$page}, 30", null, $ljoin);
 switch ($section_search) {
     case "sejour":
         $sejours = CMbObject::massLoadFwdRef($docs, "object_id", "CSejour");
         CMbObject::massLoadFwdRef($sejours, "patient_id");
         foreach ($docs as $_doc) {
             /** @var CSejour $sejour */
             $sejour = $_doc->loadTargetObject();
             $sejour->loadRefPatient();
             $sejour->loadNDA();
             $sejour->loadRefsOperations();
             $_doc->_date = $_doc->loadFirstLog()->date;
         }
         break;
示例#3
0
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  SVN: $Id:\$
 * @link     http://www.mediboard.org
 */
$modele_id = CValue::get("modele_id");
$do_it = CValue::get("do_it", 0);
$modele = new CCompteRendu();
$modele->load($modele_id);
$where = array();
$where["object_class"] = " = '{$modele->object_class}'";
$where["nom"] = " = '" . addslashes($modele->nom) . "'";
$where["object_id"] = "IS NOT NULL";
$where["modele_id"] = "IS NULL";
$nb = $modele->countList($where);
if ($do_it) {
    $docs = $modele->loadList($where, null, "100");
    /** @var  $docs CCompteRendu[] */
    $converted = 0;
    if ($nb == 0) {
        CApp::rip();
    }
    foreach ($docs as $_doc) {
        $_doc->loadTargetObject();
        if (!$_doc->_ref_object->_id) {
            // Objet référencé qui n'existe plus.
            // Suppression du document.
            $_doc->delete();
            continue;
        }
 /**
  * Vérifie si l'enregistrement du modèle est possible.
  * 
  * @return string 
  */
 function check()
 {
     $this->completeField("type", "header_id", "footer_id", "object_class");
     // Si c'est un entête ou pied, et utilisé dans des documents dont le type ne correspond pas au nouveau
     // alors pas d'enregistrement
     if (in_array($this->type, array("footer", "header"))) {
         $doc = new CCompteRendu();
         $where = 'object_class != "' . $this->object_class . '" and (header_id ="' . $this->_id . '" or footer_id ="' . $this->_id . '")' . '  and object_id IS NULL';
         if ($doc->countList($where)) {
             return "Des documents sont rattachés à ce pied de page (ou entête) et ils ont un type différent";
         }
     }
     // Si c'est un document dont le type de l'en-tête, de l'introduction, de la conclusion
     // ou du pied de page ne correspond pas à son nouveau type, alors pas d'enregistrement
     if (!$this->object_id && $this->type == "body") {
         $this->loadComponents();
         if ($this->header_id) {
             if ($this->_ref_header->object_class != $this->object_class) {
                 return "Le document n'est pas du même type que son entête";
             }
         }
         if ($this->footer_id) {
             if ($this->_ref_footer->object_class != $this->object_class) {
                 return "Le document n'est pas du même type que son pied de page";
             }
         }
         if ($this->preface_id) {
             if ($this->_ref_preface->object_class != $this->object_class) {
                 return "Le document n'est pas du même type que son introduction";
             }
         }
         if ($this->ending_id) {
             if ($this->_ref_ending->object_class != $this->object_class) {
                 return "Le document n'est pas du même type que sa conclusion";
             }
         }
     }
     return parent::check();
 }
示例#5
0
 /**
  * Count unsent document items
  *
  * @return void
  */
 function countUnsentDocItems()
 {
     $where["file_category_id"] = "= '{$this->_id}'";
     $where["etat_envoi"] = "!= 'oui'";
     $where["object_id"] = "IS NOT NULL";
     $file = new CFile();
     $this->_count_unsent_files = $file->countList($where);
     $document = new CCompteRendu();
     $this->_count_unsent_documents = $document->countList($where);
     $this->_count_unsent_doc_items = $this->_count_unsent_documents + $this->_count_unsent_files;
 }