Skip to content

Commit

Permalink
Add Calendar Events to Vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed Jan 4, 2015
1 parent cbfb301 commit aef5145
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 5 deletions.
54 changes: 54 additions & 0 deletions build/changeSets/addvend_activities.php
@@ -0,0 +1,54 @@
<?php
class addVendorActivities extends cbupdaterWorker {
function applyChange() {
global $adb;
if ($this->hasError()) $this->sendError();
if ($this->isApplied()) {
$this->sendMsg('Changeset '.get_class($this).' already applied!');
} else {
global $adb;
$modname = 'Vendors';
$module = Vtiger_Module::getInstance($modname);

$qtModule = Vtiger_Module::getInstance('Calendar');
$relationLabel = 'Activities';
$module->setRelatedList($qtModule , $relationLabel, Array("ADD"),'get_activities');

$relationLabel = 'Activities History';
$module->setRelatedList($qtModule , $relationLabel, Array("ADD"),'get_history');

$this->sendMsg('Changeset '.get_class($this).' applied!');
$this->markApplied();
}
$this->finishExecution();
}

function undoChange() {
if ($this->isBlocked()) return true;
if ($this->hasError()) $this->sendError();
if ($this->isSystemUpdate()) {
$this->sendMsg('Changeset '.get_class($this).' is a system update, it cannot be undone!');
} else {
if ($this->isApplied()) {
// undo your magic here
$modname = 'Vendors';
$module = Vtiger_Module::getInstance($modname);

$qtModule = Vtiger_Module::getInstance('Calendar');
$relationLabel = 'Activities';
$module->unsetRelatedList($qtModule , $relationLabel, 'get_activities');

$relationLabel = 'Activities History';
$module->unsetRelatedList($qtModule , $relationLabel, 'get_history');

$this->sendMsg('Changeset '.get_class($this).' undone!');
$this->markUndone();
} else {
$this->sendMsg('Changeset '.get_class($this).' not applied!');
}
}
$this->finishExecution();
}
}

?>
2 changes: 2 additions & 0 deletions include/language/de_de.lang.php
Expand Up @@ -328,6 +328,8 @@
'COMBO_HELPDESK'=>'Trouble Tickets',
'COMBO_USERS'=>'Benutzer',
'COMBO_CAMPAIGNS'=>'Kampagnen',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT'=>'wähle',
'LBL_EDIT'=>'Bearbeiten',
'LBL_DELETE'=>'Lö',
Expand Down
2 changes: 2 additions & 0 deletions include/language/en_gb.lang.php
Expand Up @@ -324,6 +324,8 @@
'COMBO_HELPDESK' => 'Trouble Tickets',
'COMBO_USERS' => 'Users',
'COMBO_CAMPAIGNS' => 'Campaigns',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SAVE_AS'=>" Save As",
'LBL_SELECT' => 'Select',
'LBL_EDIT' => 'Edit',
Expand Down
2 changes: 2 additions & 0 deletions include/language/en_us.lang.php
Expand Up @@ -336,6 +336,8 @@
'COMBO_HELPDESK' => 'Trouble Tickets',
'COMBO_USERS' => 'Users',
'COMBO_CAMPAIGNS' => 'Campaigns',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT' => 'Select',
'LBL_EDIT' => 'Edit',
'LBL_DELETE' => 'Delete',
Expand Down
2 changes: 2 additions & 0 deletions include/language/es_es.lang.php
Expand Up @@ -333,6 +333,8 @@
'COMBO_HELPDESK' => 'Incidencias',
'COMBO_USERS' => 'Usuarios',
'COMBO_CAMPAIGNS' => 'Campañas',
'COMBO_VENDORS' => 'Proveedores', //MSL
'LBL_VENDOR_NAME' => 'Proveedor', //MSL
'LBL_SELECT' => 'Seleccionar',
'LBL_EDIT' => 'Editar',
'LBL_DELETE' => 'Eliminar',
Expand Down
2 changes: 2 additions & 0 deletions include/language/es_mx.lang.php
Expand Up @@ -332,6 +332,8 @@
'COMBO_HELPDESK' => 'Casos',
'COMBO_USERS' => 'Usuarios',
'COMBO_CAMPAIGNS' => 'Campañas',
'COMBO_VENDORS' => 'Proveedores', //MSL
'LBL_VENDOR_NAME' => 'Proveedor', //MSL
'LBL_SELECT' => 'Seleccionar',
'LBL_EDIT' => 'Editar',
'LBL_DELETE' => 'Eliminar',
Expand Down
2 changes: 2 additions & 0 deletions include/language/fr_fr.lang.php
Expand Up @@ -322,6 +322,8 @@
'COMBO_HELPDESK' => 'Tickets',
'COMBO_USERS' => 'Collaborateurs',
'COMBO_CAMPAIGNS' => 'Campagnes',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT' => 'Sélectionner',
'LBL_EDIT' => 'Editer',
'LBL_SAVE_AS'=>" Save As",
Expand Down
2 changes: 2 additions & 0 deletions include/language/hu_hu.lang.php
Expand Up @@ -333,6 +333,8 @@
'COMBO_HELPDESK' => 'Kérések',
'COMBO_USERS' => 'Felhasználók',
'COMBO_CAMPAIGNS' => 'Kampányok',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT' => 'Kiválaszt',
'LBL_EDIT' => 'Szerkeszt',
'LBL_DELETE' => 'Törlés',
Expand Down
3 changes: 2 additions & 1 deletion include/language/nl_nl.lang.php
@@ -1,5 +1,4 @@
<?php

/*******************************************************************************
* The contents of this file are subject to the following licences:
* - SugarCRM Public License Version 1.1.2 http://www.sugarcrm.com/SPL
Expand Down Expand Up @@ -354,6 +353,8 @@
'COMBO_HELPDESK' => 'Help-tickets',
'COMBO_USERS' => 'Gebruikers',
'COMBO_CAMPAIGNS' => 'Campagnes',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT' => 'Selecteer',
'LBL_EDIT' => 'Bewerk',
'LBL_DELETE' => 'Verwijder',
Expand Down
2 changes: 2 additions & 0 deletions include/language/pt_br.lang.php
Expand Up @@ -335,6 +335,8 @@
'COMBO_HELPDESK' => 'Tickets',
'COMBO_USERS' => 'Usuários',
'COMBO_CAMPAIGNS' => 'Campanhas',
'COMBO_VENDORS' => 'Vendors', //MSL
'LBL_VENDOR_NAME' => 'Vendor Name', //MSL
'LBL_SELECT' => 'Selecionar',
'LBL_EDIT' => 'Editar',
'LBL_DELETE' => 'Apagar',
Expand Down
8 changes: 7 additions & 1 deletion include/utils/DetailViewUtils.php
Expand Up @@ -800,7 +800,13 @@ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields,
$tickettitle = substr($tickettitle, 0, 25) . '...';
}
$label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>';
}
} elseif ($parent_module == "Vendors") { //MSL
$label_fld[] = $app_strings['LBL_VENDOR_NAME'];
$sql = "select vendorname from vtiger_vendor where vendorid=?";
$result = $adb->pquery($sql, array($value));
$vendor_name = $adb->query_result($result, 0, "vendorname");
$label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>';
} //MSL -------------------------------------------
} else {
$label_fld[] = getTranslatedString($fieldlabel, $module);
$label_fld[] = $value;
Expand Down
3 changes: 2 additions & 1 deletion include/utils/EditViewUtils.php
Expand Up @@ -789,7 +789,8 @@ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields
'Accounts' => $app_strings['COMBO_ACCOUNTS'],
'Potentials' => $app_strings['COMBO_POTENTIALS'],
'HelpDesk' => $app_strings['COMBO_HELPDESK'],
'Campaigns' => $app_strings['COMBO_CAMPAIGNS']
'Campaigns' => $app_strings['COMBO_CAMPAIGNS'],
'Vendors' => $app_strings['COMBO_VENDORS'] //MSL
);
if($act_mode == "Task") {
$parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
Expand Down
2 changes: 1 addition & 1 deletion include/utils/ListViewUtils.php
Expand Up @@ -3160,7 +3160,7 @@ function getRelatedTo($module, $list_result, $rset) {
$parent_result = $adb->pquery($parent_query, array($parent_id));
$parent_name = getFullNameFromQResult($parent_result, 0, "Contacts");
}
if ($parent_module == 'Vendors' && ($module == 'Emails')) {
if ($parent_module == 'Vendors' && ($module == 'Emails' || $module == 'Calendar')) { //MSL
$parent_query = "SELECT vendorname FROM vtiger_vendor WHERE vendorid=?";
$parent_result = $adb->pquery($parent_query, array($parent_id));
$parent_name = $adb->query_result($parent_result, 0, "vendorname");
Expand Down
6 changes: 5 additions & 1 deletion modules/Calendar/EditView.php
Expand Up @@ -134,7 +134,11 @@

$account_id = vtlib_purify($_REQUEST['account_id']);
$account_name = getAccountName($account_id);
}
} else { //MSL
$account_id = vtlib_purify($_REQUEST['vendor_id']);
$vndinfo = getEntityName('Vendors', $account_id);
$account_name = $vndinfo[$account_id];
} //--- MSL
}
if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
$focus->id = "";
Expand Down
1 change: 1 addition & 0 deletions modules/Calendar/addEventUI.php
Expand Up @@ -659,6 +659,7 @@ function getAssignedToHTML($assignedto,$toggletype)
<option value="Potentials"><?php echo $app_strings['Potentials']?></option>
<option value="HelpDesk"><?php echo $app_strings['HelpDesk']?></option>
<option value="Campaigns"><?php echo $app_strings['Campaigns']?></option>
<option value="Vendors"><?php echo $app_strings['Vendors']?></option> <!-- MSL -->
</select>
</td>
<td>
Expand Down
1 change: 1 addition & 0 deletions modules/Calendar4You/addEventUI.php
Expand Up @@ -649,6 +649,7 @@ function getAssignedToHTML($assignedto,$toggletype)
<option value="Potentials"><?php echo $app_strings['Potentials']?></option>
<option value="HelpDesk"><?php echo $app_strings['HelpDesk']?></option>
<option value="Campaigns"><?php echo $app_strings['Campaigns']?></option>
<option value="Vendors"><?php echo $app_strings['Vendors']?></option> <!-- MSL -->
</select>
</td>
<td>
Expand Down
11 changes: 11 additions & 0 deletions modules/Vendors/Vendors.js
Expand Up @@ -70,3 +70,14 @@ function set_return_address(vendor_id, vendor_name, street, city, state, code, c
window.opener.document.EditView.ship_pobox.value = pobox;
}

//MSL
function set_return(product_id, product_name) {
if(document.getElementById('from_link').value != '') {
window.opener.document.QcEditView.parent_name.value = product_name;
window.opener.document.QcEditView.parent_id.value = product_id;
} else {
window.opener.document.EditView.parent_name.value = product_name;
window.opener.document.EditView.parent_id.value = product_id;
}
}

118 changes: 118 additions & 0 deletions modules/Vendors/Vendors.php
Expand Up @@ -498,5 +498,123 @@ function save_related_module($module, $crmid, $with_module, $with_crmids) {
}
}

/** Returns a list of the associated tasks
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
* All Rights Reserved..
* Contributor(s): _MSL_____________________________________..
*/
function get_activities($id, $cur_tab_id, $rel_tab_id, $actions=false) {
global $log, $singlepane_view,$currentModule,$current_user;
$log->debug("Entering get_activities(".$id.") method ...");
$this_module = $currentModule;

$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once("modules/$related_module/Activity.php");
$other = new Activity();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);

$parenttab = getParentTab();

if($singlepane_view == 'true')
$returnset = '&return_module='.$this_module.'&return_action=DetailView&return_id='.$id;
else
$returnset = '&return_module='.$this_module.'&return_action=CallRelatedList&return_id='.$id;

$button = '';

$button .= '<input type="hidden" name="activity_mode">';

if($actions) {
if(is_string($actions)) $actions = explode(',', strtoupper($actions));
if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes') {
if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id', 'readwrite') == '0') {
$button .= "<input title='".getTranslatedString('LBL_NEW'). " ". getTranslatedString('LBL_TODO', $related_module) ."' class='crmbutton small create'" .
" onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$related_module\";this.form.return_module.value=\"$this_module\";this.form.activity_mode.value=\"Task\";' type='submit' name='button'" .
" value='". getTranslatedString('LBL_ADD_NEW'). " " . getTranslatedString('LBL_TODO', $related_module) ."'>&nbsp;";
}
if(getFieldVisibilityPermission('Events',$current_user->id,'parent_id', 'readwrite') == '0') {
$button .= "<input title='".getTranslatedString('LBL_NEW'). " ". getTranslatedString('LBL_TODO', $related_module) ."' class='crmbutton small create'" .
" onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$related_module\";this.form.return_module.value=\"$this_module\";this.form.activity_mode.value=\"Events\";' type='submit' name='button'" .
" value='". getTranslatedString('LBL_ADD_NEW'). " " . getTranslatedString('LBL_EVENT', $related_module) ."'>";
}
}
}

$userNameSql = getSqlForNameInDisplayFormat(array('first_name'=>
'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');

$query = "SELECT vtiger_activity.*,
vtiger_seactivityrel.*,vtiger_vendor.vendorname,
vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendor.vendorid as parent_id,
vtiger_crmentity.modifiedtime,
case when (vtiger_users.user_name not like '') then $userNameSql else vtiger_groups.groupname end as user_name,
vtiger_recurringevents.recurringtype
FROM vtiger_activity
INNER JOIN vtiger_seactivityrel
ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
inner join vtiger_vendor on vtiger_vendor.vendorid=vtiger_seactivityrel.crmid
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT OUTER JOIN vtiger_recurringevents
ON vtiger_recurringevents.activityid = vtiger_activity.activityid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
WHERE vtiger_seactivityrel.crmid = ".$id."
AND vtiger_crmentity.deleted = 0
AND ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred'))
OR (vtiger_activity.activitytype not in ('Emails','Task') and vtiger_activity.eventstatus not in ('','Held'))) ";

$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);

if($return_value == null) $return_value = Array();
$return_value['CUSTOM_BUTTON'] = $button;

$log->debug("Exiting get_activities method ...");
return $return_value;
}

/**
* Function to get Account related Task & Event which have activity type Held, Completed or Deferred.
* @param integer $id - accountid
* returns related Task or Event record in array format
* MSL
*/
function get_history($id)
{
global $log;
$log->debug("Entering get_history(".$id.") method ...");
$userNameSql = getSqlForNameInDisplayFormat(array('first_name'=>
'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject,
vtiger_activity.status, vtiger_activity.eventstatus,
vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,
vtiger_activity.time_start, vtiger_activity.time_end,
vtiger_crmentity.modifiedtime, vtiger_crmentity.createdtime,
vtiger_crmentity.description,case when (vtiger_users.user_name not like '') then $userNameSql else vtiger_groups.groupname end as user_name
FROM vtiger_activity
INNER JOIN vtiger_seactivityrel
ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id=vtiger_crmentity.smownerid
WHERE (vtiger_activity.activitytype != 'Emails')
AND (vtiger_activity.status = 'Completed'
OR vtiger_activity.status = 'Deferred'
OR (vtiger_activity.eventstatus = 'Held'
AND vtiger_activity.eventstatus != ''))
AND vtiger_seactivityrel.crmid = ".$id."
AND vtiger_crmentity.deleted = 0";
//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php

$log->debug("Exiting get_history method ...");
return getHistory('Accounts',$query,$id);
}

}
?>
7 changes: 7 additions & 0 deletions modules/cbupdater/cbupdater.xml
Expand Up @@ -190,4 +190,11 @@
<classname>MassUploadImageOnProduct</classname>
<systemupdate>false</systemupdate>
</changeSet>
<changeSet>
<author>mslokhat</author>
<description>Add Calendar Events to Vendors</description>
<filename>build/changeSets/addvend_activities.php</filename>
<classname>addVendorActivities</classname>
<systemupdate>false</systemupdate>
</changeSet>
</updatesChangeLog>

0 comments on commit aef5145

Please sign in to comment.