Пример #1
0
 /**
  * event function to delete the notes
  * @param object $evctl
  * first it will delete the note and then check if there are some document attached with it.
  * if documents are attached then delete from the database and then from physical location
  * @see class/core/CRMFilesAndAttachments.class.php
  * @see class/fields/fieldtypes/FieldType21.class.php
  */
 function eventAjaxDeleteNotes(\EventControler $evctl)
 {
     if ((int) $evctl->idnotes > 0) {
         $this->getId($evctl->idnotes);
         if ($_SESSION["do_cpaneluser"]->idcpanel_user === $this->idcpanel_user) {
             $qry = "\n\t\t\t\tdelete from `" . $this->getTable() . "`\n\t\t\t\twhere \n\t\t\t\t`idnotes` = ?\n\t\t\t\t";
             $this->query($qry, array((int) $evctl->idnotes));
             $do_files_and_attachment = new \CRMFilesAndAttachments();
             $do_files_and_attachment->get_uploaded_files(8, (int) $evctl->idnotes);
             if ($do_files_and_attachment->getNumRows() > 0) {
                 while ($do_files_and_attachment->next()) {
                     $file_name = $do_files_and_attachment->file_name;
                     $file_extension = $do_files_and_attachment->file_extension;
                     $do_files_and_attachment->delete_record($do_files_and_attachment->idfile_uploads);
                     \FieldType21::remove_file($file_name, $file_extension);
                 }
             }
             echo '1';
         } else {
             echo '0';
         }
     }
 }