Beispiel #1
0
 public function process(Vtiger_Request $request)
 {
     $recordId = $request->get('record');
     $qualifiedModuleName = $request->getModule(false);
     if ($recordId) {
         $recordModel = Settings_SMSNotifier_Record_Model::getInstanceById($recordId, $qualifiedModuleName);
     } else {
         $recordModel = Settings_SMSNotifier_Record_Model::getCleanInstance($qualifiedModuleName);
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('RECORD_ID', $recordId);
     $viewer->assign('RECORD_MODEL', $recordModel);
     $viewer->assign('EDITABLE_FIELDS', $recordModel->getEditableFields());
     $viewer->assign('PROVIDERS_FIELD_MODELS', Settings_SMSNotifier_ProviderField_Model::getAll());
     $viewer->assign('QUALIFIED_MODULE_NAME', $qualifiedModuleName);
     $viewer->assign('PROVIDERS', $recordModel->getModule()->getAllProviders());
     $viewer->view('EditView.tpl', $qualifiedModuleName);
 }
Beispiel #2
0
 public function process(Vtiger_Request $request)
 {
     $recordId = $request->get('record');
     $qualifiedModuleName = $request->getModule(false);
     if ($recordId) {
         $recordModel = Settings_SMSNotifier_Record_Model::getInstanceById($recordId, $qualifiedModuleName);
     } else {
         $recordModel = Settings_SMSNotifier_Record_Model::getCleanInstance($qualifiedModuleName);
     }
     $editableFields = $recordModel->getEditableFields();
     foreach ($editableFields as $fieldName => $fieldModel) {
         $recordModel->set($fieldName, $request->get($fieldName));
     }
     $parameters = '';
     $selectedProvider = $request->get('providertype');
     $allProviders = $recordModel->getModule()->getAllProviders();
     foreach ($allProviders as $provider) {
         if ($provider->getName() === $selectedProvider) {
             $fieldsInfo = Settings_SMSNotifier_ProviderField_Model::getInstanceByProvider($provider);
             foreach ($fieldsInfo as $fieldInfo) {
                 $recordModel->set($fieldInfo['name'], $request->get($fieldInfo['name']));
                 $parameters[$fieldInfo['name']] = $request->get($fieldInfo['name']);
             }
             $recordModel->set('parameters', Zend_Json::encode($parameters));
             break;
         }
     }
     $response = new Vtiger_Response();
     try {
         $recordModel->save();
         $response->setResult(array(vtranslate('LBL_SAVED_SUCCESSFULLY', $qualifiedModuleName)));
     } catch (Exception $e) {
         $response->setError($e->getMessage());
     }
     $response->emit();
 }
    function content_56854fd55be53($_smarty_tpl)
    {
        ?>
<div class="modal"><div class="modal-header contentsBackground"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><?php 
        if ($_smarty_tpl->tpl_vars['RECORD_ID']->value) {
            ?>
<h3><?php 
            echo vtranslate('LBL_EDIT_CONFIGURATION', $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
            ?>
 </h3><?php 
        } else {
            ?>
<h3><?php 
            echo vtranslate('LBL_ADD_CONFIGURATION', $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
            ?>
 </h3><?php 
        }
        ?>
</div><form class="form-horizontal" id="smsConfig" method="POST"><div class="modal-body configContent"><?php 
        if ($_smarty_tpl->tpl_vars['RECORD_ID']->value) {
            ?>
<input type="hidden" value="<?php 
            echo $_smarty_tpl->tpl_vars['RECORD_ID']->value;
            ?>
" name="record" id="recordId"/><?php 
        }
        $_smarty_tpl->tpl_vars['FIELD_MODEL'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['FIELD_MODEL']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['EDITABLE_FIELDS']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['FIELD_MODEL']->key => $_smarty_tpl->tpl_vars['FIELD_MODEL']->value) {
            $_smarty_tpl->tpl_vars['FIELD_MODEL']->_loop = true;
            ?>
<div class="control-group"><?php 
            $_smarty_tpl->tpl_vars['FIELD_NAME'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->get('name'), null, 0);
            ?>
<span class="control-label"><strong><?php 
            echo vtranslate($_smarty_tpl->tpl_vars['FIELD_NAME']->value, $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
            ?>
</strong></span><div class="controls"><?php 
            $_smarty_tpl->tpl_vars['FIELD_TYPE'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getFieldDataType(), null, 0);
            $_smarty_tpl->tpl_vars['FIELD_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['RECORD_MODEL']->value->get($_smarty_tpl->tpl_vars['FIELD_NAME']->value), null, 0);
            if ($_smarty_tpl->tpl_vars['FIELD_TYPE']->value == 'picklist') {
                ?>
<select class="chzn-select providerType" name="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_NAME']->value;
                ?>
" data-validation-engine="validate[ required,funcCall[Vtiger_Base_Validator_Js.invokeValidation]]"><option></option><?php 
                $_smarty_tpl->tpl_vars['PROVIDER_MODEL'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['PROVIDERS']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->key => $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->value) {
                    $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->_loop = true;
                    $_smarty_tpl->tpl_vars['PROVIDER_NAME'] = new Smarty_variable($_smarty_tpl->tpl_vars['PROVIDER_MODEL']->value->getName(), null, 0);
                    ?>
<option value="<?php 
                    echo $_smarty_tpl->tpl_vars['PROVIDER_NAME']->value;
                    ?>
" <?php 
                    if ($_smarty_tpl->tpl_vars['FIELD_VALUE']->value == $_smarty_tpl->tpl_vars['PROVIDER_NAME']->value) {
                        ?>
 selected <?php 
                    }
                    ?>
><?php 
                    echo vtranslate($_smarty_tpl->tpl_vars['PROVIDER_NAME']->value, $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
                    ?>
</option><?php 
                }
                ?>
</select><?php 
            } elseif ($_smarty_tpl->tpl_vars['FIELD_TYPE']->value == 'radio') {
                ?>
<input type="radio" name="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_NAME']->value;
                ?>
" value='1' <?php 
                if ($_smarty_tpl->tpl_vars['FIELD_VALUE']->value) {
                    ?>
 checked="checked" <?php 
                }
                ?>
 />&nbsp;<?php 
                echo vtranslate('LBL_YES', $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
                ?>
&nbsp;&nbsp;&nbsp;<input type="radio" name="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_NAME']->value;
                ?>
" value='0' <?php 
                if (!$_smarty_tpl->tpl_vars['FIELD_VALUE']->value) {
                    ?>
 checked="checked" <?php 
                }
                ?>
/>&nbsp;<?php 
                echo vtranslate('LBL_NO', $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value);
            } elseif ($_smarty_tpl->tpl_vars['FIELD_TYPE']->value == 'password') {
                ?>
<input type="password" name="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_NAME']->value;
                ?>
" class="span3" data-validation-engine="validate[required]" value="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_VALUE']->value;
                ?>
" /><?php 
            } else {
                ?>
<input type="text" name="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_NAME']->value;
                ?>
" class="span3" <?php 
                if ($_smarty_tpl->tpl_vars['FIELD_NAME']->value == 'username') {
                    ?>
 data-validation-engine="validate[required]" <?php 
                }
                ?>
 value="<?php 
                echo $_smarty_tpl->tpl_vars['FIELD_VALUE']->value;
                ?>
" /><?php 
            }
            ?>
</div></div><?php 
        }
        $_smarty_tpl->tpl_vars['PROVIDER_MODEL'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->_loop = false;
        $_smarty_tpl->tpl_vars['PROVIDER_NAME'] = new Smarty_Variable();
        $_from = $_smarty_tpl->tpl_vars['PROVIDERS_FIELD_MODELS']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->key => $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->value) {
            $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->_loop = true;
            $_smarty_tpl->tpl_vars['PROVIDER_NAME']->value = $_smarty_tpl->tpl_vars['PROVIDER_MODEL']->key;
            ?>
<div id="<?php 
            echo $_smarty_tpl->tpl_vars['PROVIDER_NAME']->value;
            ?>
_container" class="providerFields <?php 
            if ($_smarty_tpl->tpl_vars['PROVIDER_NAME']->value != $_smarty_tpl->tpl_vars['RECORD_MODEL']->value->get('providertype')) {
                ?>
 hide <?php 
            }
            ?>
"><?php 
            $_smarty_tpl->tpl_vars['TEMPLATE_NAME'] = new Smarty_variable(Settings_SMSNotifier_ProviderField_Model::getEditFieldTemplateName($_smarty_tpl->tpl_vars['PROVIDER_NAME']->value), null, 0);
            echo $_smarty_tpl->getSubTemplate(vtemplate_path($_smarty_tpl->tpl_vars['TEMPLATE_NAME']->value, $_smarty_tpl->tpl_vars['QUALIFIED_MODULE_NAME']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
            ?>
</div><?php 
        }
        ?>
</div><?php 
        echo $_smarty_tpl->getSubTemplate(vtemplate_path('ModalFooter.tpl', $_smarty_tpl->tpl_vars['MODULE']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
        ?>
</form></div><?php 
    }