[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 * The contents of this file are subject to the SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________.. 14 ********************************************************************************/ 15 /********************************************************************************* 16 * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/Notes.php,v 1.15 2005/03/15 10:01:08 shaw Exp $ 17 * Description: TODO: To be written. 18 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 19 * All Rights Reserved. 20 * Contributor(s): ______________________________________.. 21 ********************************************************************************/ 22 23 include_once ('config.php'); 24 require_once ('include/logging.php'); 25 require_once ('include/database/PearDatabase.php'); 26 require_once ('data/SugarBean.php'); 27 require_once ('data/CRMEntity.php'); 28 require_once ('include/upload_file.php'); 29 30 // Note is used to store customer information. 31 class Notes extends CRMEntity { 32 var $log; 33 var $db; 34 35 var $default_note_name_dom = array('Meeting vtiger_notes', 'Reminder'); 36 37 var $tab_name = Array('vtiger_crmentity','vtiger_notes','vtiger_attachments'); 38 var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_notes'=>'notesid','vtiger_senotesrel'=>'notesid','vtiger_attachments'=>'attachmentsid'); 39 40 var $column_fields = Array(); 41 42 var $sortby_fields = Array('notes_title','modifiedtime','contact_id','filename'); 43 44 // This is used to retrieve related vtiger_fields from form posts. 45 var $additional_column_fields = Array('', '', '', ''); 46 47 // This is the list of vtiger_fields that are in the lists. 48 var $list_fields = Array( 49 'Subject'=>Array('notes'=>'notes_title'), 50 'Contact Name'=>Array('notes'=>'contact_id'), 51 'Related to'=>Array('senotesrel'=>'crmid'), 52 'File'=>Array('notes'=>'filename'), 53 'Last Modified'=>Array('crmentity'=>'modifiedtime') 54 ); 55 var $list_fields_name = Array( 56 'Subject'=>'notes_title', 57 'Contact Name'=>'contact_id', 58 'Related to'=>'crmid', 59 'File'=>'filename', 60 'Last Modified'=>'modifiedtime' 61 ); 62 var $list_link_field= 'notes_title'; 63 64 //Added these variables which are used as default order by and sortorder in ListView 65 var $default_order_by = 'modifiedtime'; 66 var $default_sort_order = 'ASC'; 67 68 function Notes() { 69 $this->log = LoggerManager::getLogger('notes'); 70 $this->log->debug("Entering Notes() method ..."); 71 $this->db = new PearDatabase(); 72 $this->column_fields = getColumnFields('Notes'); 73 $this->log->debug("Exiting Note method ..."); 74 } 75 76 function save_module($module) 77 { 78 79 //inserting into vtiger_senotesrel 80 if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '') 81 { 82 $this->insertIntoEntityTable('vtiger_senotesrel', $module); 83 } 84 elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit") 85 { 86 $this->deleteRelation('vtiger_senotesrel'); 87 } 88 89 90 //Inserting into attachments table 91 $this->insertIntoAttachment($this->id,'Notes'); 92 93 } 94 95 96 /** 97 * This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database. 98 * @param int $id - entity id to which the vtiger_files to be uploaded 99 * @param string $module - the current module name 100 */ 101 function insertIntoAttachment($id,$module) 102 { 103 global $log, $adb; 104 $log->debug("Entering into insertIntoAttachment($id,$module) method."); 105 106 $file_saved = false; 107 108 foreach($_FILES as $fileindex => $files) 109 { 110 if($files['name'] != '' && $files['size'] > 0) 111 { 112 $file_saved = $this->uploadAndSaveFile($id,$module,$files); 113 } 114 } 115 116 $log->debug("Exiting from insertIntoAttachment($id,$module) method."); 117 } 118 119 120 /** Function to export the notes in CSV Format 121 * @param reference variable - order by is passed when the query is executed 122 * @param reference variable - where condition is passed when the query is executed 123 * Returns Export Notes Query. 124 */ 125 function create_export_query(&$order_by, &$where) 126 { 127 global $log; 128 $log->debug("Entering create_export_query(".$order_by.",". $where.") method ..."); 129 130 include ("include/utils/ExportUtils.php"); 131 132 //To get the Permitted fields query and the permitted fields list 133 $sql = getPermittedFieldsQuery("Notes", "detail_view"); 134 $fields_list = getFieldsListFromQuery($sql); 135 136 $query = "SELECT $fields_list FROM vtiger_notes 137 inner join vtiger_crmentity 138 on vtiger_crmentity.crmid=vtiger_notes.notesid 139 LEFT JOIN vtiger_senotesrel 140 ON vtiger_senotesrel.notesid = vtiger_notes.notesid 141 LEFT JOIN vtiger_contactdetails 142 ON vtiger_notes.contact_id=vtiger_contactdetails.contactid 143 144 LEFT JOIN vtiger_crmentity vtiger_crmentityRelatedTo 145 ON vtiger_crmentityRelatedTo.crmid = vtiger_senotesrel.crmid 146 147 LEFT JOIN vtiger_leaddetails vtiger_NoteRelatedToLead 148 ON vtiger_NoteRelatedToLead.leadid = vtiger_senotesrel.crmid 149 LEFT JOIN vtiger_account vtiger_NoteRelatedToAccount 150 ON vtiger_NoteRelatedToAccount.accountid = vtiger_senotesrel.crmid 151 LEFT JOIN vtiger_potential vtiger_NoteRelatedToPotential 152 ON vtiger_NoteRelatedToPotential.potentialid = vtiger_senotesrel.crmid 153 LEFT JOIN vtiger_products vtiger_NoteRelatedToProduct 154 ON vtiger_NoteRelatedToProduct.productid = vtiger_senotesrel.crmid 155 LEFT JOIN vtiger_invoice vtiger_NoteRelatedToInvoice 156 ON vtiger_NoteRelatedToInvoice.invoiceid = vtiger_senotesrel.crmid 157 LEFT JOIN vtiger_purchaseorder vtiger_NoteRelatedToPO 158 ON vtiger_NoteRelatedToPO.purchaseorderid = vtiger_senotesrel.crmid 159 LEFT JOIN vtiger_salesorder vtiger_NoteRelatedToSO 160 ON vtiger_NoteRelatedToSO.salesorderid = vtiger_senotesrel.crmid 161 162 WHERE vtiger_crmentity.deleted=0 163 164 AND ((vtiger_senotesrel.crmid IS NULL 165 AND (vtiger_notes.contact_id = 0 166 OR vtiger_notes.contact_id IS NULL)) 167 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Leads').") 168 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Accounts').") 169 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Potentials').") 170 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Products').") 171 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Invoice').") 172 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('PurchaseOrder').") 173 OR vtiger_senotesrel.crmid IN (".getReadEntityIds('SalesOrder').") 174 OR vtiger_notes.contact_id IN (".getReadEntityIds('Contacts').")) 175 176 "; 177 178 $log->debug("Exiting create_export_query method ..."); 179 return $query; 180 } 181 182 } 183 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |