diff --git a/config.php b/config.php index 3f620e49f71ca87ffc43cf152d800afb12766884..e835cce53fec0800deece75922c04a445fbaf1ec 100644 --- a/config.php +++ b/config.php @@ -22,6 +22,10 @@ include('config.inc.php'); $THIS_DIR = dirname(__FILE__); +if (file_exists($THIS_DIR.'/config_override.php')) { + include_once $THIS_DIR.'/config_override.php'; +} + class VtigerConfig { static function get($key, $defvalue='') { diff --git a/config_override.php b/config_override.php new file mode 100644 index 0000000000000000000000000000000000000000..5ee107fea70d4e10c4f7e998dc4448895677a537 --- /dev/null +++ b/config_override.php @@ -0,0 +1,13 @@ +<?php +/* +********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.1 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + * ***********************************************************************************/ + +//Maximum number of Mailboxes in mail converter +$max_mailboxes = 3; + diff --git a/includes/runtime/BaseModel.php b/includes/runtime/BaseModel.php index fb6c93f68418cdf2af8405c09956b2eeca07674d..2da7c659447a80cd4af112c557ffc45b483f5113 100644 --- a/includes/runtime/BaseModel.php +++ b/includes/runtime/BaseModel.php @@ -28,7 +28,7 @@ class Vtiger_Base_Model { * @return Value for the given key */ public function get($key){ - return isset($this->valueMap[$key]) ? $this->valueMap[$key] : false; + return $this->valueMap[$key]; } /** diff --git a/layouts/v7/modules/Settings/MailConverter/EditHeader.tpl b/layouts/v7/modules/Settings/MailConverter/EditHeader.tpl index d05fd4a0beba5e0d034b488646a234c079bd7091..5714e616bb5295cb6ae0566afc5e5f4b6401b92a 100644 --- a/layouts/v7/modules/Settings/MailConverter/EditHeader.tpl +++ b/layouts/v7/modules/Settings/MailConverter/EditHeader.tpl @@ -15,16 +15,19 @@ <input type="hidden" id="step" value="{$STEP}" /> <h4> {if $CREATE eq 'new'} - {vtranslate('LBL_ADDING_NEW_MAILBOX',$QUALIFIED_MODULE)} + {vtranslate('LBL_ADDING_NEW_MAILBOX', $QUALIFIED_MODULE)} {else} - {vtranslate('LBL_EDIT_MAILBOX',$QUALIFIED_MODULE)} + {vtranslate('LBL_EDIT_MAILBOX', $QUALIFIED_MODULE)} {/if} </h4> <hr> <div class="editViewContainer" style="padding-left: 2%;padding-right: 2%"> <div class="row"> - {assign var=BREADCRUMB_LABELS value = ["step1" => "MAILBOX_DETAILS", "step2" => "SELECT_FOLDERS", "step3" => "ADD_RULES"]} - {include file="BreadCrumbs.tpl"|vtemplate_path:$QUALIFIED_MODULE ACTIVESTEP=1 BREADCRUMB_LABELS=$BREADCRUMB_LABELS MODULE=$QUALIFIED_MODULE} + {assign var=BREADCRUMB_LABELS value = ["step1" => "MAILBOX_DETAILS", "step2" => "SELECT_FOLDERS"]} + {if $CREATE eq 'new'} + {append var=BREADCRUMB_LABELS index=step3 value=ADD_RULES} + {/if} + {include file="BreadCrumbs.tpl"|vtemplate_path:$QUALIFIED_MODULE BREADCRUMB_LABELS=$BREADCRUMB_LABELS MODULE=$QUALIFIED_MODULE} </div> <div class="clearfix"></div> {/strip} \ No newline at end of file diff --git a/layouts/v7/modules/Settings/MailConverter/Rule.tpl b/layouts/v7/modules/Settings/MailConverter/Rule.tpl index 191fde2544a9d5672a7093cb391d1855a89e7af5..3464341628859f723859d394fee3080df98336ad 100644 --- a/layouts/v7/modules/Settings/MailConverter/Rule.tpl +++ b/layouts/v7/modules/Settings/MailConverter/Rule.tpl @@ -1,12 +1,76 @@ -{*+********************************************************************************** - * The contents of this file are subject to the vtiger CRM Public License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * The Original Code is: vtiger CRM Open Source - * The Initial Developer of the Original Code is vtiger. - * Portions created by vtiger are Copyright (C) vtiger. - * All Rights Reserved. - ************************************************************************************} -{* modules/Settings/MailConverter/views/RuleAjax.php *} - -{* START YOUR IMPLEMENTATION FROM BELOW. Use {debug} for information *} -<DIV>TEMPLATE: layout/modules/Settings/MailConverter/Rule.tpl</DIV> +{*+********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.1 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + ************************************************************************************} + +{strip} + <div class="mailConverterRuleBlock"> + <div class="details border1px"> + <div class="ruleHead modal-header" style="cursor: move; min-height: 30px; padding: 10px 0px;"> + <strong> + <img class="alignMiddle" src="{vimage_path('white-drag.png')}" style="margin-left: 10px;" /> {vtranslate('LBL_RULE', $QUALIFIED_MODULE)} <span class="sequenceNumber">{$RULE_COUNT}</span> : {vtranslate($RULE_MODEL->get('action'), $QUALIFIED_MODULE)} + <div class="pull-right" style="padding-right: 10px;"> + {foreach from=$RULE_MODEL->getRecordLinks() item=ACTION_LINK} + <span {if stripos($ACTION_LINK->getUrl(), 'javascript:')===0} + onclick='{$ACTION_LINK->getUrl()|substr:strlen("javascript:")}' + {else} + onclick='window.location.href = "{$ACTION_LINK->getUrl()}"' + {/if}> + <i title="{vtranslate($ACTION_LINK->get('linklabel'), $MODULE)}" class="{$ACTION_LINK->get('linkicon')} alignMiddle cursorPointer"></i> + </span> + {/foreach} + </div> + </strong> + </div> + <fieldset class="marginTop10px"> + <strong class="marginLeft10px">{vtranslate('LBL_CONDITIONS', $QUALIFIED_MODULE)}</strong> + <hr> + {foreach key=FIELD_NAME item=FIELD_MODEL from=$FIELDS} + <div class="col-lg-12 padding10"> + <div class="col-lg-1"></div> + <div class="col-lg-3 fieldLabel"><label>{vtranslate($FIELD_MODEL->get('label'), $QUALIFIED_MODULE)}</label></div> + <div class="col-lg-7 fieldValue"> + {if $FIELD_NAME neq 'action' && $FIELD_NAME neq 'assigned_to'} + {assign var=FIELD_VALUE value=$RULE_MODEL->get($FIELD_NAME)} + {if $FIELD_NAME eq 'matchusing'} + {assign var=FIELD_VALUE value=vtranslate('LBL_ANY_CONDITIONS', $QUALIFIED_MODULE)} + {if $RULE_MODEL->get('matchusing') eq 'AND'} + {assign var=FIELD_VALUE value=vtranslate('LBL_ALL_CONDITIONS', $QUALIFIED_MODULE)} + {/if} + {else if $FIELD_NAME eq 'subject'} + {vtranslate($RULE_MODEL->get('subjectop'))} + {else if $FIELD_NAME eq 'body'} + {vtranslate($RULE_MODEL->get('bodyop'))} + {/if} + {$FIELD_VALUE} + {/if} + </div> + </div> + {/foreach} + {assign var=ASSIGNED_TO_RULES_ARRAY value=array('CREATE_HelpDesk_FROM', 'CREATE_Leads_SUBJECT', 'CREATE_Contacts_SUBJECT', 'CREATE_Accounts_SUBJECT')} + {if in_array($RULE_MODEL->get('action'), $ASSIGNED_TO_RULES_ARRAY)} + <div class="col-lg-12 padding10"> + <div class="col-lg-1"></div> + <div class="col-lg-3 fieldLabel"><label>{vtranslate('Assigned To')}</label></div> + <div class="col-lg-7 fieldValue">{$RULE_MODEL->get('assigned_to')}</div> + </div> + {/if} + </fieldset> + <hr> + <fieldset class="marginTop10px"> + <strong class="marginLeft10px">{vtranslate('LBL_ACTIONS', $QUALIFIED_MODULE)}</strong> + <hr> + <div class="col-lg-12 padding10" style="padding-bottom: 10px;"> + <div class="col-lg-1"></div> + <div class="col-lg-3 fieldLabel"><label>{vtranslate('action', $QUALIFIED_MODULE)}</label></div> + <div class="col-lg-7 fieldValue">{vtranslate($RULE_MODEL->get('action'), $QUALIFIED_MODULE)}</small></div> + </div> + </fieldset> + </div> + </div> + <br> +{/strip} diff --git a/layouts/v7/modules/Settings/MailConverter/RuleEditView.tpl b/layouts/v7/modules/Settings/MailConverter/RuleEditView.tpl index dcbc63bfe4508f7790183a0e4017152a69af57e8..c0fdfe609c55d7b2ad8514646ba5742529933070 100644 --- a/layouts/v7/modules/Settings/MailConverter/RuleEditView.tpl +++ b/layouts/v7/modules/Settings/MailConverter/RuleEditView.tpl @@ -8,94 +8,105 @@ *************************************************************************************} {strip} - <div class='modelContainer'> - <div class="modal-header contentsBackground"> - <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> - <h3>{vtranslate('LBL_ADD_RULE', $QUALIFIED_MODULE)}</h3> - </div> - <form class="form-horizontal" id="ruleSave" method="post" action="index.php"> - <input type="hidden" name="module" value="{$MODULE_NAME}" /> - <input type="hidden" name="parent" value="Settings" /> - <input type="hidden" name="action" value="SaveRule" /> - <input type="hidden" name="scannerId" value="{$SCANNER_ID}" /> - <input type="hidden" name="record" value="{$RECORD_ID}" /> - <div class="modal-body tabbable"> - {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFiels()} - {foreach key=FIELD_NAME item=FIELD_MODEL from=$FIELDS} - <div class="control-group"> - <div class="control-label"> - <label> - {vtranslate($FIELD_MODEL->get('label'),$QUALIFIED_MODULE)} - </label> - </div> - <div class="controls"> - {assign var=FIELD_DATA_TYPE value=$FIELD_MODEL->getFieldDataType()} - {if $FIELD_DATA_TYPE eq 'picklist'} - {assign var=PICKLIST_VALUES value=$FIELD_MODEL->getPickListValues()} - {if $FIELD_NAME eq 'subject'} - <select name="subjectop" class="chzn-select" style="min-width:220px"> - <option value="">{vtranslate('LBL_SELECT_OPTION',$QUALIFIED_MODULE)}</option> - {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} - <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('subjectop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> - {/foreach} - </select> - <input type="text" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" /> - {elseif $FIELD_NAME eq 'body'} - <select name="bodyop" class="chzn-select" style="min-width:220px"> - <option value="" {if $RECORD_MODEL->get('bodyop') eq ""}selected{/if}>{vtranslate('LBL_SELECT_OPTION',$QUALIFIED_MODULE)}</option> - {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} - <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('bodyop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> - {/foreach} - </select> - <br><br> - <textarea name="{$FIELD_MODEL->getName()}">{$RECORD_MODEL->get($FIELD_NAME)}</textarea> - {else} - <select id="actions" name="action1" class="select2" style="min-width:220px"> - {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} - <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get($FIELD_NAME) eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> - {/foreach} + <div class="modelContainer modal-dialog modal-xs" style="width: 600px;"> + <div class="modal-content"> + <form class="form-horizontal" id="ruleSave" method="post" action="index.php"> + {if $RECORD_ID} + {assign var=TITLE value={vtranslate('LBL_EDIT_RULE', $QUALIFIED_MODULE)}} + {else} + {assign var=TITLE value={vtranslate('LBL_ADD_RULE', $QUALIFIED_MODULE)}} + {/if} + {include file="ModalHeader.tpl"|vtemplate_path:$MODULE TITLE=$TITLE} + <input type="hidden" name="module" value="{$MODULE_NAME}" /> + <input type="hidden" name="parent" value="Settings" /> + <input type="hidden" name="action" value="SaveRule" /> + <input type="hidden" name="scannerId" value="{$SCANNER_ID}" /> + <input type="hidden" name="record" value="{$RECORD_ID}" /> + <div class="addMailBoxStep modal-body"> + {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFields()} + <table class="table editview-table no-border"> + <tbody> + {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFields()} + {foreach key=FIELD_NAME item=FIELD_MODEL from=$FIELDS} + <tr class="row"> + <td class="col-lg-2 control-label"><label class="fieldLabel">{vtranslate($FIELD_MODEL->get('label'), $QUALIFIED_MODULE)}</label> + <td class="col-lg-4"> + {assign var=FIELD_DATA_TYPE value=$FIELD_MODEL->getFieldDataType()} + {if $FIELD_DATA_TYPE eq 'picklist'} + {assign var=PICKLIST_VALUES value=$FIELD_MODEL->getPickListValues()} + {if $FIELD_NAME eq 'subject'} + <select name="subjectop" class="select2 fieldValue inputElement"> + <option value="">{vtranslate('LBL_SELECT_OPTION', $QUALIFIED_MODULE)}</option> + {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} + <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('subjectop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> + {/foreach} + </select> + {elseif $FIELD_NAME eq 'body'} + <select name="bodyop" class="select2 fieldValue inputElement"> + <option value="" {if $RECORD_MODEL->get('bodyop') eq ""}selected{/if}>{vtranslate('LBL_SELECT_OPTION', $QUALIFIED_MODULE)}</option> + {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} + <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('bodyop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> + {/foreach} + </select> + <br><br> + <textarea name="{$FIELD_MODEL->getName()}" class="form-control col-sm-12" style="padding: 3px 8px;">{$RECORD_MODEL->get($FIELD_NAME)}</textarea> + {else} + <select id="actions" name="action1" class="select2 fieldValue inputElement"> + {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} + <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get($FIELD_NAME) eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> + {/foreach} + </select> + {/if} + {elseif $FIELD_DATA_TYPE eq 'radio'} + {assign var=RADIO_OPTIONS value=$FIELD_MODEL->getRadioOptions()} + {foreach key=RADIO_NAME item=RADIO_VALUE from=$RADIO_OPTIONS} + <label class="radioOption inline"> + <input class="radioOption" type="radio" name="{$FIELD_MODEL->getName()}" value="{$RADIO_NAME}" {if $RECORD_MODEL->get($FIELD_NAME) eq $RADIO_NAME} checked {/if} /> + {$RADIO_VALUE} + </label> + {/foreach} + {elseif $FIELD_DATA_TYPE eq 'email'} + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" data-validation-engine="validate[funcCall[Vtiger_Email_Validator_Js.invokeValidation]]"/> + {else} + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}"/> + {/if} + </td> + <td class="col-lg-4"> + {if $FIELD_NAME eq 'subject'} + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" /> + {/if} + </td> + </tr> + {/foreach} + <tr class="row" id="assignedToBlock"> + <td class="col-lg-2 control-label"><label class="fieldLabel">{vtranslate('Assigned To')}</label></td> + <td class="col-lg-4"> + <select class="select2 fieldValue inputElement" id="assignedTo" name="assignedTo"> + <optgroup label="{vtranslate('LBL_USERS')}"> + {assign var=USERS value=$USER_MODEL->getAccessibleUsersForModule($MODULE_NAME)} + {foreach key=OWNER_ID item=OWNER_NAME from=$USERS} + <option value="{$OWNER_ID}" data-picklistvalue= '{$OWNER_NAME}' {if $ASSIGNED_USER eq $OWNER_ID} selected {/if}> + {$OWNER_NAME} + </option> + {/foreach} + </optgroup> + <optgroup label="{vtranslate('LBL_GROUPS')}"> + {assign var=GROUPS value=$USER_MODEL->getAccessibleGroups()} + {foreach key=OWNER_ID item=OWNER_NAME from=$GROUPS} + <option value="{$OWNER_ID}" data-picklistvalue= '{$OWNER_NAME}' {if $ASSIGNED_USER eq $OWNER_ID} selected {/if}> + {$OWNER_NAME} + </option> + {/foreach} + </optgroup> </select> - {/if} - {elseif $FIELD_DATA_TYPE eq 'radio'} - {assign var=RADIO_OPTIONS value=$FIELD_MODEL->getRadioOptions()} - {foreach key=RADIO_NAME item=RADIO_VALUE from=$RADIO_OPTIONS} - <label class="radio inline"> - <input class="radio" type="radio" name="{$FIELD_MODEL->getName()}" value="{$RADIO_NAME}" - {if empty($RECORD_ID) && ($RADIO_NAME eq 'AND')} checked="" {/if} {if $RECORD_MODEL->get($FIELD_NAME) eq $RADIO_NAME} checked {/if} /> - {$RADIO_VALUE} - </label> - {/foreach} - {elseif $FIELD_DATA_TYPE eq 'email'} - <input type="text" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" data-validation-engine="validate[funcCall[Vtiger_Email_Validator_Js.invokeValidation]]"/> - {else} - <input type="text" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}"/> - {/if} - </div> - </div> - {/foreach} - <div style="" id="assignedToBlock" {if $RECORD_MODEL->get('action') eq 'UPDATE_HelpDesk_SUBJECT'}class="hide"{/if}> - <div class="control-label"> - <label>{vtranslate('Assigned To')}</label> - </div> - <div class="controls"> - <select class="select2-container select2" id="assignedTo" name="assignedTo" style="width: 49%;"> - <optgroup label="{vtranslate('LBL_USERS')}"> - {assign var=USERS value=$USER_MODEL->getAccessibleUsersForModule($MODULE_NAME)} - {foreach key=OWNER_ID item=OWNER_NAME from=$USERS} - <option value="{$OWNER_ID}" data-picklistvalue= '{$OWNER_NAME}' {if $ASSIGNED_USER eq $OWNER_ID} selected {/if}>{$OWNER_NAME}</option> - {/foreach} - </optgroup> - <optgroup label="{vtranslate('LBL_GROUPS')}"> - {assign var=GROUPS value=$USER_MODEL->getAccessibleGroups()} - {foreach key=OWNER_ID item=OWNER_NAME from=$GROUPS} - <option value="{$OWNER_ID}" data-picklistvalue= '{$OWNER_NAME}' {if $ASSIGNED_USER eq $OWNER_ID} selected {/if}>{$OWNER_NAME}</option> - {/foreach} - </optgroup> - </select> - </div> + </td> + <td class="col-lg-4"></td> + </tr> + </tbody> + </table> </div> - </div> - {include file='ModalFooter.tpl'|@vtemplate_path:$QUALIFIED_MODULE} - </form> + {include file='ModalFooter.tpl'|@vtemplate_path:$QUALIFIED_MODULE} + </form> + </div> </div> {/strip} diff --git a/layouts/v7/modules/Settings/MailConverter/RulesList.tpl b/layouts/v7/modules/Settings/MailConverter/RulesList.tpl index cc8ea580207bf7a12c038294b3964ac066c999d5..2b26044f53a30a05be3fc66eb799e63fa503fb1e 100644 --- a/layouts/v7/modules/Settings/MailConverter/RulesList.tpl +++ b/layouts/v7/modules/Settings/MailConverter/RulesList.tpl @@ -1,12 +1,92 @@ -{*+********************************************************************************** - * The contents of this file are subject to the vtiger CRM Public License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * The Original Code is: vtiger CRM Open Source - * The Initial Developer of the Original Code is vtiger. - * Portions created by vtiger are Copyright (C) vtiger. - * All Rights Reserved. - ************************************************************************************} -{* modules/Settings/MailConverter/views/List.php *} - -{* START YOUR IMPLEMENTATION FROM BELOW. Use {debug} for information *} -<DIV>TEMPLATE: layout/modules/Settings/MailConverter/RulesList.tpl</DIV> +{*+********************************************************************************** +* The contents of this file are subject to the vtiger CRM Public License Version 1.1 +* ("License"); You may not use this file except in compliance with the License +* The Original Code is: vtiger CRM Open Source +* The Initial Developer of the Original Code is vtiger. +* Portions created by vtiger are Copyright (C) vtiger. +* All Rights Reserved. +************************************************************************************} + +{strip} + <div class="listViewContentDiv col-lg-12"> + <h4>{vtranslate($MODULE, $QUALIFIED_MODULE)}</h4> + <hr> + {if !$RECORD_EXISTS} + <div class="mailConveterDesc"> + <center><br><br> + <div>{vtranslate('LBL_MAILCONVERTER_DESCRIPTION', $QUALIFIED_MODULE)}</div> + <img src="{vimage_path('MailConverter.png')}" alt="Mail Converter"><br><br> + <a onclick="window.location.href='{$MODULE_MODEL->getCreateRecordUrl()}'" style="color: #15c !important;"><u class="cursorPointer" style="font-size:12pt;">{vtranslate('LBL_CREATE_MAILBOX_NOW', $QUALIFIED_MODULE)}</u></a> + <br><br> + </center> + </div> + {else} + <input type="hidden" id="scannerId" value="{$SCANNER_ID}"/> + <div class="col-lg-12"> + <div class="col-lg-4 mailBoxDropdownWrapper" style="padding-left: 0px;"> + <select class="mailBoxDropdown select2" style="max-width: 300px; min-width: 200px;"> + {foreach item=SCANNER from=$MAILBOXES} + <option value="{$SCANNER['scannerid']}" {if $SCANNER_ID eq $SCANNER['scannerid']}selected{/if}>{$SCANNER['scannername']}</option> + {/foreach} + </select> + </div> + <div class="col-lg-4" id="mailConverterStats"> + {if $CRON_RECORD_MODEL->isEnabled()} + {if $CRON_RECORD_MODEL->hadTimedout()} + {vtranslate('LBL_LAST_SCAN_TIMED_OUT', $QUALIFIED_MODULE_NAME)}. + {elseif $CRON_RECORD_MODEL->getLastEndDateTime() neq ''} + {vtranslate('LBL_LAST_SCAN_AT', $QUALIFIED_MODULE_NAME)} + {$CRON_RECORD_MODEL->getLastEndDateTime()} + <br /> + {vtranslate('LBL_FOLDERS_SCANNED', $QUALIFIED_MODULE_NAME)} : + {foreach from=$FOLDERS_SCANNED item=FOLDER}<strong>{$FOLDER} </strong>{/foreach} + {/if} + {/if} + </div> + <div class="col-lg-4" style="padding-right: 0px;"> + <div class="btn-group pull-right"> + <button class="btn btn-default addButton" id="addRuleButton" title="{vtranslate('LBL_DRAG_AND_DROP_BLOCK_TO_PRIORITISE_THE_RULE', $QUALIFIED_MODULE)}" + {if stripos($SCANNER_MODEL->getCreateRuleRecordUrl(), 'javascript:')===0} + onclick='{$SCANNER_MODEL->getCreateRuleRecordUrl()|substr:strlen("javascript:")}' + {else} + onclick='window.location.href="{$SCANNER_MODEL->getCreateRuleRecordUrl()}"' + {/if}> + <i class="fa fa-plus"></i> {vtranslate('LBL_ADD_RULE', $QUALIFIED_MODULE)} + </button> + <button href="javascript:void(0);" data-toggle="dropdown" class="btn btn-default" style="margin-left: 4px;"> + {vtranslate('LBL_ACTIONS', $QUALIFIED_MODULE_NAME)} <i class="caret"></i> + </button> + <ul class="dropdown-menu pull-right"> + {foreach item=LINK from=$RECORD->getRecordLinks()} + <li> + <a {if strpos($LINK->getUrl(), 'javascript:')===0} href='javascript:void(0);' onclick='{$LINK->getUrl()|substr:strlen("javascript:")};'{else}href={$LINK->getUrl()}{/if}> + {vtranslate($LINK->getLabel(), $QUALIFIED_MODULE)} + </a> + </li> + {/foreach} + </ul> + </div> + </div> + </div> + <br> + <div id="mailConverterBody" class="col-lg-12"> + <br> + <div id="rulesList"> + {if count($RULE_MODELS_LIST)} + {assign var=RULE_COUNT value=1} + {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFields()} + {foreach from=$RULE_MODELS_LIST item=RULE_MODEL} + <div class="row-fluid padding-bottom1per rule" data-id="{$RULE_MODEL->get('ruleid')}" data-blockid="block_{$RULE_MODEL->get('ruleid')}"> + {include file="Rule.tpl"|@vtemplate_path:$QUALIFIED_MODULE RULE_COUNT=$RULE_COUNT} + </div> + {assign var=RULE_COUNT value=$RULE_COUNT+1} + {/foreach} + {else} + <div class="details border1px" style="text-align: center; min-height: 200px; padding-top: 100px;"> + {vtranslate('LBL_NO_RULES', $QUALIFIED_MODULE)} + </div> + {/if} + </div> + </div> + {/if} +{/strip} diff --git a/layouts/v7/modules/Settings/MailConverter/Step1.tpl b/layouts/v7/modules/Settings/MailConverter/Step1.tpl index c2b8c893735b5a19229ad871c7f9408e8f71f3e3..cd06a1801de7c9287c58077450d5e9e906750823 100644 --- a/layouts/v7/modules/Settings/MailConverter/Step1.tpl +++ b/layouts/v7/modules/Settings/MailConverter/Step1.tpl @@ -30,11 +30,13 @@ {continue} {/if} <tr> - <td class="fieldLabel" style="width:20%;"><label>{vtranslate($FIELD_MODEL->get('label'),$QUALIFIED_MODULE)}</label></td> - <td class="fieldValue"> + <td class="fieldLabel control-label" style="width:25%;"> + <label>{vtranslate($FIELD_MODEL->get('label'), $QUALIFIED_MODULE)}{if $FIELD_MODEL->isMandatory()} <span class="redColor">*</span>{/if}</label> + </td> + <td style="word-wrap:break-word;"> {assign var=FIELD_DATA_TYPE value=$FIELD_MODEL->getFieldDataType()} {if $FIELD_DATA_TYPE eq 'password'} - <input class="inputElement" type="password" name="{$FIELD_MODEL->getName()}" {if $RECORD_EXISTS} value="{$RECORD_MODEL->get($FIELD_NAME)}" {/if} + <input class="fieldValue inputElement" type="password" name="{$FIELD_MODEL->getName()}" {if $RECORD_EXISTS} value="{$RECORD_MODEL->get($FIELD_NAME)}" {/if} {if $FIELD_MODEL->isMandatory()}data-validation-engine="validate[required]"{/if} /> {elseif $FIELD_DATA_TYPE eq 'boolean'} {assign var=RECORD_ID value=$RECORD_MODEL->getId()} @@ -46,7 +48,7 @@ {if $FIELD_MODEL->getName() eq 'time_zone' && empty($FIELD_VALUE)} {assign var=FIELD_VALUE value=" "} {/if} - <select name="{$FIELD_MODEL->getName()}" class="select2 inputElement" + <select name="{$FIELD_MODEL->getName()}" class="select2 fieldValue inputElement" {* to show dropdown above *} {if $FIELD_MODEL->getName() eq 'time_zone'} data-dropdownCssClass="select2-drop-above" @@ -55,7 +57,7 @@ {if $FIELD_MODEL->getName() eq 'time_zone'} {* since in time zone its array of value and key, since there will mutiple areas with same time_zone *} {foreach item=PICKLIST_VALUE key=PICKLIST_KEY from=$PICKLIST_VALUES} - <option value="{$PICKLIST_KEY}" {if $FIELD_VALUE eq $PICKLIST_KEY} selected {/if} >{vtranslate($PICKLIST_VALUE,$QUALIFIED_MODULE)}</option> + <option value="{$PICKLIST_KEY}" {if $FIELD_VALUE eq $PICKLIST_KEY} selected {/if} >{vtranslate($PICKLIST_VALUE, $QUALIFIED_MODULE)}</option> {/foreach} {else} {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} @@ -77,7 +79,7 @@ </label> {/foreach} {else} - <input type="text" class="inputElement" name="{$FIELD_MODEL->getName()}" {if $FIELD_MODEL->isMandatory()}data-validation-engine="validate[required]"{/if} value="{$RECORD_MODEL->get($FIELD_NAME)}"/> + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" {if $FIELD_MODEL->isMandatory()}data-validation-engine="validate[required]"{/if} value="{$RECORD_MODEL->get($FIELD_NAME)}"/> {/if} </td> </tr> diff --git a/layouts/v7/modules/Settings/MailConverter/Step2.tpl b/layouts/v7/modules/Settings/MailConverter/Step2.tpl index aadb8ac97c40ecacc2bafb0bd00742e75e29fea1..253e6d1384a2734042101cec5b557b135aac3db2 100644 --- a/layouts/v7/modules/Settings/MailConverter/Step2.tpl +++ b/layouts/v7/modules/Settings/MailConverter/Step2.tpl @@ -14,7 +14,7 @@ {if $IMAP_ERROR} {$IMAP_ERROR} {else if $CONNECTION_ERROR} - {vtranslate('LBL_CONNECTION_ERROR',$QUALIFIED_MODULE)} + {vtranslate('LBL_CONNECTION_ERROR', $QUALIFIED_MODULE)} {/if} </strong> </div> @@ -22,17 +22,19 @@ {/if} <div class="addMailBoxBlock"> <div class="row col-lg-12 padding-bottom1per"> - <div id="mailConverterDragIcon"><i class="icon-info-sign"></i> {vtranslate('TO_CHANGE_THE_FOLDER_SELECTION_DESELECT_ANY_OF_THE_SELECTED_FOLDERS',$QUALIFIED_MODULE)}</div> + <div id="mailConverterDragIcon"><i class="icon-info-sign"></i> {vtranslate('TO_CHANGE_THE_FOLDER_SELECTION_DESELECT_ANY_OF_THE_SELECTED_FOLDERS', $QUALIFIED_MODULE)}</div> </div> <br> <br> <form class="form-horizontal" id="mailBoxEditView" name="step2"> <div class="block"> - <div class="addMailBoxStep row"> + <div class="addMailBoxStep row" style="margin-top: 10px; margin-bottom: 10px;"> {foreach key=FOLDER item=SELECTED from=$FOLDERS} <div class="col-lg-3"> - <input type="checkbox" name="folders" value="{$FOLDER}" {if $SELECTED eq 'checked'}checked{/if}> - {$FOLDER} + <label> + <input type="checkbox" name="folders" value="{$FOLDER}" {if $SELECTED eq 'checked'}checked{/if}> + <span> {$FOLDER}</span> + </label> </div> {/foreach} </div> diff --git a/layouts/v7/modules/Settings/MailConverter/Step3.tpl b/layouts/v7/modules/Settings/MailConverter/Step3.tpl index 277d1c88c2d44794efec7553989585d884aa0b46..b8a82992a118fec9403e9306191a7aecfed2d0d8 100644 --- a/layouts/v7/modules/Settings/MailConverter/Step3.tpl +++ b/layouts/v7/modules/Settings/MailConverter/Step3.tpl @@ -19,33 +19,33 @@ <div class="row"> <table class="table editview-table no-border"> <tbody> - {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFiels()} + {assign var=FIELDS value=$MODULE_MODEL->getSetupRuleFields()} {foreach key=FIELD_NAME item=FIELD_MODEL from=$FIELDS} <tr> - <td class="fieldLabel" style="width:20%;"><label>{vtranslate($FIELD_MODEL->get('label'),$QUALIFIED_MODULE)}</label></td> - <td class="fieldValue"> + <td class="fieldLabel control-label" style="width:25%; padding-right:20px;"><label>{vtranslate($FIELD_MODEL->get('label'), $QUALIFIED_MODULE)}</label> + <td style="word-wrap:break-word;"> {assign var=FIELD_DATA_TYPE value=$FIELD_MODEL->getFieldDataType()} {if $FIELD_DATA_TYPE eq 'picklist'} {assign var=PICKLIST_VALUES value=$FIELD_MODEL->getPickListValues()} {if $FIELD_NAME eq 'subject'} - <select name="subjectop" class="select2 inputElement"> - <option value="">{vtranslate('LBL_SELECT_OPTION',$QUALIFIED_MODULE)}</option> + <select name="subjectop" class="select2 fieldValue inputElement"> + <option value="">{vtranslate('LBL_SELECT_OPTION', $QUALIFIED_MODULE)}</option> {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('subjectop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> {/foreach} </select> - <input type="text" class="inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" style="margin-left: 10px;" /> + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" style="margin-left: 10px;" /> {elseif $FIELD_NAME eq 'body'} - <select name="bodyop" class="select2 inputElement"> - <option value="" {if $RECORD_MODEL->get('bodyop') eq ""}selected{/if}>{vtranslate('LBL_SELECT_OPTION',$QUALIFIED_MODULE)}</option> + <select name="bodyop" class="select2 fieldValue inputElement"> + <option value="" {if $RECORD_MODEL->get('bodyop') eq ""}selected{/if}>{vtranslate('LBL_SELECT_OPTION', $QUALIFIED_MODULE)}</option> {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get('bodyop') eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> {/foreach} - </select> + </select> <br><br> - <textarea name="{$FIELD_MODEL->getName()}" class="boxSizingBorderBox inputElement" style="width:416px;padding: 3px 8px;">{$RECORD_MODEL->get($FIELD_NAME)}</textarea> + <textarea name="{$FIELD_MODEL->getName()}" class="boxSizingBorderBox fieldValue inputElement" style="width:416px;padding: 3px 8px;">{$RECORD_MODEL->get($FIELD_NAME)}</textarea> {else} - <select id="actions" name="action1" class="select2 inputElement" style="min-width:220px"> + <select id="actions" name="action1" class="select2 fieldValue inputElement" style="min-width:220px"> {foreach key=PICKLIST_KEY item=PICKLIST_VALUE from=$PICKLIST_VALUES} <option value="{$PICKLIST_KEY}" {if $RECORD_MODEL->get($FIELD_NAME) eq $PICKLIST_KEY} selected {/if} >{$PICKLIST_VALUE}</option> {/foreach} @@ -60,17 +60,17 @@ </label> {/foreach} {elseif $FIELD_DATA_TYPE eq 'email'} - <input type="text" class="inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" data-validation-engine="validate[funcCall[Vtiger_Email_Validator_Js.invokeValidation]]"/> + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}" data-validation-engine="validate[funcCall[Vtiger_Email_Validator_Js.invokeValidation]]"/> {else} - <input type="text" class="inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}"/> + <input type="text" class="fieldValue inputElement" name="{$FIELD_MODEL->getName()}" value="{$RECORD_MODEL->get($FIELD_NAME)}"/> {/if} </td> </tr> {/foreach} - <tr> - <td class="fieldLabel" style="width:20%;"><label>{vtranslate('Assigned To')}</label></td> - <td class="fieldValue"> - <select class="select2 inputElement" id="assignedTo" name="assignedTo"> + <tr id="assignedToBlock"> + <td class="fieldLabel control-label" style="width:25%; padding-right:20px;"><label>{vtranslate('Assigned To')}</label></td> + <td style="word-wrap:break-word;"> + <select class="select2 fieldValue inputElement" id="assignedTo" name="assignedTo"> <optgroup label="{vtranslate('LBL_USERS')}"> {assign var=USERS value=$USER_MODEL->getAccessibleUsersForModule($MODULE_NAME)} {foreach key=OWNER_ID item=OWNER_NAME from=$USERS} diff --git a/layouts/v7/modules/Settings/MailConverter/resources/Edit.js b/layouts/v7/modules/Settings/MailConverter/resources/Edit.js new file mode 100644 index 0000000000000000000000000000000000000000..3cdceff84309df42eadf7e439e0696cf76c631fd --- /dev/null +++ b/layouts/v7/modules/Settings/MailConverter/resources/Edit.js @@ -0,0 +1,135 @@ +/*+********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.0 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + ************************************************************************************/ + +Vtiger.Class('Settings_MailConverter_Edit_Js', { + firstStep: function (e) { + var form = jQuery('#mailBoxEditView'); + var params = { + submitHandler: function (form) { + var form = jQuery(form); + form.find('[name="saveButton"]').attr('disabled', 'disabled'); + Settings_MailConverter_Edit_Js.saveMailBox(form); + } + } + form.vtValidate(params); + + form.submit(function (e) { + e.preventDefault(); + }); + }, + + saveMailBox: function (form) { + var params = form.serializeFormData(); + params.scannername = jQuery('input[name="scannername"]').val(); + params.module = app.getModuleName(); + params.parent = app.getParentModuleName(); + params.action = 'SaveMailBox'; + + app.helper.showProgress(); + app.request.post({'data': params}).then(function (err, data) { + app.helper.hideProgress(); + if (typeof data != 'undefined') { + var create = jQuery("#create").val(); + window.location.href = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=Edit&mode=step2&create='+create+'&record='+data.id; + } else { + app.helper.showErrorNotification({'message': err['message']}); + } + }); + }, + + secondStep: function (e) { + var form = jQuery('#mailBoxEditView'); + var params = { + submitHandler: function (form) { + var form = jQuery(form); + var checked = jQuery('input[type=checkbox][name=folders]:checked').length; + if (checked < 1) { + app.helper.showAlertNotification({'message': app.vtranslate('JS_SELECT_ONE_FOLDER')}); + return false; + } else { + form.find('[name="saveButton"]').attr('disabled', 'disabled'); + var selectedFolders = jQuery('input[name=folders]:checked').map(function () { + return jQuery(this).val(); + }).get(); + Settings_MailConverter_Edit_Js.saveFolders(selectedFolders); + } + } + } + form.vtValidate(params); + + form.submit(function (e) { + e.preventDefault(); + }); + }, + + saveFolders: function (selectedFolders) { + var create = jQuery('#create').val(); + var id = jQuery('#recordId').val(); + var url = 'module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&action=SaveFolders&folders='+selectedFolders+'&create='+create+'&record='+id; + + app.helper.showProgress(); + app.request.post({'url': url}).then(function (err, data) { + app.helper.hideProgress(); + if (typeof data != 'undefined') { + var fallbackUrl = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=List&record='+data.id; + if (create == 'new') { + fallbackUrl = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=Edit&mode=step3&create='+create+'&record='+data.id; + } + window.location.href = fallbackUrl; + } else { + app.helper.showErrorNotification({'message': err['message']}); + } + }); + }, + + thirdStep: function (e) { + var form = jQuery('#ruleSave'); + var params = { + submitHandler: function (form) { + var form = jQuery(form); + form.find('[name="saveButton"]').attr('disabled', 'disabled'); + Settings_MailConverter_Edit_Js.saveRule(form); + } + } + form.vtValidate(params); + + form.submit(function (e) { + e.preventDefault(); + }); + }, + + saveRule: function (form) { + app.helper.showProgress(); + var params = form.serializeFormData(); + params.record = ''; + app.request.post({'data': params}).then(function (err, data) { + app.helper.hideProgress(); + if (typeof data != 'undefined') { + window.location.href = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=List&record='+data.scannerId; + } else { + app.helper.showErrorNotification({'message': err['message']}); + } + }); + }, + + /* + * Function to activate the header based on the class + * @params class name + */ + activateHeader: function () { + var step = jQuery('#step').val(); + jQuery('#'+step).addClass('active'); + } + +},{ + registerEvents: function () { + Settings_MailConverter_Edit_Js.firstStep(); + Settings_MailConverter_Edit_Js.activateHeader(); + } +}); \ No newline at end of file diff --git a/layouts/v7/modules/Settings/MailConverter/resources/List.js b/layouts/v7/modules/Settings/MailConverter/resources/List.js new file mode 100644 index 0000000000000000000000000000000000000000..974be236f9a9efa11846e3c50f8a75d1b528bdb1 --- /dev/null +++ b/layouts/v7/modules/Settings/MailConverter/resources/List.js @@ -0,0 +1,74 @@ +/*+********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.0 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + ************************************************************************************/ + +Settings_Vtiger_Index_Js('Settings_MailConverter_List_Js', { + + checkMailBoxMaxLimit: function (url) { + app.request.post({'url': url}).then(function (err, data) { + if (typeof response.result != 'undefined') { + window.location.href = 'index.php?module='+app.getModuleName()+'&parent='+app.getParentModuleName()+'&view=Edit&mode=step1&create=new'; + } else { + app.helper.showErrorNotification({'message': err['message']}); + } + }); + }, + + triggerScan: function (url) { + app.helper.showProgress(); + app.request.post({'url': url}).then(function (err, data) { + app.helper.hideProgress(); + if (typeof data != 'undefined') { + app.helper.showSuccessNotification({'message': data.message}); + } else { + app.helper.showErrorNotification({'message': err['message']}); + } + }); + }, + + triggerDelete: function (url) { + app.helper.showConfirmationBox({'message': app.vtranslate('LBL_DELETE_CONFIRMATION')}).then(function () { + app.helper.showProgress(); + app.request.post({'url': url}).then(function (err, data) { + jQuery('#SCANNER_'+data.id).remove(); + var url = window.location.href; + var url1 = url.split('&'); + var path = url1[0]+'&'+url1[1]+'&'+url1[2]; + app.helper.showSuccessNotification({'message': app.vtranslate('JS_MAILBOX_DELETED_SUCCESSFULLY')}); + app.helper.hideProgress(); + window.location.assign(path); + }); + }); + }, + + loadMailBox: function (params) { + params.module = app.getModuleName(); + params.parent = app.getParentModuleName(); + params.view = 'ListAjax'; + params.mode = 'getMailBoxContentView' + + app.helper.showProgress(); + app.request.post({'data': params}).then(function (err, html) { + app.helper.hideProgress(); + var scannerContentdId = 'SCANNER_'+params.record; + if (jQuery('#'+scannerContentdId).length > 0) { + jQuery('#'+scannerContentdId).html(html) + } else { + jQuery('#listViewContents').append('<br>'+html); + } + app.helper.showSuccessNotification({'message': app.vtranslate('JS_MAILBOX_LOADED_SUCCESSFULLY')}); + if (typeof params.listViewUrl != 'undefined') { + var path = params.listViewUrl+'&record='+params.record; + window.location.assign(path); + } + }); + } +}, { + registerEvents: function () { + } +}) \ No newline at end of file diff --git a/layouts/v7/modules/Settings/MailConverter/resources/MailConverter.js b/layouts/v7/modules/Settings/MailConverter/resources/MailConverter.js new file mode 100644 index 0000000000000000000000000000000000000000..38bc5d2477ab79ee568c01f7f233b09d394652ef --- /dev/null +++ b/layouts/v7/modules/Settings/MailConverter/resources/MailConverter.js @@ -0,0 +1,185 @@ +/*+*********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.0 + * ('License'); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + *************************************************************************************/ + +jQuery.Class('Settings_MailConverter_Index_Js', { + mailConverterInstance: false, + triggerRuleEdit: function (url) { + app.request.get({url:url}).then(function (err, data) { + var callBackFunction = function (data) { + var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance; + app.helper.showVerticalScroll(jQuery('.addMailBoxStep'), {setHeight:'450px'}); + mcInstance.saveRuleEvent(); + mcInstance.setAssignedTo(); + jQuery('#actions').trigger('change'); + } + app.helper.showModal(data, {cb:callBackFunction}); + }); + }, + + triggerDeleteRule: function (currentElement, url) { + var deleteElement = jQuery(currentElement); + app.helper.showConfirmationBox({'message': app.vtranslate('LBL_DELETE_CONFIRMATION')}).then(function () { + app.request.get({url:url}).then(function (err, data) { + if (data) { + var closestBlock = deleteElement.closest('[data-blockid]'); + var nextBlocks = closestBlock.nextAll('[data-blockid]'); + + if (nextBlocks.length > 0) { + jQuery.each(nextBlocks, function (i, element) { + var currentSequenceElement = jQuery(element).find('.sequenceNumber'); + var updatedNumber = parseInt(currentSequenceElement.text()) - 1; + currentSequenceElement.text(updatedNumber); + }); + } + + closestBlock.remove(); + app.helper.showSuccessNotification({'message':data}); + } + }); + }); + } +}, { + registerSortableEvent: function () { + var thisInstance = this; + var sequenceList = {}; + var container = jQuery('#rulesList'); + container.sortable({ + revert : true, + handle : '.ruleHead', + start : function (event, ui) { + ui.placeholder.height(ui.helper.height()); + }, + update : function (e, ui) { + jQuery('[data-blockid]', container).each(function (i) { + sequenceList[++i] = jQuery(this).data('id'); + }); + + var params = { + sequencesList : JSON.stringify(sequenceList), + module : app.getModuleName(), + parent : app.getParentModuleName(), + action : 'UpdateSequence', + scannerId : jQuery('#scannerId').val() + } + + app.request.post({data:params}).then(function (err, data) { + if (typeof data != 'undefined') { + jQuery('[data-blockid]', container).each(function (i) { + jQuery(this).find('.sequenceNumber').text(++i); + }); + + app.helper.hideModal(); + app.helper.showSuccessNotification({'message':data}); + } + }); + } + }); + }, + + saveRuleEvent: function () { + var thisInstance = this; + var form = jQuery('#ruleSave'); + var params = { + submitHandler: function (form) { + var form = jQuery(form); + form.find('[name="saveButton"]').attr('disabled', 'disabled'); + app.helper.showProgress(); + var params = form.serializeFormData(); + app.request.post({data:params}).then(function (err, data) { + app.helper.hideProgress(); + app.helper.hideModal(); + if (typeof data != 'undefined') { + var params = { + module: app.getModuleName(), + parent: app.getParentModuleName(), + scannerId: jQuery('[name="scannerId"]', form).val(), + record: data.id, + view: 'RuleAjax' + } + thisInstance.getRule(params); + app.helper.showSuccessNotification({'message':data.message}); + } + }); + } + } + form.vtValidate(params); + + form.submit(function (e) { + e.preventDefault(); + }); + }, + + getRule: function (params) { + app.helper.showProgress(); + var ruleId = params.record; + app.request.get({data:params}).then(function (err, data) { + app.helper.hideProgress(); + var currentBlock = jQuery('[data-blockid="block_'+ruleId+'"]') + if (currentBlock.length > 0) { + var previousValue = currentBlock.prevAll('[data-blockid]').first().find('.sequenceNumber').text(); + if (previousValue == '') { + previousValue = 0; + } + currentBlock.html(data); + currentBlock.find('.sequenceNumber').text(parseInt(previousValue)+1) + } else { + var lastBlockValue = jQuery('[data-blockid]').size(); + jQuery('#rulesList').append('<div class="row-fluid padding-bottom1per" data-blockid="block_'+ruleId+'">'+data+'</div>'); + jQuery('[data-blockid="block_'+ruleId+'"]').find('.sequenceNumber').text(parseInt(lastBlockValue)+1); + } + }); + }, + + setAssignedTo: function () { + jQuery('#actions').on('change', function () { + var selectedAction = jQuery('#actions').val(); + if (!(selectedAction == 'CREATE_HelpDesk_FROM' + || selectedAction == 'CREATE_Leads_SUBJECT' + || selectedAction == 'CREATE_Contacts_SUBJECT' + || selectedAction == 'CREATE_Accounts_SUBJECT')) { + jQuery('#assignedTo').val(''); + jQuery('#assignedToBlock').hide(); + } else { + jQuery('#assignedToBlock').show(); + } + }); + }, + + openMailBox: function () { + jQuery('.mailBoxDropdown').change(function () { + var id = jQuery('.mailBoxDropdown option:selected').val(); + var path = 'index.php?parent='+app.getParentModuleName()+'&module='+app.getModuleName()+'&view=List&record='+id; + window.location.assign(path); + }); + }, + + disableFolderSelection: function () { + var checked = jQuery('input[type=checkbox][name=folders]:checked').length >= 2; + jQuery('input[type=checkbox][name=folders]').not(':checked').attr('disabled', checked); + + jQuery('input[type=checkbox][name=folders]').click(function () { + var checked = jQuery('input[type=checkbox][name=folders]:checked').length >= 2; + jQuery('input[type=checkbox][name=folders]').not(':checked').attr('disabled', checked); + }); + }, + + registerEvents: function () { + this.registerSortableEvent(); + this.openMailBox(); + this.setAssignedTo(); + this.disableFolderSelection(); + jQuery('#actions').trigger('change'); + } +}); + +//On Page Load +jQuery(document).ready(function () { + var mcInstance = Settings_MailConverter_Index_Js.mailConverterInstance = new Settings_MailConverter_Index_Js(); + mcInstance.registerEvents(); +}); \ No newline at end of file diff --git a/layouts/v7/modules/Settings/ModuleManager/ImportUserModuleStep2.tpl b/layouts/v7/modules/Settings/ModuleManager/ImportUserModuleStep2.tpl index 3aced8c87db433ea5bbad53817ac32b230393468..863db51d343bf7d023c8a79f5e60b41a4fd5959e 100644 --- a/layouts/v7/modules/Settings/ModuleManager/ImportUserModuleStep2.tpl +++ b/layouts/v7/modules/Settings/ModuleManager/ImportUserModuleStep2.tpl @@ -31,72 +31,60 @@ </div> <input type="hidden" name="view" value="List"> {else} - <div class="row" style="margin-top: 2%"> + <div class="col-lg-12"> <div> <h3>{vtranslate('LBL_VERIFY_IMPORT_DETAILS',$QUALIFIED_MODULE)}</h3> </div><hr> </div> <div class="container-fluid"><br> - <div class="row"> - <div class="col-lg-12"> - <h4> - {vtranslate($MODULEIMPORT_NAME, $QUALIFIED_MODULE)} - {if $MODULEIMPORT_EXISTS eq 'true'} <font color=red><b>{vtranslate('LBL_EXISTS', $QUALIFIED_MODULE)}</b></font> {/if} - </h4> - </div> + <div class="col-lg-12"> + <h4> + {vtranslate($MODULEIMPORT_NAME, $QUALIFIED_MODULE)} + {if $MODULEIMPORT_EXISTS eq 'true'} <font color=red><b>{vtranslate('LBL_EXISTS', $QUALIFIED_MODULE)}</b></font> {/if} + </h4> </div> - <div class="row"> - <div class="col-lg-12"> - <p> - <small>{vtranslate('LBL_REQ_VTIGER_VERSION', $QUALIFIED_MODULE)} : {$MODULEIMPORT_DEP_VTVERSION}</small> - </p> - </div> + <div class="col-lg-12"> + <p> + <small>{vtranslate('LBL_REQ_VTIGER_VERSION', $QUALIFIED_MODULE)} : {$MODULEIMPORT_DEP_VTVERSION}</small> + </p> </div> {assign var="need_license_agreement" value="false"} {if $MODULEIMPORT_LICENSE} {assign var="need_license_agreement" value="true"} - <div class="row"> - <div class="col-lg-12"> - <p>{vtranslate('LBL_LICENSE', $QUALIFIED_MODULE)}</p> - </div> + <div class="col-lg-12"> + <p>{vtranslate('LBL_LICENSE', $QUALIFIED_MODULE)}</p> </div> - <div class="row"> - <div class="col-lg-12"> - <div style="background: #eee;padding: 20px;box-sizing: border-box;height: 150px;overflow-y: scroll;"> - <p>{$MODULEIMPORT_LICENSE|nl2br}</p> - </div> + <div class="col-lg-12"> + <div style="background: #eee;padding: 20px;box-sizing: border-box;height: 150px;overflow-y: scroll;"> + <p>{$MODULEIMPORT_LICENSE|nl2br}</p> </div> </div> {/if} <br> - <div class="row"> - <div class="col-lg-4"> - {if $MODULEIMPORT_EXISTS neq 'true'} - <input type="checkbox" class="acceptLicense"> {vtranslate('LBL_LICENSE_ACCEPT_AGREEMENT', $QUALIFIED_MODULE)} - {/if} - </div> - <div class="col-lg-8"> - <span class="pull-right"> - <div class="row"> - {if $MODULEIMPORT_EXISTS eq 'true' || $MODULEIMPORT_DIR_EXISTS eq 'true'} - <div class="col-lg-2"></div> - <div class="col-lg-10"> - {if $MODULEIMPORT_EXISTS eq 'true'} - <input type="hidden" name="module_import_file" value="{$MODULEIMPORT_FILE}"> - <input type="hidden" name="module_import_type" value="{$MODULEIMPORT_TYPE}"> - <input type="hidden" name="module_import_name" value="{$MODULEIMPORT_NAME}"> - {else} - <p class="alert-info">{vtranslate('LBL_DELETE_EXIST_DIRECTORY', $QUALIFIED_MODULE)}</p> - {/if} - </div> - {else} - <input type="hidden" name="module_import_file" value="{$MODULEIMPORT_FILE}"> - <input type="hidden" name="module_import_type" value="{$MODULEIMPORT_TYPE}"> - <input type="hidden" name="module_import_name" value="{$MODULEIMPORT_NAME}"> - {/if} - </div> - </span> - </div> + <div class="col-lg-12"> + {if $MODULEIMPORT_EXISTS neq 'true'} + <input type="checkbox" class="acceptLicense"> {vtranslate('LBL_LICENSE_ACCEPT_AGREEMENT', $QUALIFIED_MODULE)} + {/if} + <span class="pull-right"> + <div class="row"> + {if $MODULEIMPORT_EXISTS eq 'true' || $MODULEIMPORT_DIR_EXISTS eq 'true'} + <div class="col-lg-2"></div> + <div class="col-lg-10"> + {if $MODULEIMPORT_EXISTS eq 'true'} + <input type="hidden" name="module_import_file" value="{$MODULEIMPORT_FILE}"> + <input type="hidden" name="module_import_type" value="{$MODULEIMPORT_TYPE}"> + <input type="hidden" name="module_import_name" value="{$MODULEIMPORT_NAME}"> + {else} + <p class="alert-info">{vtranslate('LBL_DELETE_EXIST_DIRECTORY', $QUALIFIED_MODULE)}</p> + {/if} + </div> + {else} + <input type="hidden" name="module_import_file" value="{$MODULEIMPORT_FILE}"> + <input type="hidden" name="module_import_type" value="{$MODULEIMPORT_TYPE}"> + <input type="hidden" name="module_import_name" value="{$MODULEIMPORT_NAME}"> + {/if} + </div> + </span> </div> </div> <br><br> diff --git a/layouts/v7/skins/images/MailConverter.png b/layouts/v7/skins/images/MailConverter.png new file mode 100644 index 0000000000000000000000000000000000000000..d2885be255ccffcedf17195e079e5e9490e1fff1 Binary files /dev/null and b/layouts/v7/skins/images/MailConverter.png differ diff --git a/layouts/v7/skins/images/white-drag.png b/layouts/v7/skins/images/white-drag.png new file mode 100644 index 0000000000000000000000000000000000000000..c435d33c1721ac42a657821b29aefb55cbae2b95 Binary files /dev/null and b/layouts/v7/skins/images/white-drag.png differ diff --git a/modules/Emails/models/Mailer.php b/modules/Emails/models/Mailer.php index bd8f97ac048c80cf2543fa298132205bf567e68f..e2e7c72a1cb32a81c9b082843cf5c974e2af6610 100644 --- a/modules/Emails/models/Mailer.php +++ b/modules/Emails/models/Mailer.php @@ -63,7 +63,7 @@ class Emails_Mailer_Model extends Vtiger_Mailer { public static function retrieveMessageIdFromMailroom($crmId) { $db = PearDatabase::getInstance(); - $result = $db->pquery('SELECT messageid FROM vtiger_message_ids WHERE crmid=?', array($crmId)); + $result = $db->pquery('SELECT messageid FROM vtiger_mailscanner_ids WHERE crmid=?', array($crmId)); return $db->query_result($result, 'messageid', 0); } @@ -85,7 +85,7 @@ class Emails_Mailer_Model extends Vtiger_Mailer { $db = PearDatabase::getInstance(); $existingResult = array(); //Get existing refids for a given crm id and update new refids to the crmid - $existingResultObject = $db->pquery("SELECT refids FROM vtiger_message_ids WHERE crmid=? AND refids != 'null'", array($crmId)); + $existingResultObject = $db->pquery("SELECT refids FROM vtiger_mailscanner_ids WHERE crmid=? AND refids != 'null'", array($crmId)); $num_rows = $db->num_rows($existingResultObject); if ($num_rows > 0) { $existingResult = json_decode($db->query_result($existingResultObject, 'refids', 0), true); @@ -93,10 +93,10 @@ class Emails_Mailer_Model extends Vtiger_Mailer { if (is_array($existingResult)) { $existingResultValue = array_merge($existingResult, array($messageId)); $refIds = json_encode($existingResultValue); - $db->pquery("UPDATE vtiger_message_ids SET refids=? WHERE crmid=? ", array($refIds, $crmId)); + $db->pquery("UPDATE vtiger_mailscanner_ids SET refids=? WHERE crmid=? ", array($refIds, $crmId)); } } else { - $db->pquery("INSERT INTO vtiger_message_ids (messageid, crmid) VALUES(?,?)", array($messageId, $crmId)); + $db->pquery("INSERT INTO vtiger_mailscanner_ids (messageid, crmid) VALUES(?,?)", array($messageId, $crmId)); } } diff --git a/modules/Install/views/Index.php b/modules/Install/views/Index.php index 7429a2d19ad423a82eea51781953d602b0986d80..30987167ef71a94473fc83300dd59c568b079c97 100644 --- a/modules/Install/views/Index.php +++ b/modules/Install/views/Index.php @@ -232,7 +232,9 @@ class Install_Index_view extends Vtiger_View_Controller { public function getHeaderScripts(Vtiger_Request $request) { $moduleName = $request->getModule(); $parentScripts = parent::getHeaderScripts($request); - $jsFileNames = array("modules.$moduleName.resources.Index"); + $jsFileNames = array("modules.Vtiger.resources.List", + "modules.Vtiger.resources.Popup", + "modules.$moduleName.resources.Index"); $jsScriptInstances = $this->checkAndConvertJsScripts($jsFileNames); $headerScriptInstances = array_merge($parentScripts, $jsScriptInstances); return $headerScriptInstances; diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php index 0d2b26b1b80717ef26cbc462607b4c67b5e9543b..cd7888329d3261417fa8a53d61bc9bdc8bacbc5e 100644 --- a/modules/Migration/schema/660_to_700.php +++ b/modules/Migration/schema/660_to_700.php @@ -324,6 +324,11 @@ if(defined('VTIGER_UPGRADE')) { $folderModel->save(); } + $columns = $db->getColumnNames('vtiger_schedulereports'); + if (!in_array('fileformat', $columns)) { + $db->pquery('ALTER TABLE vtiger_schedulereports ADD COLUMN fileformat VARCHAR(10) DEFAULT "CSV"', array()); + } + $modCommentsInstance = Vtiger_Module_Model::getInstance('ModComments'); $modCommentsTabId = $modCommentsInstance->getId(); @@ -692,7 +697,7 @@ if(defined('VTIGER_UPGRADE')) { } $columns = $db->getColumnNames('vtiger_customerportal_relatedmoduleinfo'); - if (!in_array('module', $columns)) { + if (in_array('module', $columns)) { $db->pquery('ALTER TABLE vtiger_customerportal_relatedmoduleinfo CHANGE module tabid INT(19)', array()); $db->pquery('ALTER TABLE vtiger_customerportal_relatedmoduleinfo ADD PRIMARY KEY(tabid)', array()); $db->pquery('ALTER TABLE vtiger_customerportal_fields ADD PRIMARY KEY(tabid)', array()); @@ -1832,10 +1837,14 @@ if(defined('VTIGER_UPGRADE')) { } } + $columns = $db->getColumnNames('vtiger_mailscanner'); + if (!in_array('scanfrom', $columns)) { + $db->pquery('ALTER TABLE vtiger_mailscanner ADD COLUMN scanfrom VARCHAR(10) DEFAULT "ALL"', array()); + } + if (Vtiger_Utils::CheckTable('vtiger_mailscanner_ids')) { - $db->pquery('RENAME TABLE vtiger_mailscanner_ids TO vtiger_message_ids', array()); - $db->pquery('ALTER TABLE vtiger_message_ids ADD COLUMN refids MEDIUMTEXT', array()); - $db->pquery('ALTER TABLE vtiger_message_ids ADD INDEX messageids_crmid_idx(crmid)',array()); + $db->pquery('ALTER TABLE vtiger_mailscanner_ids ADD COLUMN refids MEDIUMTEXT', array()); + $db->pquery('ALTER TABLE vtiger_mailscanner_ids ADD INDEX messageids_crmid_idx(crmid)',array()); } //Migrating data missed in vtiger_settings_field from file to database. diff --git a/modules/Settings/MailConverter/actions/SaveFolders.php b/modules/Settings/MailConverter/actions/SaveFolders.php index 4709877860d60d74e4eff6c9ac18f50d61a688f8..68a9a653a665d16e1de104a58baf43e1c80caa00 100755 --- a/modules/Settings/MailConverter/actions/SaveFolders.php +++ b/modules/Settings/MailConverter/actions/SaveFolders.php @@ -11,20 +11,20 @@ class Settings_MailConverter_SaveFolders_Action extends Settings_Vtiger_Index_Action { public function process(Vtiger_Request $request) { - $recordId = $request->get('record'); - $qualifiedModuleName = $request->getModule(false); - $checkedFolders = $request->get('folders'); - $folders = explode(',', $checkedFolders); - Settings_MailConverter_Module_Model::updateFolders($recordId, $folders); + $recordId = $request->get('record'); + $qualifiedModuleName = $request->getModule(false); + $checkedFolders = $request->get('folders'); + $folders = explode(',', $checkedFolders); + Settings_MailConverter_Module_Model::updateFolders($recordId, $folders); - $response = new Vtiger_Response(); + $response = new Vtiger_Response(); - $result = array('message' => vtranslate('LBL_SAVED_SUCCESSFULLY', $qualifiedModuleName)); - $result['id'] = $recordId; - $response->setResult($result); + $result = array('message' => vtranslate('LBL_SAVED_SUCCESSFULLY', $qualifiedModuleName)); + $result['id'] = $recordId; + $response->setResult($result); - $response->emit(); - } + $response->emit(); + } } diff --git a/modules/Settings/MailConverter/actions/ScanNow.php b/modules/Settings/MailConverter/actions/ScanNow.php index a61fe2ddfc04f5fc7da0a07e3539befdc6cd4f26..d52902309a776c398a0f45a6f5d30374387b9b64 100644 --- a/modules/Settings/MailConverter/actions/ScanNow.php +++ b/modules/Settings/MailConverter/actions/ScanNow.php @@ -29,12 +29,12 @@ class Settings_MailConverter_ScanNow_Action extends Settings_Vtiger_Index_Action $response = new Vtiger_Response(); if (is_bool($status) && $status) { $result = array('message'=> vtranslate('LBL_SCANNED_SUCCESSFULLY', $qualifiedModuleName)); - $result['id'] = $recordModel->getId(); + $result['id'] = $recordModel->getId(); $response->setResult($result); - } else if($status) { - $response->setError($status); - } else { - $response->setError(vtranslate($request->getModule(), $qualifiedModuleName). ' ' .vtranslate('LBL_IS_IN_RUNNING_STATE', $qualifiedModuleName)); + } else if ($status) { + $response->setError($status); + } else { + $response->setError(vtranslate($request->getModule(), $qualifiedModuleName).' '.vtranslate('LBL_IS_IN_RUNNING_STATE', $qualifiedModuleName)); } $response->emit(); } diff --git a/modules/Settings/MailConverter/handlers/MailScannerAction.php b/modules/Settings/MailConverter/handlers/MailScannerAction.php index 459ff9b33bbcf3ce721eb25f7d9ee6c90e247c26..3e11d5435cab8945e0108976ec9946913cd1300d 100644 --- a/modules/Settings/MailConverter/handlers/MailScannerAction.php +++ b/modules/Settings/MailConverter/handlers/MailScannerAction.php @@ -1,13 +1,12 @@ <?php -/********************************************************************************* - ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 +/* +********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.1 * ("License"); You may not use this file except in compliance with the License - * The Original Code is: vtiger CRM Open Source + * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. - * - ********************************************************************************/ + * ***********************************************************************************/ require_once('modules/Emails/Emails.php'); require_once('modules/HelpDesk/HelpDesk.php'); @@ -23,23 +22,23 @@ require_once ('modules/Accounts/Accounts.php'); */ class Vtiger_MailScannerAction { // actionid for this instance - var $actionid = false; + var $actionid = false; // scanner to which this action is associated - var $scannerid = false; + var $scannerid = false; // type of mailscanner action - var $actiontype= false; + var $actiontype = false; // text representation of action - var $actiontext= false; + var $actiontext = false; // target module for action - var $module = false; + var $module = false; // lookup information while taking action - var $lookup = false; + var $lookup = false; // Storage folder to use var $STORAGE_FOLDER = 'storage/mailscanner/'; /** DEBUG functionality */ - var $debug = false; + var $debug = false; function log($message) { global $log; if($log && $this->debug) { $log->debug($message); } @@ -61,12 +60,12 @@ class Vtiger_MailScannerAction { $result = $adb->pquery("SELECT * FROM vtiger_mailscanner_actions WHERE actionid=? ORDER BY sequence", Array($foractionid)); if($adb->num_rows($result)) { - $this->actionid = $adb->query_result($result, 0, 'actionid'); - $this->scannerid = $adb->query_result($result, 0, 'scannerid'); - $this->actiontype = $adb->query_result($result, 0, 'actiontype'); - $this->module = $adb->query_result($result, 0, 'module'); - $this->lookup = $adb->query_result($result, 0, 'lookup'); - $this->actiontext = "$this->actiontype,$this->module,$this->lookup"; + $this->actionid = $adb->query_result($result, 0, 'actionid'); + $this->scannerid = $adb->query_result($result, 0, 'scannerid'); + $this->actiontype = $adb->query_result($result, 0, 'actiontype'); + $this->module = $adb->query_result($result, 0, 'module'); + $this->lookup = $adb->query_result($result, 0, 'lookup'); + $this->actiontext = "$this->actiontype,$this->module,$this->lookup"; } } @@ -77,9 +76,9 @@ class Vtiger_MailScannerAction { global $adb; $inputparts = explode(',', $actiontext); - $this->actiontype = $inputparts[0]; // LINK, CREATE - $this->module = $inputparts[1]; // Module name - $this->lookup = $inputparts[2]; // FROM, TO + $this->actiontype = $inputparts[0]; // LINK, CREATE + $this->module = $inputparts[1]; // Module name + $this->lookup = $inputparts[2]; // FROM, TO $this->actiontext = $actiontext; @@ -168,24 +167,24 @@ class Vtiger_MailScannerAction { $fromemail = $mailrecord->_from[0]; $linkfocus = $mailscanner->GetTicketRecord($usesubject, $fromemail); - - $commentedBy = $mailscanner->LookupContact($fromemail); - if(!$commentedBy) { - $commentedBy = $mailscanner->LookupAccount($fromemail); - } + + $commentedBy = $mailscanner->LookupContact($fromemail); + if(!$commentedBy) { + $commentedBy = $mailscanner->LookupAccount($fromemail); + } // If matching ticket is found, update comment, attach email if($linkfocus) { $commentFocus = new ModComments(); $commentFocus->column_fields['commentcontent'] = $mailrecord->getBodyText(); $commentFocus->column_fields['related_to'] = $linkfocus->id; - $commentFocus->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; - if($commentedBy) { - $commentFocus->column_fields['customer'] = $commentedBy; - $commentFocus->column_fields['from_mailconverter'] = 1; - } else { - $commentFocus->column_fields['userid'] = $mailscannerrule->assigned_to; - } + $commentFocus->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; + if($commentedBy) { + $commentFocus->column_fields['customer'] = $commentedBy; + $commentFocus->column_fields['from_mailconverter'] = 1; + } else { + $commentFocus->column_fields['userid'] = $mailscannerrule->assigned_to; + } $commentFocus->saveentity('ModComments'); // Set the ticket status to Open if its Closed @@ -205,20 +204,20 @@ class Vtiger_MailScannerAction { * Create ticket action. */ function __CreateContact($mailscanner, $mailrecord, $mailscannerrule) { - if($mailscanner->LookupContact($mailrecord->_from[0])) { - $this->lookup = 'FROM'; - return $this->__LinkToRecord($mailscanner, $mailrecord); - } - $name = $this->getName($mailrecord); + if($mailscanner->LookupContact($mailrecord->_from[0])) { + $this->lookup = 'FROM'; + return $this->__LinkToRecord($mailscanner, $mailrecord); + } + $name = $this->getName($mailrecord); $email = $mailrecord->_from[0]; $description = $mailrecord->getBodyText(); $contact = new Contacts(); - $this->setDefaultValue('Contacts', $contact); + $this->setDefaultValue('Contacts', $contact); $contact->column_fields['firstname'] = $name[0]; - $contact->column_fields['lastname'] = $name[1]; + $contact->column_fields['lastname'] = $name[1]; $contact->column_fields['email'] = $email; - $contact->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; + $contact->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; $contact->column_fields['description'] = $description; $contact->save('Contacts'); @@ -231,18 +230,18 @@ class Vtiger_MailScannerAction { * Create Lead action. */ function __CreateLead($mailscanner, $mailrecord, $mailscannerrule) { - if($mailscanner->LookupLead($mailrecord->_from[0])) { - $this->lookup = 'FROM'; - return $this->__LinkToRecord($mailscanner, $mailrecord); - } + if($mailscanner->LookupLead($mailrecord->_from[0])) { + $this->lookup = 'FROM'; + return $this->__LinkToRecord($mailscanner, $mailrecord); + } $name = $this->getName($mailrecord); $email = $mailrecord->_from[0]; $description = $mailrecord->getBodyText(); $lead = new Leads(); - $this->setDefaultValue('Leads', $lead); + $this->setDefaultValue('Leads', $lead); $lead->column_fields['firstname'] = $name[0]; - $lead->column_fields['lastname'] = $name[1]; + $lead->column_fields['lastname'] = $name[1]; $lead->column_fields['email'] = $email; $lead->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; $lead->column_fields['description'] = $description; @@ -257,19 +256,19 @@ class Vtiger_MailScannerAction { * Create Account action. */ function __CreateAccount($mailscanner, $mailrecord, $mailscannerrule) { - if($mailscanner->LookupAccount($mailrecord->_from[0])) { - $this->lookup = 'FROM'; - return $this->__LinkToRecord($mailscanner, $mailrecord); - } + if($mailscanner->LookupAccount($mailrecord->_from[0])) { + $this->lookup = 'FROM'; + return $this->__LinkToRecord($mailscanner, $mailrecord); + } $name = $this->getName($mailrecord); $email = $mailrecord->_from[0]; $description = $mailrecord->getBodyText(); $account = new Accounts(); - $this->setDefaultValue('Accounts', $account); + $this->setDefaultValue('Accounts', $account); $account->column_fields['accountname'] = $name[0].' '.$name[1]; $account->column_fields['email1'] = $email; - $account->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; + $account->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; $account->column_fields['description'] = $description; $account->save('Accounts'); @@ -289,22 +288,22 @@ class Vtiger_MailScannerAction { // There will be only on FROM address to email, so pick the first one $fromemail = $mailrecord->_from[0]; $contactLinktoid = $mailscanner->LookupContact($fromemail); - if(!$contactLinktoid) { - $contactLinktoid = $this-> __CreateContact($mailscanner, $mailrecord, $mailscannerrule); - } + if(!$contactLinktoid) { + $contactLinktoid = $this-> __CreateContact($mailscanner, $mailrecord, $mailscannerrule); + } if ($contactLinktoid) $linktoid = $mailscanner->getAccountId($contactLinktoid); - if(!$linktoid) - $linktoid = $mailscanner->LookupAccount($fromemail); + if(!$linktoid) + $linktoid = $mailscanner->LookupAccount($fromemail); // Create trouble ticket record $ticket = new HelpDesk(); - $this->setDefaultValue('HelpDesk', $ticket); + $this->setDefaultValue('HelpDesk', $ticket); if(empty($ticket->column_fields['ticketstatus']) || $ticket->column_fields['ticketstatus'] == '?????') - $ticket->column_fields['ticketstatus'] = 'Open'; - $ticket->column_fields['ticket_title'] = $usetitle; + $ticket->column_fields['ticketstatus'] = 'Open'; + $ticket->column_fields['ticket_title'] = $usetitle; $ticket->column_fields['description'] = $description; - $ticket->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; + $ticket->column_fields['assigned_user_id'] = $mailscannerrule->assigned_to; if ($contactLinktoid) $ticket->column_fields['contact_id'] = $contactLinktoid; if ($linktoid) @@ -313,44 +312,44 @@ class Vtiger_MailScannerAction { // Associate any attachement of the email to ticket $this->__SaveAttachements($mailrecord, 'HelpDesk', $ticket); - - if($contactLinktoid) - $relatedTo = $contactLinktoid; - else - $relatedTo = $linktoid; - $this->linkMail($mailscanner, $mailrecord, $relatedTo); - + + if($contactLinktoid) + $relatedTo = $contactLinktoid; + else + $relatedTo = $linktoid; + $this->linkMail($mailscanner, $mailrecord, $relatedTo); + return $ticket->id; } - - /** - * Function to link email record to contact/account/lead - * record if exists with same email id - * @param type $mailscanner - * @param type $mailrecord - */ - function linkMail($mailscanner, $mailrecord, $relatedTo) { - $fromemail = $mailrecord->_from[0]; - - $linkfocus = $mailscanner->GetContactRecord($fromemail, $relatedTo); - $module = 'Contacts'; - if(!$linkfocus) { - $linkfocus = $mailscanner->GetAccountRecord($fromemail, $relatedTo); - $module = 'Accounts'; - } - - if($linkfocus) { - $this->__CreateNewEmail($mailrecord, $module, $linkfocus); - } - } - - /** + + /** + * Function to link email record to contact/account/lead + * record if exists with same email id + * @param type $mailscanner + * @param type $mailrecord + */ + function linkMail($mailscanner, $mailrecord, $relatedTo) { + $fromemail = $mailrecord->_from[0]; + + $linkfocus = $mailscanner->GetContactRecord($fromemail, $relatedTo); + $module = 'Contacts'; + if(!$linkfocus) { + $linkfocus = $mailscanner->GetAccountRecord($fromemail, $relatedTo); + $module = 'Accounts'; + } + + if($linkfocus) { + $this->__CreateNewEmail($mailrecord, $module, $linkfocus); + } + } + + /** * Add email to CRM record like Contacts/Accounts */ function __LinkToRecord($mailscanner, $mailrecord) { $linkfocus = false; - $useemail = false; + $useemail = false; if($this->lookup == 'FROM') $useemail = $mailrecord->_from; else if($this->lookup == 'TO') $useemail = $mailrecord->_to; @@ -389,11 +388,11 @@ class Vtiger_MailScannerAction { if(!$current_user) { $current_user = Users::getActiveAdminUser(); } - $assignedToId = $linkfocus->column_fields['assigned_user_id']; - if(vtws_getOwnerType($assignedToId) == 'Groups') { - $assignedToId = Users::getActiveAdminId(); - } - + $assignedToId = $linkfocus->column_fields['assigned_user_id']; + if(vtws_getOwnerType($assignedToId) == 'Groups') { + $assignedToId = Users::getActiveAdminId(); + } + $focus = new Emails(); $focus->column_fields['parent_type'] = $module; $focus->column_fields['activitytype'] = 'Emails'; @@ -455,13 +454,13 @@ class Vtiger_MailScannerAction { if($issaved) { // Create document record $document = new Documents(); - $document->column_fields['notes_title'] = $filename; - $document->column_fields['filename'] = $filename; - $document->column_fields['filesize'] = mb_strlen($filecontent, '8bit'); - $document->column_fields['filestatus'] = 1; - $document->column_fields['filelocationtype'] = 'I'; - $document->column_fields['folderid'] = 1; // Default Folder - $document->column_fields['assigned_user_id'] = $userid; + $document->column_fields['notes_title'] = $filename; + $document->column_fields['filename'] = $filename; + $document->column_fields['filesize'] = mb_strlen($filecontent, '8bit'); + $document->column_fields['filestatus'] = 1; + $document->column_fields['filelocationtype']= 'I'; + $document->column_fields['folderid'] = 1; // Default Folder + $document->column_fields['assigned_user_id']= $userid; $document->save('Documents'); // Link file attached to document @@ -512,49 +511,49 @@ class Vtiger_MailScannerAction { return true; } - - function setDefaultValue($module, $moduleObj) { - $moduleInstance = Vtiger_Module_Model::getInstance($module); - - $fieldInstances = Vtiger_Field_Model::getAllForModule($moduleInstance); - foreach($fieldInstances as $blockInstance) { - foreach($blockInstance as $fieldInstance) { - $fieldName = $fieldInstance->getName(); - $defaultValue = $fieldInstance->getDefaultFieldValue(); - if($defaultValue) { - $moduleObj->column_fields[$fieldName] = decode_html($defaultValue); - } - if($fieldInstance->isMandatory() && !$defaultValue) { - $moduleObj->column_fields[$fieldName] = Vtiger_Util_Helper::getDefaultMandatoryValue($fieldInstance->getFieldDataType()); - } - } - } - } - - /** - * Function to get Mail Sender's Name - * @param <Vtiger_MailRecord Object> $mailrecord - * @return <Array> containing First Name and Last Name - */ - function getName($mailrecord) { - $name = $mailrecord->_fromname; - if(!empty($name)) { - $nameParts = explode(' ', $name); - if(count($nameParts) > 1) { - $firstName = $nameParts[0]; - unset($nameParts[0]); - $lastName = implode(' ', $nameParts); - } else { - $firstName = ''; - $lastName = $nameParts[0]; - } - } else { - $firstName = ''; - $lastName = $mailrecord->_from[0]; - } - - return array($firstName, $lastName); - } - + + function setDefaultValue($module, $moduleObj) { + $moduleInstance = Vtiger_Module_Model::getInstance($module); + + $fieldInstances = Vtiger_Field_Model::getAllForModule($moduleInstance); + foreach($fieldInstances as $blockInstance) { + foreach($blockInstance as $fieldInstance) { + $fieldName = $fieldInstance->getName(); + $defaultValue = $fieldInstance->getDefaultFieldValue(); + if($defaultValue) { + $moduleObj->column_fields[$fieldName] = decode_html($defaultValue); + } + if($fieldInstance->isMandatory() && !$defaultValue) { + $moduleObj->column_fields[$fieldName] = Vtiger_Util_Helper::getDefaultMandatoryValue($fieldInstance->getFieldDataType()); + } + } + } + } + + /** + * Function to get Mail Sender's Name + * @param <Vtiger_MailRecord Object> $mailrecord + * @return <Array> containing First Name and Last Name + */ + function getName($mailrecord) { + $name = $mailrecord->_fromname; + if(!empty($name)) { + $nameParts = explode(' ', $name); + if(count($nameParts) > 1) { + $firstName = $nameParts[0]; + unset($nameParts[0]); + $lastName = implode(' ', $nameParts); + } else { + $firstName = ''; + $lastName = $nameParts[0]; + } + } else { + $firstName = ''; + $lastName = $mailrecord->_from[0]; + } + + return array($firstName, $lastName); + } + } ?> diff --git a/modules/Settings/MailConverter/handlers/MailScannerBodyRule.php b/modules/Settings/MailConverter/handlers/MailScannerBodyRule.php deleted file mode 100644 index b8ac408ebdaca5774b1917f8f9d097f1e3bf3bb9..0000000000000000000000000000000000000000 --- a/modules/Settings/MailConverter/handlers/MailScannerBodyRule.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -/********************************************************************************* - ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 - * ("License"); You may not use this file except in compliance with the License - * The Original Code is: vtiger CRM Open Source - * The Initial Developer of the Original Code is vtiger. - * Portions created by vtiger are Copyright (C) vtiger. - * All Rights Reserved. - * - ********************************************************************************/ - -class Vtiger_MailScannerBodyRule { - - var $scannerId = false; - var $ruleId = false; - var $module = false; - var $delimiter = false; - var $mappingData = false; - var $subject = false; - var $fromemail = false; - var $fromname = false; - var $body = false; - - function __construct($scannerId, $ruleId) { - $this->initialize($scannerId, $ruleId); - } - - function initialize($scannerId, $ruleId) { - $db = PearDatabase::getInstance(); - $result = $db->pquery("SELECT * FROM vtiger_mailscanner_bodyrule WHERE scannerid = ? AND ruleid = ?", array($scannerId, $ruleId)); - if($db->num_rows($result)) { - $this->scannerId = $scannerId; - $this->ruleId = $ruleId; - $this->delimiter = decode_html(decode_html($db->query_result($result, 0, 'delimiter'))); - $this->module = $db->query_result($result, 0, 'module'); - } - $result = $db->pquery("SELECT * FROM vtiger_mailscanner_mapping WHERE scannerid = ? AND ruleid = ?", array($scannerId, $ruleId)); - $count = $db->num_rows($result); - $fieldMapping = array(); - for($i = 0; $i < $count; $i++) { - $crmField = decode_html($db->query_result($result, $i, 'crm_field')); - $bodyField = decode_html($db->query_result($result, $i, 'body_field')); - $fieldMapping[$bodyField] = $crmField; - } - $this->mappingData = $fieldMapping; - } - - function getFieldValues($body) { - $bodyFields = $this->parseBody($body); - return $this->apply($bodyFields); - } - - function parseBody($body) { - $body = decode_html($body); - $this->body = $body; - $bodyFields = array(); - $rows = explode("\n", $body); - foreach($rows as $row) { - if(strrpos($row, $this->delimiter)) { - $columns = explode($this->delimiter, $row); - $label = trim(decode_html($columns[0])); - unset($columns[0]); - $bodyFields[strtolower($label)] = trim(decode_html(implode($this->delimiter, $columns))); - } - } - return $bodyFields; - } - - function apply($bodyFields) { - $data = array(); - foreach($this->mappingData as $bodyField => $crmField) { - $bodyField = strtolower($bodyField); - if(!empty($bodyFields[$bodyField])) { - $data[$crmField] = $bodyFields[$bodyField]; - } - if($bodyField == 'subject') { - $data[$crmField] = $this->subject; - } - if($bodyField == 'from email') { - $data[$crmField] = $this->fromemail; - } - if($bodyField == 'from name') { - $data[$crmField] = $this->fromname; - } - if($bodyField == 'email content') { - $data[$crmField] = $this->body; - } - } - return $this->transformData($data); - } - - function transformData($fields) { - $moduleInstance = Vtiger_Module_Model::getInstance($this->module); - foreach($fields as $fieldName => $value) { - $fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $moduleInstance); - if(!$fieldInstance) { - unset($fields[$fieldName]); - continue; - } - $fieldInfo = $fieldInstance->getFieldInfo(); - - switch ($fieldInfo['type']) { - case 'date' : $fields[$fieldName] = date('Y-m-d', strtotime($value)); - break; - case 'time' : $fields[$fieldName] = date('H:i:s', strtotime($value)); - break; - case 'currency' : if(!is_numeric($value)) - unset($fields[$fieldName]); - break; - case 'double' : if(!is_numeric($value)) - unset($fields[$fieldName]); - break; - case 'integer' : if(!is_numeric($value)) - unset($fields[$fieldName]); - else - $fields[$fieldName] = round($value); - break; - case 'percentage' : if(!is_numeric($value) || $value > 100) - unset($fields[$fieldName]); - break; - case 'email' : if(!preg_match("/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/", $value)) { - unset($fields[$fieldName]); - } - break; - case 'picklist' : $picklistValues = $fieldInfo['picklistvalues']; - $picklistValue = $this->getPicklistValue($value, $picklistValues); - if($picklistValue) - $fields[$fieldName] = $picklistValue; - else - unset($fields[$fieldName]); - break; - case 'multipicklist' : $picklistValues = $fieldInfo['picklistvalues']; - $bodyValues = explode(',', $value); - foreach($bodyValues as $key => $bodyValue) { - $picklistValue = $this->getPicklistValue($bodyValue, $picklistValues); - if($picklistValue) - $bodyValues[$key] = $picklistValue; - else - unset($bodyValues[$key]); - } - $fields[$fieldName] = implode(' |##| ', $bodyValues); - break; - case 'reference' : unset($fields[$fieldName]); - break; - default : break; - } - } - return $fields; - } - - function getPicklistValue($value, $allValues) { - $result = false; - $value = trim($value); - foreach($allValues as $option) { - if(strtolower($value) == strtolower($option)) { - $result = $option; - break; - } - } - return $result; - } - - public static function hasBodyRule($scannerId, $ruleId) { - $db = PearDatabase::getInstance(); - $result = $db->pquery("SELECT 1 FROM vtiger_mailscanner_bodyrule WHERE scannerid = ? AND ruleid = ?", array($scannerId, $ruleId)); - if($db->num_rows($result) > 0) { - return true; - } - return false; - } -} \ No newline at end of file diff --git a/modules/Settings/MailConverter/models/Module.php b/modules/Settings/MailConverter/models/Module.php index dbaf3349e64e81222c2c7c18a414e9ed10970fae..f3c9031999def0b81c94ad3abfdf4f713470f7fb 100644 --- a/modules/Settings/MailConverter/models/Module.php +++ b/modules/Settings/MailConverter/models/Module.php @@ -17,8 +17,7 @@ class Settings_MailConverter_Module_Model extends Settings_Vtiger_Module_Model { * @return <String> Url */ public function getCreateRecordUrl() { - $url = 'index.php?module=MailConverter&parent='.$this->getParentName().'&action=CheckMailBoxMaxLimit'; - return 'javascript:Settings_MailConverter_List_Js.checkMailBoxMaxLimit("'.$url.'")'; + return 'index.php?module=MailConverter&parent=Settings&view=Edit&mode=step1&create=new'; } /** @@ -27,28 +26,28 @@ class Settings_MailConverter_Module_Model extends Settings_Vtiger_Module_Model { */ public function getFields() { $fields = array( - 'scannername' => array('name' => 'scannername','typeofdata'=>'V~M','label'=>'Scanner Name','datatype'=>'string'), - 'server' => array('name' => 'server','typeofdata'=>'V~M','label'=>'Server','datatype'=>'string'), - 'username' => array('name' => 'username','typeofdata'=>'V~M','label'=>'User Name','datatype'=>'string') , - 'password' => array('name' => 'password','typeofdata'=>'V~M','label'=>'Password','datatype'=>'password') , - 'protocol' => array('name' => 'protocol','typeofdata'=>'C~O','label'=>'Protocol','datatype'=>'radio') , - 'ssltype' => array('name' => 'ssltype','typeofdata'=>'C~O','label'=>'SSL Type','datatype'=>'radio') , - 'sslmethod' => array('name' => 'sslmethod','typeofdata'=>'C~O','label'=>'SSL Method','datatype'=>'radio') , - 'connecturl' => array('name' => 'connecturl', 'typeofdata'=>'V~O','label' => 'Connect URL','datatype' => 'string','isEditable'=>false), - 'searchfor' => array('name' => 'searchfor', 'typeofdata'=>'V~O','label'=>'Look For','datatype'=>'picklist'), - 'markas' => array('name' => 'markas', 'typeofdata'=>'V~O','label'=>'After Scan','datatype'=>'picklist'), - 'isvalid' => array('name' => 'isvalid', 'typeofdata'=>'C~O','label'=>'Status','datatype'=>'boolean'), - 'time_zone' => array('name' => 'time_zone', 'typeofdata'=>'V~O','label'=>'Time Zone','datatype'=>'picklist')); - - $fieldsList = array(); - foreach($fields as $fieldName => $fieldInfo) { - $fieldModel = new Settings_MailConverter_Field_Model(); - foreach($fieldInfo as $key=>$value) { - $fieldModel->set($key, $value); - } - $fieldsList[$fieldName] = $fieldModel; - } - return $fieldsList; + 'scannername' => array('name' => 'scannername', 'typeofdata' => 'V~M', 'label' => 'Scanner Name', 'datatype' => 'string'), + 'server' => array('name' => 'server', 'typeofdata' => 'V~M', 'label' => 'Server', 'datatype' => 'string'), + 'username' => array('name' => 'username', 'typeofdata' => 'V~M', 'label' => 'User Name', 'datatype' => 'string'), + 'password' => array('name' => 'password', 'typeofdata' => 'V~M', 'label' => 'Password', 'datatype' => 'password'), + 'protocol' => array('name' => 'protocol', 'typeofdata' => 'C~O', 'label' => 'Protocol', 'datatype' => 'radio'), + 'ssltype' => array('name' => 'ssltype', 'typeofdata' => 'C~O', 'label' => 'SSL Type', 'datatype' => 'radio'), + 'sslmethod' => array('name' => 'sslmethod', 'typeofdata' => 'C~O', 'label' => 'SSL Method', 'datatype' => 'radio'), + 'connecturl' => array('name' => 'connecturl', 'typeofdata' => 'V~O', 'label' => 'Connect URL', 'datatype' => 'string', 'isEditable' => false), + 'searchfor' => array('name' => 'searchfor', 'typeofdata' => 'V~O', 'label' => 'Look For', 'datatype' => 'picklist'), + 'markas' => array('name' => 'markas', 'typeofdata' => 'V~O', 'label' => 'After Scan', 'datatype' => 'picklist'), + 'isvalid' => array('name' => 'isvalid', 'typeofdata' => 'C~O', 'label' => 'Status', 'datatype' => 'boolean'), + 'time_zone' => array('name' => 'time_zone', 'typeofdata' => 'V~O', 'label' => 'Time Zone', 'datatype' => 'picklist')); + + $fieldsList = array(); + foreach($fields as $fieldName => $fieldInfo) { + $fieldModel = new Settings_MailConverter_Field_Model(); + foreach($fieldInfo as $key=>$value) { + $fieldModel->set($key, $value); + } + $fieldsList[$fieldName] = $fieldModel; + } + return $fieldsList; } /** @@ -56,25 +55,25 @@ class Settings_MailConverter_Module_Model extends Settings_Vtiger_Module_Model { * @return <Array> List of setup rule fields */ - public function getSetupRuleFiels() { + public function getSetupRuleFields() { $ruleFields = array( - 'fromaddress' => array('name' => 'fromaddress', 'label' => 'LBL_FROM', 'datatype' => 'email'), - 'toaddress' => array('name' => 'toaddress', 'label' => 'LBL_TO', 'datatype' => 'email'), - 'cc' => array('name' => 'cc', 'label' => 'LBL_CC', 'datatype' => 'email'), - 'bcc' => array('name' => 'bcc', 'label' => 'LBL_BCC', 'datatype' => 'email'), - 'subject' => array('name' => 'subject', 'label' => 'LBL_SUBJECT', 'datatype' => 'picklist'), - 'body' => array('name' => 'body', 'label' => 'LBL_BODY', 'datatype' => 'picklist'), - 'matchusing' => array('name' => 'matchusing', 'label' => 'LBL_MATCH', 'datatype' => 'radio'), - 'action' => array('name' => 'action', 'label' => 'LBL_ACTION', 'datatype' => 'picklist') + 'fromaddress' => array('name' => 'fromaddress', 'label' => 'LBL_FROM', 'datatype' => 'email'), + 'toaddress' => array('name' => 'toaddress', 'label' => 'LBL_TO', 'datatype' => 'email'), + 'cc' => array('name' => 'cc', 'label' => 'LBL_CC', 'datatype' => 'email'), + 'bcc' => array('name' => 'bcc', 'label' => 'LBL_BCC', 'datatype' => 'email'), + 'subject' => array('name' => 'subject', 'label' => 'LBL_SUBJECT', 'datatype' => 'picklist'), + 'body' => array('name' => 'body', 'label' => 'LBL_BODY', 'datatype' => 'picklist'), + 'matchusing' => array('name' => 'matchusing', 'label' => 'LBL_MATCH', 'datatype' => 'radio'), + 'action' => array('name' => 'action', 'label' => 'LBL_ACTION', 'datatype' => 'picklist') ); $ruleFieldsList = array(); foreach($ruleFields as $fieldName => $fieldInfo) { - $fieldModel = new Settings_MailConverter_RuleField_Model(); - foreach($fieldInfo as $key=>$value) { - $fieldModel->set($key, $value); - } - $ruleFieldsList[$fieldName] = $fieldModel; - } + $fieldModel = new Settings_MailConverter_RuleField_Model(); + foreach($fieldInfo as $key=>$value) { + $fieldModel->set($key, $value); + } + $ruleFieldsList[$fieldName] = $fieldModel; + } return $ruleFieldsList; } @@ -136,25 +135,25 @@ class Settings_MailConverter_Module_Model extends Settings_Vtiger_Module_Model { $scannerInfo = new Vtiger_MailScannerInfo($scannerName); $mailBox = new Vtiger_MailBox($scannerInfo); $isConnected = $mailBox->connect(); - if($isConnected) { - $allFolders = $mailBox->getFolders(); - $folders = array(); - $selectedFolders = Settings_MailConverter_Module_Model::getScannedFolders($id); - if(is_array($allFolders)) { - foreach ($allFolders as $a) { - if (in_array($a, $selectedFolders)) { - $folders[$a] = 'checked'; - } else { - $folders[$a] = ''; - } - } - return $folders; - } else { - return $allFolders; - } - - } - return false; + if($isConnected) { + $allFolders = $mailBox->getFolders(); + $folders = array(); + $selectedFolders = Settings_MailConverter_Module_Model::getScannedFolders($id); + if(is_array($allFolders)) { + foreach ($allFolders as $a) { + if (in_array($a, $selectedFolders)) { + $folders[$a] = 'checked'; + } else { + $folders[$a] = ''; + } + } + return $folders; + } else { + return $allFolders; + } + + } + return false; } public function getScannerName($id) { @@ -176,4 +175,15 @@ class Settings_MailConverter_Module_Model extends Settings_Vtiger_Module_Model { } } + public function hasCreatePermissions() { + $permissions = false; + $recordsCount = Settings_MailConverter_Record_Model::getCount(); + + global $max_mailboxes; + if ($recordsCount < $max_mailboxes) { + $permissions = true; + } + return $permissions; + } + } diff --git a/modules/Settings/MailConverter/models/RuleRecord.php b/modules/Settings/MailConverter/models/RuleRecord.php index 85ff9788e69ccf572b87e035ff881dbef6828da2..b1fce72e72675b1c9440b2ec8e8e9037adc4a018 100644 --- a/modules/Settings/MailConverter/models/RuleRecord.php +++ b/modules/Settings/MailConverter/models/RuleRecord.php @@ -85,13 +85,13 @@ class Settings_MailConverter_RuleRecord_Model extends Settings_Vtiger_Record_Mod 'linktype' => 'LISTVIEW', 'linklabel' => vtranslate('LBL_EDIT', $qualifiedModuleName). ' ' .vtranslate('RULE', $qualifiedModuleName), 'linkurl' => $this->getEditViewUrl(), - 'linkicon' => 'icon-pencil' + 'linkicon' => 'fa fa-pencil' ), array( 'linktype' => 'LISTVIEW', 'linklabel' => vtranslate('LBL_DELETE', $qualifiedModuleName). ' ' .vtranslate('RULE', $qualifiedModuleName), 'linkurl' => $this->getDeleteUrl(), - 'linkicon' => 'icon-trash' + 'linkicon' => 'fa fa-trash' ) ); foreach($recordLinks as $recordLink) { diff --git a/modules/Settings/MailConverter/views/Edit.php b/modules/Settings/MailConverter/views/Edit.php index ab2b21761f198f2a77d6a0a78b891eb1a8922ec5..35b509667edf7b30f4821b436eea7c41eed141ca 100644 --- a/modules/Settings/MailConverter/views/Edit.php +++ b/modules/Settings/MailConverter/views/Edit.php @@ -63,10 +63,10 @@ class Settings_MailConverter_Edit_View extends Settings_Vtiger_Index_View { $recordId = $request->get('record'); $qualifiedModuleName = $request->getModule(false); $folders = Settings_MailConverter_Module_Model::getFolders($recordId); + $viewer = $this->getViewer($request); - $folders = array('aasdasdsad','bsadasdsad','casadsad','dsdasdsa', 'eadasdsd', 'fasdsasd'); if (is_array($folders)) { - $viewer->assign('FOLDERS', array_flip($folders)); + $viewer->assign('FOLDERS', $folders); } else if ($folders) { $viewer->assign('IMAP_ERROR', $folders); } else { diff --git a/modules/Settings/MailConverter/views/EditRule.php b/modules/Settings/MailConverter/views/EditRule.php index a459ec9f787bb5c623e5a321158a6ca027e64c92..6246de4fb7a8316f936910b2998e467edc59d48a 100644 --- a/modules/Settings/MailConverter/views/EditRule.php +++ b/modules/Settings/MailConverter/views/EditRule.php @@ -41,7 +41,6 @@ class Settings_MailConverter_EditRule_View extends Settings_Vtiger_IndexAjax_Vie $viewer->assign('SCANNER_ID', $scannerId); $viewer->assign('SCANNER_MODEL', Settings_MailConverter_Record_Model::getInstanceById($scannerId)); - $viewer->assign('DEFAULT_OPTIONS', Settings_MailConverter_RuleRecord_Model::getDefaultConditions()); $viewer->assign('DEFAULT_ACTIONS', Settings_MailConverter_RuleRecord_Model::getDefaultActions()); diff --git a/modules/Settings/MailConverter/views/List.php b/modules/Settings/MailConverter/views/List.php index fd2d9685efefc66526586f221363881f90b29ad0..61d9f5cfa232ed08df0953d9335198ba227e4451 100644 --- a/modules/Settings/MailConverter/views/List.php +++ b/modules/Settings/MailConverter/views/List.php @@ -10,6 +10,21 @@ class Settings_MailConverter_List_View extends Settings_Vtiger_Index_View { + public function preProcess (Vtiger_Request $request, $display=true) { + parent::preProcess($request, false); + $qualifiedModuleName = $request->getModule(false); + $listViewModel = Settings_Vtiger_ListView_Model::getInstance($qualifiedModuleName); + $viewer = $this->getViewer($request); + $viewer->assign('LISTVIEW_LINKS', $listViewModel->getListViewLinks()); + if($display) { + $this->preProcessDisplay($request); + } + } + + protected function preProcessTplName(Vtiger_Request $request) { + return parent::preProcessTplName($request); + } + public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $scannerId = $request->get('record'); @@ -21,7 +36,7 @@ class Settings_MailConverter_List_View extends Settings_Vtiger_Index_View { $recordExists = Settings_MailConverter_Module_Model::MailBoxExists(); $recordModel = Settings_MailConverter_Record_Model::getAll(); $viewer = $this->getViewer($request); - + $viewer->assign('LISTVIEW_LINKS', $listViewModel->getListViewLinks()); $viewer->assign('MODULE_MODEL', Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName)); $viewer->assign('MAILBOXES', Settings_MailConverter_Module_Model::getMailboxes()); @@ -32,16 +47,16 @@ class Settings_MailConverter_List_View extends Settings_Vtiger_Index_View { $viewer->assign('RECORD_EXISTS', $recordExists); if ($scannerId) { - $viewer->assign('SCANNER_ID', $scannerId); - $viewer->assign('RECORD', $recordModel[$scannerId]); - $viewer->assign('SCANNER_MODEL', Settings_MailConverter_Record_Model::getInstanceById($scannerId)); - $viewer->assign('RULE_MODELS_LIST', Settings_MailConverter_RuleRecord_Model::getAll($scannerId)); - $viewer->assign('FOLDERS_SCANNED', Settings_MailConverter_Module_Model::getScannedFolders($scannerId)); + $viewer->assign('SCANNER_ID', $scannerId); + $viewer->assign('RECORD', $recordModel[$scannerId]); + $viewer->assign('SCANNER_MODEL', Settings_MailConverter_Record_Model::getInstanceById($scannerId)); + $viewer->assign('RULE_MODELS_LIST', Settings_MailConverter_RuleRecord_Model::getAll($scannerId)); + $viewer->assign('FOLDERS_SCANNED', Settings_MailConverter_Module_Model::getScannedFolders($scannerId)); } $viewer->view('RulesList.tpl', $qualifiedModuleName); - } - - /** + } + + /** * Function to get the list of Script models to be included * @param Vtiger_Request $request * @return <Array> - List of Vtiger_JsScript_Model instances diff --git a/modules/Settings/MailConverter/views/RuleAjax.php b/modules/Settings/MailConverter/views/RuleAjax.php index 2cc05a2ecf26be067791e2e49147e14f7daae372..4cf269f957ce53392e64a192450da2b3b579ba56 100644 --- a/modules/Settings/MailConverter/views/RuleAjax.php +++ b/modules/Settings/MailConverter/views/RuleAjax.php @@ -21,8 +21,12 @@ class Settings_MailConverter_RuleAjax_View extends Settings_Vtiger_IndexAjax_Vie $viewer->assign('SCANNER_ID', $scannerId); $viewer->assign('SCANNER_MODEL', Settings_MailConverter_Record_Model::getInstanceById($scannerId)); $viewer->assign('RULE_MODEL', Settings_MailConverter_RuleRecord_Model::getRule($scannerId,$ruleId)); + $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName); + $fields = $moduleModel->getSetupRuleFields(); $viewer->assign('MODULE_NAME', $moduleName); + $viewer->assign('MODULE_MODEL', $moduleModel); + $viewer->assign('FIELDS', $fields); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('Rule.tpl', $qualifiedModuleName); diff --git a/packages/vtiger/mandatory/Import.zip b/packages/vtiger/mandatory/Import.zip index 865441bf4195c0dbd0a454e07db1b786340278ba..885aaeb8921e93bb8bd33caf702ef7ba03843846 100644 Binary files a/packages/vtiger/mandatory/Import.zip and b/packages/vtiger/mandatory/Import.zip differ diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportLandingPage.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportLandingPage.tpl index 51956750086096ac893030040cd6f7d66015458e..0a33b035337cf2a0bd7ae31cc10c0ef0175eeda7 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportLandingPage.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportLandingPage.tpl @@ -37,14 +37,6 @@ </div> </div> </div> - <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12" id = "googleImport"> - <div class="menu-item app-item app-PROJECT"> - <span class="fa fa-google"></span> - <div> - <h4>{'LBL_GOOGLE'|@vtranslate:$MODULE}</h4> - </div> - </div> - </div> {else if $FOR_MODULE == 'Calendar'} <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12" id="icsImport"> <div class="menu-item app-item" style="background: #b74f6f none repeat scroll 0 0 !important;">