[Vtigercrm-commits] [vtiger-commits] r7622 - /vtigercrm/trunk/modules/Notes/Save.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed Jun 28 06:55:36 EDT 2006
Author: saraj
Date: Wed Jun 28 04:55:33 2006
New Revision: 7622
Log:
* Modified to retrieve and save the note attachment to the new note when we duplicate the note
Modified:
vtigercrm/trunk/modules/Notes/Save.php
Modified: vtigercrm/trunk/modules/Notes/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/Save.php (original)
+++ vtigercrm/trunk/modules/Notes/Save.php Wed Jun 28 04:55:33 2006
@@ -40,32 +40,40 @@
if (!isset($_REQUEST['date_due_flag'])) $focus->date_due_flag = 'off';
-//Added for retrieve the old existing vtiger_attachments when duplicated without new attachment
+//Save the Note
+$focus->save("Notes");
+
+//Added to retrieve the existing attachment of the notes and save it for the new duplicated note
if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
{
- $sql = "select vtiger_attachments.attachmentsid from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
+ $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
$result = $adb->query($sql);
if($adb->num_rows($result) != 0)
+ {
$attachmentid = $adb->query_result($result,0,'attachmentsid');
- if($attachmentid != '')
- {
- $attachquery = "select * from vtiger_attachments where attachmentsid = ".$attachmentid;
- $result = $adb->query($attachquery);
- $filename = $adb->query_result($result,0,'name');
- $filetype = $adb->query_result($result,0,'type');
- $filepath = $adb->query_result($result,0,'path');
+ $filename = $adb->query_result($result,0,'name');
+ $filetype = $adb->query_result($result,0,'type');
+ $filepath = $adb->query_result($result,0,'path');
- $_FILES['filename']['name'] = $filename;
- $_FILES['filename']['type'] = $filetype;
+ $new_attachmentid = $adb->getUniqueID("vtiger_crmentity");
+ $date_var = date('YmdHis');
- //we should read the file and calculate the size, without setting vtiger_filesize, attachment will not save
- $filesize = filesize($filepath.$filename);
- $_FILES['filename']['size'] = $filesize;
- }
+ $upload_filepath = decideFilePath();
+
+ //Read the old file contents and write it as a new file with new attachment id
+ $handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w');
+ fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename));
+ fclose($handle);
+
+ $adb->query("update vtiger_notes set filename=\"$filename\" where notesid=$focus->id");
+ $adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','Notes Attachment','".$date_var."')");
+
+ $adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')");
+
+ $adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')");
+ }
}
-
-$focus->save("Notes");
$return_id = $focus->id;
$note_id = $return_id;
More information about the vtigercrm-commits
mailing list