[ 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 Quotes 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 Quotes() { 105 $this->log =LoggerManager::getLogger('quote'); 106 $this->db = new PearDatabase(); 107 $this->column_fields = getColumnFields('Quotes'); 108 } 109 110 function save_module() 111 { 112 } 113 114 /** Function used to get the sort order for Quote listview 115 * @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. 116 */ 117 function getSortOrder() 118 { 119 global $log; 120 $log->debug("Entering getSortOrder() method ..."); 121 if(isset($_REQUEST['sorder'])) 122 $sorder = $_REQUEST['sorder']; 123 else 124 $sorder = (($_SESSION['QUOTES_SORT_ORDER'] != '')?($_SESSION['QUOTES_SORT_ORDER']):($this->default_sort_order)); 125 $log->debug("Exiting getSortOrder() method ..."); 126 return $sorder; 127 } 128 129 /** Function used to get the order by value for Quotes listview 130 * @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. 131 */ 132 function getOrderBy() 133 { 134 global $log; 135 $log->debug("Entering getOrderBy() method ..."); 136 if (isset($_REQUEST['order_by'])) 137 $order_by = $_REQUEST['order_by']; 138 else 139 $order_by = (($_SESSION['QUOTES_ORDER_BY'] != '')?($_SESSION['QUOTES_ORDER_BY']):($this->default_order_by)); 140 $log->debug("Exiting getOrderBy method ..."); 141 return $order_by; 142 } 143 144 /** function used to get the list of sales orders which are related to the Quotes 145 * @param int $id - quote id 146 * @return array - return an array which will be returned from the function GetRelatedList 147 */ 148 function get_salesorder($id) 149 { 150 global $log,$singlepane_view; 151 $log->debug("Entering get_salesorder(".$id.") method ..."); 152 require_once ('modules/SalesOrder/SalesOrder.php'); 153 $focus = new SalesOrder(); 154 155 $button = ''; 156 157 if($singlepane_view == 'true') 158 $returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id; 159 else 160 $returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id; 161 162 $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; 163 $log->debug("Exiting get_salesorder method ..."); 164 return GetRelatedList('Quotes','SalesOrder',$focus,$query,$button,$returnset); 165 } 166 167 /** function used to get the list of activities which are related to the Quotes 168 * @param int $id - quote id 169 * @return array - return an array which will be returned from the function GetRelatedList 170 */ 171 function get_activities($id) 172 { 173 global $log,$singlepane_view; 174 $log->debug("Entering get_activities(".$id.") method ..."); 175 global $app_strings; 176 require_once ('modules/Calendar/Activity.php'); 177 $focus = new Activity(); 178 179 $button = ''; 180 181 if($singlepane_view == 'true') 182 $returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id; 183 else 184 $returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id; 185 186 $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')"; 187 $log->debug("Exiting get_activities method ..."); 188 return GetRelatedList('Quotes','Calendar',$focus,$query,$button,$returnset); 189 } 190 191 /** function used to get the the activity history related to the quote 192 * @param int $id - quote id 193 * @return array - return an array which will be returned from the function GetHistory 194 */ 195 function get_history($id) 196 { 197 global $log; 198 $log->debug("Entering get_history(".$id.") method ..."); 199 $query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, 200 vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid, 201 vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime, 202 vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name 203 from vtiger_activity 204 inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid 205 inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 206 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid 207 left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid 208 inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id 209 left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid 210 left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 211 where vtiger_activity.activitytype='Task' 212 and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred') 213 and vtiger_seactivityrel.crmid=".$id; 214 //Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php 215 216 $log->debug("Exiting get_history method ..."); 217 return getHistory('Quotes',$query,$id); 218 } 219 220 221 /** Function used to get the Quote Stage history of the Quotes 222 * @param $id - quote id 223 * @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 224 */ 225 function get_quotestagehistory($id) 226 { 227 global $log; 228 $log->debug("Entering get_quotestagehistory(".$id.") method ..."); 229 230 global $adb; 231 global $mod_strings; 232 global $app_strings; 233 234 $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; 235 $result=$adb->query($query); 236 $noofrows = $adb->num_rows($result); 237 238 $header[] = $app_strings['Quote Id']; 239 $header[] = $app_strings['LBL_ACCOUNT_NAME']; 240 $header[] = $app_strings['LBL_AMOUNT']; 241 $header[] = $app_strings['Quote Stage']; 242 $header[] = $app_strings['LBL_LAST_MODIFIED']; 243 244 while($row = $adb->fetch_array($result)) 245 { 246 $entries = Array(); 247 248 $entries[] = $row['quoteid']; 249 $entries[] = $row['accountname']; 250 $entries[] = $row['total']; 251 $entries[] = $row['quotestage']; 252 $entries[] = getDisplayDate($row['lastmodified']); 253 254 $entries_list[] = $entries; 255 } 256 257 $return_data = Array('header'=>$header,'entries'=>$entries_list); 258 259 $log->debug("Exiting get_quotestagehistory method ..."); 260 261 return $return_data; 262 } 263 264 } 265 266 ?>
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 |