[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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 vimport('~~include/utils/RecurringType.php'); 11 12 class Calendar_Record_Model extends Vtiger_Record_Model { 13 14 /** 15 * Function returns the Entity Name of Record Model 16 * @return <String> 17 */ 18 function getName() { 19 $name = $this->get('subject'); 20 if(empty($name)) { 21 $name = parent::getName(); 22 } 23 return $name; 24 } 25 26 /** 27 * Function to insert details about reminder in to Database 28 * @param <Date> $reminderSent 29 * @param <integer> $recurId 30 * @param <String> $reminderMode like edit/delete 31 */ 32 public function setActivityReminder($reminderSent = 0, $recurId = '', $reminderMode = '') { 33 $moduleInstance = CRMEntity::getInstance($this->getModuleName()); 34 $moduleInstance->activity_reminder($this->getId(), $this->get('reminder_time'), $reminderSent, $recurId, $reminderMode); 35 } 36 37 /** 38 * Function returns the Module Name based on the activity type 39 * @return <String> 40 */ 41 function getType() { 42 $activityType = $this->get('activitytype'); 43 if($activityType == 'Task') { 44 return 'Calendar'; 45 } 46 return 'Events'; 47 } 48 49 /** 50 * Function to get the Detail View url for the record 51 * @return <String> - Record Detail View Url 52 */ 53 public function getDetailViewUrl() { 54 $module = $this->getModule(); 55 return 'index.php?module=Calendar&view='.$module->getDetailViewName().'&record='.$this->getId(); 56 } 57 58 /** 59 * Function returns recurring information for EditView 60 * @return <Array> - which contains recurring Information 61 */ 62 public function getRecurrenceInformation() { 63 $recurringObject = $this->getRecurringObject(); 64 65 if ($recurringObject) { 66 $recurringData['recurringcheck'] = 'Yes'; 67 $recurringData['repeat_frequency'] = $recurringObject->getRecurringFrequency(); 68 $recurringData['eventrecurringtype'] = $recurringObject->getRecurringType(); 69 $recurringEndDate = $recurringObject->getRecurringEndDate(); 70 if(!empty($recurringEndDate)){ 71 $recurringData['recurringenddate'] = $recurringEndDate->get_formatted_date(); 72 } 73 $recurringInfo = $recurringObject->getUserRecurringInfo(); 74 75 if ($recurringObject->getRecurringType() == 'Weekly') { 76 $noOfDays = count($recurringInfo['dayofweek_to_repeat']); 77 for ($i = 0; $i < $noOfDays; ++$i) { 78 $recurringData['week'.$recurringInfo['dayofweek_to_repeat'][$i]] = 'checked'; 79 } 80 } elseif ($recurringObject->getRecurringType() == 'Monthly') { 81 $recurringData['repeatMonth'] = $recurringInfo['repeatmonth_type']; 82 if ($recurringInfo['repeatmonth_type'] == 'date') { 83 $recurringData['repeatMonth_date'] = $recurringInfo['repeatmonth_date']; 84 } else { 85 $recurringData['repeatMonth_daytype'] = $recurringInfo['repeatmonth_daytype']; 86 $recurringData['repeatMonth_day'] = $recurringInfo['dayofweek_to_repeat'][0]; 87 } 88 } 89 } else { 90 $recurringData['recurringcheck'] = 'No'; 91 } 92 return $recurringData; 93 } 94 95 function save() { 96 //Time should changed to 24hrs format 97 $_REQUEST['time_start'] = Vtiger_Time_UIType::getTimeValueWithSeconds($_REQUEST['time_start']); 98 $_REQUEST['time_end'] = Vtiger_Time_UIType::getTimeValueWithSeconds($_REQUEST['time_end']); 99 parent::save(); 100 } 101 102 /** 103 * Function to get recurring information for the current record in detail view 104 * @return <Array> - which contains Recurring Information 105 */ 106 public function getRecurringDetails() { 107 $recurringObject = $this->getRecurringObject(); 108 if ($recurringObject) { 109 $recurringInfoDisplayData = $recurringObject->getDisplayRecurringInfo(); 110 $recurringEndDate = $recurringObject->getRecurringEndDate(); 111 } else { 112 $recurringInfoDisplayData['recurringcheck'] = vtranslate('LBL_NO', $currentModule); 113 $recurringInfoDisplayData['repeat_str'] = ''; 114 } 115 if(!empty($recurringEndDate)){ 116 $recurringInfoDisplayData['recurringenddate'] = $recurringEndDate->get_formatted_date(); 117 } 118 119 return $recurringInfoDisplayData; 120 } 121 122 /** 123 * Function to get the recurring object 124 * @return Object - recurring object 125 */ 126 public function getRecurringObject() { 127 $db = PearDatabase::getInstance(); 128 $query = 'SELECT vtiger_recurringevents.*, vtiger_activity.date_start, vtiger_activity.time_start, vtiger_activity.due_date, vtiger_activity.time_end FROM vtiger_recurringevents 129 INNER JOIN vtiger_activity ON vtiger_activity.activityid = vtiger_recurringevents.activityid 130 WHERE vtiger_recurringevents.activityid = ?'; 131 $result = $db->pquery($query, array($this->getId())); 132 if ($db->num_rows($result)) { 133 return RecurringType::fromDBRequest($db->query_result_rowdata($result, 0)); 134 } 135 return false; 136 } 137 138 /** 139 * Function updates the Calendar Reminder popup's status 140 */ 141 public function updateReminderStatus($status=1) { 142 $db = PearDatabase::getInstance(); 143 $db->pquery("UPDATE vtiger_activity_reminder_popup set status = ? where recordid = ?", array($status, $this->getId())); 144 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |