예제 #1
0
 public function quickNoteSelector(CFormModel $formModel)
 {
     ob_start();
     ob_implicit_flush(false);
     echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;'));
     echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2')), 'id' => $this->resolveId('quickNote'), 'class' => 'quick-note'));
     echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2'), 'class' => 'quick-note'));
     Yii::app()->clientScript->registerScript('quickNoteSelector', "\n            \$('#{$this->resolveId('quickNote2')}').change (function () {\n                \$(this).next ().val (\$(this).val ());\n            });\n        ");
     return ob_get_clean();
 }
예제 #2
0
 /**
  *  Convert the Quote into an Invoice
  *  An invoice is a quote with field type='invoice'. The only difference is that
  *  when listing, printing, or emailing an invoice, we call it an invoice instead
  *  of a quote.
  *
  *  @param $id id of the quote to convert to invoice
  *
  */
 public function actionConvertToInvoice($id)
 {
     $model = $this->getModel($id);
     // get model
     // convert to invoice
     $model->type = 'invoice';
     $model->invoiceCreateDate = time();
     // set invoice status to the top choice in the invoice status drop down
     $field = $model->getField('invoiceStatus');
     if ($field) {
         $dropDownId = $field->linkType;
         if ($dropDownId) {
             $dropdowns = Dropdowns::getItems($field->linkType);
             if ($dropdowns) {
                 reset($dropdowns);
                 $status = key($dropdowns);
                 if ($status) {
                     $model->invoiceStatus = $status;
                 }
             }
         }
     }
     $model->update();
     // ajax request from a contact view, don't reload page, instead return a list of quotes
     // for this contact
     if (isset($_GET['modelName']) && isset($_GET['recordId'])) {
         //$contact = X2Model::model('Contacts')->findByPk($_GET['contactId']);
         if ($model) {
             Yii::app()->clientScript->scriptMap['*.js'] = false;
             $this->renderPartial('quoteFormWrapper', array('modelId' => $_GET['recordId'], 'modelName' => $_GET['modelName']), false, true);
             return;
         }
     }
     $this->redirect(array('view', 'id' => $model->id));
     // view quote
 }
예제 #3
0
		</div>
	</div>
</div>
<form id='feed-post-publisher'><!-- submitted via ajax, doesn't need csrf token -->
    <textarea class='x2-textarea' type='text' name='name' id='feed-post-editor' 
     placeholder='<?php 
echo Yii::t('app', 'Enter text here...');
?>
'></textarea>
    <div id='feed-post-controls' style='display:none;'>
    <?php 
$users = User::getUserIds();
$userIds = array_keys($users);
$firstUser = $userIds[0];
echo CHtml::dropDownList('subtype', 1, Dropdowns::getItems(113), array('class' => 'x2-select', 'id' => 'feed-post-subtype'));
echo CHtml::dropDownList('associationId', $firstUser, $users, array('class' => 'x2-select', 'id' => 'feed-post-association-id'));
?>
        <div class='post-button-row-2'>
            <button type='submit' class='x2-button' id='feed-post-button' 
             data-inline='true'><?php 
echo Yii::t('app', 'Submit Post');
?>
</button>
            <?php 
echo CHtml::dropDownList('visibility', 1, array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private')), array('class' => 'x2-select', 'id' => 'feed-post-visibility'));
?>
        </div>
    </div>
</form>
예제 #4
0
 /**
  *  Show or hide a certain status in the gridview
  *
  *  Called through ajax with a status and if that status should be shown or hidden.
  *  Saves the result in the user's profile.
  *
  */
 public function actionStatusFilter()
 {
     if (isset($_POST['all'])) {
         // show all the things!!
         Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode(array());
         // hide none
         Yii::app()->params->profile->update(array('hideCasesWithStatus'));
     } elseif (isset($_POST['none'])) {
         // hide all the things!!!!11
         $statuses = array();
         $dropdownId = Yii::app()->db->createCommand()->select('linkType')->from('x2_fields')->where('modelName="Services" AND fieldName="status" AND type="dropdown"')->queryScalar();
         if ($dropdownId !== null) {
             $statuses = Dropdowns::getItems($dropdownId);
         }
         // get the actual statuses
         Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode($statuses);
         Yii::app()->params->profile->update(array('hideCasesWithStatus'));
     } elseif (isset($_POST['checked'])) {
         $checked = CJSON::decode($_POST['checked']);
         $status = isset($_POST['status']) ? $_POST['status'] : false;
         // var_dump($checked);
         // var_dump($status);
         $hideStatuses = CJSON::decode(Yii::app()->params->profile->hideCasesWithStatus);
         // get a list of statuses the user wants to hide
         if ($hideStatuses === null || !is_array($hideStatuses)) {
             $hideStatuses = array();
         }
         // var_dump($checked);
         // var_dump(in_array($status, $hideStatuses));
         if ($checked && ($key = array_search($status, $hideStatuses)) !== false) {
             // if we want to show the status, and it's not being shown
             unset($hideStatuses[$key]);
             // show status
         } else {
             if (!$checked && !in_array($status, $hideStatuses)) {
                 // if we want to hide the status, and it's not being hidden
                 $hideStatuses[] = $status;
             }
         }
         Yii::app()->params->profile->hideCasesWithStatus = CJSON::encode($hideStatuses);
         Yii::app()->params->profile->update(array('hideCasesWithStatus'));
     }
 }
예제 #5
0
파일: _callForm.php 프로젝트: keyeMyria/CRM
<div id='<?php 
echo $this->resolveId('log-a-call');
?>
' class='publisher-form' 
 <?php 
echo $startVisible ? '' : "style='display: none;'";
?>
>


    <div class="row">
        <div>
            <?php 
echo CHtml::label(Yii::t('app', 'Quick Note'), 'quickNote', array('style' => 'display:inline-block; margin-right: 10px;'));
echo X2Html::dropDownList('quickNote', '', array_merge(array('' => '-'), Dropdowns::getItems(117)), array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"117"}', 'update' => $this->resolveIds('#quickNote2'), 'complete' => $this->resolveIds('function() {
                            auxlib.getElement("#call-action-description").val(""); 
                        }')), 'id' => $this->resolveId('quickNote')));
echo X2Html::dropDownList('quickNote2', '', array('' => '-'), array('id' => $this->resolveId('quickNote2')));
?>
        </div>
    </div>
    <div class="row">
        <div class="text-area-wrapper">
            <?php 
echo $model->renderInput('actionDescription', array('rows' => 3, 'cols' => 40, 'class' => 'action-description x2-textarea', 'id' => $this->resolveId('call-action-description')));
?>
        </div>
    </div>

    <div class='row action-event-panel'>
예제 #6
0
 public function getDropdownOptions()
 {
     if ($this->linkType instanceof X2StaticDropdown) {
         return array('options' => $this->linkType->options, 'multi' => false);
     } else {
         return Dropdowns::getItems($this->linkType, null, true);
     }
 }
