| [ 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$ 17 * Description: Defines the Account SugarBean Account entity with the necessary 18 * methods and variables. 19 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 20 * All Rights Reserved. 21 * Contributor(s): ______________________________________.. 22 ********************************************************************************/ 23 24 include_once ('config.php'); 25 require_once ('include/logging.php'); 26 require_once ('include/database/PearDatabase.php'); 27 require_once ('data/SugarBean.php'); 28 require_once ('data/CRMEntity.php'); 29 require_once ('include/utils/utils.php'); 30 require_once ('user_privileges/default_module_view.php'); 31 32 // Account is used to store vtiger_account information. 33 class PurchaseOrder extends CRMEntity { 34 var $log; 35 var $db; 36 37 var $table_name = "vtiger_purchaseorder"; 38 var $tab_name = Array('vtiger_crmentity','vtiger_purchaseorder','vtiger_pobillads','vtiger_poshipads','vtiger_purchaseordercf'); 39 var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_purchaseorder'=>'purchaseorderid','vtiger_pobillads'=>'pobilladdressid','vtiger_poshipads'=>'poshipaddressid','vtiger_purchaseordercf'=>'purchaseorderid'); 40 41 var $entity_table = "vtiger_crmentity"; 42 43 var $billadr_table = "vtiger_pobillads"; 44 45 var $module_id = "purchaseorderid"; 46 47 var $column_fields = Array(); 48 49 var $sortby_fields = Array('subject','tracking_no','smownerid'); 50 51 // This is used to retrieve related vtiger_fields from form posts. 52 var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' ); 53 54 // This is the list of vtiger_fields that are in the lists. 55 var $list_fields = Array( 56 'Order Id'=>Array('crmentity'=>'crmid'), 57 'Subject'=>Array('purchaseorder'=>'subject'), 58 'Vendor Name'=>Array('purchaseorder'=>'vendorid'), 59 'Tracking Number'=>Array('purchaseorder'=> 'tracking_no'), 60 'Assigned To'=>Array('crmentity'=>'smownerid') 61 ); 62 63 var $list_fields_name = Array( 64 'Order Id'=>'', 65 'Subject'=>'subject', 66 'Vendor Name'=>'vendor_id', 67 'Tracking Number'=>'tracking_no', 68 'Assigned To'=>'assigned_user_id' 69 ); 70 var $list_link_field= 'subject'; 71 72 var $search_fields = Array( 73 'Order Id'=>Array('crmentity'=>'crmid'), 74 'Subject'=>Array('purchaseorder'=>'subject'), 75 ); 76 77 var $search_fields_name = Array( 78 'Order Id'=>'', 79 'Subject'=>'subject', 80 ); 81 82 // This is the list of vtiger_fields that are required. 83 var $required_fields = array("accountname"=>1); 84 85 //Added these variables which are used as default order by and sortorder in ListView 86 var $default_order_by = 'subject'; 87 var $default_sort_order = 'ASC'; 88 89 /** Constructor Function for Order class 90 * This function creates an instance of LoggerManager class using getLogger method 91 * creates an instance for PearDatabase class and get values for column_fields array of Order class. 92 */ 93 function PurchaseOrder() { 94 $this->log =LoggerManager::getLogger('PurchaseOrder'); 95 $this->db = new PearDatabase(); 96 $this->column_fields = getColumnFields('PurchaseOrder'); 97 } 98 99 function save_module($module) 100 { 101 //Based on the total Number of rows we will save the product relationship with this entity 102 saveInventoryProductDetails(&$this, 'PurchaseOrder', $this->update_prod_stock); 103 } 104 105 106 107 /** Function used to get the sort order for Purchase Order listview 108 * @return string $sorder - first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['PURCHASEORDER_SORT_ORDER'] if this session value is empty then default sort order will be returned. 109 */ 110 function getSortOrder() 111 { 112 global $log; 113 $log->debug("Entering getSortOrder() method ..."); 114 if(isset($_REQUEST['sorder'])) 115 $sorder = $_REQUEST['sorder']; 116 else 117 $sorder = (($_SESSION['PURCHASEORDER_SORT_ORDER'] != '')?($_SESSION['PURCHASEORDER_SORT_ORDER']):($this->default_sort_order)); 118 $log->debug("Exiting getSortOrder() method ..."); 119 return $sorder; 120 } 121 122 /** Function used to get the order by value for Purchase Order listview 123 * @return string $order_by - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['PURCHASEORDER_ORDER_BY'] if this session value is empty then default order by will be returned. 124 */ 125 function getOrderBy() 126 { 127 global $log; 128 $log->debug("Entering getOrderBy() method ..."); 129 if (isset($_REQUEST['order_by'])) 130 $order_by = $_REQUEST['order_by']; 131 else 132 $order_by = (($_SESSION['PURCHASEORDER_ORDER_BY'] != '')?($_SESSION['PURCHASEORDER_ORDER_BY']):($this->default_order_by)); 133 $log->debug("Exiting getOrderBy method ..."); 134 return $order_by; 135 } 136 137 /** Function to get activities associated with the Purchase Order 138 * This function accepts the id as arguments and execute the MySQL query using the id 139 * and sends the query and the id as arguments to renderRelatedActivities() method 140 */ 141 function get_activities($id) 142 { 143 global $log,$singlepane_view; 144 $log->debug("Entering get_activities(".$id.") method ..."); 145 global $app_strings; 146 require_once ('modules/Calendar/Activity.php'); 147 $focus = new Activity(); 148 149 $button = ''; 150 151 if($singlepane_view == 'true') 152 $returnset = '&return_module=PurchaseOrder&return_action=DetailView&return_id='.$id; 153 else 154 $returnset = '&return_module=PurchaseOrder&return_action=CallRelatedList&return_id='.$id; 155 156 $query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') "; 157 $log->debug("Exiting get_activities method ..."); 158 return GetRelatedList('PurchaseOrder','Calendar',$focus,$query,$button,$returnset); 159 } 160 161 /** Function to get the activities history associated with the Purchase Order 162 * This function accepts the id as arguments and execute the MySQL query using the id 163 * and sends the query and the id as arguments to renderRelatedHistory() method 164 */ 165 function get_history($id) 166 { 167 global $log; 168 $log->debug("Entering get_history(".$id.") method ..."); 169 $query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, 170 vtiger_activity.* ,vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, 171 vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name 172 from vtiger_activity 173 inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid 174 inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 175 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid 176 left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid 177 inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id 178 left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid 179 left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 180 where vtiger_activity.activitytype='Task' 181 and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred') 182 and vtiger_seactivityrel.crmid=".$id; 183 //Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php 184 185 $log->debug("Exiting get_history method ..."); 186 return getHistory('PurchaseOrder',$query,$id); 187 } 188 189 /** Function to get the attachments associated with the Purchase Order 190 * This function accepts the id as arguments and execute the MySQL query using the id 191 * and sends the query and the id as arguments to renderRelatedAttachments() method. 192 */ 193 function get_attachments($id) 194 { 195 global $log; 196 $log->debug("Entering get_attachments(".$id.") method ..."); 197 198 $query = "select vtiger_notes.title, 'Notes ' ActivityType, vtiger_notes.filename, 199 vtiger_attachments.type FileType, crm2.modifiedtime lastmodified, 200 vtiger_seattachmentsrel.attachmentsid attachmentsid, vtiger_notes.notesid crmid, 201 crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name 202 from vtiger_notes 203 inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid 204 inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid 205 inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0 206 left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid 207 left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid 208 inner join vtiger_users on crm2.smcreatorid= vtiger_users.id 209 where vtiger_crmentity.crmid=".$id; 210 211 $query .= ' union all '; 212 213 $query .= "select vtiger_attachments.description title ,'Attachments' ActivityType, 214 vtiger_attachments.name filename, vtiger_attachments.type FileType, crm2.modifiedtime lastmodified, 215 vtiger_attachments.attachmentsid attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid, 216 crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name 217 from vtiger_attachments 218 inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid 219 inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid 220 inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid 221 inner join vtiger_users on crm2.smcreatorid= vtiger_users.id 222 where vtiger_crmentity.crmid=".$id." 223 order by createdtime desc"; 224 225 $log->debug("Exiting get_attachments method ..."); 226 return getAttachmentsAndNotes('PurchaseOrder',$query,$id,$sid='purchaseorderid'); 227 } 228 229 /** Function used to get the Status history of the Purchase Order 230 * @param $id - purchaseorder id 231 * @return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries 232 */ 233 function get_postatushistory($id) 234 { 235 global $log; 236 $log->debug("Entering get_postatushistory(".$id.") method ..."); 237 238 global $adb; 239 global $mod_strings; 240 global $app_strings; 241 242 $query = 'select vtiger_postatushistory.*, vtiger_purchaseorder.subject from vtiger_postatushistory inner join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_postatushistory.purchaseorderid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid where vtiger_crmentity.deleted = 0 and vtiger_purchaseorder.purchaseorderid = '.$id; 243 $result=$adb->query($query); 244 $noofrows = $adb->num_rows($result); 245 246 $header[] = $app_strings['Order Id']; 247 $header[] = $app_strings['Vendor Name']; 248 $header[] = $app_strings['LBL_AMOUNT']; 249 $header[] = $app_strings['LBL_PO_STATUS']; 250 $header[] = $app_strings['LBL_LAST_MODIFIED']; 251 252 while($row = $adb->fetch_array($result)) 253 { 254 $entries = Array(); 255 256 $entries[] = $row['purchaseorderid']; 257 $entries[] = $row['vendorname']; 258 $entries[] = $row['total']; 259 $entries[] = $row['postatus']; 260 $entries[] = getDisplayDate($row['lastmodified']); 261 262 $entries_list[] = $entries; 263 } 264 265 $return_data = Array('header'=>$header,'entries'=>$entries_list); 266 267 $log->debug("Exiting get_postatushistory method ..."); 268 269 return $return_data; 270 } 271 272 273 } 274 275 ?>
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 |