[ 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 ('include/RelatedListView.php'); 31 require_once ('user_privileges/default_module_view.php'); 32 33 // Account is used to store vtiger_account information. 34 class Quote extends CRMEntity { 35 var $log; 36 var $db; 37 38 var $table_name = "vtiger_quotes"; 39 var $tab_name = Array('vtiger_crmentity','vtiger_quotes','vtiger_quotesbillads','vtiger_quotesshipads','vtiger_quotescf'); 40 var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_quotes'=>'quoteid','vtiger_quotesbillads'=>'quotebilladdressid','vtiger_quotesshipads'=>'quoteshipaddressid','vtiger_quotescf'=>'quoteid'); 41 42 var $entity_table = "vtiger_crmentity"; 43 44 var $billadr_table = "vtiger_quotesbillads"; 45 46 var $object_name = "Quote"; 47 48 var $new_schema = true; 49 50 var $module_id = "quoteid"; 51 52 var $column_fields = Array(); 53 54 var $sortby_fields = Array('subject','crmid','smownerid'); 55 56 // This is used to retrieve related vtiger_fields from form posts. 57 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' ); 58 59 // This is the list of vtiger_fields that are in the lists. 60 var $list_fields = Array( 61 'Quote Id'=>Array('crmentity'=>'crmid'), 62 'Subject'=>Array('quotes'=>'subject'), 63 'Quote Stage'=>Array('quotes'=>'quotestage'), 64 'Potential Name'=>Array('quotes'=>'potentialid'), 65 'Account Name'=>Array('account'=> 'accountid'), 66 'Total'=>Array('quotes'=> 'total'), 67 'Assigned To'=>Array('crmentity'=>'smownerid') 68 ); 69 70 var $list_fields_name = Array( 71 'Quote Id'=>'', 72 'Subject'=>'subject', 73 'Quote Stage'=>'quotestage', 74 'Potential Name'=>'potential_id', 75 'Account Name'=>'account_id', 76 'Total'=>'hdnGrandTotal', 77 'Assigned To'=>'assigned_user_id' 78 ); 79 var $list_link_field= 'subject'; 80 81 var $search_fields = Array( 82 'Quote Id'=>Array('crmentity'=>'crmid'), 83 'Subject'=>Array('quotes'=>'subject'), 84 'Account Name'=>Array('quotes'=>'accountid'), 85 'Quote Stage'=>Array('quotes'=>'quotestage'), 86 ); 87 88 var $search_fields_name = Array( 89 'Quote Id'=>'', 90 'Subject'=>'subject', 91 'Account Name'=>'account_id', 92 'Quote Stage'=>'quotestage', 93 ); 94 95 // This is the list of vtiger_fields that are required. 96 var $required_fields = array("accountname"=>1); 97 98 //Added these variables which are used as default order by and sortorder in ListView 99 var $default_order_by = 'crmid'; 100 var $default_sort_order = 'ASC'; 101 102 /** Constructor which will set the column_fields in this object 103 */ 104 function Quote() { 105 $this->log =LoggerManager::getLogger('quote'); 106 $this->db = new PearDatabase(); 107 $this->column_fields = getColumnFields('Quotes'); 108 } 109 110 /** Function used to get the sort order for Quote listview 111 * @return string $sorder - first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['QUOTES_SORT_ORDER'] if this session value is empty then default sort order will be returned. 112 */ 113 function getSortOrder() 114 { 115 global $log; 116 $log->debug("Entering getSortOrder() method ..."); 117 if(isset($_REQUEST['sorder'])) 118 $sorder = $_REQUEST['sorder']; 119 else 120 $sorder = (($_SESSION['QUOTES_SORT_ORDER'] != '')?($_SESSION['QUOTES_SORT_ORDER']):($this->default_sort_order)); 121 $log->debug("Exiting getSortOrder() method ..."); 122 return $sorder; 123 } 124 125 /** Function used to get the order by value for Quotes listview 126 * @return string $order_by - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['QUOTES_ORDER_BY'] if this session value is empty then default order by will be returned. 127 */ 128 function getOrderBy() 129 { 130 global $log; 131 $log->debug("Entering getOrderBy() method ..."); 132 if (isset($_REQUEST['order_by'])) 133 $order_by = $_REQUEST['order_by']; 134 else 135 $order_by = (($_SESSION['QUOTES_ORDER_BY'] != '')?($_SESSION['QUOTES_ORDER_BY']):($this->default_order_by)); 136 $log->debug("Exiting getOrderBy method ..."); 137 return $order_by; 138 } 139 140 /** function used to get the list of sales orders which are related to the Quotes 141 * @param int $id - quote id 142 * @return array - return an array which will be returned from the function GetRelatedList 143 */ 144 function get_salesorder($id) 145 { 146 global $log,$singlepane_view; 147 $log->debug("Entering get_salesorder(".$id.") method ..."); 148 require_once ('modules/SalesOrder/SalesOrder.php'); 149 $focus = new SalesOrder(); 150 151 $button = ''; 152 153 if($singlepane_view == 'true') 154 $returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id; 155 else 156 $returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id; 157 158 $query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.quoteid = ".$id; 159 $log->debug("Exiting get_salesorder method ..."); 160 return GetRelatedList('Quotes','SalesOrder',$focus,$query,$button,$returnset); 161 } 162 163 /** function used to get the list of activities which are related to the Quotes 164 * @param int $id - quote id 165 * @return array - return an array which will be returned from the function GetRelatedList 166 */ 167 function get_activities($id) 168 { 169 global $log,$singlepane_view; 170 $log->debug("Entering get_activities(".$id.") method ..."); 171 global $app_strings; 172 require_once ('modules/Calendar/Activity.php'); 173 $focus = new Activity(); 174 175 $button = ''; 176 177 if($singlepane_view == 'true') 178 $returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id; 179 else 180 $returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id; 181 182 $query = "SELECT vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name,vtiger_recurringevents.recurringtype 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 outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid 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_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred')"; 183 $log->debug("Exiting get_activities method ..."); 184 return GetRelatedList('Quotes','Calendar',$focus,$query,$button,$returnset); 185 } 186 187 /** function used to get the the activity history related to the quote 188 * @param int $id - quote id 189 * @return array - return an array which will be returned from the function GetHistory 190 */ 191 function get_history($id) 192 { 193 global $log; 194 $log->debug("Entering get_history(".$id.") method ..."); 195 $query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, 196 vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid, 197 vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime, 198 vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name 199 from vtiger_activity 200 inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid 201 inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 202 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid 203 left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid 204 inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id 205 left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid 206 left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 207 where vtiger_activity.activitytype='Task' 208 and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred') 209 and vtiger_seactivityrel.crmid=".$id; 210 //Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php 211 212 $log->debug("Exiting get_history method ..."); 213 return getHistory('Quotes',$query,$id); 214 } 215 216 217 /** Function used to get the Quote Stage history of the Quotes 218 * @param $id - quote id 219 * @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 220 */ 221 function get_quotestagehistory($id) 222 { 223 global $log; 224 $log->debug("Entering get_quotestagehistory(".$id.") method ..."); 225 226 global $adb; 227 global $mod_strings; 228 global $app_strings; 229 230 $query = 'select vtiger_quotestagehistory.*, vtiger_quotes.subject from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = '.$id; 231 $result=$adb->query($query); 232 $noofrows = $adb->num_rows($result); 233 234 $header[] = $app_strings['Quote Id']; 235 $header[] = $app_strings['LBL_ACCOUNT_NAME']; 236 $header[] = $app_strings['LBL_AMOUNT']; 237 $header[] = $app_strings['Quote Stage']; 238 $header[] = $app_strings['LBL_LAST_MODIFIED']; 239 240 while($row = $adb->fetch_array($result)) 241 { 242 $entries = Array(); 243 244 $entries[] = $row['quoteid']; 245 $entries[] = $row['accountname']; 246 $entries[] = $row['total']; 247 $entries[] = $row['quotestage']; 248 $entries[] = getDisplayDate($row['lastmodified']); 249 250 $entries_list[] = $entries; 251 } 252 253 $return_data = Array('header'=>$header,'entries'=>$entries_list); 254 255 $log->debug("Exiting get_quotestagehistory method ..."); 256 257 return $return_data; 258 } 259 260 } 261 262 ?>
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 |