/**
  * load files linked to the present attachment
  *
  * @return CFile
  */
 function loadFiles()
 {
     //a file is already linked and we have the id
     $file = new CFile();
     if ($this->file_id) {
         $file->load($this->file_id);
         $file->loadRefsFwd();
         //TODO : fix this
     } else {
         $file->setObject($this);
         $file->loadMatchingObject();
     }
     $file->updateFormFields();
     return $this->_file = $file;
 }
Example #2
0
$journal = new CJournalBill();
$journal->load($journal_id);
$user = CMediusers::get();
$printer_bvr = new CPrinter();
$printer_bvr->function_id = $user->function_id;
$printer_bvr->label = "bvr";
$printer_bvr->loadMatchingObject();
if (!$printer_bvr->_id) {
    CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR);
    echo CAppUI::getMsg();
    return false;
} else {
    $file = new CFile();
    $file->object_id = $journal->checklist_id;
    $file->object_class = "CJournalBill";
    $file->loadMatchingObject();
    $printer_bvr->loadRefSource()->sendDocument($file);
}
if (!$uniq_checklist) {
    $factures = $journal->loadRefsFacture();
    if (count($factures)) {
        $printer_justif = new CPrinter();
        $printer_justif->function_id = $user->function_id;
        $printer_justif->label = "justif";
        $printer_justif->loadMatchingObject();
        if (!$printer_justif->_id) {
            CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR);
            echo CAppUI::getMsg();
            return false;
        }
        $file = new CFile();
Example #3
0
 /**
  * create the CFiles attached to the mail
  *
  * @param CMailAttachments[] $attachList The list of CMailAttachment
  * @param CPop               $popClient  the CPop client
  *
  * @return void
  */
 function attachFiles($attachList, $popClient)
 {
     //size limit
     $size_required = CAppUI::pref("getAttachmentOnUpdate");
     if ($size_required == "") {
         $size_required = 0;
     }
     foreach ($attachList as $_attch) {
         $_attch->mail_id = $this->_id;
         $_attch->loadMatchingObject();
         if (!$_attch->_id) {
             $_attch->store();
         }
         //si preference taille ok OU que la piece jointe est incluse au texte => CFile
         if ($_attch->bytes <= $size_required || $_attch->disposition == "INLINE") {
             $file = new CFile();
             $file->setObject($_attch);
             $file->author_id = CAppUI::$user->_id;
             if (!$file->loadMatchingObject()) {
                 $file_pop = $popClient->decodeMail($_attch->encoding, $popClient->openPart($this->uid, $_attch->getpartDL()));
                 $file->file_name = $_attch->name;
                 //apicrypt attachment
                 if (strpos($_attch->name, ".apz") !== false) {
                     $file_pop = CApicrypt::uncryptAttachment($popClient->source->object_id, $file_pop);
                 }
                 //file type detection
                 $first = is_array($file_pop) ? reset($file_pop) : $file_pop;
                 $mime = $this->extensionDetection($first);
                 //file name
                 $infos = pathinfo($_attch->name);
                 $extension = $infos['extension'];
                 $mime_extension = strtolower(end(explode("/", $mime)));
                 if (strtolower($extension) != $mime_extension) {
                     $file->file_name = $infos['filename'] . "." . $mime_extension;
                 }
                 $file->file_type = $mime ? $mime : $_attch->getType($_attch->type, $_attch->subtype);
                 $file->fillFields();
                 $file->updateFormFields();
                 $file->putContent($file_pop);
                 $file->store();
             }
         }
     }
 }
 /**
  * OBX Segment with reference pointer to external report
  *
  * @param DOMNode   $OBX    DOM node
  * @param CMbObject $object object
  * @param String    $name   name
  *
  * @return bool
  */
 function getReferencePointerToExternalReport(DOMNode $OBX, CMbObject $object, $name)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $exchange_hl7v2->_ref_sender;
     //Récupération de l'emplacement et du type du fichier (full path)
     $observation = $this->getObservationValue($OBX);
     $rp = explode("^", $observation);
     $pointer = CMbArray::get($rp, 0);
     $type = CMbArray::get($rp, 2);
     // Création d'un lien Hypertext sur l'objet
     if ($type == "HTML") {
         $hyperlink = new CHyperTextLink();
         $hyperlink->setObject($object);
         $hyperlink->name = $name;
         $hyperlink->link = $pointer;
         $hyperlink->loadMatchingObject();
         if ($msg = $hyperlink->store()) {
             $this->codes[] = "E343";
             return false;
         }
         return true;
     }
     // Chargement des objets associés à l'expéditeur
     /** @var CInteropSender $sender_link */
     $object_links = $sender->loadRefsObjectLinks();
     if (!$object_links) {
         $this->codes[] = "E340";
         return false;
     }
     $sender_link = new CInteropSender();
     $files_category = new CFilesCategory();
     // On récupère toujours une seule catégorie, et une seule source associée à l'expéditeur
     foreach ($object_links as $_object_link) {
         if ($_object_link->_ref_object instanceof CFilesCategory) {
             $files_category = $_object_link->_ref_object;
         }
         if ($_object_link->_ref_object instanceof CInteropSender) {
             $sender_link = $_object_link->_ref_object;
             continue 1;
         }
     }
     // Aucun expéditeur permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E340";
         return false;
     }
     $authorized_sources = array("CSenderFileSystem", "CSenderFTP");
     // L'expéditeur n'est pas prise en charge pour la réception de fichiers
     if (!CMbArray::in($sender_link->_class, $authorized_sources)) {
         $this->codes[] = "E341";
         return false;
     }
     $sender_link->loadRefsExchangesSources();
     // Aucune source permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E342";
         return false;
     }
     $source = $sender_link->getFirstExchangesSources();
     $path = str_replace("\\", "/", $pointer);
     $path = basename($path);
     if ($source instanceof CSourceFileSystem) {
         $path = $source->getFullPath() . "/{$path}";
     }
     // Exception déclenchée sur la lecture du fichier
     try {
         $content = $source->getData("{$path}");
     } catch (Exception $e) {
         $this->codes[] = "E345";
         return false;
     }
     if (!$type) {
         $type = CMbPath::getExtension($path);
     }
     $file_type = $this->getFileType($type);
     $file_name = $this->getObservationFilename($OBX);
     // Gestion du CFile
     $file = new CFile();
     $file->setObject($object);
     $file->file_name = $file_name ? $file_name : $name;
     $file->file_type = $file_type;
     $file->loadMatchingObject();
     if ($files_category->_id && $sender->_configs["associate_category_to_a_file"]) {
         $file->file_category_id = $files_category->_id;
     }
     $file->file_date = "now";
     $file->doc_size = strlen($content);
     $file->fillFields();
     $file->updateFormFields();
     $file->putContent($content);
     if ($msg = $file->store()) {
         $this->codes[] = "E343";
     }
     $this->codes[] = "I340";
     return true;
 }
