public function addAttachment(
        string $name,
        string $mimetype,
        string $file,
        CNabuIContactProspectDiary $nb_diary = null,
        bool $save = true
    ) {
        if ($this->isFetched()) {
            $nb_icontact = $this->getIContact();
            $base_path = $nb_icontact->getBasePath();
            $retval = $nb_attachment = new CNabuIContactProspectAttachment();
            $nb_attachment->setIcontactProspect($this);
            $nb_attachment->setIcontactProspectDiaryId(
                $nb_diary instanceof CNabuIContactProspectDiary ? $nb_diary->getId() : null
            );
            $nb_attachment->setName($name);
            $nb_attachment->setMIMEType($mimetype);
            $nb_attachment->grantHash();
            $nb_attachment->putFile($file);

            if ($save) {
                $nb_attachment->save();
                $this->nb_attachment_list->addItem($nb_attachment);
            }

            return $retval;
        } else {
            throw new ENabuIContactException(ENabuIContactException::ERROR_ICONTACT_NOT_FETCHED);
        }
    }
public function addAttachment(
        string $name,
        string $mimetype,
        string $file,
        CNabuIContactProspectDiary $nb_diary = null,
        bool $save = true
    ) {
        if ($this->isFetched()) {
            $nb_icontact = $this->getIContact();
            $base_path = $nb_icontact->getBasePath();
            $retval = $nb_attachment = new CNabuIContactProspectAttachment();
            $nb_attachment->setIcontactProspect($this);
            $nb_attachment->setIcontactProspectDiaryId(
                $nb_diary instanceof CNabuIContactProspectDiary ? $nb_diary->getId() : null
            );
            $nb_attachment->setName($name);
            $nb_attachment->setMIMEType($mimetype);
            $nb_attachment->grantHash();
            $nb_attachment->putFile($file);

            if ($save) {
                $nb_attachment->save();
                $this->nb_attachment_list->addItem($nb_attachment);
            }

            return $retval;
        } else {
            throw new ENabuIContactException(ENabuIContactException::ERROR_ICONTACT_NOT_FETCHED);
        }
    }
public function addAttachment ( string $ name , string $ mimetype , string $ file , CNabuIContactProspectDiary $ nb_diary = null , bool $ save = true ) { if ( $ this -> isFetched ( ) ) { $ nb_icontact = $ this -> getIContact ( ) ; $ base_path = $ nb_icontact -> getBasePath ( ) ; $ retval = $ nb_attachment = new CNabuIContactProspectAttachment ( ) ; $ nb_attachment -> setIcontactProspect ( $ this ) ; $ nb_attachment -> setIcontactProspectDiaryId ( $ nb_diary instanceof CNabuIContactProspectDiary ? $ nb_diary -> getId ( ) : null ) ; $ nb_attachment -> setName ( $ name ) ; $ nb_attachment -> setMIMEType ( $ mimetype ) ; $ nb_attachment -> grantHash ( ) ; $ nb_attachment -> putFile ( $ file ) ; if ( $ save ) { $ nb_attachment -> save ( ) ; $ this -> nb_attachment_list -> addItem ( $ nb_attachment ) ; } return $ retval ; } else { throw new ENabuIContactException ( ENabuIContactException :: ERROR_ICONTACT_NOT_FETCHED ) ; } }
Add an Attachment file to this Prospect.
@param string $name Name of the attachment
@param string $mimetype Mime Type of the attachement
@param string $file Full File path and name where the Attachment is originaly stored. I.E. the temporary folder.
@param bool $save If true, the Attachment is inmediately saved in the database storage.
@param CNabuIContactProspectDiary|null $nb_diary If needed the Diary annotation instance
related with this attachment.
@return CNabuIContactProspectAttachment Returns a instance object descriptor of created Attachemnt.
Add an Attachment file to this Prospect .