예제 #7
0
파일: Actions.php 프로젝트: keyeMyria/CRM
 /**
  * @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);
 }
예제 #8
0
 public static function listOption($attributes, $name)
 {
     if ($attributes instanceof Fields) {
         $attributes = $attributes->getAttributes();
     }
     $data = array('name' => $name, 'label' => $attributes['attributeLabel']);
     if (isset($attributes['type']) && $attributes['type']) {
         $data['type'] = $attributes['type'];
     }
     if (isset($attributes['required']) && $attributes['required']) {
         $data['required'] = 1;
     }
     if (isset($attributes['readOnly']) && $attributes['readOnly']) {
         $data['readOnly'] = 1;
     }
     if (isset($attributes['type'])) {
         if ($attributes['type'] === 'assignment' || $attributes['type'] === 'optionalAssignment') {
             $data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true));
         } elseif ($attributes['type'] === 'dropdown' && isset($attributes['linkType'])) {
             $data['linkType'] = $attributes['linkType'];
             $data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($attributes['linkType']));
         } elseif ($attributes['type'] === 'link' && isset($attributes['linkType'])) {
             $staticLinkModel = X2Model::model($attributes['linkType']);
             if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) {
                 $data['linkType'] = $attributes['linkType'];
                 $data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource);
             }
         }
     }
     return $data;
 }
예제 #9
0
 public function actionGetFields($model)
 {
     if (!class_exists($model)) {
         echo 'false';
         return;
     }
     $fieldModels = X2Model::model($model)->getFields();
     $fields = array();
     foreach ($fieldModels as &$field) {
         if ($field->isVirtual) {
             continue;
         }
         $data = array('name' => $field->fieldName, 'label' => $field->attributeLabel, 'type' => $field->type);
         if ($field->required) {
             $data['required'] = 1;
         }
         if ($field->readOnly) {
             $data['readOnly'] = 1;
         }
         if ($field->type === 'assignment' || $field->type === 'optionalAssignment') {
             $data['options'] = AuxLib::dropdownForJson(X2Model::getAssignmentOptions(true, true));
         } elseif ($field->type === 'dropdown') {
             $data['linkType'] = $field->linkType;
             $data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($field->linkType));
         }
         if ($field->type === 'link') {
             $staticLinkModel = X2Model::model($field->linkType);
             if (array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) {
                 $data['linkType'] = $field->linkType;
                 $data['linkSource'] = Yii::app()->controller->createUrl($staticLinkModel->autoCompleteSource);
             }
         }
         $fields[] = $data;
     }
     echo CJSON::encode($fields);
 }
예제 #10
0
파일: index.php 프로젝트: tymiles003/X2CRM
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
$menuOptions = array('index', 'create', 'createWebForm', 'import', 'export');
$this->insertMenu($menuOptions);
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('services-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
/*
?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php
*/
$field = Fields::model()->findByAttributes(array('modelName' => 'Services', 'fieldName' => 'status', 'type' => 'dropdown'));
if ($field) {
    $statuses = Dropdowns::getItems($field->linkType);
    if ($statuses) {
        //		var_dump(json_decode($dropdown->options));
        $this->serviceCaseStatuses = $statuses;
    }
}
$this->widget('X2GridView', array('id' => 'services-grid', 'title' => Yii::t('services', 'Service Cases'), 'buttons' => array('advancedSearch', 'clearFilters', 'columnSelector', 'autoResize', 'showHidden'), 'template' => '<div id="x2-gridview-top-bar-outer" class="x2-gridview-fixed-top-bar-outer">' . '<div id="x2-gridview-top-bar-inner" class="x2-gridview-fixed-top-bar-inner">' . '<div id="x2-gridview-page-title" ' . 'class="page-title icon services x2-gridview-fixed-title">' . '{title}{buttons}{filterHint}' . '{summary}{topPager}{items}{pager}', 'fixedHeader' => true, 'dataProvider' => $model->searchWithStatusFilter(), 'filter' => $model, 'pager' => array('class' => 'CLinkPager', 'maxButtonCount' => 10), 'modelName' => 'Services', 'viewName' => 'services', 'defaultGvSettings' => array('gvCheckbox' => 30, 'id' => 43, 'impact' => 80, 'status' => 233, 'assignedTo' => 112, 'lastUpdated' => 79, 'updatedBy' => 111), 'specialColumns' => array('id' => array('name' => 'id', 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("view","id"=>$data->id))'), 'account' => array('name' => 'account', 'header' => Yii::t('contacts', 'Account'), 'type' => 'raw', 'value' => 'isset ($data->contactIdModel) ? ($data->contactIdModel ? (isset($data->contactIdModel->companyModel) ? $data->contactIdModel->companyModel->getLink() : "") : "") : ""'), 'status' => array('name' => 'status', 'type' => 'raw', 'value' => 'Yii::t("services",$data->renderAttribute("status"))'), 'impact' => array('name' => 'impact', 'type' => 'raw', 'value' => 'Yii::t("services",$data->renderAttribute("impact"))')), 'enableControls' => true, 'fullscreen' => true));
예제 #11
0
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
if (!Yii::app()->user->isGuest) {
    if ($this->action->id === 'view') {
    } else {
        // get a list of statuses the user wants to hide
        $hideStatus = CJSON::decode(Yii::app()->params->profile->hideBugsWithStatus);
        if (!$hideStatus) {
            $hideStatus = array();
        }
        $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('services', 'Filter By Status'), 'id' => 'service-case-status-filter'));
        echo '<ul id="bug-statuses-picker" style="font-size: 0.8em; font-weight: bold; color: black;">';
        $i = 1;
        foreach (Dropdowns::getItems(115) as $status) {
            $checked = !in_array($status, $hideStatus);
            echo "<li>\n";
            echo CHtml::checkBox("service-case-status-filter-{$i}", $checked, array('id' => "service-case-status-filter-{$i}", 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('/bugReports/bugReports/statusFilter'), 'success' => 'js:function(response) { 
                        $.fn.yiiGridView.update("bugReports-grid"); }', 'data' => 'js:{
                        checked: $(this).attr("checked")=="checked", status:"' . $status . '"
                    }', 'complete' => 'function(){
                        if($("#service-case-status-filter-' . $i . '").
                            attr("checked")=="checked") {

                            $("#service-case-status-filter-' . $i . '").removeAttr(
                                "checked","checked");
                        } else {
                            $("#service-case-status-filter-' . $i . '").attr(
                                "checked","checked");
                        }
예제 #12
0
 public function paramRules()
 {
     // $eventTypes = array('auto'=>Yii::t('app','Auto')) + Dropdowns::getItems(113,'app');
     $eventTypes = Dropdowns::getItems(113, 'studio');
     return array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'options' => array(array('name' => 'type', 'label' => Yii::t('studio', 'Post Type'), 'type' => 'dropdown', 'options' => $eventTypes), array('name' => 'text', 'label' => Yii::t('studio', 'Text'), 'type' => 'text'), array('name' => 'user', 'optional' => 1, 'label' => 'User (optional)', 'type' => 'dropdown', 'options' => array('' => '----------', 'auto' => 'Auto') + X2Model::getAssignmentOptions(false, false)), array('name' => 'createNotif', 'label' => Yii::t('studio', 'Create Notification?'), 'type' => 'boolean', 'defaultVal' => true)));
 }
예제 #13
0
 public function paramRules()
 {
     // $eventTypes = array('auto'=>Yii::t('app','Auto')) + Dropdowns::getItems(113,'app');
     $eventTypes = Dropdowns::getItems(113, 'studio');
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'options' => array(array('name' => 'type', 'label' => Yii::t('studio', 'Post Type'), 'type' => 'dropdown', 'options' => $eventTypes), array('name' => 'text', 'label' => Yii::t('studio', 'Text'), 'type' => 'text'), array('name' => 'visibility', 'label' => Yii::t('studio', 'Visibility'), 'type' => 'dropdown', 'options' => array(1 => Yii::t('admin', 'Public'), 0 => Yii::t('admin', 'Private')), 'defaultVal' => 1), array('name' => 'feed', 'optional' => 1, 'label' => 'User (optional)', 'type' => 'dropdown', 'options' => array('' => '----------', 'auto' => 'Auto') + X2Model::getAssignmentOptions(false, false)), array('name' => 'user', 'optional' => 1, 'label' => 'Author', 'type' => 'dropdown', 'options' => array('admin' => 'admin', 'auto' => Yii::t('studio', 'Auto')) + array_diff_key(X2Model::getAssignmentOptions(false, false), array('admin' => '')), 'defaultVal' => 'admin'), array('name' => 'createNotif', 'label' => Yii::t('studio', 'Create Notification?'), 'type' => 'boolean', 'defaultVal' => true))));
 }
예제 #14
0
파일: Dropdowns.php 프로젝트: shayanyi/CRM
 /**
  * Returns dropdown value(s) for given key(s)
  * @return array|string 
  */
 public function getDropdownIndex($id, $key)
 {
     $arr = Dropdowns::getItems($id);
     if (is_array($key)) {
         return array_map(function ($value) use($arr) {
             $index = array_search($value, $arr);
             if ($index === false) {
                 return $value;
             } else {
                 return $index;
             }
         }, $key);
     } else {
         if (array_search($key, $arr) !== false) {
             return array_search($key, $arr);
         } else {
             return $key;
         }
     }
 }
예제 #15
0
 echo '<div class="formInputBox" style="width:' . $item['width'] . 'px;height:' . $item['height'] . ';">';
 $default = $model->{$fieldName} == $field->attributeLabel;
 if ($field->type == 'varchar' || $field->type == 'email' || $field->type == 'url' || $field->type == 'int' || $field->type == 'float' || $field->type == 'currency') {
     echo $form->textField($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null));
 } else {
     if ($field->type == 'text') {
         echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'style' => $default ? 'color:#aaa;' : null));
     } else {
         if ($field->type == 'text') {
             echo $form->textArea($model, $field->fieldName, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel, 'onfocus' => $default ? 'toggleText(this);' : null, 'onblur' => $default ? 'toggleText(this);' : null, 'style' => $default ? 'color:#aaa;' : null));
         } elseif ($field->type == 'date') {
             $model->{$fieldName} = $this->formatDate($model->{$fieldName});
             Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
             $this->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $field->fieldName, 'mode' => 'date', 'options' => array('dateFormat' => $this->formatDatePicker()), 'htmlOptions' => array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => defined($item['readOnly']) && $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()));
         } elseif ($field->type == 'dropdown') {
             $dropdowns = Dropdowns::getItems($field->linkType);
             echo $form->dropDownList($model, $field->fieldName, $dropdowns, array('tabindex' => isset($item['tabindex']) ? $item['tabindex'] : null, 'disabled' => $item['readOnly'] ? 'disabled' : null, 'title' => $field->attributeLabel));
         } elseif ($field->type == 'link') {
             // if(empty($model->$fieldName))
             // $model->$fieldName = '';
             $linkSource = null;
             $linkId = '';
             if (class_exists($field->linkType)) {
                 // if the field is an ID, look up the actual name
                 if (isset($model->{$fieldName}) && ctype_digit($model->{$fieldName})) {
                     $linkModel = CActiveRecord::model($field->linkType)->findByPk($model->{$fieldName});
                     if (isset($linkModel)) {
                         $model->{$fieldName} = $linkModel->name;
                         $linkId = $linkModel->id;
                     } else {
                         $model->{$fieldName} = '';
예제 #16
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);
     }
 }
예제 #17
0
파일: X2Model.php 프로젝트: keyeMyria/CRM
    public static function renderModelInput(CModel $model, Fields $field, $htmlOptions = array())
    {
        if ($field->required) {
            if (isset($htmlOptions['class'])) {
                $htmlOptions['class'] .= ' x2-required';
            } else {
                $htmlOptions = array_merge(array('class' => 'x2-required'), $htmlOptions);
            }
        }
        $fieldName = $field->fieldName;
        if (!isset($field)) {
            return null;
        }
        switch ($field->type) {
            case 'text':
                return CHtml::activeTextArea($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
                // array(
                // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
                // 'disabled'=>$item['readOnly']? 'disabled' : null,
                // 'title'=>$field->attributeLabel,
                // 'style'=>$default?'color:#aaa;':null,
                // ));
            // array(
            // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
            // 'disabled'=>$item['readOnly']? 'disabled' : null,
            // 'title'=>$field->attributeLabel,
            // 'style'=>$default?'color:#aaa;':null,
            // ));
            case 'date':
                $oldDateVal = $model->{$fieldName};
                $model->{$fieldName} = Formatter::formatDate($model->{$fieldName}, 'medium');
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateVal;
                return $input;
            case 'dateTime':
                $oldDateTimeVal = $model->{$fieldName};
                $model->{$fieldName} = Formatter::formatDateTime($model->{$fieldName});
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'datetime', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => true, 'changeYear' => true), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateTimeVal;
                return $input;
            case 'dropdown':
                // Note: if desired to translate dropdown options, change the seecond argument to
                // $model->module
                $om = Dropdowns::getItems($field->linkType, null, true);
                $multi = (bool) $om['multi'];
                $dropdowns = $om['options'];
                $curVal = $multi ? CJSON::decode($model->{$field->fieldName}) : $model->{$field->fieldName};
                $dependencyCount = X2Model::model('Dropdowns')->countByAttributes(array('parent' => $field->linkType));
                $fieldDependencyCount = X2Model::model('Fields')->countByAttributes(array('modelName' => $field->modelName, 'type' => 'dependentDropdown', 'linkType' => $field->linkType));
                if ($dependencyCount > 0 && $fieldDependencyCount > 0) {
                    $ajaxArray = array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{"val":$(this).val(),"dropdownId":"' . $field->linkType . '", "field":true, "module":"' . $field->modelName . '"}', 'success' => 'function(data){
                                            if(data){
                                                data=JSON.parse(data);
                                                if(data[0] && data[1]){
                                                    $("#' . $field->modelName . '_"+data[0]).html(data[1]);
                                                }
                                            }
                                        }'));
                } else {
                    $ajaxArray = array();
                }
                $htmlOptions = array_merge($htmlOptions, $ajaxArray, array('title' => $field->attributeLabel));
                if ($multi) {
                    $multiSelectOptions = array();
                    if (!is_array($curVal)) {
                        $curVal = array();
                    }
                    foreach ($curVal as $option) {
                        $multiSelectOptions[$option] = array('selected' => 'selected');
                    }
                    $htmlOptions = array_merge($htmlOptions, array('options' => $multiSelectOptions, 'multiple' => 'multiple'));
                } else {
                    $htmlOptions = array_merge($htmlOptions, array('empty' => Yii::t('app', "Select an option")));
                }
                return CHtml::activeDropDownList($model, $field->fieldName, $dropdowns, $htmlOptions);
            case 'dependentDropdown':
                return CHtml::activeDropDownList($model, $field->fieldName, array('' => '-'), array_merge(array('title' => $field->attributeLabel), $htmlOptions));
            case 'link':
                $linkSource = null;
                $linkId = '';
                $name = '';
                if (class_exists($field->linkType)) {
                    // Create a model for autocompletion:
                    if (!empty($model->{$fieldName})) {
                        list($name, $linkId) = Fields::nameAndId($model->{$fieldName});
                        $linkModel = self::getLinkedModelMock($field->linkType, $name, $linkId, true);
                    } else {
                        $linkModel = X2Model::model($field->linkType);
                    }
                    if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
                        $linkSource = Yii::app()->controller->createUrl($linkModel->autoCompleteSource);
                        $linkId = $linkModel->id;
                        $oldLinkFieldVal = $model->{$fieldName};
                        $model->{$fieldName} = $name;
                    }
                }
                $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array('id' => $field->modelName . '_' . $fieldName . "_id")) . Yii::app()->controller->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => $fieldName, 'source' => $linkSource, 'value' => $name, 'options' => array('minLength' => '1', 'select' => 'js:function( event, ui ) {
                                $("#' . $field->modelName . '_' . $fieldName . '_id").val(ui.item.id);
                                $(this).val(ui.item.value);
                                return false;
                            }', 'create' => $field->linkType == 'Contacts' ? 'js:function(event, ui) {
                                    $(this).data( "uiAutocomplete" )._renderItem = function(ul,item) {
                                        return $("<li>").data("item.autocomplete",item).append(x2.forms.renderContactLookup(item)).appendTo(ul);
                                    };
                                }' : ($field->linkType == 'BugReports' ? 'js:function(event, ui) {
                                    $(this).data( "uiAutocomplete" )._renderItem = function( ul, item ) {
                                        var label = "<a style=\\"line-height: 1;\\">" + item.label;

                                        label += "<span style=\\"font-size: 0.6em;\\">";

                                        // add email if defined
                                        if(item.subject) {
                                            label += "<br>";
                                            label += item.subject;
                                        }

                                        label += "</span>";
                                        label += "</a>";

                                        return $( "<li>" )
                                            .data( "item.autocomplete", item )
                                            .append( label )
                                            .appendTo( ul );
                                    };
                                }' : '')), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions)), true);
                if (isset($oldLinkFieldVal)) {
                    $model->{$fieldName} = $oldLinkFieldVal;
                }
                return $input;
            case 'rating':
                return Yii::app()->controller->widget('CStarRating', array('model' => $model, 'attribute' => $field->fieldName, 'readOnly' => isset($htmlOptions['disabled']) && $htmlOptions['disabled'], 'minRating' => Fields::RATING_MIN, 'maxRating' => Fields::RATING_MAX, 'starCount' => Fields::RATING_MAX - Fields::RATING_MIN + 1, 'cssFile' => Yii::app()->theme->getBaseUrl() . '/css/rating/jquery.rating.css', 'htmlOptions' => $htmlOptions, 'callback' => 'function(value, link){
                        if (typeof x2 !== "undefined" &&
                            typeof x2.InlineEditor !== "undefined" &&
                            typeof x2.InlineEditor.ratingFields !== "undefined") {

                            x2.InlineEditor.ratingFields["' . $field->modelName . '[' . $field->fieldName . ']"] = value;
                        }
                    }'), true);
            case 'boolean':
                return '<div class="checkboxWrapper">' . CHtml::activeCheckBox($model, $field->fieldName, array_merge(array('unchecked' => 0, 'title' => $field->attributeLabel), $htmlOptions)) . '</div>';
            case 'assignment':
                $oldAssignmentVal = $model->{$fieldName};
                $model->{$fieldName} = !empty($model->{$fieldName}) ? $field->linkType == 'multiple' && !is_array($model->{$fieldName}) ? explode(', ', $model->{$fieldName}) : $model->{$fieldName} : self::getDefaultAssignment();
                $dropdownList = CHtml::activeDropDownList($model, $fieldName, X2Model::getAssignmentOptions(true, true), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown', 'multiple' => $field->linkType == 'multiple' ? 'multiple' : null), $htmlOptions));
                $model->{$fieldName} = $oldAssignmentVal;
                return $dropdownList;
                /*
                 $group = is_numeric($model->$fieldName);
                 // if(is_numeric($model->assignedTo)){
                 // $group=true;
                 // $groups=Groups::getNames();
                 // }else{
                 // $group=false;
                 // }
                 if (is_array($model[$fieldName]))
                 $model[$fieldName] = implode(', ', $model[$fieldName]);
                
                 if (empty($model->$fieldName))
                 $model->$fieldName = Yii::app()->user->getName();
                 return CHtml::activeDropDownList($model, $fieldName, $group ? Groups::getNames() : User::getNames(), array_merge(array(
                 // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
                 // 'disabled'=>$item['readOnly']? 'disabled' : null,
                 'title' => $field->attributeLabel,
                 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown',
                 'multiple' => ($field->linkType == 'multiple' ? 'multiple' : null),
                 ), $htmlOptions))
                 /* x2temp
                 . '<div class="checkboxWrapper">'
                 . CHtml::checkBox('group', $group, array_merge(array(
                 // array(
                 // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
                 // 'disabled'=>$item['readOnly']? 'disabled' : null,
                 'title' => $field->attributeLabel,
                 'id' => $field->modelName . '_' . $fieldName . '_groupCheckbox',
                 'ajax' => array(
                 'type' => 'POST', //request type
                 'url' => Yii::app()->controller->createUrl('/groups/getGroups'), //url to call.
                 'update' => '#' . $field->modelName . '_' . $fieldName . '_assignedToDropdown', //selector to update
                 'data' => 'js:{checked: $(this).attr("checked")=="checked", field:"' . $model->$fieldName . '"}',
                 'complete' => 'function(){
                 if($("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked")!="checked"){
                 $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked","checked");
                 $("#' . $field->modelName . '_' . $fieldName . '_visibility option[value=\'2\']").remove();
                 }else{
                 $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").removeAttr("checked");
                 $("#' . $field->modelName . '_' . $fieldName . '_visibility").append(
                 $("<option></option>").val("2").html("User\'s Groups")
                 );
                 }
                 }')
                 ), array_merge($htmlOptions, array('style' => 'margin-left:10px;'))))
                 . '<label for="group" class="groupLabel">' . Yii::t('app', 'Group?') . '</label></div>';
                 /* end x2temp
                
                 // case 'association':
                 // if($field->linkType!='multiple') {
                 // return CHtml::activeDropDownList($model, $fieldName, $contacts,array_merge(array(
                 // 'title'=>$field->attributeLabel,
                 // ),$htmlOptions));
                 // } else {
                 // return CHtml::activeListBox($model, $fieldName, $contacts,array_merge(array(
                 // 'title'=>$field->attributeLabel,
                 // 'multiple'=>'multiple',
                 // ),$htmlOptions));
                 // }
                */
            /*
             $group = is_numeric($model->$fieldName);
             // if(is_numeric($model->assignedTo)){
             // $group=true;
             // $groups=Groups::getNames();
             // }else{
             // $group=false;
             // }
             if (is_array($model[$fieldName]))
             $model[$fieldName] = implode(', ', $model[$fieldName]);
            
             if (empty($model->$fieldName))
             $model->$fieldName = Yii::app()->user->getName();
             return CHtml::activeDropDownList($model, $fieldName, $group ? Groups::getNames() : User::getNames(), array_merge(array(
             // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
             // 'disabled'=>$item['readOnly']? 'disabled' : null,
             'title' => $field->attributeLabel,
             'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown',
             'multiple' => ($field->linkType == 'multiple' ? 'multiple' : null),
             ), $htmlOptions))
             /* x2temp
             . '<div class="checkboxWrapper">'
             . CHtml::checkBox('group', $group, array_merge(array(
             // array(
             // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
             // 'disabled'=>$item['readOnly']? 'disabled' : null,
             'title' => $field->attributeLabel,
             'id' => $field->modelName . '_' . $fieldName . '_groupCheckbox',
             'ajax' => array(
             'type' => 'POST', //request type
             'url' => Yii::app()->controller->createUrl('/groups/getGroups'), //url to call.
             'update' => '#' . $field->modelName . '_' . $fieldName . '_assignedToDropdown', //selector to update
             'data' => 'js:{checked: $(this).attr("checked")=="checked", field:"' . $model->$fieldName . '"}',
             'complete' => 'function(){
             if($("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked")!="checked"){
             $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").attr("checked","checked");
             $("#' . $field->modelName . '_' . $fieldName . '_visibility option[value=\'2\']").remove();
             }else{
             $("#' . $field->modelName . '_' . $fieldName . '_groupCheckbox").removeAttr("checked");
             $("#' . $field->modelName . '_' . $fieldName . '_visibility").append(
             $("<option></option>").val("2").html("User\'s Groups")
             );
             }
             }')
             ), array_merge($htmlOptions, array('style' => 'margin-left:10px;'))))
             . '<label for="group" class="groupLabel">' . Yii::t('app', 'Group?') . '</label></div>';
             /* end x2temp
            
             // case 'association':
             // if($field->linkType!='multiple') {
             // return CHtml::activeDropDownList($model, $fieldName, $contacts,array_merge(array(
             // 'title'=>$field->attributeLabel,
             // ),$htmlOptions));
             // } else {
             // return CHtml::activeListBox($model, $fieldName, $contacts,array_merge(array(
             // 'title'=>$field->attributeLabel,
             // 'multiple'=>'multiple',
             // ),$htmlOptions));
             // }
            */
            case 'optionalAssignment':
                // optional assignment for users (can be left blank)
                $users = User::getNames();
                unset($users['Anyone']);
                return CHtml::activeDropDownList($model, $fieldName, $users, array_merge(array('title' => $field->attributeLabel, 'empty' => ''), $htmlOptions));
            case 'visibility':
                $permissionsBehavior = Yii::app()->params->modelPermissions;
                return CHtml::activeDropDownList($model, $field->fieldName, $permissionsBehavior::getVisibilityOptions(), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . "_visibility"), $htmlOptions));
                // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone'
                // case 'int':
                // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array(
                // 'title' => $field->attributeLabel,
                // ), $htmlOptions));
            // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone'
            // case 'int':
            // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array(
            // 'title' => $field->attributeLabel,
            // ), $htmlOptions));
            case 'percentage':
                $htmlOptions['class'] = empty($htmlOptions['class']) ? 'input-percentage' : $htmlOptions['class'] . ' input-percentage';
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
            case 'currency':
                $fieldName = $field->fieldName;
                $elementId = isset($htmlOptions['id']) ? '#' . $htmlOptions['id'] : '#' . $field->modelName . '_' . $field->fieldName;
                Yii::app()->controller->widget('application.extensions.moneymask.MMask', array('element' => $elementId, 'currency' => Yii::app()->params['currency'], 'config' => array('affixStay' => true, 'decimal' => Yii::app()->locale->getNumberSymbol('decimal'), 'thousands' => Yii::app()->locale->getNumberSymbol('group'))));
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'class' => 'currency-field'), $htmlOptions));
            case 'credentials':
                $typeAlias = explode(':', $field->linkType);
                $type = $typeAlias[0];
                if (count($typeAlias) > 1) {
                    $uid = Credentials::$sysUseId[$typeAlias[1]];
                } else {
                    $uid = Yii::app()->user->id;
                }
                return Credentials::selectorField($model, $field->fieldName, $type, $uid);
            case 'timerSum':
                // Sorry, no-can-do. This is field derives its value from a sum over timer records.
                return $model->renderAttribute($field->fieldName);
            case 'float':
            case 'int':
                if (isset($model->{$fieldName})) {
                    $oldNumVal = $model->{$fieldName};
                    $model->{$fieldName} = Yii::app()->locale->numberFormatter->formatDecimal($model->{$fieldName});
                }
                $input = CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
                if (isset($oldNumVal)) {
                    $model->{$fieldName} = $oldNumVal;
                }
                return $input;
            default:
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
                // array(
                // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
                // 'disabled'=>$item['readOnly']? 'disabled' : null,
                // 'title'=>$field->attributeLabel,
                // 'style'=>$default?'color:#aaa;':null,
                // ));
        }
    }
예제 #18
0
파일: _listForm.php 프로젝트: dsyman2/X2CRM
$cs->registerScript('highlightSaveContact', $js, CClientScript::POS_READY);
$cs->registerCssFile($assets . '/jquery-ui-timepicker-addon.css');
$cs->registerScriptFile($assets . '/jquery-ui-timepicker-addon.js', CClientScript::POS_END);
// $cs->registerScript(__CLASS__,     $this->defaultOptions?'jQuery.{$this->mode}picker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':'');
// $cs->registerScript(__CLASS__.'#'.$id, $js);
$fieldTypes = array();
$fieldLinkTypes = array();
$fieldOptions = array();
foreach ($itemModel->getFields() as $field) {
    $fieldTypes[$field->fieldName] = $field->type;
    if (!empty($field->linkType)) {
        $fieldLinkTypes[$field->fieldName] = $field->linkType;
    }
    switch ($field->type) {
        case 'dropdown':
            $fieldOptions[$field->fieldName] = Dropdowns::getItems($field->linkType);
            break;
        case 'assignment':
            $fieldOptions[$field->fieldName] = User::getNames() + Groups::getNames();
            break;
        case 'link':
            $fieldOptions[$field->fieldName] = Yii::app()->request->scriptUrl . X2Model::model($field->linkType)->autoCompleteSource;
            break;
    }
}
$attributeLabels = $model->itemAttributeLabels;
//hack tags in
$fieldTypes['tags'] = 'tags';
$fieldOptions['tags'] = Tags::getAllTags();
$attributeLabels['tags'] = Yii::t('contacts', 'Tags');
natcasesort($attributeLabels);
예제 #19
0
파일: Fields.php 프로젝트: tymiles003/X2CRM
 public function getDropdownOptions()
 {
     return Dropdowns::getItems($this->linkType, null, true);
 }