Exemplo n.º 1
0
 /**
  * @param type $fieldName
  * @param type $htmlOptions
  */
 public function renderInput($fieldName, $htmlOptions = array())
 {
     switch ($fieldName) {
         case 'color':
             $field = $this->getField($fieldName);
             $options = Dropdowns::getItems($field->linkType, null, false);
             $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend;
             if ($enableDropdownLegend) {
                 $htmlOptions['options'] = array();
                 foreach ($options as $value => $label) {
                     $brightness = X2Color::getColorBrightness($value);
                     $fontColor = $brightness > 127.5 ? 'black' : 'white';
                     $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . ';
                              color: ' . $fontColor);
                 }
             }
             return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions);
         case 'priority':
             return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels());
         case 'associationType':
             return X2Html::activeMultiTypeAutocomplete($this, 'associationType', 'associationId', array('calendar' => Yii::t('app', 'Select an option')) + X2Model::getAssociationTypeOptions());
         case 'reminder':
             $reminderInput = parent::renderInput($fieldName, array('class' => 'reminder-checkbox'));
             $reminderInput .= X2Html::openTag('div', X2Html::mergeHtmlOptions($htmlOptions, array('class' => 'reminder-config'))) . Yii::t('actions', 'Create a notification reminder for {user} {time} before this {action} ' . 'is due', array('{user}' => CHtml::activeDropDownList($this, 'notificationUsers', array('me' => Yii::t('actions', 'me'), 'assigned' => Yii::t('actions', 'the assigned user'), 'both' => Yii::t('actions', 'me and the assigned user'))), '{time}' => CHtml::activeDropDownList($this, 'notificationTime', array(1 => Yii::t('actions', '1 minute'), 5 => Yii::t('actions', '5 minutes'), 10 => Yii::t('actions', '10 minutes'), 15 => Yii::t('actions', '15 minutes'), 30 => Yii::t('actions', '30 minutes'), 60 => Yii::t('actions', '1 hour'), 1440 => Yii::t('actions', '1 day'), 10080 => Yii::t('actions', '1 week'))), '{action}' => lcfirst(Modules::displayName(false, 'Actions')))) . '</div>';
             return $reminderInput;
         default:
             return parent::renderInput($fieldName, $htmlOptions);
     }
 }
Exemplo n.º 2
0
 public function formatActionToEvent($action, $id)
 {
     if (!($action->visibility >= 1 || $action->assignedTo == Yii::app()->user->name || Yii::app()->params->isAdmin)) {
         // admin sees all
         return false;
     }
     $linked = !empty($action->associationType) && strtolower($action->associationType) != 'none' && class_exists(X2Model::getModelName($action->associationType));
     if ($linked) {
         $associatedModel = X2Model::getMOdelOfTypeWithId(X2Model::getModelName($action->associationType), $action->associationId);
         if ($associatedModel) {
             $associationUrl = $associatedModel->getUrl();
         } else {
             $associationUrl = '';
         }
     }
     $title = $action->shortActionText;
     //Email formatting
     $title = preg_replace('/<b>/', '', $title);
     $title = preg_replace('/<\\/b>/', '', $title);
     $title = preg_replace('/\\n\\n/', "\n", $title);
     $title = preg_replace('/<!--EndSig-->/', '', $title);
     $title = preg_replace('/<!--BeginOpenedEmail-->/', '', $title);
     $title = preg_replace('/<!--BeginSignature-->/', '', $title);
     if (in_array($action->type, array('email', 'emailFrom', 'email_quote', 'email_invoice', 'emailOpened', 'emailOpened_quote', 'emailOpened_invoice'))) {
         $title = 'Email: ' . $title;
     }
     $event = array('title' => $title, 'description' => $title, 'start' => date('Y-m-d H:i', $action->dueDate), 'id' => $action->id, 'complete' => $action->complete, 'calendarAssignment' => $id, 'allDay' => false);
     if ($action->allDay) {
         $event['allDay'] = $action->allDay;
     }
     if ($action->color) {
         $event['color'] = $action->color;
     } else {
         $event['color'] = '#6389de';
         // old default color
         //$event['color'] = '#3a87ad';
     }
     static $brightnesses = array();
     if (!isset($brightnesses[$event['color']])) {
         $brightnesses[$event['color']] = X2Color::getColorBrightness($event['color']);
     }
     if ($brightnesses[$event['color']] < 115) {
         $event['textColor'] = 'white';
     }
     if ($action->type == 'event') {
         if ($action->completeDate) {
             $event['end'] = date('Y-m-d H:i', $action->completeDate);
         }
         $event['type'] = 'event';
         $event['associationType'] = $action->associationType;
     }
     $event['linked'] = $linked;
     if ($linked) {
         $event['associationType'] = $action->associationType;
         $event['associationUrl'] = $associationUrl;
         $event['associationName'] = $action->associationName;
     }
     $editable = X2CalendarPermissions::getEditableUserCalendarNames();
     // If it is a group id, we don't need to check this
     $userEditable = !is_int($id) && isset($editable[$id]);
     $event['editable'] = $userEditable && Yii::app()->user->checkAccess('ActionsUpdate', array('X2Model' => $action));
     return $event;
 }
Exemplo n.º 3
0
 /**
  * @param type $fieldName
  * @param type $htmlOptions
  */
 public function renderInput($fieldName, $htmlOptions = array())
 {
     if ($fieldName === 'color') {
         $field = $this->getField($fieldName);
         $options = Dropdowns::getItems($field->linkType, null, false);
         $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend;
         if ($enableDropdownLegend) {
             $htmlOptions['options'] = array();
             foreach ($options as $value => $label) {
                 $brightness = X2Color::getColorBrightness($value);
                 $fontColor = $brightness > 127.5 ? 'black' : 'white';
                 $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . ';
                          color: ' . $fontColor);
             }
         }
         return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions);
     } elseif ($fieldName == 'priority') {
         return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels());
     }
     return parent::renderInput($fieldName, $htmlOptions);
 }