Skip to content
Snippets Groups Projects
Commit d5ba2146 authored by Vijay Tilak's avatar Vijay Tilak
Browse files

Merge remote-tracking branch 'upstream/master'

parents 81ce19af bcd5e436
No related branches found
No related tags found
No related merge requests found
......@@ -70,9 +70,11 @@
<option value="none">{vtranslate('LBL_NONE',$MODULE)}</option>
{assign var=ADVANCE_FILTER_OPTIONS value=$ADVANCED_FILTER_OPTIONS_BY_TYPE[$FIELD_TYPE]}
{foreach item=ADVANCE_FILTER_OPTION from=$ADVANCE_FILTER_OPTIONS}
<option value="{$ADVANCE_FILTER_OPTION}" {if $ADVANCE_FILTER_OPTION eq $CONDITION_INFO['comparator']} selected {/if}>
{vtranslate($ADVANCED_FILTER_OPTIONS[$ADVANCE_FILTER_OPTION])}
</option>
<option value="{$ADVANCE_FILTER_OPTION}"
{if $ADVANCE_FILTER_OPTION === $CONDITION_INFO['comparator']}
selected
{/if}
>{vtranslate($ADVANCED_FILTER_OPTIONS[$ADVANCE_FILTER_OPTION])}</option>
{/foreach}
</select>
</span>
......
......@@ -485,7 +485,7 @@ Vtiger_Owner_Field_Js('Workflows_Ownergroup_Field_Js',{},{
}
});
Vtiger_Picklist_Field_Js('Workflows_Picklist_Field_Js',{},{
AdvanceFilter_Picklist_Field_Js('Workflows_Picklist_Field_Js',{},{
getUi : function(){
var selectedOption = app.htmlDecode(this.getValue());
......
......@@ -215,8 +215,22 @@ class WorkFlowScheduler {
if($operation == 'has changed from') continue;
$value = $condition['value'];
$fieldname = $condition['fieldname'];
preg_match('/(\w+) : \((\w+)\) (\w+)/', $condition['fieldname'], $matches);
if (count($matches) != 0) {
list($full, $referenceField, $referenceModule, $fieldname) = $matches;
}
if($referenceField) {
$moduleName = $referenceModule;
} else {
$moduleName = $queryGenerator->getModule();
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$fieldModel = $moduleModel->getField($fieldname);
if(in_array($operation, $this->_specialDateTimeOperator())) {
$value = $this->_parseValueForDate($condition);
$value = $this->_parseValueForDate($condition, $fieldModel);
}
$columnCondition = $condition['joincondition'];
$groupId = $condition['groupid'];
......@@ -294,7 +308,7 @@ class WorkFlowScheduler {
* @param <Array> $condition
* @return <String>
*/
function _parseValueForDate($condition) {
function _parseValueForDate($condition,$fieldModel = false) {
$value = $condition['value'];
$operation = $condition['operation'];
......@@ -303,6 +317,11 @@ class WorkFlowScheduler {
$admin = Users::getActiveAdminUser();
$adminTimeZone = $admin->time_zone;
@date_default_timezone_set($adminTimeZone);
$fieldType = array();
if($fieldModel){
$dataType = $fieldModel->get('typeofdata');
$fieldType = explode('~',$dataType);
}
switch($operation) {
case 'less than days ago' : //between current date and (currentdate - givenValue)
......
......@@ -532,8 +532,11 @@ class ServiceContracts extends CRMEntity {
$totalUnits = decimalFormat($this->column_fields['total_units']);
$contractStatus = $this->column_fields['contract_status'];
$checkServiceContractExistence = $this->db->pquery('SELECT if (EXISTS (select vsc.servicecontractsid from vtiger_servicecontracts vsc WHERE vsc.servicecontractsid = ?), 1, 0) AS exist_sc', array($this->id));
$ServiceContractExistFlag = isset($checkServiceContractExistence->fields['exist_sc']) ? $checkServiceContractExistence->fields['exist_sc'] : "1";
// Update the End date if the status is Complete or if the Used Units reaches/exceeds Total Units
// Update the End date if the status is Complete or if the Used Units reaches/exceeds Total Units
// We need to do this first to make sure Actual duration is computed properly
if($contractStatus == 'Complete' || (!empty($usedUnits) && !empty($totalUnits) && $usedUnits >= $totalUnits)) {
if(empty($endDate)) {
......@@ -542,7 +545,9 @@ class ServiceContracts extends CRMEntity {
}
} else {
$endDate = null;
$this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(null, $this->id));
if ( $ServiceContractExistFlag !== "0") {
$this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(null, $this->id));
}
}
// Calculate the Planned Duration based on Due date and Start date. (in days)
......@@ -575,7 +580,9 @@ class ServiceContracts extends CRMEntity {
if(count($updateCols) > 0) {
$updateQuery = 'UPDATE vtiger_servicecontracts SET '. implode(",", $updateCols) .' WHERE servicecontractsid = ?';
array_push($updateParams, $this->id);
$this->db->pquery($updateQuery, $updateParams);
if ( $ServiceContractExistFlag !== "0") {
$this->db->pquery($updateQuery, $updateParams);
}
}
}
......
......@@ -15,6 +15,11 @@ include_once('vtlib/Vtiger/ModuleBasic.php');
* @package vtlib
*/
class Vtiger_Module extends Vtiger_ModuleBasic {
const ONE_TO_ONE = '1:1';
const ONE_TO_MANY = '1:N';
const MANY_TO_ONE = 'N:1';
const MANY_TO_MANY = 'N:N';
/**
* Function to get the Module/Tab id
......@@ -79,13 +84,22 @@ class Vtiger_Module extends Vtiger_ModuleBasic {
$useactions_text = $actions;
if(is_array($actions)) $useactions_text = implode(',', $actions);
$useactions_text = strtoupper($useactions_text);
if($fieldId != null){
//Default relation type if relation fieldid is set
$relationType = Vtiger_Module::ONE_TO_MANY;
} else {
//Default relation type if relation fieldid is not set
$relationType = Vtiger_Module::MANY_TO_MANY;
}
// Add column to vtiger_relatedlists to save extended actions
Vtiger_Utils::AddColumn('vtiger_relatedlists', 'actions', 'VARCHAR(50)');
$adb->pquery("INSERT INTO vtiger_relatedlists(relation_id,tabid,related_tabid,name,sequence,label,presence,actions,relationfieldid) VALUES(?,?,?,?,?,?,?,?,?)",
Array($relation_id,$this->id,$moduleInstance->id,$function_name,$sequence,$label,$presence,$useactions_text,$fieldId));
$adb->pquery("INSERT INTO vtiger_relatedlists(relation_id,tabid,related_tabid,name,sequence,label,presence,actions,relationfieldid,relationtype) VALUES(?,?,?,?,?,?,?,?,?,?)",
Array($relation_id,$this->id,$moduleInstance->id,$function_name,$sequence,$label,$presence,$useactions_text,$fieldId,$relationType));
if(method_exists($this,'set')) {
$this->set('relation_id', $relation_id);
}
self::log("Setting relation with $moduleInstance->name [$useactions_text] ... DONE");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment