[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 //Code Added by Minnie -Starts 12 /** 13 * To get the lists of sharedids 14 * @param $id -- The user id :: Type integer 15 * @returns $sharedids -- The shared vtiger_users id :: Type Array 16 */ 17 function getSharedUserId($id) 18 { 19 global $adb; 20 $sharedid = Array(); 21 $query = "SELECT * from vtiger_sharedcalendar where userid=".$id; 22 $result = $adb->query($query); 23 $rows = $adb->num_rows($result); 24 for($j=0;$j<$rows;$j++) 25 { 26 $sharedid[] = $adb->query_result($result,$j,'sharedid'); 27 } 28 return $sharedid; 29 } 30 31 /** 32 * To get the lists of vtiger_users id who shared their calendar with specified user 33 * @param $sharedid -- The shared user id :: Type integer 34 * @returns $shared_ids -- a comma seperated vtiger_users id :: Type string 35 */ 36 function getSharedCalendarId($sharedid) 37 { 38 global $adb; 39 $query = "SELECT * from vtiger_sharedcalendar where sharedid=".$sharedid; 40 $result = $adb->query($query); 41 if($adb->num_rows($result)!=0) 42 { 43 for($j=0;$j<$adb->num_rows($result);$j++) 44 $userid[] = $adb->query_result($result,$j,'userid'); 45 $shared_ids = implode (",",$userid); 46 } 47 return $shared_ids; 48 } 49 50 /** 51 * To get userid and username of all vtiger_users except the current user 52 * @param $id -- The user id :: Type integer 53 * @param $check -- true/false :: Type boolean 54 * @returns $user_details -- Array in the following format: 55 * $user_details=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username); 56 */ 57 function getOtherUserName($id,$check) 58 { 59 global $adb,$current_user; 60 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 61 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 62 $user_details=Array(); 63 if($check) 64 { 65 $query="select * from vtiger_users where deleted=0 and status='Active' and id!=".$id; 66 $result = $adb->query($query); 67 $num_rows=$adb->num_rows($result); 68 for($i=0;$i<$num_rows;$i++) 69 { 70 $userid=$adb->query_result($result,$i,'id'); 71 $username=$adb->query_result($result,$i,'user_name'); 72 $user_details[$userid]=$username; 73 } 74 75 } 76 else 77 { 78 if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid('Calendar')] == 3 or $defaultOrgSharingPermission[getTabid('Calendar')] == 0)) 79 { 80 $user_details = get_user_array(FALSE, "Active", $id, 'private'); 81 unset($user_details[$id]); 82 } 83 else 84 { 85 $user_details = get_user_array(FALSE, "Active", $id); 86 unset($user_details[$id]); 87 } 88 } 89 return $user_details; 90 } 91 92 /** 93 * To get hour,minute and format 94 * @param $starttime -- The date&time :: Type string 95 * @param $endtime -- The date&time :: Type string 96 * @param $format -- The format :: Type string 97 * @returns $timearr :: Type Array 98 */ 99 function getaddEventPopupTime($starttime,$endtime,$format) 100 { 101 $timearr = Array(); 102 list($sthr,$stmin) = explode(":",$starttime); 103 list($edhr,$edmin) = explode(":",$endtime); 104 if($format == 'am/pm') 105 { 106 $hr = $sthr+0; 107 if($hr <= 11) 108 { 109 if($hr == 0) 110 $sthr = 12; 111 $timearr['starthour'] = $sthr; 112 $timearr['startfmt'] = 'am'; 113 } 114 else 115 { 116 if($hr == 12) $sthr = $hr; 117 else $sthr = $hr - 12; 118 119 if($sthr <= 9 && strlen(trim($sthr)) < 2) 120 $hrvalue= '0'.$sthr; 121 else $hrvalue=$sthr; 122 123 $timearr['starthour'] = $hrvalue; 124 $timearr['startfmt'] = 'pm'; 125 } 126 $edhr = $edhr+0; 127 if($edhr <= 11) 128 { 129 if($edhr == 0) 130 $edhr = 12; 131 132 if($edhr <= 9 && strlen(trim($edhr)) < 2) 133 $edhr = '0'.$edhr; 134 $timearr['endhour'] = $edhr; 135 $timearr['endfmt'] = 'am'; 136 } 137 else 138 { 139 $fmt = 'pm'; 140 if($edhr == 12) 141 $edhr = $edhr; 142 else 143 { 144 $edhr = $edhr - 12; 145 if($edhr == 12) 146 $fmt = 'am'; 147 } 148 if($edhr <= 9 && strlen(trim($edhr)) < 2) 149 $hrvalue= '0'.$edhr; 150 else $hrvalue=$edhr; 151 152 $timearr['endhour'] = $hrvalue; 153 $timearr['endfmt'] = $fmt; 154 } 155 $timearr['startmin'] = $stmin; 156 $timearr['endmin'] = $edmin; 157 return $timearr; 158 } 159 if($format == '24') 160 { 161 if($edhr <= 9 && strlen(trim($edhr)) < 2) 162 $edhr = '0'.$edhr; 163 if($sthr <= 9 && strlen(trim($sthr)) < 2) 164 $sthr = '0'.$sthr; 165 $timearr['starthour'] = $sthr; 166 $timearr['startmin'] = $stmin; 167 $timearr['startfmt'] = ''; 168 $timearr['endhour'] = $edhr; 169 $timearr['endmin'] = $edmin; 170 $timearr['endfmt'] = ''; 171 return $timearr; 172 } 173 } 174 175 /** 176 *To construct time select combo box 177 *@param $format -- the format :: Type string 178 *@param $bimode -- The mode :: Type string 179 *constructs html select combo box for time selection 180 *and returns it in string format. 181 */ 182 function getTimeCombo($format,$bimode,$hour='',$min='',$fmt='') 183 { 184 $combo = ''; 185 $min = $min - ($min%5); 186 if($format == 'am/pm') 187 { 188 $combo .= '<select class=small name="'.$bimode.'hr" id="'.$bimode.'hr">'; 189 for($i=0;$i<12;$i++) 190 { 191 if($i == 0) 192 { 193 $hrtext= 12; 194 $hrvalue = 12; 195 } 196 else 197 { 198 if($i <= 9 && strlen(trim($i)) < 2) 199 { 200 $hrtext= '0'.$i; 201 } 202 else $hrtext= $i; 203 $hrvalue = $hrtext; 204 } 205 if($hour == $hrvalue) 206 $hrsel = 'selected'; 207 else 208 $hrsel = ''; 209 $combo .= '<option value="'.$hrvalue.'" '.$hrsel.'>'.$hrtext.'</option>'; 210 } 211 $combo .= '</select> '; 212 $combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small>'; 213 for($i=0;$i<12;$i++) 214 { 215 $minvalue = 5; 216 $value = $i*5; 217 if($value <= 9 && strlen(trim($value)) < 2) 218 { 219 $value= '0'.$value; 220 } 221 else $value = $value; 222 if($min == $value) 223 $minsel = 'selected'; 224 else 225 $minsel = ''; 226 $combo .= '<option value="'.$value.'" '.$minsel.'>'.$value.'</option>'; 227 } 228 $combo .= '</select> '; 229 $combo .= '<select name="'.$bimode.'fmt" id="'.$bimode.'fmt" class=small>'; 230 if($fmt == 'am') 231 { 232 $amselected = 'selected'; 233 $pmselected = ''; 234 } 235 elseif($fmt == 'pm') 236 { 237 $amselected = ''; 238 $pmselected = 'selected'; 239 } 240 $combo .= '<option value="am" '.$amselected.'>AM</option>'; 241 $combo .= '<option value="pm" '.$pmselected.'>PM</option>'; 242 $combo .= '</select>'; 243 } 244 else 245 { 246 $combo .= '<select name="'.$bimode.'hr" id="'.$bimode.'hr" class=small>'; 247 for($i=0;$i<=23;$i++) 248 { 249 if($i <= 9 && strlen(trim($i)) < 2) 250 { 251 $hrvalue= '0'.$i; 252 } 253 else $hrvalue = $i; 254 if($hour == $hrvalue) 255 $hrsel = 'selected'; 256 else 257 $hrsel = ''; 258 $combo .= '<option value="'.$hrvalue.'" '.$hrsel.'>'.$hrvalue.'</option>'; 259 } 260 $combo .= '</select>Hr '; 261 $combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small>'; 262 for($i=0;$i<12;$i++) 263 { 264 $minvalue = 5; 265 $value = $i*5; 266 if($value <= 9 && strlen(trim($value)) < 2) 267 { 268 $value= '0'.$value; 269 } 270 else $value=$value; 271 if($min == $value) 272 $minsel = 'selected'; 273 else 274 $minsel = ''; 275 $combo .= '<option value="'.$value.'" '.$minsel.'>'.$value.'</option>'; 276 } 277 $combo .= '</select> min<input type="hidden" name="'.$bimode.'fmt" id="'.$bimode.'fmt">'; 278 } 279 return $combo; 280 } 281 282 /** 283 *Function to construct HTML select combo box 284 *@param $fieldname -- the field name :: Type string 285 *@param $tablename -- The table name :: Type string 286 *constructs html select combo box for combo field 287 *and returns it in string format. 288 */ 289 290 function getActFieldCombo($fieldname,$tablename) 291 { 292 global $adb, $mod_strings; 293 $combo = ''; 294 $combo .= '<select name="'.$fieldname.'" id="'.$fieldname.'" class=small>'; 295 $q = "select * from ".$tablename; 296 $Res = $adb->query($q); 297 $noofrows = $adb->num_rows($Res); 298 299 for($i = 0; $i < $noofrows; $i++) 300 { 301 $value = $adb->query_result($Res,$i,$fieldname); 302 $combo .= '<option value="'.$value.'">'.$value.'</option>'; 303 } 304 305 $combo .= '</select>'; 306 return $combo; 307 } 308 309 /*Fuction to get value for Assigned To field 310 *returns values of Assigned To field in array format 311 */ 312 function getAssignedTo($tabid) 313 { 314 global $current_user,$noof_group_rows,$adb; 315 $assigned_user_id = $current_user->id; 316 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 317 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 318 if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[$tabid] == 3 or $defaultOrgSharingPermission[$tabid] == 0)) 319 { 320 $result=get_current_user_access_groups('Calendar'); 321 } 322 else 323 { 324 $result = get_group_options(); 325 } 326 $nameArray = $adb->fetch_array($result); 327 328 if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[$tabid] == 3 or $defaultOrgSharingPermission[$tabid] == 0)) 329 { 330 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id); 331 } 332 else 333 { 334 $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); 335 } 336 if($noof_group_rows!=0) 337 { 338 do 339 { 340 $groupname=$nameArray["groupname"]; 341 $group_option[] = array($groupname=>$selected); 342 343 }while($nameArray = $adb->fetch_array($result)); 344 } 345 $fieldvalue[]=$users_combo; 346 $fieldvalue[] = $group_option; 347 return $fieldvalue; 348 } 349 350 //Code Added by Minnie -Ends 351 ?>
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 |