Example #5
0
 /**
  * Load a pdf file conversion
  *
  * @return CFile
  */
 function loadPDFconverted()
 {
     $file = new CFile();
     $file->object_class = "CFile";
     $file->object_id = $this->_id;
     $file->loadMatchingObject();
     return $file;
 }
Example #6
0
$file->loadTargetObject();
$file->updateFormFields();
if ($del) {
    if ($msg = $file->delete()) {
        CAppUI::stepAjax($msg, UI_MSG_ERROR);
    } else {
        CAppUI::stepAjax("CFile-msg-delete", UI_MSG_OK);
    }
} else {
    $file->file_type = "image/fabricjs";
    if ($export) {
        $svg = new CFile();
        $svg->file_name = $file->file_name;
        $svg->file_type = "image/svg+xml";
        $svg->author_id = $file->author_id;
        $svg->loadMatchingObject();
        $svg->fillFields();
        $svg->setObject($file->_ref_object);
        $svg->updateFormFields();
        if (strpos($svg->file_name, ".") === false) {
            $svg->file_name = $svg->file_name . ".svg";
        }
        if (strpos($svg->file_name, ".fjs") !== false) {
            $svg->file_name = str_replace(".fjs", ".svg", $svg->file_name);
        }
        // @TODO : replace url by datauri
        $content = str_replace(array("&a=fileviewer", "&file_id", "&suppressHeaders"), array("&amp;a=fileviewer", "&amp;file_id", "&amp;suppressHeaders"), $content);
        if ($result = $svg->putContent(stripslashes($content))) {
            if ($msg = $svg->store()) {
                CAppUI::stepAjax($msg, UI_MSG_ERROR);
            } else {