更新到 5.2 后第一次 SVN 提交。

yuchenghu@hawebs.net



git-svn-id: https://svn.code.sf.net/p/hawebs/svn@539 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-08-21 15:24:22 +00:00
parent cb87254354
commit fce9ce115a
124 changed files with 7392 additions and 943 deletions
+66 -45
View File
@@ -73,11 +73,13 @@ class Accounts extends CRMEntity {
var $search_fields = Array(
'Account Name'=>Array('vtiger_account'=>'accountname'),
'Billing City'=>Array('vtiger_accountbillads'=>'bill_city'),
'Assigned To'=>Array('vtiger_crmentity'=>'smownerid'),
);
var $search_fields_name = Array(
'Account Name'=>'accountname',
'Billing City'=>'bill_city',
'Assigned To'=>'assigned_user_id',
);
// This is the list of vtiger_fields that are required
var $required_fields = array();
@@ -145,6 +147,60 @@ class Accounts extends CRMEntity {
}
// Mike Crowe Mod --------------------------------------------------------
/** Returns a list of the associated Campaigns
* @param $id -- campaign id :: Type Integer
* @returns list of campaigns in array format
*/
function get_campaigns($id, $cur_tab_id, $rel_tab_id, $actions=false) {
global $log, $singlepane_view,$currentModule,$current_user;
$log->debug("Entering get_campaigns(".$id.") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once("modules/$related_module/$related_module.php");
$other = new $related_module();
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="email_directing_module"><input type="hidden" name="record">';
if($actions) {
if(is_string($actions)) $actions = explode(',', strtoupper($actions));
if(in_array('SELECT', $actions) && isPermitted($related_module,4, '') == 'yes') {
$button .= "<input title='".getTranslatedString('LBL_SELECT')." ". getTranslatedString($related_module). "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id&parenttab=$parenttab','test','width=640,height=602,resizable=0,scrollbars=0');\" value='". getTranslatedString('LBL_SELECT'). " " . getTranslatedString($related_module) ."'>&nbsp;";
}
if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes') {
$button .= "<input title='". getTranslatedString('LBL_ADD_NEW')." ". getTranslatedString($singular_modname)."' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"$this_module\",$id);' type='button' name='button' value='". getTranslatedString('LBL_ADD_NEW')." ". getTranslatedString($singular_modname)."'></td>";
}
}
$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus,
vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_crmentity.modifiedtime from vtiger_campaign
inner join vtiger_campaignaccountrel on vtiger_campaignaccountrel.campaignid=vtiger_campaign.campaignid
inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid
left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid
left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
where vtiger_campaignaccountrel.accountid=".$id." and vtiger_crmentity.deleted=0";
$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_campaigns method ...");
return $return_value;
}
/** Returns a list of the associated contacts
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
@@ -371,9 +427,7 @@ class Accounts extends CRMEntity {
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id=vtiger_crmentity.smownerid
WHERE (vtiger_activity.activitytype = 'Meeting'
OR vtiger_activity.activitytype = 'Call'
OR vtiger_activity.activitytype = 'Task')
WHERE (vtiger_activity.activitytype != 'Emails')
AND (vtiger_activity.status = 'Completed'
OR vtiger_activity.status = 'Deferred'
OR (vtiger_activity.eventstatus = 'Held'
@@ -690,34 +744,7 @@ class Accounts extends CRMEntity {
ON vtiger_users.id=vtiger_crmentity.smownerid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
WHERE vtiger_crmentity.deleted = 0 and ( vtiger_troubletickets.parent_id=".$id." or " ;
$query .= " vtiger_troubletickets.parent_id in(SELECT vtiger_contactdetails.contactid
FROM vtiger_contactdetails
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_crmentity.smownerid = vtiger_users.id
WHERE vtiger_crmentity.deleted = 0
AND vtiger_contactdetails.accountid = ".$id;
//Appending the security parameter
global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
$tab_id=getTabid('Contacts');
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
{
$sec_parameter=getListViewSecurityParameter('Contacts');
$query .= ' '.$sec_parameter;
}
$query .= ") )";
WHERE vtiger_crmentity.deleted = 0 and vtiger_troubletickets.parent_id=$id" ;
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if($return_value == null) $return_value = Array();
@@ -816,7 +843,7 @@ class Accounts extends CRMEntity {
ON vtiger_account2.accountid = vtiger_account.parentid
";//vtiger_account2 is added to get the Member of account
$query .= $this->getNonAdminAccessControlQuery('Accounts',$current_user);
$where_auto = " vtiger_crmentity.deleted = 0 ";
if($where != "")
@@ -824,15 +851,6 @@ class Accounts extends CRMEntity {
else
$query .= " WHERE ".$where_auto;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
//we should add security check when the user has Private Access
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3)
{
//Added security check to get the permitted records only
$query = $query." ".getListViewSecurityParameter("Accounts");
}
$log->debug("Exiting create_export_query method ...");
return $query;
}
@@ -865,7 +883,7 @@ class Accounts extends CRMEntity {
for($i=0; $i < $numRows;$i++)
{
$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
$custom_fields[$i] = preg_replace("/\s+/","",$custom_fields[$i]);
$custom_fields[$i] = strtoupper($custom_fields[$i]);
}
$mergeflds = $custom_fields;
@@ -935,6 +953,7 @@ class Accounts extends CRMEntity {
"HelpDesk" => array("vtiger_troubletickets"=>array("parent_id","ticketid"),"vtiger_account"=>"accountid"),
"Products" => array("vtiger_seproductsrel"=>array("crmid","productid"),"vtiger_account"=>"accountid"),
"Documents" => array("vtiger_senotesrel"=>array("crmid","notesid"),"vtiger_account"=>"accountid"),
"Campaigns" => array("vtiger_campaignaccountrel"=>array("accountid","campaignid"),"vtiger_account"=>"accountid"),
);
return $rel_tables[$secmodule];
}
@@ -1218,7 +1237,10 @@ class Accounts extends CRMEntity {
global $log;
if(empty($return_module) || empty($return_id)) return;
if($return_module == 'Products') {
if($return_module == 'Campaigns') {
$sql = 'DELETE FROM vtiger_campaignaccountrel WHERE accountid=? AND campaignid=?';
$this->db->pquery($sql, array($id, $return_id));
} else if($return_module == 'Products') {
$sql = 'DELETE FROM vtiger_seproductsrel WHERE crmid=? AND productid=?';
$this->db->pquery($sql, array($id, $return_id));
} else {
@@ -1227,7 +1249,6 @@ class Accounts extends CRMEntity {
$this->db->pquery($sql, $params);
}
}
}
?>
?>
@@ -62,6 +62,14 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') {
$smarty->assign("UPDATEINFO",updateInfo($focus->id));
if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
$related_array=getRelatedLists("Accounts",$focus);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
$relationId = vtlib_purify($_REQUEST['relation_id']);
RelatedListViewSession::addRelatedModuleToSession($relationId,
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
$smarty->assign("RELATEDLISTS", $related_array);
$smarty->assign("ID",$focus->id);
$smarty->assign("MODULE",$currentmodule);
@@ -145,6 +145,13 @@ if($singlepane_view == 'true')
{
$related_array = getRelatedLists($currentModule,$focus);
$smarty->assign("RELATEDLISTS", $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
}
$smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar'));
$smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events'));
@@ -157,7 +164,7 @@ $focus->markAsViewed($current_user->id);
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW'), $customlink_params));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
@@ -10,11 +10,11 @@
require_once('include/logging.php');
require_once('include/database/PearDatabase.php');
global $adb;
global $adb,$mod_strings;
$local_log =& LoggerManager::getLogger('AccountsAjax');
global $currentModule;
$acntObj = CRMEntity::getInstance($currentModule);
$modObj = CRMEntity::getInstance($currentModule);
$ajaxaction = $_REQUEST["ajxaction"];
if($ajaxaction == "DETAILVIEW")
@@ -25,20 +25,47 @@ if($ajaxaction == "DETAILVIEW")
$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
if($crmid != "")
{
$acntObj->retrieve_entity_info($crmid,"Accounts");
$acntObj->column_fields[$fieldname] = $fieldvalue;
$modObj->retrieve_entity_info($crmid,"Accounts");
$modObj->column_fields[$fieldname] = $fieldvalue;
if($fieldname=='accountname'){
$value = $fieldvalue;
$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
$params = array($value);
if(isset($crmid) && $crmid !='') {
$query .= " and vtiger_account.accountid != ?";
array_push($params, $crmid);
}
$result = $adb->pquery($query, $params);
if($adb->num_rows($result) > 0)
{
echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST'];
return false;
}
}
if($fieldname=='accountname'){
$value = $fieldvalue;
$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
$params = array($value);
if(isset($crmid) && $crmid !='') {
$query .= " and vtiger_account.accountid != ?";
array_push($params, $crmid);
}
$result = $adb->pquery($query, $params);
if($adb->num_rows($result) > 0)
{
echo ":#:ERR".$mod_strings['LBL_ACCOUNT_EXIST'];
return false;
}
}
if($fieldname == 'annual_revenue')//annual revenue converted to dollar value while saving
{
$acntObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue);
$modObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue);
}
$acntObj->id = $crmid;
$acntObj->mode = "edit";
$acntObj->save("Accounts");
if($acntObj->column_fields['notify_owner'] == 1 )
{
sendNotificationToOwner('Accounts',&$acntObj);
}
if($acntObj->id != "")
$modObj->id = $crmid;
$modObj->mode = "edit";
$modObj->save("Accounts");
if($modObj->id != "")
{
echo ":#:SUCCESS";
}else
@@ -49,5 +76,8 @@ if($ajaxaction == "DETAILVIEW")
{
echo ":#:FAILURE";
}
}elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
require_once 'include/ListView/RelatedListViewContents.php';
}
?>
?>
+37 -29
View File
@@ -91,15 +91,6 @@ $smarty->assign("CV_DELETE_PERMIT",$delete_permit);
//<<<<<customview>>>>>
$smarty->assign("CHANGE_OWNER",getUserslist());
$smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
{
list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
// we have a query
$url_string .="&query=true".$ustring;
$log->info("Here is the where clause for the list view: $where");
$smarty->assign("SEARCH_URL",$url_string);
}
if($viewid != 0)
{
$CActionDtls = $oCustomView->getCustomActionDetails($viewid);
@@ -170,23 +161,31 @@ $smarty->assign("SINGLE_MOD",'Account');
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if($viewid != "0")
{
$listquery = getListQuery("Accounts");
$query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Accounts");
}else
{
$query = getListQuery("Accounts");
global $current_user;
$queryGenerator = new QueryGenerator($currentModule, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
//<<<<<<<<customview>>>>>>>>>
if(isset($where) && $where != '')
{
$query .= ' and '.$where;
$_SESSION['export_where'] = $where;
// Enabling Module Search
$url_string = '';
if($_REQUEST['query'] == 'true') {
$queryGenerator->addUserSearchConditions($_REQUEST);
$ustring = getSearchURL($_REQUEST);
$url_string .= "&query=true$ustring";
$smarty->assign('SEARCH_URL', $url_string);
}
$query = $queryGenerator->getQuery();
$where = $queryGenerator->getConditionalWhere();
if(isset($where) && $where != '') {
$_SESSION['export_where'] = $where;
} else {
unset($_SESSION['export_where']);
}
else
unset($_SESSION['export_where']);
$view_script = "<script language='javascript'>
function set_selected()
@@ -257,13 +256,13 @@ if( $adb->dbType == "pgsql")
else
$list_result = $adb->pquery($query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
$smarty->assign('recordListRange',$recordListRangeMsg);
//mass merge for word templates -- *Raj*17/11
while($row = $adb->fetch_array($list_result))
{
$ids[] = $row["crmid"];
$ids[] = $row[$focus->table_index];
}
if(isset($ids))
{
@@ -302,13 +301,16 @@ if(isPermitted("Accounts","Merge") == 'yes')
if($viewid !='')
$url_string .= "&viewname=".$viewid;
$listview_header = getListViewHeader($focus,"Accounts",$url_string,$sorder,$order_by,"",$oCustomView);
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
$order_by);
$smarty->assign("LISTHEADER", $listview_header);
$listview_header_search=getSearchListHeaderValues($focus,"Accounts",$url_string,$sorder,$order_by,"",$oCustomView);
$listview_header_search = $controller->getBasicSearchFieldInfoList();
$smarty->assign("SEARCHLISTHEADER", $listview_header_search);
$listview_entries = getListViewEntries($focus,"Accounts",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
$navigation_array);
$smarty->assign("LISTENTITY", $listview_entries);
$smarty->assign("SELECT_SCRIPT", $view_script);
@@ -324,7 +326,7 @@ $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";")
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Accounts","index",$viewid);
$alphabetical = AlphabeticalSearch($currentModule,'index','accountname','true','basic',"","","","",$viewid);
$fieldnames = getAdvSearchfields($currentModule);
$fieldnames = $controller->getAdvancedSearchOptionString();
$criteria = getcriteria_options();
$smarty->assign("CRITERIA", $criteria);
$smarty->assign("FIELDNAMES", $fieldnames);
@@ -336,9 +338,15 @@ $smarty->assign("CHECK", $check_button);
$_SESSION[$currentModule.'_listquery'] = $query;
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
// END
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("ListViewEntries.tpl");
else
$smarty->display("ListView.tpl");
?>
?>
@@ -40,14 +40,16 @@ function getTopAccounts($maxval,$calCnt)
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
$list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) left join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) left join vtiger_groups on (vtiger_groups.groupid = vtiger_crmentity.smownerid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='".$current_user->id."' and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','".$app_strings['LBL_CLOSE_WON']."','".$app_strings['LBL_CLOSE_LOST']."')";
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3)
{
$sec_parameter=getListViewSecurityParameter('Accounts');
$list_query .= $sec_parameter;
}
$list_query .= " group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc";
$list_query = "select vtiger_potential.potentialname,vtiger_account.accountid, vtiger_account.accountname, ".
"vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential ".
"inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) ".
"left join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) ";
$list_query .= " WHERE vtiger_crmentity.deleted = 0 ".$where.
" AND vtiger_potential.potentialid>0";
$list_query .= " AND vtiger_crmentity.smownerid='".$current_user->id."' ".
"and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','".
$app_strings['LBL_CLOSE_WON']."','".$app_strings['LBL_CLOSE_LOST']."')";
$list_query .= " group by vtiger_account.accountid, vtiger_account.tickersymbol order by amount desc";
$list_query .= " LIMIT 0," . $adb->sql_escape_string($maxval);
@@ -82,7 +84,8 @@ function getTopAccounts($maxval,$calCnt)
$rate_symbol = getCurrencySymbolandCRate($currencyid);
$rate = $rate_symbol['rate'];
$curr_symbol = $rate_symbol['symbol'];
$header[]=$current_module_strings['LBL_LIST_AMOUNT'].'('.$curr_symbol.')';
$header[]=$current_module_strings['LBL_LIST_AMOUNT'].'('.$curr_symbol.')';
$header[] = $current_module_strings['LBL_POTENTIAL_TITLE'];
$entries=array();
foreach($open_accounts_list as $account)
+1 -1
View File
@@ -234,7 +234,7 @@ while($columnValues = $adb->fetch_array($result))
$actual_values[$x] = $value;
$actual_values[$x] = str_replace('"'," ",$actual_values[$x]);
//if value contains any line feed or carriage return replace the value with ".value."
if (preg_match ("/(\r\n)/", $actual_values[$x]))
if (preg_match ("/(\r?\n)/", $actual_values[$x]))
{
$actual_values[$x] = '"'.$actual_values[$x].'"';
}
+19 -5
View File
@@ -107,6 +107,24 @@ if($focus->mode == 'edit' && $_REQUEST['address_change'] == 'yes')
//Changing account address - Ends
$focus->save("Accounts");
if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == "Campaigns")
{
if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
{
$campAccStatusResult = $adb->pquery("select campaignrelstatusid from vtiger_campaignaccountrel where campaignid=? AND accountid=?",array($_REQUEST['return_id'], $focus->id));
$accountStatus = $adb->query_result($campAccStatusResult,0,'campaignrelstatusid');
$sql = "delete from vtiger_campaignaccountrel where accountid = ?";
$adb->pquery($sql, array($focus->id));
if(isset($accountStatus) && $accountStatus!=''){
$sql = "insert into vtiger_campaignaccountrel values (?,?,?)";
$adb->pquery($sql, array($_REQUEST['return_id'], $focus->id,$accountStatus));
}
else{
$sql = "insert into vtiger_campaignaccountrel values (?,?,1)";
$adb->pquery($sql, array($_REQUEST['return_id'], $focus->id));
}
}
}
$return_id = $focus->id;
$parenttab = getParentTab();
@@ -122,10 +140,6 @@ $local_log->debug("Saved record with id of ".$return_id);
if($_REQUEST['return_viewname'] == '') $return_viewname='0';
if($_REQUEST['return_viewname'] != '')$return_viewname=vtlib_purify($_REQUEST['return_viewname']);
//Send notification mail to the assigned to owner about the vtiger_account creation
if($focus->column_fields['notify_owner'] == 1 || $focus->column_fields['notify_owner'] == 'on')
$status = sendNotificationToOwner('Accounts',$focus);
header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname&start=".vtlib_purify($_REQUEST['pagenumber']).$search);
/** Function to save Accounts custom field info into database
* @param integer $entity_id - accountid
@@ -214,4 +228,4 @@ function save_customfields($entity_id)
}
$log->debug("Exiting save_customfields method ...");
}
?>
?>
@@ -39,7 +39,9 @@ foreach($storearray as $id)
$adb->pquery("insert into vtiger_senotesrel values (?,?)", array($forCRMRecord,$id));
elseif($dest_mod == 'Products')
$adb->pquery("insert into vtiger_seproductsrel values(?,?,?)", array($forCRMRecord, $id, $currentModule));
else {
elseif($dest_mod == 'Campaigns')
$adb->pquery("insert into vtiger_campaignaccountrel values(?,?,1)", array($id, $forCRMRecord));
else {
$focus->save_related_module($currentModule, $forCRMRecord, $dest_mod, $id);
}
}
@@ -47,4 +49,4 @@ foreach($storearray as $id)
header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab);
?>
?>
@@ -16,10 +16,8 @@
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Administration/index.php,v 1.1 2004/08/17 15:03:27 gjayakrishnan Exp $
* Description: TODO: To be written.
********************************************************************************/
$_SESSION['user_sorder']='';
$_SESSION['user_orderby']='';
$_SESSION['user_pagestart'] = 1;
$currentModule = 'Users';
include("modules/Users/ListView.php");
?>
@@ -17,9 +17,6 @@
* Description: Defines the English language pack for the Account module.
********************************************************************************/
$mod_strings = Array(
'LBL_MODULE_NAME'=>'Administration',
'LBL_MODULE_TITLE'=>'Administration: Home',
+341
View File
@@ -0,0 +1,341 @@
/*+**********************************************************************************
* 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.
************************************************************************************/
document.write("<script type='text/javascript' src='modules/Products/multifile.js'></"+"script>");
document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");
function updateListPrice(unitprice,fieldname, oSelect)
{
if(oSelect.checked == true)
{
document.getElementById(fieldname).style.visibility = 'visible';
document.getElementById(fieldname).value = unitprice;
}else
{
document.getElementById(fieldname).style.visibility = 'hidden';
}
}
function check4null(form)
{
var isError = false;
var errorMessage = "";
if (trim(form.productname.value) =='') {
isError = true;
errorMessage += "\n Product Name";
form.productname.focus();
}
if (isError == true) {
alert(alert_arr.MISSING_REQUIRED_FIELDS + errorMessage);
return false;
}
return true;
}
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;
}
}
function set_return_specific(product_id, product_name) {
//getOpenerObj used for DetailView
if(document.getElementById('from_link').value != '')
{
var fldName = window.opener.document.QcEditView.product_name;
var fldId = window.opener.document.QcEditView.product_id;
}else if(typeof(window.opener.document.DetailView) != 'undefined')
{
var fldName = window.opener.document.DetailView.product_name;
var fldId = window.opener.document.DetailView.product_id;
}else
{
var fldName = window.opener.document.EditView.product_name;
var fldId = window.opener.document.EditView.product_id;
}
fldName.value = product_name;
fldId.value = product_id;
}
function set_return_formname_specific(formname,product_id, product_name) {
window.opener.document.EditView1.product_name.value = product_name;
window.opener.document.EditView1.product_id.value = product_id;
}
function add_data_to_relatedlist(entity_id,recordid) {
opener.document.location.href="index.php?module={RETURN_MODULE}&action=updateRelations&smodule={SMODULE}&destination_module=Products&entityid="+entity_id+"&parentid="+recordid;
}
function set_return_inventory(product_id,product_name,unitprice,taxstr,curr_row,desc) {
window.opener.document.EditView.elements["productName"+curr_row].value = product_name;
window.opener.document.EditView.elements["hdnProductId"+curr_row].value = product_id;
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
window.opener.document.EditView.elements["comment"+curr_row].value = desc;
// Apply decimal round-off to value
if(!isNaN(parseFloat(unitprice))) unitprice = roundPriceValue(unitprice);
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
var tax_array = new Array();
var tax_details = new Array();
tax_array = taxstr.split(',');
for(var i=0;i<tax_array.length;i++)
{
tax_details = tax_array[i].split('=');
}
window.opener.document.EditView.elements["qty"+curr_row].focus()
}
function set_return_inventory_po(product_id,product_name,unitprice,taxstr,curr_row,desc) {
window.opener.document.EditView.elements["productName"+curr_row].value = product_name;
window.opener.document.EditView.elements["hdnProductId"+curr_row].value = product_id;
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
window.opener.document.EditView.elements["comment"+curr_row].value = desc;
//getOpenerObj("unitPrice"+curr_row).innerHTML = unitprice;
// Apply decimal round-off to value
if(!isNaN(parseFloat(unitprice))) unitprice = roundPriceValue(unitprice);
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
var tax_array = new Array();
var tax_details = new Array();
tax_array = taxstr.split(',');
for(var i=0;i<tax_array.length;i++)
{
tax_details = tax_array[i].split('=');
}
window.opener.document.EditView.elements["qty"+curr_row].focus()
}
function InventorySelectAllServices(mod,z,image_pth)
{
if(document.selectall.selected_id != undefined)
{
var x = document.selectall.selected_id.length;
var y=0;
idstring = "";
namestr = "";
var action_str="";
if ( x == undefined) {
if (document.selectall.selected_id.checked) {
idstring = document.selectall.selected_id.value;
c = document.selectall.selected_id.value;
var prod_array = JSON.parse($('popup_product_'+c).attributes['vt_prod_arr'].nodeValue);
var prod_id = prod_array['entityid'];
var prod_name = prod_array['prodname'];
var unit_price = prod_array['unitprice'];
var taxstring = prod_array['taxstring'];
var desc = prod_array['desc'];
var row_id = prod_array['rowid'];
set_return_inventory(prod_id,prod_name,unit_price,taxstring,parseInt(row_id),desc);
y=1;
} else {
alert(alert_arr.SELECT);
return false;
}
} else {
y=0;
for(i = 0; i < x ; i++) {
if(document.selectall.selected_id[i].checked) {
idstring = document.selectall.selected_id[i].value+";"+idstring;
c = document.selectall.selected_id[i].value;
var prod_array = JSON.parse($('popup_product_'+c).attributes['vt_prod_arr'].nodeValue);
var prod_id = prod_array['entityid'];
var prod_name = prod_array['prodname'];
var unit_price = prod_array['unitprice'];
var taxstring = prod_array['taxstring'];
var desc = prod_array['desc'];
if(y>0) {
var row_id = window.opener.fnAddProductRow(mod,image_pth);
} else {
var row_id = prod_array['rowid'];
}
set_return_inventory(prod_id,prod_name,unit_price,taxstring,parseInt(row_id),desc);
y=y+1;
}
}
}
if (y != 0) {
document.selectall.idlist.value=idstring;
return true;
} else {
alert(alert_arr.SELECT);
return false;
}
}
}
function set_return_product(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.product_name.value = product_name;
window.opener.document.EditView.product_id.value = product_id;
}
}
function getImageListBody() {
if (browser_ie) {
var ImageListBody=getObj("ImageList")
} else if (browser_nn4 || browser_nn6) {
if (getObj("ImageList").childNodes.item(0).tagName=="TABLE") {
var ImageListBody=getObj("ImageList")
} else {
var ImageListBody=getObj("ImageList")
}
}
return ImageListBody;
}
// Function to Round off the Price Value
function roundPriceValue(val) {
val = parseFloat(val);
val = Math.round(val*100)/100;
val = val.toString();
if (val.indexOf(".")<0) {
val+=".00"
} else {
var dec=val.substring(val.indexOf(".")+1,val.length)
if (dec.length>2)
val=val.substring(0,val.indexOf("."))+"."+dec.substring(0,2)
else if (dec.length==1)
val=val+"0"
}
return val;
}
// End
function fnAddServiceRow(module,image_path){
rowCnt++;
var tableName = document.getElementById('proTab');
var prev = tableName.rows.length;
var count = eval(prev)-1;//As the table has two headers, we should reduce the count
var row = tableName.insertRow(prev);
row.id = "row"+count;
row.style.verticalAlign = "top";
var colone = row.insertCell(0);
var coltwo = row.insertCell(1);
if(module == "PurchaseOrder"){
var colfour = row.insertCell(2);
var colfive = row.insertCell(3);
var colsix = row.insertCell(4);
var colseven = row.insertCell(5);
}
else{
var colthree = row.insertCell(2);
var colfour = row.insertCell(3);
var colfive = row.insertCell(4);
var colsix = row.insertCell(5);
var colseven = row.insertCell(6);
}
/* Product Re-Ordering Feature Code Addition Starts */
iMax = tableName.rows.length;
for(iCount=1;iCount<=iMax-3;iCount++)
{
if(document.getElementById("row"+iCount) && document.getElementById("row"+iCount).style.display != 'none')
{
iPrevRowIndex = iCount;
}
}
iPrevCount = eval(iPrevRowIndex);
var oPrevRow = tableName.rows[iPrevRowIndex+1];
var delete_row_count=count;
/* Product Re-Ordering Feature Code Addition ends */
//Delete link
colone.className = "crmTableRow small";
colone.id = row.id+"_col1";
colone.innerHTML='<img src="themes/images/delete.gif" border="0" onclick="deleteRow(\''+module+'\','+count+',\''+image_path+'\')"><input id="deleted'+count+'" name="deleted'+count+'" type="hidden" value="0"><br/><br/>&nbsp;<a href="javascript:moveUpDown(\'UP\',\''+module+'\','+count+')" title="Move Upward"><img src="themes/images/up_layout.gif" border="0"></a>';
/* Product Re-Ordering Feature Code Addition Starts */
if(iPrevCount != 1)
{
oPrevRow.cells[0].innerHTML = '<img src="themes/images/delete.gif" border="0" onclick="deleteRow(\''+module+'\','+iPrevCount+')"><input id="deleted'+iPrevCount+'" name="deleted'+iPrevCount+'" type="hidden" value="0"><br/><br/>&nbsp;<a href="javascript:moveUpDown(\'UP\',\''+module+'\','+iPrevCount+')" title="Move Upward"><img src="themes/images/up_layout.gif" border="0"></a>&nbsp;&nbsp;<a href="javascript:moveUpDown(\'DOWN\',\''+module+'\','+iPrevCount+')" title="Move Downward"><img src="themes/images/down_layout.gif" border="0"></a>';
}
else
{
oPrevRow.cells[0].innerHTML = '<input id="deleted'+iPrevCount+'" name="deleted'+iPrevCount+'" type="hidden" value="0"><br/><br/><a href="javascript:moveUpDown(\'DOWN\',\''+module+'\','+iPrevCount+')" title="Move Downward"><img src="themes/images/down_layout.gif" border="0"></a>';
}
/* Product Re-Ordering Feature Code Addition ends */
//Product Name with Popup image to select product
coltwo.className = "crmTableRow small"
coltwo.innerHTML= '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td class="small"><input id="productName'+count+'" name="productName'+count+'" class="small" style="width: 70%;" value="" readonly="readonly" type="text" />'+
'<input id="hdnProductId'+count+'" name="hdnProductId'+count+'" value="" type="hidden" /><input type="hidden" id="lineItemType'+count+'" name="lineItemType'+count+'" value="Services" />'+
'&nbsp;<img id="searchIcon'+count+'" title="Services" src="themes/images/services.gif" style="cursor: pointer;" onclick="servicePickList(this,\''+module+'\','+count+')" align="absmiddle">'+
'</td></tr><tr><td class="small"><input type="hidden" value="" id="subproduct_ids'+count+'" name="subproduct_ids'+count+'" /><span id="subprod_names'+count+'" name="subprod_names'+count+'" style="color:#C0C0C0;font-style:italic;"> </span>'+
'</td></tr><tr><td class="small" id="setComment'+count+'"><textarea id="comment'+count+'" name="comment'+count+'" class=small style="width:70%;height:40px"></textarea><img src="themes/images/clear_field.gif" onClick="getObj(\'comment'+count+'\').value=\'\'"; style="cursor:pointer;" /></td></tr></tbody></table>';
//Quantity In Stock - only for SO, Quotes and Invoice
if(module != "PurchaseOrder"){
colthree.className = "crmTableRow small"
colthree.innerHTML='<span id="qtyInStock'+count+'">NA</span>';
}
//Quantity
var temp='';
colfour.className = "crmTableRow small"
temp='<input id="qty'+count+'" name="qty'+count+'" type="text" class="small " style="width:50px" onfocus="this.className=\'detailedViewTextBoxOn\'" onBlur="settotalnoofrows(); calcTotal(); loadTaxes_Ajax('+count+');';
temp+='" onChange="setDiscount(this,'+count+')" value=""/><br>';
colfour.innerHTML=temp;
//List Price with Discount, Total after Discount and Tax labels
colfive.className = "crmTableRow small"
colfive.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr><td align="right"><input id="listPrice'+count+'" name="listPrice'+count+'" value="0.00" type="text" class="small " style="width:70px" onBlur="calcTotal();setDiscount(this,'+count+');callTaxCalc('+count+'); calcTotal();"/>&nbsp;<img src="themes/images/pricebook.gif" onclick="priceBookPickList(this,'+count+')"></td></tr><tr><td align="right" style="padding:5px;" nowrap> (-)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(this,\'discount_div'+count+'\',\'discount\','+count+')" >'+product_labelarr.DISCOUNT+'</a> : </b><div class=\"discountUI\" id=\"discount_div'+count+'"><input type="hidden" id="discount_type'+count+'" name="discount_type'+count+'" value=""><table width="100%" border="0" cellpadding="5" cellspacing="0" class="small"><tr><td id="discount_div_title'+count+'" nowrap align="left" ></td><td align="right"><img src="themes/images/close.gif" border="0" onClick="fnHidePopDiv(\'discount_div'+count+'\')" style="cursor:pointer;"></td></tr><tr><td align="left" class="lineOnTop"><input type="radio" name="discount'+count+'" checked onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();">&nbsp; '+product_labelarr.ZERO_DISCOUNT+'</td><td class="lineOnTop">&nbsp;</td></tr><tr><td align="left"><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();">&nbsp; % '+product_labelarr.PERCENT_OF_PRICE+' </td><td align="right"><input type="text" class="small" size="2" id="discount_percentage'+count+'" name="discount_percentage'+count+'" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();">&nbsp;%</td></tr><tr><td align="left" nowrap><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();">&nbsp; '+product_labelarr.DIRECT_PRICE_REDUCTION+'</td><td align="right"><input type="text" id="discount_amount'+count+'" name="discount_amount'+count+'" size="5" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"></td></tr></table></div></td></tr><tr> <td align="right" style="padding:5px;" nowrap><b>'+product_labelarr.TOTAL_AFTER_DISCOUNT+' :</b></td></tr><tr id="individual_tax_row'+count+'" class="TaxShow"><td align="right" style="padding:5px;" nowrap>(+)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(this,\'tax_div'+count+'\',\'tax\','+count+')" >'+product_labelarr.TAX+' </a> : </b><div class="discountUI" id="tax_div'+count+'"></div></td></tr></table> ';
//Total and Discount, Total after Discount and Tax details
colsix.className = "crmTableRow small"
colsix.innerHTML = '<table width="100%" cellpadding="5" cellspacing="0"><tr><td id="productTotal'+count+'" align="right">&nbsp;</td></tr><tr><td id="discountTotal'+count+'" align="right">0.00</td></tr><tr><td id="totalAfterDiscount'+count+'" align="right">&nbsp;</td></tr><tr><td id="taxTotal'+count+'" align="right">0.00</td></tr></table>';
//Net Price
colseven.className = "crmTableRow small";
colseven.align = "right";
colseven.style.verticalAlign = "bottom";
colseven.innerHTML = '<span id="netPrice'+count+'"><b>&nbsp;</b></span>';
//This is to show or hide the individual or group tax
decideTaxDiv();
calcTotal();
return count;
}
function servicePickList(currObj,module, row_no) {
var trObj=currObj.parentNode.parentNode
var rowId = row_no;
var currentRowId = parseInt(currObj.id.match(/([0-9]+)$/)[1]);
// If we have mismatching rowId and currentRowId, it is due swapping of rows
if(rowId != currentRowId) {
rowId = currentRowId;
}
var currencyid = document.getElementById("inventory_currency").value;
popuptype = 'inventory_service';
var record_id = '';
if(document.getElementsByName("account_id").length != 0)
record_id= document.EditView.account_id.value;
if(record_id != '')
window.open("index.php?module=Services&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId+"&relmod_id="+record_id+"&parent_module=Accounts&return_module="+module+"&currencyid="+currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
else
window.open("index.php?module=Services&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId+"&return_module="+module+"&currencyid="+currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
}
+518
View File
@@ -0,0 +1,518 @@
<?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.
************************************************************************************/
require_once('data/CRMEntity.php');
require_once('data/Tracker.php');
class Assets extends CRMEntity {
var $db, $log; // Used in class functions of CRMEntity
var $table_name = 'vtiger_assets';
var $table_index= 'assetsid';
var $column_fields = Array();
/**
* Mandatory table for supporting custom fields.
*/
var $customFieldTable = Array('vtiger_assetscf', 'assetsid');
/**
* Mandatory for Saving, Include tables related to this module.
*/
var $tab_name = Array('vtiger_crmentity','vtiger_assets','vtiger_assetscf');
/**
* Mandatory for Saving, Include tablename and tablekey columnname here.
*/
var $tab_name_index = Array(
'vtiger_crmentity'=>'crmid',
'vtiger_assets'=>'assetsid',
'vtiger_assetscf'=>'assetsid');
/**
* Mandatory for Listing (Related listview)
*/
var $list_fields = Array(
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Asset No'=>Array('assets'=>'asset_no'),
'Asset Name'=>Array('assets'=>'assetname'),
'Customer Name'=>Array('account'=>'account'),
'Product Name'=>Array('products'=>'product'),
);
var $list_fields_name = Array(
/* Format: Field Label => fieldname */
'Asset No'=>'asset_no',
'Asset Name'=>'assetname',
'Customer Name'=>'account',
'Product Name'=>'product',
);
// Make the field link to detail view
var $list_link_field= 'assetname';
// For Popup listview and UI type support
var $search_fields = Array(
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Asset No'=>Array('assets'=>'asset_no'),
'Asset Name'=>Array('assets'=>'assetname'),
'Customer Name'=>Array('account'=>'account'),
'Product Name'=>Array('products'=>'product')
);
var $search_fields_name = Array(
/* Format: Field Label => fieldname */
'Asset No'=>'asset_no',
'Asset Name'=>'assetname',
'Customer Name'=>'account',
'Product Name'=>'product'
);
// For Popup window record selection
var $popup_fields = Array ('assetname','account','product');
// Placeholder for sort fields - All the fields will be initialized for Sorting through initSortFields
var $sortby_fields = Array();
// For Alphabetical search
var $def_basicsearch_col = 'assetname';
// Required Information for enabling Import feature
var $required_fields = Array('assetname'=>1);
// Used when enabling/disabling the mandatory fields for the module.
// Refers to vtiger_field.fieldname values.
var $mandatory_fields = Array('assetname', 'product');
// Callback function list during Importing
var $special_functions = Array('set_import_assigned_user');
var $default_order_by = 'assetname';
var $default_sort_order='ASC';
var $unit_price;
/** Constructor which will set the column_fields in this object
*/
function __construct() {
global $log;
$this->column_fields = getColumnFields('Assets');
$this->db = PearDatabase::getInstance();
$this->log = $log;
}
function getSortOrder() {
global $currentModule;
$sortorder = $this->default_sort_order;
if($_REQUEST['sorder']) $sortorder = $this->db->sql_escape_string($_REQUEST['sorder']);
else if($_SESSION[$currentModule.'_Sort_Order'])
$sortorder = $_SESSION[$currentModule.'_Sort_Order'];
return $sortorder;
}
function getOrderBy() {
global $currentModule;
$use_default_order_by = '';
if(PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
$use_default_order_by = $this->default_order_by;
}
$orderby = $use_default_order_by;
if($_REQUEST['order_by']) $orderby = $this->db->sql_escape_string($_REQUEST['order_by']);
else if($_SESSION[$currentModule.'_Order_By'])
$orderby = $_SESSION[$currentModule.'_Order_By'];
return $orderby;
}
function save_module($module){
//module specific save
}
/**
* Return query to use based on given modulename, fieldname
* Useful to handle specific case handling for Popup
*/
function getQueryByModuleField($module, $fieldname, $srcrecord) {
// $srcrecord could be empty
}
/**
* Get list view query.
*/
function getListQuery($module, $where='') {
$query = "SELECT vtiger_crmentity.*, $this->table_name.*";
// Select Custom Field Table Columns if present
if(!empty($this->customFieldTable)) $query .= ", " . $this->customFieldTable[0] . ".* ";
$query .= " FROM $this->table_name";
$query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $this->table_name.$this->table_index";
// Consider custom table join as well.
if(!empty($this->customFieldTable)) {
$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
" = $this->table_name.$this->table_index";
}
$query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" .
" INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" .
" WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($module));
$linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
for($i=0; $i<$linkedFieldsCount; $i++) {
$related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
$fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
$columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
$other = CRMEntity::getInstance($related_module);
vtlib_setup_modulevars($related_module, $other);
$query .= " LEFT JOIN $other->table_name ON $other->table_name.$other->table_index = $this->table_name.$columnname";
}
$query .= " WHERE vtiger_crmentity.deleted = 0 ".$where;
$query .= $this->getListViewSecurityParameter($module);
return $query;
}
/**
* Apply security restriction (sharing privilege) query part for List view.
*/
function getListViewSecurityParameter($module) {
global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
$sec_query = '';
$tabid = getTabid($module);
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1
&& $defaultOrgSharingPermission[$tabid] == 3) {
$sec_query .= " AND (vtiger_crmentity.smownerid in($current_user->id) OR vtiger_crmentity.smownerid IN
(
SELECT vtiger_user2role.userid FROM vtiger_user2role
INNER JOIN vtiger_users ON vtiger_users.id=vtiger_user2role.userid
INNER JOIN vtiger_role ON vtiger_role.roleid=vtiger_user2role.roleid
WHERE vtiger_role.parentrole LIKE '".$current_user_parent_role_seq."::%'
)
OR vtiger_crmentity.smownerid IN
(
SELECT shareduserid FROM vtiger_tmp_read_user_sharing_per
WHERE userid=".$current_user->id." AND tabid=".$tabid."
)
OR
(";
// Build the query based on the group association of current user.
if(sizeof($current_user_groups) > 0) {
$sec_query .= " vtiger_groups.groupid IN (". implode(",", $current_user_groups) .") OR ";
}
$sec_query .= " vtiger_groups.groupid IN
(
SELECT vtiger_tmp_read_group_sharing_per.sharedgroupid
FROM vtiger_tmp_read_group_sharing_per
WHERE userid=".$current_user->id." and tabid=".$tabid."
)";
$sec_query .= ")
)";
}
return $sec_query;
}
/**
* Create query to export the records.
*/
function create_export_query($where)
{
global $current_user;
$thismodule = $_REQUEST['module'];
include("include/utils/ExportUtils.php");
//To get the Permitted fields query and the permitted fields list
$sql = getPermittedFieldsQuery($thismodule, "detail_view");
$fields_list = getFieldsListFromQuery($sql);
$query = "SELECT $fields_list, vtiger_users.user_name AS user_name
FROM vtiger_crmentity INNER JOIN $this->table_name ON vtiger_crmentity.crmid=$this->table_name.$this->table_index";
if(!empty($this->customFieldTable)) {
$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
" = $this->table_name.$this->table_index";
}
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
$where_auto = " vtiger_crmentity.deleted=0";
if($where != '') $query .= " WHERE ($where) AND $where_auto";
else $query .= " WHERE $where_auto";
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
// Security Check for Field Access
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[getTabid('Assets')] == 3)
{
//Added security check to get the permitted records only
$query = $query." ".getListViewSecurityParameter($thismodule);
}
return $query;
}
/**
* Initialize this instance for importing.
*/
function initImport($module) {
$this->db = PearDatabase::getInstance();
$this->initImportableFields($module);
}
/**
* Create list query to be shown at the last step of the import.
* Called From: modules/Import/UserLastImport.php
*/
function create_import_query($module) {
global $current_user;
$query = "SELECT vtiger_crmentity.crmid, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, $this->table_name.* FROM $this->table_name
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $this->table_name.$this->table_index
LEFT JOIN vtiger_users_last_import ON vtiger_users_last_import.bean_id=vtiger_crmentity.crmid
LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid
WHERE vtiger_users_last_import.assigned_user_id='$current_user->id'
AND vtiger_users_last_import.bean_type='$module'
AND vtiger_users_last_import.deleted=0";
return $query;
}
/**
* Delete the last imported records.
*/
function undo_import($module, $user_id) {
global $adb;
$count = 0;
$query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='$module' AND deleted=0";
$result1 = $adb->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error());
while ( $row1 = $adb->fetchByAssoc($result1))
{
$query2 = "update vtiger_crmentity set deleted=1 where crmid=?";
$result2 = $adb->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error());
$count++;
}
return $count;
}
/**
* Transform the value while exporting
*/
function transform_export_value($key, $value) {
if($key == 'owner') return getOwnerName($value);
return parent::transform_export_value($key, $value);
}
/**
* Function which will set the assigned user id for import record.
*/
function set_import_assigned_user()
{
global $current_user, $adb;
$record_user = $this->column_fields["assigned_user_id"];
if($record_user != $current_user->id){
$sqlresult = $adb->pquery("select id from vtiger_users where id = ? union select groupid as id from vtiger_groups where groupid = ?", array($record_user, $record_user));
if($this->db->num_rows($sqlresult)!= 1) {
$this->column_fields["assigned_user_id"] = $current_user->id;
} else {
$row = $adb->fetchByAssoc($sqlresult, -1, false);
if (isset($row['id']) && $row['id'] != -1) {
$this->column_fields["assigned_user_id"] = $row['id'];
} else {
$this->column_fields["assigned_user_id"] = $current_user->id;
}
}
}
}
/**
* Function which will give the basic query to find duplicates
*/
function getDuplicatesQuery($module,$table_cols,$field_values,$ui_type_arr,$select_cols='') {
$select_clause = "SELECT ". $this->table_name .".".$this->table_index ." AS recordid, vtiger_users_last_import.deleted,".$table_cols;
// Select Custom Field Table Columns if present
if(isset($this->customFieldTable)) $query .= ", " . $this->customFieldTable[0] . ".* ";
$from_clause = " FROM $this->table_name";
$from_clause .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $this->table_name.$this->table_index";
// Consider custom table join as well.
if(isset($this->customFieldTable)) {
$from_clause .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
" = $this->table_name.$this->table_index";
}
$from_clause .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$where_clause = " WHERE vtiger_crmentity.deleted = 0";
$where_clause .= $this->getListViewSecurityParameter($module);
if (isset($select_cols) && trim($select_cols) != '') {
$sub_query = "SELECT $select_cols FROM $this->table_name AS t " .
" INNER JOIN vtiger_crmentity AS crm ON crm.crmid = t.".$this->table_index;
// Consider custom table join as well.
if(isset($this->customFieldTable)) {
$sub_query .= " INNER JOIN ".$this->customFieldTable[0]." tcf ON tcf.".$this->customFieldTable[1]." = t.$this->table_index";
}
$sub_query .= " WHERE crm.deleted=0 GROUP BY $select_cols HAVING COUNT(*)>1";
} else {
$sub_query = "SELECT $table_cols $from_clause $where_clause GROUP BY $table_cols HAVING COUNT(*)>1";
}
$query = $select_clause . $from_clause .
" LEFT JOIN vtiger_users_last_import ON vtiger_users_last_import.bean_id=" . $this->table_name .".".$this->table_index .
" INNER JOIN (" . $sub_query . ") AS temp ON ".get_on_clause($field_values,$ui_type_arr,$module) .
$where_clause .
" ORDER BY $table_cols,". $this->table_name .".".$this->table_index ." ASC";
return $query;
}
/**
* Handle saving related module information.
* NOTE: This function has been added to CRMEntity (base class).
* You can override the behavior by re-defining it here.
*/
// function save_related_module($module, $crmid, $with_module, $with_crmid) { }
/**
* Handle deleting related module information.
* NOTE: This function has been added to CRMEntity (base class).
* You can override the behavior by re-defining it here.
*/
//function delete_related_module($module, $crmid, $with_module, $with_crmid) { }
/**
* Handle getting related list information.
* NOTE: This function has been added to CRMEntity (base class).
* You can override the behavior by re-defining it here.
*/
//function get_related_list($id, $cur_tab_id, $rel_tab_id, $actions=false) { }
/*
* Function to get the primary query part of a report
* @param - $module primary module name
* returns the query string formed on fetching the related data for report for secondary module
*/
function generateReportsQuery($module){
global $current_user;
$query = "from vtiger_assets
inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_assets.assetsid
left join vtiger_assetscf on vtiger_assets.assetsid = vtiger_assetscf.assetsid
left join vtiger_account as vtiger_accountAssets on vtiger_accountAssets.accountid=vtiger_assets.account
left join vtiger_products as vtiger_productAssets on vtiger_productAssets.productid=vtiger_assets.product
left join vtiger_invoice as vtiger_invoiceAssets on vtiger_invoiceAssets.invoiceid=vtiger_assets.invoiceid
left join vtiger_users as vtiger_usersAssets on vtiger_usersAssets.id=vtiger_crmentity.smownerid
left join vtiger_groups as vtiger_groupsAssets on vtiger_groupsAssets.groupid=vtiger_crmentity.smownerid";
return $query;
}
/*
* Function to get the secondary query part of a report
* @param - $module primary module name
* @param - $secmodule secondary module name
* returns the query string formed on fetching the related data for report for secondary module
*/
function generateReportsSecQuery($module,$secmodule){
global $current_user;
$query = $this->getRelationQuery($module,$secmodule,"vtiger_assets","assetsid");
$query .= " left join vtiger_crmentity as vtiger_crmentityAssets on vtiger_crmentityAssets.crmid=vtiger_assets.assetsid and vtiger_crmentityAssets.deleted=0
left join vtiger_assetscf on vtiger_assets.assetsid = vtiger_assetscf.assetsid
left join vtiger_account as vtiger_accountAssets on vtiger_accountAssets.accountid=vtiger_assets.account
left join vtiger_products as vtiger_productAssets on vtiger_productAssets.productid=vtiger_assets.product
left join vtiger_invoice as vtiger_invoiceAssets on vtiger_invoiceAssets.invoiceid=vtiger_assets.invoiceid
left join vtiger_users as vtiger_usersAssets on vtiger_usersAssets.id=vtiger_crmentity.smownerid
left join vtiger_groups as vtiger_groupsAssets on vtiger_groupsAssets.groupid=vtiger_crmentity.smownerid
";
return $query;
}
// Function to unlink all the dependent entities of the given Entity by Id
function unlinkDependencies($module, $id) {
global $log;
parent::unlinkDependencies($module, $id);
}
/**
* Invoked when special actions are performed on the module.
* @param String Module name
* @param String Event Type
*/
function vtlib_handler($moduleName, $eventType) {
require_once('include/utils/utils.php');
global $adb;
if($eventType == 'module.postinstall') {
//Add Assets Module to Customer Portal
global $adb;
$visible=1;
$query = $adb->pquery("SELECT max(sequence) AS max_tabseq FROM vtiger_customerportal_tabs",array());
$maxtabseq = $adb->query_result($query, 0, 'max_tabseq');
$newTabSeq = ++$maxtabseq;
$tabid = getTabid('Assets');
$adb->pquery("INSERT INTO vtiger_customerportal_tabs(tabid, visible, sequence) VALUES(?,?,?)", array($tabid,$visible,$newTabSeq));
include_once('vtlib/Vtiger/Module.php');
// Mark the module as Standard module
$adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
//adds sharing accsess
$AssetsModule = Vtiger_Module::getInstance('Assets');
Vtiger_Access::setDefaultSharing($AssetsModule);
//Showing Assets module in the related modules in the More Information Tab
$assetInstance = Vtiger_Module::getInstance('Assets');
$assetLabel = 'Assets';
$accountInstance = Vtiger_Module::getInstance('Accounts');
$accountInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
$productInstance = Vtiger_Module::getInstance('Products');
$productInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
$InvoiceInstance = Vtiger_Module::getInstance('Invoice');
$InvoiceInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
} else if($eventType == 'module.disabled') {
// TODO Handle actions when this module is disabled.
} else if($eventType == 'module.enabled') {
// TODO Handle actions when this module is enabled.
} else if($eventType == 'module.preuninstall') {
// TODO Handle actions when this module is about to be deleted.
} else if($eventType == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if($eventType == 'module.postupdate') {
// TODO Handle actions after this module is updated.
}
}
}
?>
@@ -0,0 +1,11 @@
<?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.
************************************************************************************/
require_once('include/Ajax/CommonAjax.php');
?>
@@ -0,0 +1,85 @@
<?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.
************************************************************************************/
require_once('Smarty_setup.php');
require_once('user_privileges/default_module_view.php');
global $mod_strings, $app_strings, $currentModule, $current_user, $theme, $singlepane_view;
$category = getParentTab();
$action = vtlib_purify($_REQUEST['action']);
$record = vtlib_purify($_REQUEST['record']);
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
if($singlepane_view == 'true' && $action == 'CallRelatedList') {
header("Location:index.php?action=DetailView&module=$currentModule&record=$record&parenttab=$category");
} else {
$tool_buttons = Button_Check($currentModule);
$focus = CRMEntity::getInstance($currentModule);
if($record != '') {
$focus->retrieve_entity_info($record, $currentModule);
$focus->id = $record;
$service_base_currency = getProductBaseCurrency($focus->id,$currentModule);
} else {
$service_base_currency = fetchCurrency($current_user->id);
}
$smarty = new vtigerCRM_Smarty;
if($isduplicate == 'true') $focus->id = '';
if(isset($_REQUEST['mode']) && $_REQUEST['mode'] != ' ') $smarty->assign("OP_MODE",vtlib_purify($_REQUEST['mode']));
if(!$_SESSION['rlvs'][$currentModule]) unset($_SESSION['rlvs']);
// Identify this module as custom module.
$smarty->assign('CUSTOM_MODULE', true);
$smarty->assign('APP', $app_strings);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('MODULE', $currentModule);
// TODO: Update Single Module Instance name here.
$smarty->assign('SINGLE_MOD', getTranslatedString($currentModule));
$smarty->assign('CATEGORY', $category);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('THEME', $theme);
$smarty->assign('ID', $focus->id);
$smarty->assign('MODE', $focus->mode);
$smarty->assign('CHECK', $tool_buttons);
$smarty->assign('NAME', $focus->column_fields[$focus->def_detailview_recname]);
$smarty->assign('UPDATEINFO',updateInfo($focus->id));
$smarty->assign("CURRENCY_ID",$service_base_currency);
// Module Sequence Numbering
$mod_seq_field = getModuleSequenceField($currentModule);
if ($mod_seq_field != null) {
$mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
} else {
$mod_seq_id = $focus->id;
}
$smarty->assign('MOD_SEQ_ID', $mod_seq_id);
// END
$related_array = getRelatedLists($currentModule, $focus);
$smarty->assign('RELATEDLISTS', $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
$relationId = vtlib_purify($_REQUEST['relation_id']);
RelatedListViewSession::addRelatedModuleToSession($relationId,
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
$smarty->display('RelatedLists.tpl');
}
?>
@@ -0,0 +1,12 @@
<?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.
************************************************************************************/
include('modules/CustomView/index.php');
?>
@@ -0,0 +1,32 @@
<?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.
************************************************************************************/
global $currentModule;
$focus = CRMEntity::getInstance($currentModule);
$record = vtlib_purify($_REQUEST['record']);
$module = vtlib_purify($_REQUEST['module']);
$return_module = vtlib_purify($_REQUEST['return_module']);
$return_action = vtlib_purify($_REQUEST['return_action']);
$return_id = vtlib_purify($_REQUEST['return_id']);
$parenttab = getParentTab();
//Added to fix 4600
$url = getBasic_Advance_SearchURL();
DeleteEntity($currentModule, $return_module, $focus, $record, $return_id);
$parenttab = getParentTab();
if(isset($_REQUEST['activity_mode']))
$url .= '&activity_mode='.vtlib_purify($_REQUEST['activity_mode']);
header("Location: index.php?module=$return_module&action=$return_action&record=$return_id&parenttab=$parenttab&relmodule=$module".$url);
?>
@@ -0,0 +1,29 @@
<?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.
********************************************************************************/
global $adb;
global $log;
$return_id = vtlib_purify($_REQUEST['return_id']);
$record = vtlib_purify($_REQUEST['record']);
$return_module = vtlib_purify($_REQUEST['return_module']);
$return_action = vtlib_purify($_REQUEST['return_action']);
if($return_action !='' && $return_module == "PriceBooks" && $return_action == "CallRelatedList") {
$log->info("Products :: Deleting Price Book - Delete from PriceBook RelatedList");
$query = "delete from vtiger_pricebookproductrel where pricebookid=? and productid=?";
$adb->pquery($query, array($return_id, $record));
} else {
$log->info("Products :: Deleting Price Book");
$query = "delete from vtiger_pricebookproductrel where pricebookid=? and productid=?";
$adb->pquery($query, array($record, $return_id));
}
header("Location: index.php?module=".$return_module."&action=".$return_module."Ajax&file=$return_action&ajax=delpbprorel&record=".$return_id);
?>
@@ -0,0 +1,110 @@
<?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.
************************************************************************************/
require_once('Smarty_setup.php');
require_once('user_privileges/default_module_view.php');
global $mod_strings, $app_strings, $currentModule, $current_user, $theme, $singlepane_view;
$focus = CRMEntity::getInstance($currentModule);
$tool_buttons = Button_Check($currentModule);
$smarty = new vtigerCRM_Smarty();
$record = $_REQUEST['record'];
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
$tabid = getTabid($currentModule);
$category = getParentTab($currentModule);
if($record != '') {
$focus->id = $record;
$focus->retrieve_entity_info($record, $currentModule);
}
if($isduplicate == 'true') $focus->id = '';
// Identify this module as custom module.
$smarty->assign('CUSTOM_MODULE', true);
$smarty->assign('APP', $app_strings);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('MODULE', $currentModule);
// TODO: Update Single Module Instance name here.
$smarty->assign('SINGLE_MOD', 'SINGLE_'.$currentModule);
$smarty->assign('CATEGORY', $category);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('THEME', $theme);
$smarty->assign('ID', $focus->id);
$smarty->assign('MODE', $focus->mode);
$recordName = array_values(getEntityName($currentModule, $focus->id));
$recordName = $recordName[0];
$smarty->assign('NAME', $recordName);
$smarty->assign('UPDATEINFO',updateInfo($focus->id));
// Module Sequence Numbering
$mod_seq_field = getModuleSequenceField($currentModule);
if ($mod_seq_field != null) {
$mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
} else {
$mod_seq_id = $focus->id;
}
$smarty->assign('MOD_SEQ_ID', $mod_seq_id);
// END
$validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, $tabid));
$smarty->assign('VALIDATION_DATA_FIELDNAME',$validationArray['fieldname']);
$smarty->assign('VALIDATION_DATA_FIELDDATATYPE',$validationArray['datatype']);
$smarty->assign('VALIDATION_DATA_FIELDLABEL',$validationArray['fieldlabel']);
$smarty->assign('EDIT_PERMISSION', isPermitted($currentModule, 'EditView', $record));
$smarty->assign('CHECK', $tool_buttons);
if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule.'_listquery'])){
$recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id);
VT_detailViewNavigation($smarty,$recordNavigationInfo,$focus->id);
}
$smarty->assign('IS_REL_LIST', isPresentRelatedLists($currentModule));
$smarty->assign('SinglePane_View', $singlepane_view);
if($singlepane_view == 'true') {
$related_array = getRelatedLists($currentModule,$focus);
$smarty->assign("RELATEDLISTS", $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
}
if(isPermitted($currentModule, 'EditView', $record) == 'yes')
$smarty->assign('EDIT_DUPLICATE', 'permitted');
if(isPermitted($currentModule, 'Delete', $record) == 'yes')
$smarty->assign('DELETE', 'permitted');
$smarty->assign('BLOCKS', getBlocks($currentModule,'detail_view','',$focus->column_fields));
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
// END
// Record Change Notification
$focus->markAsViewed($current_user->id);
// END
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
$smarty->display('DetailView.tpl');
?>
@@ -0,0 +1,41 @@
<?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.
************************************************************************************/
global $currentModule;
$modObj = CRMEntity::getInstance($currentModule);
$ajaxaction = $_REQUEST["ajxaction"];
if($ajaxaction == 'DETAILVIEW')
{
$crmid = $_REQUEST['recordid'];
$tablename = $_REQUEST['tableName'];
$fieldname = $_REQUEST['fldName'];
$fieldvalue = utf8RawUrlDecode($_REQUEST['fieldValue']);
if($crmid != '')
{
$modObj->retrieve_entity_info($crmid, $currentModule);
$modObj->column_fields[$fieldname] = $fieldvalue;
$modObj->id = $crmid;
$modObj->mode = 'edit';
$modObj->save($currentModule);
if($modObj->id != '')
{
echo ':#:SUCCESS';
}else
{
echo ':#:FAILURE';
}
}else
{
echo ':#:FAILURE';
}
} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
require_once 'include/ListView/RelatedListViewContents.php';
}
?>
@@ -0,0 +1,72 @@
<?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.
********************************************************************************/
global $mod_strings;
global $app_strings;
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
if(isset($_REQUEST['return_module']) && $_REQUEST['return_module']=="PriceBooks")
{
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
$product_id = vtlib_purify($_REQUEST['record']);
$listprice = vtlib_purify($_REQUEST['listprice']);
$return_action = "CallRelatedList";
$return_id = vtlib_purify($_REQUEST['pricebook_id']);
}
else
{
$product_id = vtlib_purify($_REQUEST['record']);
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
$listprice = getListPrice($product_id,$pricebook_id);
$return_action = "CallRelatedList";
$return_id = vtlib_purify($_REQUEST['pricebook_id']);
}
$output='';
$output ='<div id="roleLay" style="display:block;" class="layerPopup">
<form action="index.php" name="index" onSubmit="if(verify_data(index) == true) gotoUpdateListPrice('.$return_id.','.$pricebook_id.','.$product_id.'); else document.getElementById(\'roleLay\').style.display=\'inline\'; return false;" >
<input type="hidden" name="module" value="Products">
<input type="hidden" name="action" value="UpdateListPrice">
<input type="hidden" name="record" value="'.$return_id.'">
<input type="hidden" name="pricebook_id" value="'.$pricebook_id.'">
<input type="hidden" name="product_id" value="'.$product_id.'">
<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
<tr>
<td class=layerPopupHeading " align="left">'.$mod_strings["LBL_EDITLISTPRICE"].'</td>
<td align="right" class="small"><img src="' . vtiger_imageurl('close.gif', $theme) . '" border=0 alt="'.$app_strings["LBL_CLOSE"].'" title="'.$app_strings["LBL_CLOSE"].'" style="cursor:pointer" onClick="document.getElementById(\'editlistprice\').style.display=\'none\';"></td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
<tr>
<td class="small">
<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
<tr>
<td width="50%" class="cellLabel small"><b>'.$mod_strings["LBL_EDITLISTPRICE"].'</b></td>
<td width="50%" class="cellText small"><input class="dataInput" type="text" id="list_price" name="list_price" value="'.$listprice.'" /></td>
</tr>
</table>
</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
<tr>
<td colspan="3" align="center" class="small">
<input type="submit" name="button" value="'.$app_strings["LBL_SAVE_BUTTON_LABEL"].'" class="crmbutton small save">
<input title="'.$app_strings["LBL_CANCEL_BUTTON_LABEL"].'" accessKey="'.$app_strings["LBL_CANCEL_BUTTON_KEY"].'" class="crmbutton small cancel" onClick="document.getElementById(\'editlistprice\').style.display=\'none\';" type="button" name="button" value="'.$app_strings["LBL_CANCEL_BUTTON_LABEL"].'">
</td>
</tr>
</table>
</form>
</div>';
echo $output;
?>
@@ -0,0 +1,113 @@
<?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.
************************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme;
require_once('Smarty_setup.php');
$focus = CRMEntity::getInstance($currentModule);
$smarty = new vtigerCRM_Smarty();
$category = getParentTab($currentModule);
$record = $_REQUEST['record'];
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
//added to fix the issue4600
$searchurl = getBasic_Advance_SearchURL();
$smarty->assign("SEARCH", $searchurl);
//4600 ends
if($record) {
$focus->id = $record;
$focus->mode = 'edit';
$focus->retrieve_entity_info($record, $currentModule);
}
if($isduplicate == 'true') {
$focus->id = '';
$focus->mode = '';
}
if(empty($_REQUEST['record']) && $focus->mode != 'edit'){
setObjectValuesFromRequest($focus);
}
$disp_view = getView($focus->mode);
if($disp_view == 'edit_view')
$smarty->assign('BLOCKS', getBlocks($currentModule, $disp_view, $focus->mode, $focus->column_fields));
else
$smarty->assign('BASBLOCKS', getBlocks($currentModule, $disp_view, $focus->mode, $focus->column_fields, 'BAS'));
$smarty->assign('OP_MODE',$disp_view);
$smarty->assign('APP', $app_strings);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('MODULE', $currentModule);
// TODO: Update Single Module Instance name here.
$smarty->assign('SINGLE_MOD', getTranslatedString('SINGLE_'.$currentModule));
$smarty->assign('CATEGORY', $category);
$smarty->assign("THEME", $theme);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('ID', $focus->id);
$smarty->assign('MODE', $focus->mode);
$smarty->assign('CHECK', Button_Check($currentModule));
$smarty->assign('DUPLICATE', $isduplicate);
if($focus->mode == 'edit' || $isduplicate) {
$recordName = array_values(getEntityName($currentModule, $record));
$recordName = $recordName[0];
$smarty->assign('NAME', $recordName);
$smarty->assign('UPDATEINFO',updateInfo($record));
}
if(isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module']));
if(isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action']));
if(isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id']));
if (isset($_REQUEST['return_viewname'])) $smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname']));
// Field Validation Information
$tabid = getTabid($currentModule);
$validationData = getDBValidationData($focus->tab_name,$tabid);
$validationArray = split_validationdataArray($validationData);
$smarty->assign("VALIDATION_DATA_FIELDNAME",$validationArray['fieldname']);
$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$validationArray['datatype']);
$smarty->assign("VALIDATION_DATA_FIELDLABEL",$validationArray['fieldlabel']);
// In case you have a date field
$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
global $adb;
// Module Sequence Numbering
$mod_seq_field = getModuleSequenceField($currentModule);
if($focus->mode != 'edit' && $mod_seq_field != null) {
$autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE');
$mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1",array($currentModule));
$mod_seq_prefix = $adb->query_result($mod_seq_string,0,'prefix');
$mod_seq_no = $adb->query_result($mod_seq_string,0,'cur_id');
if($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix.$mod_seq_no))
echo '<br><font color="#FF0000"><b>'. getTranslatedString('LBL_DUPLICATE'). ' '. getTranslatedString($mod_seq_field['label'])
.' - '. getTranslatedString('LBL_CLICK') .' <a href="index.php?module=Settings&action=CustomModEntityNo&parenttab=Settings&selmodule='.$currentModule.'">'.getTranslatedString('LBL_HERE').'</a> '
. getTranslatedString('LBL_TO_CONFIGURE'). ' '. getTranslatedString($mod_seq_field['label']) .'</b></font>';
else
$smarty->assign("MOD_SEQ_ID",$autostr);
} else {
$smarty->assign("MOD_SEQ_ID", $focus->column_fields[$mod_seq_field['name']]);
}
// END
// Gather the help information associated with fields
$smarty->assign('FIELDHELPINFO', vtlib_getFieldHelpInfo($currentModule));
// END
if($focus->mode == 'edit') {
$smarty->display('salesEditView.tpl');
} else {
$smarty->display('CreateView.tpl');
}
?>
@@ -0,0 +1,12 @@
<?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.
************************************************************************************/
require_once('include/utils/ExportRecords.php');
?>
@@ -0,0 +1,106 @@
<?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.
********************************************************************************/
require_once('Smarty_setup.php');
require_once('include/utils/utils.php');
require_once('database/DatabaseConnection.php');
global $mod_strings, $app_strings, $app_list_strings;
global $current_language, $currentModule, $current_userid, $theme;
require_once('themes/'.$theme.'/layout_utils.php');
$req_module = vtlib_purify($_REQUEST['module']);
$focus = CRMEntity::getInstance($req_module);
$return_module=vtlib_purify($_REQUEST['module']);
$delete_idstring=vtlib_purify($_REQUEST['idlist']);
$parenttab = getParenttab();
$smarty = new vtigerCRM_Smarty;
$ids_list = array();
$errormsg = '';
if(isset($_REQUEST['del_rec']))
{
$url = getBasic_Advance_SearchURL();
$delete_id_array=explode(",",$delete_idstring,-1);
foreach ($delete_id_array as $id)
{
if(isPermitted($req_module,'Delete',$id) == 'yes') {
$sql="update vtiger_crmentity set deleted=1 where crmid=?";
$result = $adb->pquery($sql, array($id));
DeleteEntity($req_module,$return_module,$focus,$id,"");
}
else {
$ids_list[] = $id;
}
}
if(count($ids_list) > 0) {
$ret = getEntityName($req_module,$ids_list);
if(count($ret) > 0)
{
$errormsg = implode(',',$ret);
}
echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
<table border='0' cellpadding='5' cellspacing='0' width='98%'>
<tbody><tr>
<td rowspan='2' width='11%'><img src='themes/$theme/images/denied.gif' ></td>
<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'>
<span class='genHeaderSmall'>$app_strings[LBL_DUP_PERMISSION] $req_module $errormsg</span></td>
</tr>
<tr>
<td class='small' align='right' nowrap='nowrap'>
<a href='javascript:window.location.reload();'>$app_strings[LBL_GO_BACK]</a><br>
</td>
</tr>
</tbody></table>
</div>";
echo "</td></tr></table>";
exit;
}
}
include("include/saveMergeCriteria.php");
$ret_arr=getDuplicateRecordsArr($req_module);
$fld_values=$ret_arr[0];
$total_num_group=count($fld_values);
$fld_name=$ret_arr[1];
$ui_type=$ret_arr[2];
$smarty->assign("NAVIGATION",$ret_arr["navigation"]);//Added for page navigation
$smarty->assign("MODULE",$req_module);
$smarty->assign("NUM_GROUP",$total_num_group);
$smarty->assign("FIELD_NAMES",$fld_name);
$smarty->assign("CATEGORY",$parenttab);
$smarty->assign("ALL_VALUES",$fld_values);
if(isPermitted($req_module,'Delete','') == 'yes')
$button_del = $app_strings['LBL_MASS_DELETE'];
$smarty->assign("DELETE",$button_del);
$smarty->assign("MOD", return_module_language($current_language,$req_module));
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH",$image_path);
$smarty->assign("APP", $app_strings);
$smarty->assign("CMOD", $mod_strings);
$smarty->assign("MODE",'view');
if(isset($_REQUEST['button_view']))
{
$smarty->assign("VIEW",'true');
}
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("FindDuplicateAjax.tpl");
else
$smarty->display('FindDuplicateDisplay.tpl');
?>
@@ -0,0 +1,12 @@
<?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.
************************************************************************************/
require_once('modules/Import/index.php');
?>
@@ -0,0 +1,36 @@
<?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.
*
********************************************************************************/
global $theme, $log;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
$currencyid = $_REQUEST['currencyid'];
$products_list = $_REQUEST['productsList'];
$product_ids = explode("::", $products_list);
$price_list = array();
if (count($product_ids) > 0) {
$product_prices = getPricesForProducts($currencyid, $product_ids);
}
// To get the Price Values in the same order as the Products
for ($i=0;$i<count($product_ids);++$i) {
$product_id = $product_ids[$i];
$price_list[] = $product_prices[$product_id];
}
$price_values = implode("::", $price_list);
echo "SUCCESS$".$price_values;
?>
@@ -0,0 +1,68 @@
<?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.
********************************************************************************/
global $theme, $mod_strings, $app_strings;
$theme_path="themes/".$theme."/";
$productid = vtlib_purify($_REQUEST['productid']);
$rowid = vtlib_purify($_REQUEST['curr_row']);
$product_total = vtlib_purify($_REQUEST['productTotal']);
$tax_details = getTaxDetailsForProduct($productid,'all');//we should pass available instead of all if we want to display only the available taxes.
$associated_tax_count = count($tax_details);
$tax_div = '
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small" id="tax_table'.$rowid.'">
<tr>
<td id="tax_div_title'.$rowid.'" nowrap align="left" ><b>'.$app_strings['LABEL_SET_TAX_FOR'].' : '.$product_total.'</b></td>
<td>&nbsp;</td>
<td align="right"><img src="'. vtiger_imageurl('close.gif', $theme) .'" border="0" onClick="fnHidePopDiv(\'tax_div'.$rowid.'\')" style="cursor:pointer;"></td>
</tr>
';
$net_tax_total = 0.00;
for($i=0,$j=$i+1;$i<count($tax_details);$i++,$j++)
{
$tax_name = $tax_details[$i]['taxname'];
$tax_label = $tax_details[$i]['taxlabel'];
$tax_percentage = $tax_details[$i]['percentage'];
$tax_name_percentage = $tax_name."_percentage".$rowid;
$tax_id_name = "hidden_tax".$j."_percentage".$rowid;//used to store the tax name, used in function callTaxCalc
$tax_name_total = "popup_tax_row".$rowid;//$tax_name."_total".$rowid;
$tax_total = $product_total*$tax_percentage/100.00;
$net_tax_total += $tax_total;
$tax_div .= '
<tr>
<td align="left" class="lineOnTop">
<input type="text" class="small" size="5" name="'.$tax_name_percentage.'" id="'.$tax_name_percentage.'" value="'.$tax_percentage.'" onBlur="calcCurrentTax(\''.$tax_name_percentage.'\','.$rowid.','.$i.');calcTotal();">&nbsp;%
<input type="hidden" id="'.$tax_id_name.'" value="'.$tax_name_percentage.'">
</td>
<td align="center" class="lineOnTop">'.$tax_label.'</td>
<td align="right" class="lineOnTop">
<input type="text" class="small" size="6" name="'.$tax_name_total.'" id="'.$tax_name_total.'" style="cursor:pointer;" value="'.$tax_total.'" readonly>
</td>
</tr>
';
}
$tax_div .= '</table>';
if($associated_tax_count == 0)
{
$tax_div .= '<div align="left" class="lineOnTop" width="100%">'.$mod_strings['LBL_NO_TAXES_ASSOCIATED'].'.</div>';
}
$tax_div .= '<input type="hidden" id="hdnTaxTotal'.$rowid.'" name="hdnTaxTotal'.$rowid.'" value="'.$net_tax_total.'">';
echo $tax_div;
?>
@@ -0,0 +1,212 @@
<?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.
************************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme;
global $list_max_entries_per_page;
require_once('Smarty_setup.php');
require_once('include/ListView/ListView.php');
require_once('modules/CustomView/CustomView.php');
require_once('include/DatabaseUtil.php');
checkFileAccess("modules/$currentModule/$currentModule.php");
require_once("modules/$currentModule/$currentModule.php");
$category = getParentTab();
$url_string = '';
$tool_buttons = Button_Check($currentModule);
$list_buttons = Array();
if(isPermitted($currentModule,'Delete','') == 'yes') $list_buttons['del'] = $app_strings[LBL_MASS_DELETE];
if(isPermitted($currentModule,'EditView','') == 'yes') {
$list_buttons['mass_edit'] = $app_strings[LBL_MASS_EDIT];
// Mass Edit could be used to change the owner as well!
//$list_buttons['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
}
$focus = new $currentModule();
$focus->initSortbyField($currentModule);
$sorder = $focus->getSortOrder();
$order_by = $focus->getOrderBy();
$_SESSION[$currentModule."_Order_By"] = $order_by;
$_SESSION[$currentModule."_Sort_Order"]=$sorder;
$smarty = new vtigerCRM_Smarty();
// Identify this module as custom module.
$smarty->assign('CUSTOM_MODULE', true);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('APP', $app_strings);
$smarty->assign('MODULE', $currentModule);
$smarty->assign('SINGLE_MOD', getTranslatedString('SINGLE_'.$currentModule));
$smarty->assign('CATEGORY', $category);
$smarty->assign('BUTTONS', $list_buttons);
$smarty->assign('CHECK', $tool_buttons);
$smarty->assign('THEME', $theme);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('CHANGE_OWNER', getUserslist());
$smarty->assign('CHANGE_GROUP_OWNER', getGroupslist());
// Custom View
$customView = new CustomView($currentModule);
$viewid = $customView->getViewId($currentModule);
$customview_html = $customView->getCustomViewCombo($viewid);
$viewinfo = $customView->getCustomViewByCvid($viewid);
// Feature available from 5.1
if(method_exists($customView, 'isPermittedChangeStatus')) {
// Approving or Denying status-public by the admin in CustomView
$statusdetails = $customView->isPermittedChangeStatus($viewinfo['status']);
// To check if a user is able to edit/delete a CustomView
$edit_permit = $customView->isPermittedCustomView($viewid,'EditView',$currentModule);
$delete_permit = $customView->isPermittedCustomView($viewid,'Delete',$currentModule);
$smarty->assign("CUSTOMVIEW_PERMISSION",$statusdetails);
$smarty->assign("CV_EDIT_PERMIT",$edit_permit);
$smarty->assign("CV_DELETE_PERMIT",$delete_permit);
}
// END
$smarty->assign("VIEWID", $viewid);
if($viewinfo['viewname'] == 'All') $smarty->assign('ALL', 'All');
if($viewid ==0)
{
echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
<table border='0' cellpadding='5' cellspacing='0' width='98%'>
<tbody><tr>
<td rowspan='2' width='11%'><img src='". vtiger_imageurl('denied.gif', $theme) ."' ></td>
<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span clas
s='genHeaderSmall'>$app_strings[LBL_PERMISSION]</span></td>
</tr>
<tr>
<td class='small' align='right' nowrap='nowrap'>
<a href='javascript:window.history.back();'>$app_strings[LBL_GO_BACK]</a><br>
</td>
</tr>
</tbody></table>
</div>";
echo "</td></tr></table>";
exit;
}
global $current_user;
$queryGenerator = new QueryGenerator($currentModule, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
// Enabling Module Search
$url_string = '';
if($_REQUEST['query'] == 'true') {
$queryGenerator->addUserSearchConditions($_REQUEST);
$ustring = getSearchURL($_REQUEST);
$url_string .= "&query=true$ustring";
$smarty->assign('SEARCH_URL', $url_string);
}
$list_query = $queryGenerator->getQuery();
$where = $queryGenerator->getConditionalWhere();
if(isset($where) && $where != '') {
$_SESSION['export_where'] = $where;
} else {
unset($_SESSION['export_where']);
}
// Sorting
if(!empty($order_by)) {
if($order_by == 'smownerid') $list_query .= ' ORDER BY user_name '.$sorder;
else {
$tablename = getTableNameForField($currentModule, $order_by);
$tablename = ($tablename != '')? ($tablename . '.') : '';
$list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
}
//Postgres 8 fixes
if( $adb->dbType == "pgsql")
$list_query = fixPostgresQuery( $list_query, $log, 0);
if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){
$count_result = $adb->query( mkCountQuery( $list_query));
$noofrows = $adb->query_result($count_result,0,"count");
}else{
$noofrows = null;
}
$queryMode = (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true');
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$noofrows);
$limit_start_rec = ($start-1) * $list_max_entries_per_page;
if( $adb->dbType == "pgsql")
$list_result = $adb->pquery($list_query. " OFFSET $limit_start_rec LIMIT $list_max_entries_per_page", array());
else
$list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
$smarty->assign('recordListRange',$recordListRangeMsg);
$smarty->assign("CUSTOMVIEW_OPTION",$customview_html);
// Navigation
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, $currentModule, 'index', $viewid);
$smarty->assign("NAVIGATION", $navigationOutput);
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
$order_by);
$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
$navigation_array);
$listview_header_search = $controller->getBasicSearchFieldInfoList();
$smarty->assign('LISTHEADER', $listview_header);
$smarty->assign('LISTENTITY', $listview_entries);
$smarty->assign('SEARCHLISTHEADER',$listview_header_search);
// Module Search
$alphabetical = AlphabeticalSearch($currentModule,'index',$focus->def_basicsearch_col,'true','basic','','','','',$viewid);
$fieldnames = $controller->getAdvancedSearchOptionString();
$criteria = getcriteria_options();
$smarty->assign("ALPHABETICAL", $alphabetical);
$smarty->assign("FIELDNAMES", $fieldnames);
$smarty->assign("CRITERIA", $criteria);
$smarty->assign("AVALABLE_FIELDS", getMergeFields($currentModule,"available_fields"));
$smarty->assign("FIELDS_TO_MERGE", getMergeFields($currentModule,"fileds_to_merge"));
//Added to select Multiple records in multiple pages
$smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs']));
$smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs']));
$smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";"));
$_SESSION[$currentModule.'_listquery'] = $list_query;
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
// END
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("ListViewEntries.tpl");
else
$smarty->display('ListView.tpl');
?>
@@ -0,0 +1,11 @@
<?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.
*********************************************************************************/
require_once 'include/ListView/ListViewPagging.php';
?>
@@ -0,0 +1,44 @@
<?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.
************************************************************************************/
global $mod_strings,$app_strings,$theme,$currentModule,$current_user;
require_once('Smarty_setup.php');
require_once('include/utils/utils.php');
$focus = CRMEntity::getInstance($currentModule);
$focus->mode = '';
$mode = 'mass_edit';
$disp_view = getView($focus->mode);
$idstring = $_REQUEST['idstring'];
$smarty = new vtigerCRM_Smarty;
$smarty->assign('MODULE',$currentModule);
$smarty->assign('APP',$app_strings);
$smarty->assign('THEME', $theme);
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
$smarty->assign('IDS',$idstring);
$smarty->assign('MASS_EDIT','1');
$smarty->assign('BLOCKS',getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
$smarty->assign("CATEGORY",getParentTab());
// Field Validation Information
$tabid = getTabid($currentModule);
$validationData = getDBValidationData($focus->tab_name,$tabid);
$validationArray = split_validationdataArray($validationData);
$smarty->assign("VALIDATION_DATA_FIELDNAME",$validationArray['fieldname']);
$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$validationArray['datatype']);
$smarty->assign("VALIDATION_DATA_FIELDLABEL",$validationArray['fieldlabel']);
$smarty->display('MassEditForm.tpl');
?>
@@ -0,0 +1,65 @@
<?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.
********************************************************************************/
global $currentModule, $rstart;
$focus = CRMEntity::getInstance($currentModule);
$idlist= vtlib_purify($_REQUEST['massedit_recordids']);
$viewid = vtlib_purify($_REQUEST['viewname']);
$return_module = vtlib_purify($_REQUEST['massedit_module']);
$return_action = 'index';
//Added to fix 4600
$url = getBasic_Advance_SearchURL();
if(isset($_REQUEST['start']) && $_REQUEST['start']!=''){
$rstart = "&start=".vtlib_purify($_REQUEST['start']);
}
if(isset($idlist)) {
$recordids = explode(';', $idlist);
for($index = 0; $index < count($recordids); ++$index) {
$recordid = $recordids[$index];
if($recordid == '') continue;
if(isPermitted($currentModule,'EditView',$recordid) == 'yes') {
// Save each module record with update value.
$focus->retrieve_entity_info($recordid, $currentModule);
$focus->mode = 'edit';
$focus->id = $recordid;
foreach($focus->column_fields as $fieldname => $val)
{
if(isset($_REQUEST[$fieldname."_mass_edit_check"])) {
if($fieldname == 'assigned_user_id'){
if($_REQUEST['assigntype'] == 'U') {
$value = $_REQUEST['assigned_user_id'];
} elseif($_REQUEST['assigntype'] == 'T') {
$value = $_REQUEST['assigned_group_id'];
}
} else {
if(is_array($_REQUEST[$fieldname]))
$value = $_REQUEST[$fieldname];
else
$value = trim($_REQUEST[$fieldname]);
}
$focus->column_fields[$fieldname] = $value;
}
else {
$focus->column_fields[$fieldname] = decode_html($focus->column_fields[$fieldname]);
}
}
$focus->save($currentModule);
}
}
}
$parenttab = getParentTab();
header("Location: index.php?module=$return_module&action=$return_action&parenttab=$parenttab$rstart");
?>
+11
View File
@@ -0,0 +1,11 @@
<?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.
************************************************************************************/
require_once('Popup.php');
?>
@@ -0,0 +1,134 @@
<?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.
*
********************************************************************************/
require_once('Smarty_setup.php');
require_once('database/DatabaseConnection.php');
require_once('modules/Users/Users.php');
require_once('include/utils/utils.php');
$module = vtlib_purify($_REQUEST['module']);
$focus = CRMEntity::getInstance($module);
global $mod_strings, $app_strings, $app_list_strings;
global $current_language, $currentModule, $theme;
global $adb;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
$mode = $_REQUEST['mergemode'];
if($mode == 'mergesave') {
$return_module=vtlib_purify($_REQUEST['return_module']);
$action=vtlib_purify($_REQUEST['action']);
$return_action=vtlib_purify($_REQUEST['return_action']);
$parenttab=vtlib_purify($_REQUEST['parent']);
$merge_id=vtlib_purify($_REQUEST['record']);
$recordids=vtlib_purify($_REQUEST['pass_rec']);
$result = $adb->pquery("SELECT count(*) AS count FROM vtiger_crmentity WHERE crmid=? and deleted=0", array($merge_id));
$count = $adb->query_result($result,0,'count');
if($count > 0)
{
// First, save the primary record
$focus->mode="edit";
setObjectValuesFromRequest($focus);
$focus->save($module);
$rec_values=$focus->column_fields;
// Remove the id of primary record from the list of records to be deleted.
$del_value=explode(",",$recordids,-1);
$offset = array_search($merge_id,$del_value);
unset($del_value[$offset]);
// Transfer the related lists of the records to be deleted, to the primary record's related list
if(method_exists($focus, 'transferRelatedRecords')){
$focus->transferRelatedRecords($module,$del_value,$merge_id);
} else {
transferRelatedRecords($module,$del_value,$merge_id);
}
// Delete the records by id specified in the list
foreach($del_value as $value)
{
DeleteEntity($_REQUEST['module'],$_REQUEST['return_module'],$focus,$value,"");
}
}
?>
<script>
window.self.close();window.opener.location.href=window.opener.location.href;
</script>
<?php
} elseif ($mode == 'mergefields') {
$idstring=vtlib_purify($_REQUEST['passurl']);
$parent_tab=getParentTab();
$exploded_id=explode(",",$idstring,-1);
$record_count = count($exploded_id);
$smarty = new vtigerCRM_Smarty;
$smarty->assign("EDIT_DUPLICATE","");
if($record_count == 2) {
if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes'
&& isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes')
$smarty->assign("EDIT_DUPLICATE","permitted");
}
else {
if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[2]) == 'yes'
&& isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[2]) == 'yes')
$smarty->assign("EDIT_DUPLICATE","permitted");
}
$all_values_array=getRecordValues($exploded_id,$module);
$all_values=$all_values_array[0];
$js_arr_val=$all_values_array[1];
$fld_array=$all_values_array[2];
$js_arr=implode(",",$js_arr_val);
$imported_records = Array();
$sql="select bean_id from vtiger_users_last_import where bean_type=? and deleted=0";
$result = $adb->pquery($sql, array($module));
$num_rows=$adb->num_rows($result);
$count=0;
for($i=0; $i<$num_rows;$i++)
{
foreach($exploded_id as $value)
if($value == $adb->query_result($result,$i,"bean_id"))
$count++;
array_push($imported_records,$adb->query_result($result,$i,"bean_id"));
}
if ($record_count == $count)
$no_existing=1;
else
$no_existing=0;
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("RECORD_COUNT",$record_count);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULENAME", $module);
$smarty->assign("PARENT_TAB", $parent_tab);
$smarty->assign("JS_ARRAY", $js_arr);
$smarty->assign("ID_ARRAY", $exploded_id);
$smarty->assign("IDSTRING",$idstring);
$smarty->assign("ALLVALUES", $all_values);
$smarty->assign("FIELD_ARRAY", $fld_array);
$smarty->assign("IMPORTED_RECORDS", $imported_records);
$smarty->assign("NO_EXISTING", $no_existing);
$smarty->display("MergeFields.tpl");
}
?>
@@ -0,0 +1,11 @@
<?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.
************************************************************************************/
require_once('include/quickcreate.php');
?>
+59
View File
@@ -0,0 +1,59 @@
<?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.
************************************************************************************/
global $current_user, $currentModule;
checkFileAccess("modules/$currentModule/$currentModule.php");
require_once("modules/$currentModule/$currentModule.php");
$focus = new $currentModule();
setObjectValuesFromRequest($focus);
$mode = $_REQUEST['mode'];
$record=$_REQUEST['record'];
if($mode) $focus->mode = $mode;
if($record)$focus->id = $record;
$currencyid=fetchCurrency($current_user->id);
$rate_symbol = getCurrencySymbolandCRate($currencyid);
$rate = $rate_symbol['rate'];
if($_REQUEST['assigntype'] == 'U') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id'];
} elseif($_REQUEST['assigntype'] == 'T') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id'];
}
$focus->save($currentModule);
$return_id = $focus->id;
$search = vtlib_purify($_REQUEST['search_url']);
$parenttab = getParentTab();
if($_REQUEST['return_module'] != '') {
$return_module = vtlib_purify($_REQUEST['return_module']);
} else {
$return_module = $currentModule;
}
if($_REQUEST['return_action'] != '') {
$return_action = vtlib_purify($_REQUEST['return_action']);
} else {
$return_action = "DetailView";
}
if($_REQUEST['return_id'] != '') {
$return_id = vtlib_purify($_REQUEST['return_id']);
}
if(isset($_REQUEST['activity_mode'])) $return_action .= '&activity_mode='.vtlib_purify($_REQUEST['activity_mode']);
header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&parenttab=$parenttab&start=".vtlib_purify($_REQUEST['pagenumber']).$search);
?>
@@ -0,0 +1,13 @@
<?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.
************************************************************************************/
include('modules/Vtiger/Settings.php');
?>
@@ -0,0 +1,11 @@
<?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.
************************************************************************************/
require_once('include/Ajax/TagCloud.php');
?>
@@ -0,0 +1,11 @@
<?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.
*********************************************************************************/
require_once 'modules/Home/UnifiedSearch.php';
?>
@@ -0,0 +1,24 @@
<?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.
********************************************************************************/
global $adb;
global $log;
$log->debug("Going to update the ListPrice in (modules/Products/UpdateListPrice.php).");
$record = vtlib_purify($_REQUEST['record']);
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
$product_id = vtlib_purify($_REQUEST['product_id']);
$listprice = vtlib_purify($_REQUEST['list_price']);
$return_action = vtlib_purify($_REQUEST['return_action']);
$return_module = vtlib_purify($_REQUEST['return_module']);
$query = "update vtiger_pricebookproductrel set listprice=? where pricebookid=? and productid=?";
$adb->pquery($query, array($listprice, $pricebook_id, $product_id));
header("Location: index.php?module=$return_module&action=".$return_module."Ajax&file=$return_action&ajax=updatelistprice&record=$record");
?>
+15
View File
@@ -0,0 +1,15 @@
<?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.
************************************************************************************/
global $currentModule;
checkFileAccess("modules/$currentModule/ListView.php");
include_once("modules/$currentModule/ListView.php");
?>
@@ -0,0 +1,43 @@
<?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.
************************************************************************************/
$mod_strings = Array(
/*some general information*/
'LBL_MODULE_NAME'=>'Assets',
'SINGLE_Assets'=>'Asset',
/*blocks for the module*/
'LBL_ASSET_INFORMATION'=>'Asset Information',
'LBL_CUSTOM_INFORMATION'=>'Custom Information',
'LBL_DESCRIPTION_INFORMATION'=>'Notes',
/*fields for the module*/
'Assets'=>'Assets',
'Asset Name' => 'Asset Name',
'Customer Name'=>'Customer Name',
'Product Name'=>'Product Name',
'Serial Number'=>'Serial Number',
'Asset No'=>'Asset No',
'Date Sold'=>'Date Sold',
'Date in Service'=>'Date in Service',
'Status'=>'Status',
'Shipping Method'=>'Shipping Method',
'Shipping Tracking Number'=>'Shipping Tracking Number',
'Tag Number'=>'Tag Number',
'Notes'=>'Notes',
'Invoice Name'=>'Invoice Name',
/*picklist values*/
'In Service'=>'In Service',
'Out-of-service'=>'Out-of-service',
);
?>
@@ -0,0 +1,32 @@
<?xml version='1.0'?>
<schema>
<tables>
<table>
<name>vtiger_assets</name>
<sql><![CDATA[CREATE TABLE `vtiger_assets` (
`assetsid` int(11) NOT NULL,
`asset_no` varchar(30) NOT NULL,
`account` int(19) NOT NULL,
`product` int(19) NOT NULL,
`serialnumber` varchar(200) NOT NULL,
`datesold` date NOT NULL,
`dateinservice` date NOT NULL,
`assetstatus` varchar(200) default 'In Service',
`tagnumber` varchar(300) default NULL,
`invoiceid` int(19) default NULL,
`shippingmethod` varchar(200) default NULL,
`shippingtrackingnumber` varchar(200) default NULL,
`assetname` varchar(100) default NULL,
PRIMARY KEY (`assetsid`),
CONSTRAINT `fk_1_vtiger_assets` FOREIGN KEY (`assetsid`) REFERENCES `vtiger_crmentity` (`crmid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
<table>
<name>vtiger_assetscf</name>
<sql><![CDATA[CREATE TABLE `vtiger_assetscf` (
`assetsid` int(19) NOT NULL,
PRIMARY KEY (`assetsid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
</tables>
</schema>
@@ -0,0 +1,53 @@
<?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.
************************************************************************************/
require_once('include/database/PearDatabase.php');
@include_once('user_privileges/default_module_view.php');
global $adb, $singlepane_view, $currentModule;
$idlist = vtlib_purify($_REQUEST['idlist']);
$destinationModule = vtlib_purify($_REQUEST['destination_module']);
$parenttab = getParentTab();
$forCRMRecord = vtlib_purify($_REQUEST['parentid']);
$mode = $_REQUEST['mode'];
if($singlepane_view == 'true')
$action = "DetailView";
else
$action = "CallRelatedList";
$storearray = array();
if(!empty($_REQUEST['idlist'])) {
// Split the string of ids
$storearray = explode (";",trim($idlist,";"));
} else if(!empty($_REQUEST['entityid'])){
$storearray = array($_REQUEST['entityid']);
}
$focus = CRMEntity::getInstance($currentModule);
if($mode == 'delete') {
// Split the string of ids
$ids = explode (";",$idlist);
if(!empty($ids)) {
$focus->delete_related_module($currentModule, $forCRMRecord, $destinationModule, $ids);
}
} else {
if(!empty($_REQUEST['idlist'])) {
// Split the string of ids
$ids = explode (";",trim($idlist,";"));
} else if(!empty($_REQUEST['entityid'])){
$ids = $_REQUEST['entityid'];
}
if(!empty($ids)) {
$focus->save_related_module($currentModule, $forCRMRecord, $destinationModule, $ids);
}
}
header("Location: index.php?module=$currentModule&record=$forCRMRecord&action=$action&parenttab=$parenttab");
?>
+69 -5
View File
@@ -25,6 +25,7 @@ require_once('include/logging.php');
require_once('include/database/PearDatabase.php');
require_once('modules/Calendar/RenderRelatedListUI.php');
require_once('data/CRMEntity.php');
require_once('modules/Calendar/CalendarCommon.php');
// Task is used to store customer information.
class Activity extends CRMEntity {
@@ -127,7 +128,22 @@ class Activity extends CRMEntity {
{
$this->deleteRelation('vtiger_cntactivityrel');
}
if(isset($this->column_fields['sendnotification'])){
$mail_data = Array();
$mail_data['user_id'] = $this->column_fields['assigned_user_id'];
$mail_data['subject'] = $this->column_fields['subject'];
$mail_data['status'] = (($this->column_fields['activitytype']=='Task')?($this->column_fields['taskstatus']):($this->column_fields['eventstatus']));
$mail_data['taskpriority'] = $this->column_fields['taskpriority'];
$mail_data['contact_name'] = $this->column_fields['contact_id'];
$mail_data['description'] = $this->column_fields['description'];
$value = getaddEventPopupTime($this->column_fields['time_start'],$this->column_fields['time_end'],'24');
$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
$mail_data['st_date_time'] = getDisplayDate($this->column_fields['date_start'])." ".$start_hour;
$mail_data['end_date_time']=getDisplayDate($this->column_fields['due_date']);
getEventNotification($this->column_fields['activitytype'],$this->column_fields['subject'],$mail_data);
}
$recur_type='';
if(($recur_type == "--None--" || $recur_type == '') && $this->mode == "edit")
{
@@ -167,9 +183,10 @@ class Activity extends CRMEntity {
global $adb;
$cbrecord = $this->id;
$cbrecord = $this->id;
unset($_SESSION['next_reminder_time']);
if(isset($cbmodule) && isset($cbrecord)) {
$cbdate = $this->column_fields['date_start'];
$cbdate = getValidDBInsertDateValue($this->column_fields['date_start']);
$cbtime = $this->column_fields['time_start'];
$reminder_query = "SELECT reminderid FROM vtiger_activity_reminder_popup WHERE semodule = ? and recordid = ?";
@@ -204,6 +221,7 @@ class Activity extends CRMEntity {
$log->info("in insertIntoReminderTable ".$table_name." module is ".$module);
if($_REQUEST['set_reminder'] == 'Yes')
{
unset($_SESSION['next_reminder_time']);
$log->debug("set reminder is set");
$rem_days = $_REQUEST['remdays'];
$log->debug("rem_days is ".$rem_days);
@@ -335,6 +353,7 @@ function insertIntoRecurringTable(& $recurObj)
$recurring_insert = "insert into vtiger_recurringevents values (?,?,?,?,?,?)";
$rec_params = array($current_id, $this->id, $tdate, $type, $recur_freq, $recurringinfo);
$adb->pquery($recurring_insert, $rec_params);
unset($_SESSION['next_reminder_time']);
if($_REQUEST['set_reminder'] == 'Yes')
{
$this->insertIntoReminderTable("vtiger_activity_reminder",$module,$current_id,'');
@@ -872,7 +891,7 @@ function insertIntoRecurringTable(& $recurObj)
$sql = 'DELETE FROM vtiger_cntactivityrel WHERE contactid = ? AND activityid = ?';
$this->db->pquery($sql, array($return_id, $id));
} elseif($return_module == 'HelpDesk') {
$sql = 'DELETE FROM vtiger_seticketsrel WHERE ticketid = ? AND crmid = ?';
$sql = 'DELETE FROM vtiger_seactivityrel WHERE crmid = ? AND activityid = ?';
$this->db->pquery($sql, array($return_id, $id));
} else {
$sql='DELETE FROM vtiger_seactivityrel WHERE activityid=?';
@@ -948,5 +967,50 @@ function insertIntoRecurringTable(& $recurObj)
return $query;
}
public function getNonAdminAccessControlQuery($module, $user,$scope='') {
require('user_privileges/user_privileges_'.$user->id.'.php');
require('user_privileges/sharing_privileges_'.$user->id.'.php');
$query = ' ';
$tabId = getTabid($module);
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2]
== 1 && $defaultOrgSharingPermission[$tabId] == 3) {
$tableName = 'vt_tmp_u'.$user->id.'_t'.$tabId;
$sharingRuleInfoVariable = $module.'_share_read_permission';
$sharingRuleInfo = $$sharingRuleInfoVariable;
$sharedTabId = null;
$this->setupTemporaryTable($tableName, $sharedTabId, $user,
$current_user_parent_role_seq, $current_user_groups);
$query = " INNER JOIN $tableName $tableName$scope ON ($tableName$scope.id = ".
"vtiger_crmentity$scope.smownerid and $tableName$scope.shared=0) ";
$sharedIds = getSharedCalendarId($user->id);
if(!empty($sharedIds)){
$query .= "or ($tableName$scope.id = vtiger_crmentity$scope.smownerid AND ".
"$tableName$scope.shared=1 and vtiger_activity$scope.visibility = 'Public') ";
}
}
return $query;
}
protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups) {
$module = null;
if (!empty($tabId)) {
$module = getTabname($tabId);
}
$query = $this->getNonAdminAccessQuery($module, $user, $parentRole, $userGroups);
$query = "create temporary table IF NOT EXISTS $tableName(id int(11) primary key, shared ".
"int(1) default 0) ignore ".$query;
$db = PearDatabase::getInstance();
$result = $db->pquery($query, array());
if(is_object($result)) {
$query = "create temporary table IF NOT EXISTS $tableName(id int(11) primary key, shared ".
"int(1) default 0) replace select 1, userid as id from vtiger_sharedcalendar where ".
"sharedid = $user->id";
$result = $db->pquery($query, array());
if(is_object($result)) {
return true;
}
}
return false;
}
}
?>
?>
@@ -22,38 +22,41 @@ require_once('themes/'.$theme.'/layout_utils.php');
require_once('include/utils/utils.php');
require_once('modules/Calendar/Activity.php');
$cur_time = time();
$_SESSION['last_reminder_check_time'] = $cur_time;
$_SESSION['next_reminder_interval'] = 60;
if($_SESSION['next_reminder_time'] == 'None') {
return;
} elseif(isset($_SESSION['next_reminder_interval']) && (($_SESSION['next_reminder_time'] -
$_SESSION['next_reminder_interval']) > $cur_time)) {
echo "<script type='text/javascript' id='_vtiger_activityreminder_callback_interval_'>".
($_SESSION['next_reminder_interval'] * 1000)."</script>";
return;
}
$log = LoggerManager::getLogger('Activity_Reminder');
$smarty = new vtigerCRM_Smarty;
if(isPermitted('Calendar','index') == 'yes'){
$active = $adb->pquery("select * from vtiger_users where id=?",array($current_user->id));
$active_res = $adb->query_result($active,0,'reminder_interval');
if($active_res!='None'){
$reminder_next=$adb->query_result($active,0,"reminder_next_time");
$lastlogin_time =$adb->query_result($active,0,"date_entered");
if(empty($reminder_next)) {
$reminder_next = date('Y-m-d H:i');
$active = $adb->pquery("select * from vtiger_users where id=?",array($current_user->id));
$active_res = $adb->query_result($active,0,'reminder_interval');
if($active_res == 'None') {
$_SESSION['next_reminder_time'] = 'None';
}
if(strtotime($lastlogin_time) > strtotime($reminder_next)) {
$reminder_next = $lastlogin_time;
}
$reminder_next_time = strtotime($reminder_next);
$cur_time = mktime(date('H'),date('i'),0,date('m'),date('d'),date('Y'));
if($reminder_next_time <= $cur_time)
{
$cb_time=$adb->query_result($active,0,"reminder_interval");
$cb_time = ConvertToMinutes($cb_time);
$cb_mktime = strtotime($reminder_next);
$cbdate1 = date('Y-m-d', strtotime("+$cb_time minutes", $cb_mktime));
$cbtime1 = date('H:i', strtotime("+$cb_time minutes", $cb_mktime));
$callback_query =
if($active_res!='None'){
$interval=$adb->query_result($active,0,"reminder_interval");
$intervalInMinutes = ConvertToMinutes($interval);
// check for reminders every minute
$time = time();
$_SESSION['next_reminder_time'] = $time + ($intervalInMinutes * 60);
$date = date('Y-m-d', strtotime("+$intervalInMinutes minutes", $time));
$time = date('H:i', strtotime("+$intervalInMinutes minutes", $time));
$callback_query =
"SELECT * FROM vtiger_activity_reminder_popup inner join vtiger_crmentity where " .
" vtiger_activity_reminder_popup.status = 0 and " .
" vtiger_activity_reminder_popup.recordid = vtiger_crmentity.crmid " .
" and vtiger_crmentity.smownerid = ".$current_user->id." and vtiger_crmentity.deleted = 0 " .
" and ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') < '" . $cbdate1 . "')" .
" OR ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') = '" . $cbdate1 . "')" .
" AND (TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') <= '" . $cbtime1 . "')))";
" and ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') < '" . $date . "')" .
" OR ((DATE_FORMAT(vtiger_activity_reminder_popup.date_start,'%Y-%m-%d') = '" . $date . "')" .
" AND (TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') <= '" . $time . "')))";
$result = $adb->query($callback_query);
@@ -63,12 +66,12 @@ if($active_res!='None'){
$reminderid = $adb->query_result($result, $index, "reminderid");
$cbrecord = $adb->query_result($result, $index, "recordid");
$cbmodule = $adb->query_result($result, $index, "semodule");
$focus = CRMEntity::getInstance($cbmodule);
if($cbmodule == 'Calendar') {
$focus->retrieve_entity_info($cbrecord,$cbmodule);
$cbsubject = $focus->column_fields['subject'];
$cbactivitytype = $focus->column_fields['activitytype'];
$cbdate = $focus->column_fields["date_start"];
@@ -79,9 +82,9 @@ if($active_res!='None'){
$cbsubject = $cbsubject[0];
$cbactivitytype = getTranslatedString($cbmodule, $cbmodule);
$cbdate = $adb->query_result($result, $index, 'date_start');
$cbtime = $adb->query_result($result, $index, 'time_start');
$cbtime = $adb->query_result($result, $index, 'time_start');
}
if($cbactivitytype=='Task')
$cbstatus = $focus->column_fields["taskstatus"];
else
@@ -109,20 +112,28 @@ if($active_res!='None'){
$mark_reminder_as_read = "UPDATE vtiger_activity_reminder_popup set status = 1 where reminderid = ?";
$adb->pquery($mark_reminder_as_read, array($reminderid));
echo "<script type='text/javascript'>window.top.document.title= '".
$app_strings['LBL_NEW_BUTTON_LABEL'].$app_strings['LBL_Reminder']."';</script>";
}
} else {
$callback_query =
"SELECT * FROM vtiger_activity_reminder_popup inner join vtiger_crmentity where " .
" vtiger_activity_reminder_popup.status = 0 and " .
" vtiger_activity_reminder_popup.recordid = vtiger_crmentity.crmid " .
" and vtiger_crmentity.smownerid = ".$current_user->id." and vtiger_crmentity.deleted = 0 ".
"AND vtiger_activity_reminder_popup.reminderid > 0 ORDER BY date_start DESC , ".
"TIME_FORMAT(vtiger_activity_reminder_popup.time_start,'%H:%i') DESC LIMIT 1";
$result = $adb->query($callback_query);
$it = new SqlResultIterator($adb, $result);
$nextReminderTime = null;
foreach ($it as $row) {
$nextReminderTime = strtotime($row->date_start.' '.$row->time_start);
}
$_SESSION['next_reminder_time'] = $nextReminderTime - ($intervalInMinutes * 60);
}
$reminder_next = date('Y-m-d H:i', strtotime("+$cb_time minutes", $cur_time));
// NOTE date_entered has CURRENT_TIMESTAMP constraint, so we need to reset when updating the table
$adb->pquery("UPDATE vtiger_users set reminder_next_time=?, date_entered=? where id=?",array($reminder_next, $lastlogin_time, $current_user->id));
$reminder_interval_reset = (strtotime($reminder_next) - $cur_time) * 1000;
// NOTE (Overcome Browser's issue): If required comment out the following line if condition below.
// To make popup work fine when interval is set to 1 minute, we need decrement the timeout
// if($reminder_interval_reset / 1000 == 60) $reminder_interval_reset = (40 * 1000);
echo "<script type='text/javascript' id='_vtiger_activityreminder_callback_interval_'>$reminder_interval_reset</script>";
echo "<script type='text/javascript' id='_vtiger_activityreminder_callback_interval_'>".
($_SESSION['next_reminder_interval'] * 1000)."</script>";
}
}
}
?>
@@ -33,6 +33,7 @@ if($cbaction == 'POSTPONE') {
if(isset($cbmodule) && isset($cbrecord)) {
$reminderid = $_REQUEST['cbreminderid'];
if(!empty($reminderid) ) {
unset($_SESSION['next_reminder_time']);
$reminder_query = "UPDATE vtiger_activity_reminder_popup set status = 0 WHERE reminderid = ? AND semodule = ? AND recordid = ?";
$adb->pquery($reminder_query, array($reminderid, $cbmodule, $cbrecord));
echo ":#:SUCCESS";
@@ -127,7 +127,8 @@ class Appointment
}
//Get Recurring events
$q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid ";
$q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
$q .= getNonAdminAccessControlQuery('Calendar',$current_user);
$q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') AND (recurringdate between ? and ?) ";
// User Select Customization
@@ -135,12 +136,6 @@ class Appointment
// END
$params = array($from_datetime->get_formatted_date(), $to_datetime->get_formatted_date());
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
{
$sec_parameter=getListViewSecurityParameter('Calendar');
$q .= $sec_parameter;
}
$q .= " ORDER by vtiger_recurringevents.recurringid";
$r = $adb->pquery($q, $params);
@@ -96,4 +96,28 @@ function showActivityView(selectactivity_view)
document.frmOpenLstView.submit();
}
function exportCalendar(){
if(document.getElementsByName('exportCalendar')[0].value == 'iCal'){
var filename = $('ics_filename').value;
VtigerJS_DialogBox.block();
var url = "index.php?module=Calendar&action=iCalExport&filename="+filename;
location.href = url;
VtigerJS_DialogBox.unblock();
ghide('CalExport')
}
}
function importCalendar(){
var file = document.getElementById('ics_file').value;
if (file != '') {
if (file.indexOf('.ics') != (file.length - 4)) {
alert(alert_arr.PLS_SELECT_VALID_FILE+".ics")
}
else {
document.ical_import.action.value='iCalImport';
document.ical_import.module.value='Calendar';
document.ical_import.submit();
}
}
}
@@ -332,13 +332,14 @@ function getAssignedTo($tabid)
*/
function getActivityDetails($description,$user_id,$from='')
{
global $log,$current_user;
global $adb,$mod_strings;
$log->debug("Entering getActivityDetails(".$description.") method ...");
global $log,$current_user,$current_language;
global $adb;
require_once 'include/utils/utils.php';
$mod_strings = return_module_language($current_language, 'Calendar');
$log->debug("Entering getActivityDetails(".$description.") method ...");
$updated = $mod_strings['LBL_UPDATED'];
$created = $mod_strings['LBL_CREATED'];
$reply = (($description['mode'] == 'edit')?"$updated":"$created");
$reply = (($description['mode'] == 'edit')?"$updated":"$created");
if($description['activity_mode'] == "Events")
{
$end_date_lable=$mod_strings['End date and time'];
@@ -355,17 +356,16 @@ function getActivityDetails($description,$user_id,$from='')
else
$msg = getTranslatedString($mod_strings['LBL_ACTIVITY_NOTIFICATION']);
$current_username = getUserName($current_user->id);
$status = getTranslatedString($description['status']);
$list = $name.',';
$current_username = getUserName($current_user->id);
$status = getTranslatedString($description['status'],'Calendar');
$list = $name.',';
$list .= '<br><br>'.$msg.' '.$reply.'.<br> '.$mod_strings['LBL_DETAILS_STRING'].':<br>';
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_SUBJECT"].' '.$description['subject'];
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_SUBJECT"].' : '.$description['subject'];
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Start date and time"].' : '.$description['st_date_time'];
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$end_date_lable.' : '.$description['end_date_time'];
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_STATUS"].': '.$status;
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Priority"].': '.getTranslatedString($description['taskpriority']);
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Related To"].': '.getTranslatedString($description['relatedto']);
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_STATUS"].': '.$status;
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Priority"].': '.getTranslatedString($description['taskpriority']);
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Related To"].': '.getTranslatedString($description['relatedto']);
if(!empty($description['contact_name']))
{
$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_CONTACT_LIST"].' '.$description['contact_name'];
@@ -378,7 +378,7 @@ function getActivityDetails($description,$user_id,$from='')
$list .= '<br>'.$current_username.'.';
$log->debug("Exiting getActivityDetails method ...");
return $list;
return $list;
}
function twoDigit( $no ){
@@ -414,24 +414,15 @@ function getEventNotification($mode,$subject,$desc)
require_once("modules/Emails/mail.php");
$subject = $mode.' : '.$subject;
$crmentity = new CRMEntity();
if($desc['assingn_type'] == "U")
if(getUserName($desc['user_id']))
{
$to_email = getUserEmailId('id',$desc['user_id']);
$description = getActivityDetails($desc,$desc['user_id']);
send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
}
if($desc['assingn_type'] == "T")
else
{
$groupid = '';
$groupname=$desc['group_name'];
// getGroupName API was changed to return array of two elements!
if(is_array($groupname) && !empty($groupname)) {
$groupid = $groupname[1];
$groupname = $groupname[0];
} else {
$resultqry=$adb->pquery("select groupid from vtiger_groups where groupname=?", array($groupname));
$groupid=$adb->query_result($resultqry,0,"groupid");
}
$groupid = $desc['user_id'];
require_once('include/utils/GetGroupUsers.php');
$getGroupObj=new GetGroupUsers();
$getGroupObj->getAllUsersInGroup($groupid);
@@ -531,7 +522,7 @@ function getActivityMailInfo($return_id,$status,$activity_type)
$mail_data['relatedto'] = $rel_name;
$mail_data['contact_name'] = $cont_name;
$mail_data['description'] = $description;
$mail_data['assingn_type'] = $assignType;
$mail_data['assign_type'] = $assignType;
$mail_data['group_name'] = $grp_name;
$value = getaddEventPopupTime($st_time,$end_time,'24');
$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
@@ -274,7 +274,8 @@ elseif($activity_mode == 'Events')
$invited_users[$userid]=$username;
}
$smarty->assign("INVITEDUSERS",$invited_users);
$related_array = getRelatedLists("Calendar", $focus);
$related_array = getRelatedListsInformation("Calendar", $focus);
$smarty->assign("CONTACTS",$related_array['Contacts']['entries']);
$is_fname_permitted = getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname');
@@ -347,7 +348,7 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), 'DETAILVIEW', $customlink_params));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
// END
$custom_fields_data = getCalendarCustomFields($tabid,'detail_view',$focus->column_fields);
@@ -70,7 +70,7 @@ if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
}
$smarty->assign("INVITEDUSERS",$invited_users);
$smarty->assign("UPDATEINFO",updateInfo($focus->id));
$related_array = getRelatedLists("Calendar", $focus);
$related_array = getRelatedListsInformation("Calendar", $focus);
$cntlist = $related_array['Contacts']['entries'];
$is_fname_permitted = getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname');
$cnt_idlist = '';
@@ -86,8 +86,8 @@ if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
$cnt_namelist .= "\n";
}
$cnt_idlist .= $key;
$contName = eregi_replace("(<a[^>]*>)(.*)(</a>)", "\\2", $cntvalue[0]);
if ($is_fname_permitted == '0') $contName .= ' '.eregi_replace("(<a[^>]*>)(.*)(</a>)", "\\2", $cntvalue[1]);
$contName = preg_replace("/(<a[^>]*>)(.*)(<\/a>)/i", "\\2", $cntvalue[0]);
if ($is_fname_permitted == '0') $contName .= ' '.preg_replace("/(<a[^>]*>)(.*)(<\/a>)/i", "\\2", $cntvalue[1]);
$cnt_namelist .= '<option value="'.$key.'">'.$contName.'</option>';
$i++;
}
@@ -226,7 +226,7 @@ if( $adb->dbType == "pgsql")
else
$list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
$smarty->assign('recordListRange',$recordListRangeMsg);
//Retreive the List View Table Header
@@ -269,6 +269,12 @@ $smarty->assign("CHECK", $check_button);
$_SESSION[$currentModule.'_listquery'] = $list_query;
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
// END
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("ListViewEntries.tpl");
else
@@ -45,9 +45,7 @@ function getPendingActivities($mode,$view=''){
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
if($_REQUEST['activity_view']==''){
$activity_view='today';
}else{
@@ -64,21 +62,32 @@ function getPendingActivities($mode,$view=''){
}
if($mode != 1){
$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_recurringevents.recurringdate,
vtiger_activity.activityid, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,
from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in ('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held') )".$upcoming_condition;
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3){
$sec_parameter=getListViewSecurityParameter('Calendar');
$list_query .= $sec_parameter;
}
$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.".
"setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, ".
"vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,".
"from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=".
"vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = ".
"vtiger_crmentity.smownerid left outer join vtiger_recurringevents on ".
"vtiger_recurringevents.activityid=vtiger_activity.activityid";
$list_query .= getNonAdminAccessControlQuery('Calendar',$current_user);
$list_query .= " WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in ".
"('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in".
"('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.".
"eventstatus not in ('Held','Not Held') )".$upcoming_condition;
}else{
$list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_recurringevents.recurringdate,
vtiger_activity.activityid, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,
from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held')) ".$pending_condition;
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3){
$sec_parameter=getListViewSecurityParameter('Calendar');
$list_query .= $sec_parameter;
}
$list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity".
"setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, vtiger_activity".
".activitytype, vtiger_activity.date_start, vtiger_activity.due_date, from vtiger_activity".
"inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid ".
"LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid ".
"left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=".
"vtiger_activity.activityid";
$list_query .= getNonAdminAccessControlQuery('Calendar',$current_user);
$list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.".
"activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.".
"status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR ".
"vtiger_activity.eventstatus not in ('Held','Not Held')) ".$pending_condition;
$list_query.= " GROUP BY vtiger_activity.activityid";
$list_query.= " ORDER BY date_start,time_start ASC";
@@ -117,7 +126,7 @@ function getPendingActivities($mode,$view=''){
$entries=array();
foreach($open_activity_list as $event){
$recur_date=ereg_replace('--','',$event['recurringdate']);
$recur_date=preg_replace('/--/','',$event['recurringdate']);
if($recur_date!=""){
$event['date_start']=$event['recurringdate'];
}
@@ -54,7 +54,7 @@ require_once('include/utils/UserInfoUtil.php');
global $log;
$log->debug("Entering time_to_number(".$time_start.") method ...");
$start_time_array = explode(":",$time_start);
if(ereg("^[0]",$start_time_array[0]))
if(preg_match("/^[0]/",$start_time_array[0]))
{
$time_start_hrs=str_replace('0',"",$start_time_array[0]);
}
@@ -148,7 +148,8 @@ class Calendar_RepeatEvents {
/** Create instance before and reuse */
$new_focus = new Activity();
foreach($repeatIntervals as $interval) {
$numberOfRepeats = count($repeatIntervals);
foreach($repeatIntervals as $index => $interval) {
$new_focus_start_timing = self::nexttime($base_focus_start, "+$interval days");
$new_focus_start_timing = self::splittime(self::formattime($new_focus_start_timing));
@@ -157,7 +158,7 @@ class Calendar_RepeatEvents {
// Reset the new_focus and prepare for reuse
if(isset($new_focus->id)) unset($new_focus->id);
foreach($new_focus->column_fields as $key=>$value) $new_focus->column_fields[$key] = '';
$new_focus->column_fields = array();
foreach($base_focus->column_fields as $key=>$value) {
if(in_array($key, $skip_focus_fields)) {
@@ -173,7 +174,10 @@ class Calendar_RepeatEvents {
} else {
$new_focus->column_fields[$key] = $value;
}
}
}
if($numberOfRepeats > 10 && $index > 10) {
unset($new_focus->column_fields['sendnotification']);
}
$new_focus->save('Calendar');
}
}
+10 -11
View File
@@ -83,11 +83,6 @@ if((isset($_REQUEST['change_status']) && $_REQUEST['change_status']) && ($_REQUE
</div>";
echo "</td></tr></table>";die;
}
$mail_data = getActivityMailInfo($return_id,$status,$activity_type);
if($mail_data['sendnotification'] == 1)
{
getEventNotification($activity_type,$mail_data['subject'],$mail_data);
}
$invitee_qry = "select * from vtiger_invitees where activityid=?";
$invitee_res = $adb->pquery($invitee_qry, array($return_id));
$count = $adb->num_rows($invitee_res);
@@ -196,7 +191,7 @@ function getRequestData($return_id)
$mail_data['relatedto'] = $_REQUEST['parent_name'];
$mail_data['contact_name'] = $cont_name;
$mail_data['description'] = $_REQUEST['description'];
$mail_data['assingn_type'] = $_REQUEST['assigntype'];
$mail_data['assign_type'] = $_REQUEST['assigntype'];
$mail_data['group_name'] = getGroupName($_REQUEST['assigned_group_id']);
$mail_data['mode'] = $_REQUEST['mode'];
$value = getaddEventPopupTime($_REQUEST['time_start'],$_REQUEST['time_end'],'24');
@@ -215,11 +210,12 @@ if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '')
$storearray = explode (";",$_REQUEST['contactidlist']);
$del_sql = "delete from vtiger_cntactivityrel where activityid=?";
$adb->pquery($del_sql, array($record));
$record = $focus->id;
foreach($storearray as $id)
{
if($id != '')
{
$record = $focus->id;
$sql = "insert into vtiger_cntactivityrel values (?,?)";
$adb->pquery($sql, array($id, $record));
if(!empty($heldevent_id)) {
@@ -229,7 +225,6 @@ if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '')
}
}
}
//Added code to send mail to the assigned to user about the details of the vtiger_activity if sendnotification = on and assigned to user
if($_REQUEST['sendnotification'] == 'on')
{
@@ -297,10 +292,14 @@ if($_REQUEST['return_viewname'] != '')
$parenttab=getParentTab();
if($_REQUEST['start'] !='')
if(!empty($_REQUEST['start'])) {
$page='&start='.vtlib_purify($_REQUEST['start']);
}
if(!empty($_REQUEST['pagenumber'])){
$page = "&start=".vtlib_purify($_REQUEST['pagenumber']);
}
if($_REQUEST['maintab'] == 'Calendar')
header("Location: index.php?action=".$return_action."&module=".$return_module."&view=".$view."&hour=".$hour."&day=".$day."&month=".$month."&year=".$year."&record=".$return_id."&viewOption=".$viewOption."&subtab=".$subtab."&parenttab=$parenttab");
else
header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page&parenttab=$parenttab&start=".vtlib_purify($_REQUEST['pagenumber']).$search);
?>
header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page&parenttab=$parenttab$search");
?>
+9 -12
View File
@@ -43,9 +43,12 @@ foreach($focus->column_fields as $fieldname => $val)
}
$focus->column_fields["subject"] = $_REQUEST["task_subject"];
$focus->column_fields["time_start"] = $_REQUEST["task_time_start"];
$focus->column_fields["assigned_user_id"] = $_REQUEST["task_assigned_user_id"];
$_REQUEST["assigned_group_id"] = $_REQUEST['task_assigned_group_id'];
$_REQUEST['assigntype'] = $_REQUEST['task_assigntype'];
if($_REQUEST['task_assigntype'] == 'U') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['task_assigned_user_id'];
} elseif($_REQUEST['task_assigntype'] == 'T') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['task_assigned_group_id'];
}
$focus->column_fields["taskstatus"] = $_REQUEST["taskstatus"];
$focus->column_fields["date_start"] = $_REQUEST["task_date_start"];
$focus->column_fields["due_date"] = $_REQUEST["task_due_date"];
@@ -55,14 +58,8 @@ foreach($focus->column_fields as $fieldname => $val)
$focus->column_fields["description"] = $_REQUEST["task_description"];
if(isset($_REQUEST['task_sendnotification']) && $_REQUEST['task_sendnotification'] != null)
$focus->column_fields["sendnotification"] = $_REQUEST["task_sendnotification"];
$focus->save($tab_type);
$focus->save($tab_type);
if($_REQUEST["task_sendnotification"]=='on')
{
$mail_contents = getRequestedToData();
getEventNotification($_REQUEST['activity_mode'],$_REQUEST['task_subject'],$mail_contents);
}
function getRequestedToData()
{
$mail_data = Array();
@@ -74,7 +71,7 @@ function getRequestedToData()
$mail_data['relatedto'] = $_REQUEST['task_parent_name'];
$mail_data['contact_name'] = $_REQUEST['task_contact_name'];
$mail_data['description'] = $_REQUEST['task_description'];
$mail_data['assingn_type'] = $_REQUEST['task_assigntype'];
$mail_data['assign_type'] = $_REQUEST['task_assigntype'];
$mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']);
$mail_data['mode'] = $_REQUEST['task_mode'];
$value = getaddEventPopupTime($_REQUEST['task_time_start'],$_REQUEST['task_time_end'],'24');
@@ -85,4 +82,4 @@ function getRequestedToData()
}
header("Location: index.php?action=index&module=Calendar&view=".vtlib_purify($_REQUEST['view'])."&hour=".vtlib_purify($_REQUEST['hour'])."&day=".vtlib_purify($_REQUEST['day'])."&month=".vtlib_purify($_REQUEST['month'])."&year=".vtlib_purify($_REQUEST['year'])."&viewOption=".vtlib_purify($_REQUEST['viewOption'])."&subtab=todo&parenttab=".getParentTab());
?>
?>
@@ -1105,7 +1105,7 @@ function getdayEventLayer(& $cal,$slice,$rows)
$color = $act[$i]->color;
$image = vtiger_imageurl($act[$i]->image_name, $theme);
if($act[$i]->recurring)
$recurring = '<img src="'.$image.''.$act[$i]->recurring.'" align="middle" border="0"></img>';
$recurring = '<img src="'.vtiger_imageurl($act[$i]->recurring, $theme).'" align="middle" border="0"></img>';
else
$recurring = '&nbsp;';
$height = $rowspan * 75;
@@ -1207,7 +1207,7 @@ function getweekEventLayer(& $cal,$slice)
$image = vtiger_imageurl($act[$i]->image_name, $theme);
$idShared = "normal"; if($act[$i]->shared) $idShared = "shared";
if($act[$i]->recurring)
$recurring = '<img src="'.$image.''.$act[$i]->recurring.'" align="middle" border="0"></img>';
$recurring = '<img src="'.vtiger_imageurl($act[$i]->recurring, $theme).'" align="middle" border="0"></img>';
else
$recurring = '&nbsp;';
$color = $act[$i]->color;
@@ -1360,24 +1360,10 @@ function getEventList(& $calendar,$start_date,$end_date,$info='')
$cal_log->debug("Entering getEventList() method...");
//modified query to fix the ticket #5014 & #5180
$and = "AND ((((vtiger_activity.date_start between ? AND ?)
OR (vtiger_activity.date_start < ? AND vtiger_activity.due_date > ?)
OR (vtiger_activity.due_date between ? AND ?))
$and = "AND (((vtiger_activity.date_start >= ? AND vtiger_activity.due_date <= ?)
AND (vtiger_recurringevents.activityid is NULL))
OR (vtiger_recurringevents.recurringdate BETWEEN ? AND ?))";
$count_qry = "SELECT count(*) as count FROM vtiger_activity
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
LEFT OUTER JOIN vtiger_recurringevents
ON vtiger_recurringevents.activityid = vtiger_activity.activityid
WHERE vtiger_crmentity.deleted = 0
AND (vtiger_activity.activitytype not in ('Emails','Task')) $and ";
$query = "SELECT vtiger_groups.groupname, vtiger_users.user_name,vtiger_crmentity.smownerid, vtiger_crmentity.crmid,
vtiger_activity.* FROM vtiger_activity
INNER JOIN vtiger_crmentity
@@ -1390,7 +1376,8 @@ function getEventList(& $calendar,$start_date,$end_date,$info='')
ON vtiger_recurringevents.activityid = vtiger_activity.activityid
WHERE vtiger_crmentity.deleted = 0
AND (vtiger_activity.activitytype not in ('Emails','Task')) $and ";
$list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id;
$list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id;
// User Select Customization: Changes should made also in (Appointment::readAppointment)
$query_filter_prefix = calendarview_getSelectedUserFilterQuerySuffix();
@@ -1398,7 +1385,7 @@ function getEventList(& $calendar,$start_date,$end_date,$info='')
$count_query .= $query_filter_prefix;
// END
$params = $info_params = array($start_date, $end_date, $start_date, $end_date, $start_date, $end_date, $start_date, $end_date);
$params = $info_params = array($start_date, $end_date, $start_date, $end_date);
if($info != '')
{
$groupids = explode(",", fetchUserGroupids($current_user->id)); // Explode can be removed, once implode is removed from fetchUserGroupids
@@ -1432,40 +1419,50 @@ function getEventList(& $calendar,$start_date,$end_date,$info='')
{
$sec_parameter=getCalendarViewSecurityParameter();
$query .= $sec_parameter;
$list_query .= $sec_parameter;
$count_qry .= $sec_parameter;
}
if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'search')
{
$search_where = calendar_search_where($_REQUEST['field_name'],$_REQUEST['search_option'],$_REQUEST['search_text']);
$group_cond .= $search_where;
$count_qry .= $search_where;
}
$group_cond .= $search_where;
}
$group_cond .= " GROUP BY vtiger_activity.activityid ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
$count_qry .= ' GROUP BY vtiger_activity.activityid ';
$count_res = $adb->pquery($count_qry, $params);
$total_rec_count = $adb->num_rows($count_res);
if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
$start = vtlib_purify($_REQUEST['start']);
else
$start = 1;
$navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page);
$start_rec = $navigation_array['start'];
//Ticket 6476
if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){
$count_result = $adb->pquery( mkCountQuery( $query),$params);
$noofrows = $adb->query_result($count_result,0,"count");
}else{
$noofrows = null;
}
global $currentModule;
$queryMode = (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true');
//$viewid is used as a key for cache query and other info so pass the dates as viewid
$viewid = $start_date.$end_date;
$start = ListViewSession::getRequestCurrentPage($currentModule, $adb->convert2sql($query,
$params), $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$noofrows);
//end
$start_rec = ($start-1) * $list_max_entries_per_page;
$end_rec = $navigation_array['end_val'];
if($start_rec <= 1)
//print_r($navigation_array);die();
//echo $end_rec.'val';
$list_query = $adb->convert2Sql($query, $params);
$_SESSION['Calendar_listquery'] = $list_query;
if($start_rec < 0)
$start_rec = 0;
else
$start_rec = $start_rec-1;
$query .= $group_cond." limit $start_rec,$list_max_entries_per_page";
$list_query .= $group_cond;
if( $adb->dbType == "pgsql"){
$query = fixPostgresQuery( $query, $log, 0);
$list_query = fixPostgresQuery( $list_query, $log, 0);
$query = fixPostgresQuery($query, $log, 0);
}
$list_query = $adb->convert2Sql($list_query, $params);
$_SESSION['Calendar_listquery'] = $list_query;
$result = $adb->pquery($query, $params);
$rows = $adb->num_rows($result);
$c = 0;
@@ -1597,20 +1594,8 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='')
$cal_log->debug("Entering getTodoList() method...");
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
$count_qry = "SELECT count(*) as count FROM vtiger_activity
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
LEFT JOIN vtiger_cntactivityrel
ON vtiger_cntactivityrel.activityid = 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_crmentity.deleted = 0
AND vtiger_activity.activitytype = 'Task'
AND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
$query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid,
$query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid,
vtiger_activity.* FROM vtiger_activity
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
@@ -1619,13 +1604,12 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='')
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
WHERE vtiger_crmentity.deleted = 0
AND vtiger_activity.activitytype = 'Task'
AND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
$list_query = $query;
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery('Calendar',$current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype = 'Task'".
" AND (vtiger_activity.date_start BETWEEN ? AND ?)";
$list_query = $query." AND vtiger_crmentity.smownerid = " . $current_user->id;
// User Select Customization
/*$only_for_user = calendarview_getSelectedUserId();
if($only_for_user != 'ALL') {
@@ -1669,39 +1653,38 @@ function getTodoList(& $calendar,$start_date,$end_date,$info='')
return Array('totaltodo'=>$total,'pendingtodo'=>$pending_rows);
}
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[9] == 3)
{
$sec_parameter=getListViewSecurityParameter('Calendar');
$query .= $sec_parameter;
$list_query .= $sec_parameter;
$count_qry .= $sec_parameter;
}
$group_cond = '';
$count_res = $adb->pquery($count_qry, $params);
$total_rec_count = $adb->query_result($count_res,0,'count');
$group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
$start = vtlib_purify($_REQUEST['start']);
else
$start = 1;
$navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page);
$start_rec = $navigation_array['start'];
//T6477 changes
if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){
$count_res = $adb->pquery(mkCountQuery($query), $params);
$total_rec_count = $adb->query_result($count_res,0,'count');
}else{
$total_rec_count = null;
}
$navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$total_rec_count);
$start_rec = ($start-1) * $list_max_entries_per_page;
$end_rec = $navigation_array['end_val'];
if($start_rec <= 1)
$list_query = $adb->convert2Sql($query, $params);
$_SESSION['Calendar_listquery'] = $list_query;
if($start_rec < 0)
$start_rec = 0;
else
$start_rec = $start_rec-1;
//ends
$query .= $group_cond." limit $start_rec,$list_max_entries_per_page";
$list_query .= $group_cond;
if( $adb->dbType == "pgsql"){
$query = fixPostgresQuery( $query, $log, 0);
$list_query = fixPostgresQuery( $list_query, $log, 0);
}
$list_query = $adb->convert2Sql($list_query, $params);
$_SESSION['Calendar_listquery'] = $list_query;
$result = $adb->pquery($query, $params);
$rows = $adb->num_rows($result);
@@ -1892,7 +1875,9 @@ function constructEventListView(& $cal,$entry_list,$navigation_array='')
$list_view .="<table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>
<tr>";
$header_rows = count($header);
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Calendar","index");
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Calendar","index");
if($navigationOutput != '')
{
$list_view .= "<tr width=100% bgcolor=white><td align=center colspan=$header_rows>";
@@ -1946,7 +1931,7 @@ function constructEventListView(& $cal,$entry_list,$navigation_array='')
//checking permission for Create/Edit Operation
if(isPermitted("Calendar","EditView") == "yes")
{
$list_view .="<td class='small' align='left' nowrap='nowrap'>".$app_strings['LBL_YOU_CAN_CREATE']."&nbsp;".$app_strings['LBL_AN']."&nbsp;".$app_strings['Event']."&nbsp;".$app_strings['LBL_NOW'].".<br>
$list_view .="<td class='small' align='left' nowrap='nowrap'>".$app_strings['LBL_YOU_CAN_CREATE']."&nbsp;".$app_strings['LBL_AN']."&nbsp;".$app_strings['Event']."&nbsp;".$app_strings['LBL_NOW'].".&nbsp;".$app_strings['LBL_CLICK_THE_LINK'].":<br>
&nbsp;&nbsp;-<a href='javascript:void(0);' onClick='gshow(\"addEvent\",\"Call\",\"".$temp_date."\",\"".$endtemp_date."\",\"".$time_arr['starthour']."\",\"".$time_arr['startmin']."\",\"".$time_arr['startfmt']."\",\"".$time_arr['endhour']."\",\"".$time_arr['endmin']."\",\"".$time_arr['endfmt']."\",\"listview\",\"event\");'>".$app_strings['LBL_CREATE']."&nbsp;".$app_strings['LBL_AN']."&nbsp;".$app_strings['Event']."</a><br>
</td>";
}
@@ -2102,7 +2087,7 @@ function constructTodoListView($todo_list,$cal,$subtab,$navigation_array='')
{
$list_view .="<tr><td>&nbsp;</td>";
}
$list_view .="<td align='center' width='60%'><span id='total_activities'>".getTodoInfo($cal,'listcnt')."</span>&nbsp;</td>
$list_view .="<td align='center' width='60%'><span id='total_activities'>".getTodoInfo($cal,'listcnt')."</span>&nbsp;</td>
<td align='right' width='28%'>&nbsp;</td>
</tr>
</table>
@@ -2110,7 +2095,9 @@ function constructTodoListView($todo_list,$cal,$subtab,$navigation_array='')
<br><table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>
";
$header_rows = count($header);
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Calendar","index");
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Calendar","index");
if($navigationOutput != '')
{
$list_view .= "<tr width=100% bgcolor=white><td align=center colspan=$header_rows>";
@@ -2193,4 +2180,4 @@ function getCalendarViewSecurityParameter()
$sec_query .= ")";
return $sec_query;
}
?>
?>
@@ -0,0 +1,628 @@
<?php // $Id: iCalendar_components.php,v 1.8 2005/07/21 22:31:44 defacer Exp $
require_once('include/utils/utils.php');
class iCalendar_component {
var $name = NULL;
var $properties = NULL;
var $components = NULL;
var $valid_properties = NULL;
var $valid_components = NULL;
function iCalendar_component() {
$this->construct();
}
function construct() {
// Initialize the components array
if(empty($this->components)) {
$this->components = array();
foreach($this->valid_components as $name) {
$this->components[$name] = array();
}
}
}
function get_name() {
return $this->name;
}
function add_property($name, $value = NULL, $parameters = NULL) {
// Uppercase first of all
$name = strtoupper($name);
// Are we trying to add a valid property?
$xname = false;
if(!isset($this->valid_properties[$name])) {
// If not, is it an x-name as per RFC 2445?
if(!rfc2445_is_xname($name)) {
return false;
}
// Since this is an xname, all components are supposed to allow this property
$xname = true;
}
// Create a property object of the correct class
if($xname) {
$property = new iCalendar_property_x;
$property->set_name($name);
}
else {
$classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $name));
$property = new $classname;
}
// If $value is NULL, then this property must define a default value.
if($value === NULL) {
$value = $property->default_value();
if($value === NULL) {
return false;
}
}
// Set this property's parent component to ourselves, because some
// properties behave differently according to what component they apply to.
$property->set_parent_component($this->name);
// Set parameters before value; this helps with some properties which
// accept a VALUE parameter, and thus change their default value type.
// The parameters must be valid according to property specifications
if(!empty($parameters)) {
foreach($parameters as $paramname => $paramvalue) {
if(!$property->set_parameter($paramname, $paramvalue)) {
return false;
}
}
// Some parameters interact among themselves (e.g. ENCODING and VALUE)
// so make sure that after the dust settles, these invariants hold true
if(!$property->invariant_holds()) {
return false;
}
}
// $value MUST be valid according to the property data type
if(!$property->set_value($value)) {
return false;
}
// If this property is restricted to only once, blindly overwrite value
if(!$xname && $this->valid_properties[$name] & RFC2445_ONCE) {
$this->properties[$name] = array($property);
}
// Otherwise add it to the instance array for this property
else {
$this->properties[$name][] = $property;
}
// Finally: after all these, does the component invariant hold?
if(!$this->invariant_holds()) {
// If not, completely undo the property addition
array_pop($this->properties[$name]);
if(empty($this->properties[$name])) {
unset($this->properties[$name]);
}
return false;
}
return true;
}
function add_component($component) {
// With the detailed interface, you can add only components with this function
if(!is_object($component) || !is_subclass_of($component, 'iCalendar_component')) {
return false;
}
$name = $component->get_name();
// Only valid components as specified by this component are allowed
if(!in_array($name, $this->valid_components)) {
return false;
}
// Add it
$this->components[$name][] = $component;
return true;
}
function get_property_list($name) {
}
function invariant_holds() {
return true;
}
function is_valid() {
// If we have any child components, check that they are all valid
if(!empty($this->components)) {
foreach($this->components as $component => $instances) {
foreach($instances as $number => $instance) {
if(!$instance->is_valid()) {
return false;
}
}
}
}
// Finally, check the valid property list for any mandatory properties
// that have not been set and do not have a default value
foreach($this->valid_properties as $property => $propdata) {
if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) {
$classname = 'iCalendar_property_'.strtolower(str_replace('-', '_', $property));
$object = new $classname;
if($object->default_value() === NULL) {
return false;
}
unset($object);
}
}
return true;
}
function serialize() {
// Check for validity of the object
if(!$this->is_valid()) {
return false;
}
// Maybe the object is valid, but there are some required properties that
// have not been given explicit values. In that case, set them to defaults.
foreach($this->valid_properties as $property => $propdata) {
if(($propdata & RFC2445_REQUIRED) && empty($this->properties[$property])) {
$this->add_property($property);
}
}
// Start tag
$string = rfc2445_fold('BEGIN:'.$this->name) . RFC2445_CRLF;
// List of properties
if(!empty($this->properties)) {
foreach($this->properties as $name => $properties) {
foreach($properties as $property) {
$string .= $property->serialize();
}
}
}
// List of components
if(!empty($this->components)) {
foreach($this->components as $name => $components) {
foreach($components as $component) {
$string .= $component->serialize();
}
}
}
// End tag
$string .= rfc2445_fold('END:'.$this->name) . RFC2445_CRLF;
return $string;
}
function assign_values($activity) {
foreach($this->mapping_arr as $key=>$components){
if(!is_array($components['component']) && empty($components['function'])){
$this->add_property($key,$activity[$components['component']]);
} else if(is_array($components['component']) && empty($components['function'])){
$component = '';
foreach($components['component'] as $comp){
if(!empty($component)) $component .= ',';
$component .= $activity[$comp];
}
$this->add_property($key,$component);
} else if(!empty($components['function'])){
$this->$components['function']($activity);
}
}
return true;
}
function generateArray($ical_activity){
global $current_user;
$activity = array();
$activitytype = $ical_activity['TYPE'];
if($activitytype=='VEVENT'){
$modtype = 'Events';
} else {
$modtype = 'Calendar';
}
foreach($this->mapping_arr as $key=>$comp){
$type = $comp['type'];
$component = $comp['component'];
if(!is_array($component)){
if($type!='user'){
if(isset($this->field_mapping_arr[$component])){
if(getFieldVisibilityPermission($modtype,$current_user->id,$this->field_mapping_arr[$component])=='0')
$activity[$this->field_mapping_arr[$component]] = $ical_activity[$key];
else
$activity[$this->field_mapping_arr[$component]] = '';
} else {
if(getFieldVisibilityPermission($modtype,$current_user->id,$component)=='0')
$activity[$component] = $ical_activity[$key];
else
$activity[$component] = '';
}
}
} else {
$temp = $ical_activity[$key];
$count = 0;
if($type == 'string'){
$values = explode('\\,',$temp);
} else if($type == 'datetime'){
$values = $this->strtodatetime($temp);
}
foreach($component as $index){
if(!isset($activity[$index])){
if(isset($this->field_mapping_arr[$index])){
if(getFieldVisibilityPermission($modtype,$current_user->id,$this->field_mapping_arr[$index])=='0')
$activity[$this->field_mapping_arr[$index]] = $values[$count];
else
$activity[$this->field_mapping_arr[$index]] = '';
} else {
if(getFieldVisibilityPermission($modtype,$current_user->id,$index)=='0')
$activity[$index] = $values[$count];
else
$activity[$index] = '';
}
}
$count++;
}
unset($values);
}
}
if($activitytype=='VEVENT'){
$activity['activitytype'] = 'Meeting';
if(!empty($ical_activity['VALARM'])){
$temp = str_replace("PT",'',$ical_activity['VALARM']['TRIGGER']);
$duration_type = $temp[strlen($temp)-1];
$duration = intval($temp);
if($duration_type=='H'){
$reminder_time = $duration*60;
} else if($duration_type=='M'){
$reminder_time = $duration;
}
$activity['reminder_time'] = $reminder_time;
}
} else {
$activity['activitytype'] = 'Task';
}
return $activity;
}
function strtodatetime($date){
$date = preg_replace('/[A-Za-z_]*/', '', $date);
$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
$hours = substr($date,8,2);
$minutes = substr($date,10,2);
$seconds = substr($date,12,2);
$datetime[] = $year."-".$month."-".$day;
$datetime[] = $hours.":".$minutes.":".$seconds;
return $datetime;
}
}
class iCalendar extends iCalendar_component {
var $name = 'VCALENDAR';
function construct() {
$this->valid_properties = array(
'CALSCALE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'METHOD' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRODID' => RFC2445_REQUIRED | RFC2445_ONCE,
'VERSION' => RFC2445_REQUIRED | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
);
$this->valid_components = array(
'VEVENT', 'VTODO', 'VTIMEZONE'
// TODO: add support for the other component types
//, 'VJOURNAL', 'VFREEBUSY', 'VALARM'
);
parent::construct();
}
}
class iCalendar_event extends iCalendar_component {
var $name = 'VEVENT';
var $properties;
var $mapping_arr = array(
'CLASS' => array('component'=>'visibility','type'=>'string'),
'DESCRIPTION' => array('component'=>'description','type'=>'string'),
'DTSTART' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstart','type'=>'datetime'),
'DTEND' => array('component'=>array('due_date','time_end'),'function'=>'iCalendar_event_dtend','type'=>'datetime'),
'DTSTAMP' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstamp','type'=>'datetime'),
'LOCATION' => array('component'=>'location','type'=>'string'),
'STATUS' => array('component'=>'eventstatus','type'=>'string'),
'SUMMARY' => array('component'=>'subject','type'=>'string'),
'PRIORITY' => array('component'=>'priority','type'=>'string'),
'ATTENDEE' => array('component'=>'activityid','function'=>'iCalendar_event_attendee','type'=>'user'),
'RESOURCES' => array('component'=>array('location','eventstatus'),'type'=>'string'),
);
var $field_mapping_arr = array(
'priority'=>'taskpriority'
);
function construct() {
$this->valid_components = array('VALARM');
$this->valid_properties = array(
'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that DTSTAMP in optional,
// while in 4.8.7.2 it says it's REQUIRED. Go with REQUIRED.
'DTSTAMP' => RFC2445_REQUIRED | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that DTSTART in optional,
// while in 4.8.2.4 it says it's REQUIRED. Go with REQUIRED.
'DTSTART' => RFC2445_REQUIRED | RFC2445_ONCE,
'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TRANSP' => RFC2445_OPTIONAL | RFC2445_ONCE,
// Standard ambiguous here: in 4.6.1 it says that UID in optional,
// while in 4.8.4.7 it says it's REQUIRED. Go with REQUIRED.
'UID' => RFC2445_REQUIRED | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RECURRENCE-ID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTEND' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTACH' => RFC2445_OPTIONAL,
'ATTENDEE' => RFC2445_OPTIONAL,
'CATEGORIES' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'CONTACT' => RFC2445_OPTIONAL,
'EXDATE' => RFC2445_OPTIONAL,
'EXRULE' => RFC2445_OPTIONAL,
'REQUEST-STATUS' => RFC2445_OPTIONAL,
'RELATED-TO' => RFC2445_OPTIONAL,
'RESOURCES' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::construct();
}
function invariant_holds() {
// DTEND and DURATION must not appear together
if(isset($this->properties['DTEND']) && isset($this->properties['DURATION'])) {
return false;
}
if(isset($this->properties['DTEND']) && isset($this->properties['DTSTART'])) {
// DTEND must be later than DTSTART
// The standard is not clear on how to hande different value types though
// TODO: handle this correctly even if the value types are different
if($this->properties['DTEND'][0]->value <= $this->properties['DTSTART'][0]->value) {
return false;
}
// DTEND and DTSTART must have the same value type
if($this->properties['DTEND'][0]->val_type != $this->properties['DTSTART'][0]->val_type) {
return false;
}
}
return true;
}
function iCalendar_event_dtstamp($activity){
$components = gmdate('Ymd', strtotime($activity['date_start']." ".$activity['time_start']))."T".gmdate('His', strtotime($activity['date_start']." ".$activity['time_start']))."Z";
$this->add_property("DTSTAMP",$components);
return true;
}
function iCalendar_event_dtstart($activity){
$time = str_replace(':','',$activity['time_start']);
if(strlen($time)<6){
while((6-strlen($time)) > 0 ){
$time .= '0';
}
}
$components = str_replace('-', '', $activity['date_start']).'T'. $time . 'Z';
$this->add_property("DTSTART",$components);
return true;
}
function iCalendar_event_dtend($activity){
$time = str_replace(':','',$activity['time_end']);
if(strlen($time)<6){
while((6-strlen($time)) > 0 ){
$time .= '0';
}
}
$components = str_replace('-', '', $activity['due_date']).'T'. $time . 'Z';
$this->add_property("DTEND",$components);
return true;
}
function iCalendar_event_attendee($activity){
global $adb;
$users_res = $adb->pquery("SELECT inviteeid FROM vtiger_invitees WHERE activityid=?", array($activity['id']));
if($adb->num_rows($users_res)>0){
for($i=0;$i<$adb->num_rows($users_res);$i++){
$inviteeid = $adb->query_result($users_res,$i,'inviteeid');
$username = getUserFullName($inviteeid);
$user_email = getUserEmail($inviteeid);
$attendee = 'mailto:'.$user_email;
$this->add_property('ATTENDEE',$attendee);
}
}
return true;
}
}
class iCalendar_todo extends iCalendar_component {
var $name = 'VTODO';
var $properties;
var $mapping_arr = array(
'DESCRIPTION' => array('component'=>'description','type'=>'string'),
'DTSTAMP' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstamp','type'=>'datetime'),
'DTSTART' => array('component'=>array('date_start','time_start'),'function'=>'iCalendar_event_dtstart','type'=>'datetime'),
'DUE' => array('component'=>array('due_date'),'function'=>'iCalendar_event_dtend','type'=>'datetime'),
'STATUS' => array('component'=>'status','type'=>'string'),
'SUMMARY' => array('component'=>'subject','type'=>'string'),
'PRIORITY' => array('component'=>'priority','type'=>'string'),
'RESOURCES' => array('component'=>array('status'),'type'=>'string'),
);
var $field_mapping_arr = array(
'status'=>'taskstatus',
'priority'=>'taskpriority'
);
function construct() {
$this->valid_components = array();
$this->valid_properties = array(
'CLASS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'COMPLETED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CREATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTAMP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DTSTART' => RFC2445_OPTIONAL | RFC2445_ONCE,
'GEO' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LOCATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ORGANIZER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PERCENT' => RFC2445_OPTIONAL | RFC2445_ONCE,
'PRIORITY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RECURID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SEQUENCE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'STATUS' => RFC2445_OPTIONAL | RFC2445_ONCE,
'SUMMARY' => RFC2445_OPTIONAL | RFC2445_ONCE,
'UID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'URL' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DURATION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ATTACH' => RFC2445_OPTIONAL,
'ATTENDEE' => RFC2445_OPTIONAL,
'CATEGORIES' => RFC2445_OPTIONAL,
'COMMENT' => RFC2445_OPTIONAL,
'CONTACT' => RFC2445_OPTIONAL,
'EXDATE' => RFC2445_OPTIONAL,
'EXRULE' => RFC2445_OPTIONAL,
'RSTATUS' => RFC2445_OPTIONAL,
'RELATED' => RFC2445_OPTIONAL,
'RESOURCES' => RFC2445_OPTIONAL,
'RDATE' => RFC2445_OPTIONAL,
'RRULE' => RFC2445_OPTIONAL,
'XPROP' => RFC2445_OPTIONAL
);
parent::construct();
// TODO:
// either 'due' or 'duration' may appear in a 'eventprop', but 'due'
// and 'duration' MUST NOT occur in the same 'eventprop'
}
function iCalendar_event_dtstamp($activity){
$components = gmdate('Ymd', strtotime($activity['date_start']." ".$activity['time_start']))."T".gmdate('His', strtotime($activity['date_start']." ".$activity['time_start']))."Z";
$this->add_property("DTSTAMP",$components);
return true;
}
function iCalendar_event_dtstart($activity){
$time = str_replace(':','',$activity['time_start']);
if(strlen($time)<6){
while((6-strlen($time)) > 0 ){
$time .= '0';
}
}
$components = str_replace('-', '', $activity['date_start']).'T'. $time . 'Z';
$this->add_property("DTSTART",$components);
return true;
}
function iCalendar_event_dtend($activity){
$components = str_replace('-', '', $activity['due_date']).'T000000Z';
$this->add_property("DUE",$components);
return true;
}
}
class iCalendar_journal extends iCalendar_component {
// TODO: implement
}
class iCalendar_freebusy extends iCalendar_component {
// TODO: implement
}
class iCalendar_alarm extends iCalendar_component {
var $name='VALARM';
var $properties;
var $mapping_arr = array(
'TRIGGER' => array('component'=>'reminder_time', 'function'=>'iCalendar_event_trigger'),
);
function construct() {
$this->valid_components = array();
$this->valid_properties = array(
'TRIGGER' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DESCRIPTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ACTION' => RFC2445_OPTIONAL | RFC2445_ONCE,
'X-WR-ALARMUID' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
);
parent::construct();
}
function iCalendar_event_trigger($activity){
$reminder_time = $activity['reminder_time'];
if($reminder_time>60){
$reminder_time = round($reminder_time/60);
$reminder = $reminder_time.'H';
}else {
$reminder = $reminder_time.'M';
}
$this->add_property('ACTION', 'DISPLAY');
$this->add_property('TRIGGER', 'PT'.$reminder);
$this->add_property('DESCRIPTION', 'Reminder');
return true;
}
}
class iCalendar_timezone extends iCalendar_component {
var $name = 'VTIMEZONE';
var $properties;
function construct() {
$this->valid_components = array();
$this->valid_properties = array(
'TZID' => RFC2445_REQUIRED | RFC2445_ONCE,
'LAST-MODIFIED' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZURL' => RFC2445_OPTIONAL | RFC2445_ONCE,
// TODO: the next two are components of their own!
'STANDARDC' => RFC2445_OPTIONAL,
'DAYLIGHTC' => RFC2445_OPTIONAL,
'TZOFFSETFROM' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZOFFSETTO' => RFC2445_OPTIONAL | RFC2445_ONCE,
'X-PROP' => RFC2445_OPTIONAL
);
parent::construct();
}
}
// REMINDER: DTEND must be later than DTSTART for all components which support both
// REMINDER: DUE must be later than DTSTART for all components which support both
?>
@@ -0,0 +1,227 @@
<?php // $Id: iCalendar_parameters.php,v 1.7 2005/07/21 23:17:21 defacer Exp $
class iCalendar_parameter {
function multiple_values_allowed($parameter) {
switch($parameter) {
case 'DELEGATED-FROM':
case 'DELEGATED-TO':
case 'MEMBER':
return true;
default:
return false;
}
}
function default_value($parameter) {
switch($parameter) {
case 'CUTYPE': return 'INDIVIDUAL';
case 'FBTYPE': return 'BUSY';
case 'PARTSTAT': return 'NEEDS-ACTION';
case 'RELATED': return 'START';
case 'RELTYPE': return 'PARENT';
case 'ROLE': return 'REQ-PARTICIPANT';
case 'RSVP': return 'FALSE';
default: return NULL;
}
}
function is_valid_value(&$parent_property, $parameter, $value) {
switch($parameter) {
// These must all be a URI
case 'ALTREP':
case 'DIR':
return rfc2445_is_valid_value($value, RFC2445_TYPE_URI);
break;
// These must be CAL-ADDRESS, which is equivalent to URI
case 'DELEGATED-FROM':
case 'DELEGATED-TO':
case 'MEMBER':
case 'SENT-BY':
return rfc2445_is_valid_value($value, RFC2445_TYPE_CAL_ADDRESS);
break;
// These are textual parameters, so the MUST NOT contain double quotes
case 'CN':
return (strpos($value, '"') === false);
break;
// These have enumerated legal values
case 'CUTYPE':
$value = strtoupper($value);
return ($value == 'INDIVIDUAL' || $value == 'GROUP' || $value == 'RESOURCE' || $value == 'ROOM' || $value == 'UNKNOWN' || rfc2445_is_xname($value));
break;
case 'ENCODING':
$value = strtoupper($value);
return ($value == '8BIT' || $value == 'BASE64' || rfc2445_is_xname($value));
break;
case 'FBTYPE':
$value = strtoupper($value);
return ($value == 'FREE' || $value == 'BUSY' || $value == 'BUSY-UNAVAILABLE' || $value == 'BUSY-TENTATIVE' || rfc2445_is_xname($value));
break;
case 'FMTTYPE':
$fmttypes = array(
'TEXT' => array('PLAIN', 'RICHTEXT', 'ENRICHED', 'TAB-SEPARATED-VALUES', 'HTML', 'SGML',
'VND.LATEX-Z', 'VND.FMI.FLEXSTOR'),
'MULTIPART' => array('MIXED', 'ALTERNATIVE', 'DIGEST', 'PARALLEL', 'APPLEDOUBLE', 'HEADER-SET',
'FORM-DATA', 'RELATED', 'REPORT', 'VOICE-MESSAGE', 'SIGNED', 'ENCRYPTED',
'BYTERANGES'),
'MESSAGE' => array('RFC822', 'PARTIAL', 'EXTERNAL-BODY', 'NEWS', 'HTTP'),
'APPLICATION' => array('OCTET-STREAM', 'POSTSCRIPT', 'ODA', 'ATOMICMAIL', 'ANDREW-INSET', 'SLATE',
'WITA', 'DEC-DX', 'DCA-RFT', 'ACTIVEMESSAGE', 'RTF', 'APPLEFILE',
'MAC-BINHEX40', 'NEWS-MESSAGE-ID', 'NEWS-TRANSMISSION', 'WORDPERFECT5.1',
'PDF', 'ZIP', 'MACWRITEII', 'MSWORD', 'REMOTE-PRINTING', 'MATHEMATICA',
'CYBERCASH', 'COMMONGROUND', 'IGES', 'RISCOS', 'ESHOP', 'X400-BP', 'SGML',
'CALS-1840', 'PGP-ENCRYPTED', 'PGP-SIGNATURE', 'PGP-KEYS', 'VND.FRAMEMAKER',
'VND.MIF', 'VND.MS-EXCEL', 'VND.MS-POWERPOINT', 'VND.MS-PROJECT',
'VND.MS-WORKS', 'VND.MS-TNEF', 'VND.SVD', 'VND.MUSIC-NIFF', 'VND.MS-ARTGALRY',
'VND.TRUEDOC', 'VND.KOAN', 'VND.STREET-STREAM', 'VND.FDF',
'SET-PAYMENT-INITIATION', 'SET-PAYMENT', 'SET-REGISTRATION-INITIATION',
'SET-REGISTRATION', 'VND.SEEMAIL', 'VND.BUSINESSOBJECTS',
'VND.MERIDIAN-SLINGSHOT', 'VND.XARA', 'SGML-OPEN-CATALOG', 'VND.RAPID',
'VND.ENLIVEN', 'VND.JAPANNET-REGISTRATION-WAKEUP',
'VND.JAPANNET-VERIFICATION-WAKEUP', 'VND.JAPANNET-PAYMENT-WAKEUP',
'VND.JAPANNET-DIRECTORY-SERVICE', 'VND.INTERTRUST.DIGIBOX', 'VND.INTERTRUST.NNCP'),
'IMAGE' => array('JPEG', 'GIF', 'IEF', 'G3FAX', 'TIFF', 'CGM', 'NAPLPS', 'VND.DWG', 'VND.SVF',
'VND.DXF', 'PNG', 'VND.FPX', 'VND.NET-FPX'),
'AUDIO' => array('BASIC', '32KADPCM', 'VND.QCELP'),
'VIDEO' => array('MPEG', 'QUICKTIME', 'VND.VIVO', 'VND.MOTOROLA.VIDEO', 'VND.MOTOROLA.VIDEOP')
);
$value = strtoupper($value);
if(rfc2445_is_xname($value)) {
return true;
}
@list($type, $subtype) = explode('/', $value);
if(empty($type) || empty($subtype)) {
return false;
}
if(!isset($fmttypes[$type]) || !in_array($subtype, $fmttypes[$type])) {
return false;
}
return true;
break;
case 'LANGUAGE':
$value = strtoupper($value);
$parts = explode('-', $value);
foreach($parts as $part) {
if(empty($part)) {
return false;
}
if(strspn($part, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') != strlen($part)) {
return false;
}
}
return true;
break;
case 'PARTSTAT':
$value = strtoupper($value);
switch($parent_property->parent_component) {
case 'VEVENT':
return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE'
|| $value == 'DELEGATED' || rfc2445_is_xname($value));
break;
case 'VTODO':
return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE'
|| $value == 'DELEGATED' || $value == 'COMPLETED' || $value == 'IN-PROCESS' || rfc2445_is_xname($value));
break;
case 'VJOURNAL':
return ($value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || rfc2445_is_xname($value));
break;
}
return false;
break;
case 'RANGE':
$value = strtoupper($value);
return ($value == 'THISANDPRIOR' || $value == 'THISANDFUTURE');
break;
case 'RELATED':
$value = strtoupper($value);
return ($value == 'START' || $value == 'END');
break;
case 'RELTYPE':
$value = strtoupper($value);
return ($value == 'PARENT' || $value == 'CHILD' || $value == 'SIBLING' || rfc2445_is_xname($value));
break;
case 'ROLE':
$value = strtoupper($value);
return ($value == 'CHAIR' || $value == 'REQ-PARTICIPANT' || $value == 'OPT-PARTICIPANT' || $value == 'NON-PARTICIPANT' || rfc2445_is_xname($value));
break;
case 'RSVP':
$value = strtoupper($value);
return ($value == 'TRUE' || $value == 'FALSE');
break;
case 'TZID':
if(empty($value)) {
return false;
}
return (strcspn($value, '";:,') == strlen($value));
break;
case 'VALUE':
$value = strtoupper($value);
return ($value == 'BINARY' || $value == 'BOOLEAN' || $value == 'CAL-ADDRESS' || $value == 'DATE' ||
$value == 'DATE-TIME' || $value == 'DURATION' || $value == 'FLOAT' || $value == 'INTEGER' ||
$value == 'PERIOD' || $value == 'RECUR' || $value == 'TEXT' || $value == 'TIME' ||
$value == 'URI' || $value == 'UTC-OFFSET' || rfc2445_is_xname($value));
break;
}
}
function do_value_formatting($parameter, $value) {
switch($parameter) {
// Parameters of type CAL-ADDRESS or URI MUST be double-quoted
case 'ALTREP':
case 'DIR':
case 'DELEGATED-FROM':
case 'DELEGATED-TO':
case 'MEMBER':
case 'SENT-BY':
return '"'.$value.'"';
break;
// Textual parameter types must be double quoted if they contain COLON, SEMICOLON
// or COMMA. Quoting always sounds easier and standards-conformant though.
case 'CN':
return '"'.$value.'"';
break;
// Parameters with enumerated legal values, just make them all caps
case 'CUTYPE':
case 'ENCODING':
case 'FBTYPE':
case 'FMTTYPE':
case 'LANGUAGE':
case 'PARTSTAT':
case 'RANGE':
case 'RELATED':
case 'RELTYPE':
case 'ROLE':
case 'RSVP':
case 'VALUE':
return strtoupper($value);
break;
// Parameters we shouldn't be messing with
case 'TZID':
return $value;
break;
}
}
function undo_value_formatting($parameter, $value) {
}
}
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,807 @@
<?php // $Id: iCalendar_rfc2445.php,v 1.7 2005/07/21 23:23:48 defacer Exp $
/*
All names of properties, property parameters, enumerated property
values and property parameter values are case-insensitive. However,
all other property values are case-sensitive, unless otherwise
stated.
*/
define('RFC2445_CRLF', "\r\n");
define('RFC2445_WSP', "\t ");
define('RFC2445_WEEKDAYS', 'MO,TU,WE,TH,FR,SA,SU');
define('RFC2445_FOLDED_LINE_LENGTH', 75);
define('RFC2445_REQUIRED', 0x01);
define('RFC2445_OPTIONAL', 0x02);
define('RFC2445_ONCE', 0x04);
define('RFC2445_PROP_FLAGS', 0);
define('RFC2445_PROP_TYPE', 1);
define('RFC2445_PROP_DEFAULT', 2);
define('RFC2445_XNAME', 'X-');
define('RFC2445_TYPE_BINARY', 0);
define('RFC2445_TYPE_BOOLEAN', 1);
define('RFC2445_TYPE_CAL_ADDRESS', 2);
define('RFC2445_TYPE_DATE', 3);
define('RFC2445_TYPE_DATE_TIME', 4);
define('RFC2445_TYPE_DURATION', 5);
define('RFC2445_TYPE_FLOAT', 6);
define('RFC2445_TYPE_INTEGER', 7);
define('RFC2445_TYPE_PERIOD', 8);
define('RFC2445_TYPE_RECUR', 9);
define('RFC2445_TYPE_TEXT', 10);
define('RFC2445_TYPE_TIME', 11);
define('RFC2445_TYPE_URI', 12); // CAL_ADDRESS === URI
define('RFC2445_TYPE_UTC_OFFSET', 13);
function rfc2445_fold($string) {
if(strlen($string) <= RFC2445_FOLDED_LINE_LENGTH) {
return $string;
}
$retval = '';
while(strlen($string) > RFC2445_FOLDED_LINE_LENGTH) {
$retval .= substr($string, 0, RFC2445_FOLDED_LINE_LENGTH - 1) . RFC2445_CRLF . ' ';
$string = substr($string, RFC2445_FOLDED_LINE_LENGTH - 1);
}
$retval .= $string;
return $retval;
}
function rfc2445_unfold($string) {
for($i = 0; $i < strlen(RFC2445_WSP); ++$i) {
$string = str_replace(RFC2445_CRLF.substr(RFC2445_WSP, $i, 1), '', $string);
}
return $string;
}
function rfc2445_is_xname($name) {
// If it's less than 3 chars, it cannot be legal
if(strlen($name) < 3) {
return false;
}
// If it contains an illegal char anywhere, reject it
if(strspn($name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-') != strlen($name)) {
return false;
}
// To be legal, it must still start with "X-"
return substr($name, 0, 2) === 'X-';
}
function rfc2445_is_valid_value($value, $type) {
// This branch should only be taken with xname values
if($type === NULL) {
return true;
}
switch($type) {
case RFC2445_TYPE_CAL_ADDRESS:
case RFC2445_TYPE_URI:
if(!is_string($value)) {
return false;
}
$valid_schemes = array('ftp', 'http', 'ldap', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero');
$pos = strpos($value, ':');
if(!$pos) {
return false;
}
$scheme = strtolower(substr($value, 0, $pos));
$remain = substr($value, $pos + 1);
if(!in_array($scheme, $valid_schemes)) {
return false;
}
if($scheme === 'mailto') {
$regexp = '/^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$/';
}
else {
$regexp = '/^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$/';
}
return preg_match($regexp, $remain);
break;
case RFC2445_TYPE_BINARY:
if(!is_string($value)) {
return false;
}
$len = strlen($value);
if($len % 4 != 0) {
return false;
}
for($i = 0; $i < $len; ++$i) {
$ch = $value{$i};
if(!($ch >= 'a' && $ch <= 'z' || $ch >= 'A' && $ch <= 'Z' || $ch >= '0' && $ch <= '9' || $ch == '-' || $ch == '+')) {
if($ch == '=' && $len - $i <= 2) {
continue;
}
return false;
}
}
return true;
break;
case RFC2445_TYPE_BOOLEAN:
if(is_bool($value)) {
return true;
}
if(is_string($value)) {
$value = strtoupper($value);
return ($value == 'TRUE' || $value == 'FALSE');
}
return false;
break;
case RFC2445_TYPE_DATE:
if(is_int($value)) {
if($value < 0) {
return false;
}
$value = "$value";
}
else if(!is_string($value)) {
return false;
}
if(strlen($value) != 8) {
return false;
}
$y = intval(substr($value, 0, 4));
$m = intval(substr($value, 4, 2));
$d = intval(substr($value, 6, 2));
return checkdate($m, $d, $y);
break;
case RFC2445_TYPE_DATE_TIME:
if(!is_string($value) || strlen($value) < 15) {
return false;
}
return($value{8} == 'T' &&
rfc2445_is_valid_value(substr($value, 0, 8), RFC2445_TYPE_DATE) &&
rfc2445_is_valid_value(substr($value, 9), RFC2445_TYPE_TIME));
break;
case RFC2445_TYPE_DURATION:
if(!is_string($value)) {
return false;
}
$len = strlen($value);
if($len < 3) {
// Minimum conformant length: "P1W"
return false;
}
if($value{0} == '+' || $value{0} == '-') {
$value = substr($value, 1);
--$len; // Don't forget to update this!
}
if($value{0} != 'P') {
return false;
}
// OK, now break it up
$num = '';
$allowed = 'WDT';
for($i = 1; $i < $len; ++$i) {
$ch = $value{$i};
if($ch >= '0' && $ch <= '9') {
$num .= $ch;
continue;
}
if(strpos($allowed, $ch) === false) {
// Non-numeric character which shouldn't be here
return false;
}
if($num === '' && $ch != 'T') {
// Allowed non-numeric character, but no digits came before it
return false;
}
// OK, $ch now holds a character which tells us what $num is
switch($ch) {
case 'W':
// If duration in weeks is specified, this must end the string
return ($i == $len - 1);
break;
case 'D':
// Days specified, now if anything comes after it must be a 'T'
$allowed = 'T';
break;
case 'T':
// Starting to specify time, H M S are now valid delimiters
$allowed = 'HMS';
break;
case 'H':
$allowed = 'M';
break;
case 'M':
$allowed = 'S';
break;
case 'S':
return ($i == $len - 1);
break;
}
// If we 're going to continue, reset $num
$num = '';
}
// $num is kept for this reason: if we 're here, we ran out of chars
// therefore $num must be empty for the period to be legal
return ($num === '' && $ch != 'T');
break;
case RFC2445_TYPE_FLOAT:
if(is_float($value)) {
return true;
}
if(!is_string($value) || $value === '') {
return false;
}
$dot = false;
$int = false;
$len = strlen($value);
for($i = 0; $i < $len; ++$i) {
switch($value{$i}) {
case '-': case '+':
// A sign can only be seen at position 0 and cannot be the only char
if($i != 0 || $len == 1) {
return false;
}
break;
case '.':
// A second dot is an error
// Make sure we had at least one int before the dot
if($dot || !$int) {
return false;
}
$dot = true;
// Make also sure that the float doesn't end with a dot
if($i == $len - 1) {
return false;
}
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
$int = true;
break;
default:
// Any other char is a no-no
return false;
break;
}
}
return true;
break;
case RFC2445_TYPE_INTEGER:
if(is_int($value)) {
return true;
}
if(!is_string($value) || $value === '') {
return false;
}
if($value{0} == '+' || $value{0} == '-') {
if(strlen($value) == 1) {
return false;
}
$value = substr($value, 1);
}
if(strspn($value, '0123456789') != strlen($value)) {
return false;
}
return ($value >= -2147483648 && $value <= 2147483647);
break;
case RFC2445_TYPE_PERIOD:
if(!is_string($value) || empty($value)) {
return false;
}
$parts = explode('/', $value);
if(count($parts) != 2) {
return false;
}
if(!rfc2445_is_valid_value($parts[0], RFC2445_TYPE_DATE_TIME)) {
return false;
}
// Two legal cases for the second part:
if(rfc2445_is_valid_value($parts[1], RFC2445_TYPE_DATE_TIME)) {
// It has to be after the start time, so
return ($parts[1] > $parts[0]);
}
else if(rfc2445_is_valid_value($parts[1], RFC2445_TYPE_DURATION)) {
// The period MUST NOT be negative
return ($parts[1]{0} != '-');
}
// It seems to be illegal
return false;
break;
case RFC2445_TYPE_RECUR:
if(!is_string($value)) {
return false;
}
$parts = explode(';', strtoupper($value));
// First of all, we need at least a FREQ and a UNTIL or COUNT part, so...
if(count($parts) < 2) {
return false;
}
// Let's get that into a more easily comprehensible format
$vars = array();
foreach($parts as $part) {
$pieces = explode('=', $part);
// There must be exactly 2 pieces, e.g. FREQ=WEEKLY
if(count($pieces) != 2) {
return false;
}
// It's illegal for a variable to appear twice
if(isset($vars[$pieces[0]])) {
return false;
}
// Sounds good
$vars[$pieces[0]] = $pieces[1];
}
// OK... now to test everything else
// FREQ must be the first thing appearing
reset($vars);
if(key($vars) != 'FREQ') {
return false;
}
// It's illegal to have both UNTIL and COUNT appear
if(isset($vars['UNTIL']) && isset($vars['COUNT'])) {
return false;
}
// Special case: BYWEEKNO is only valid for FREQ=YEARLY
if(isset($vars['BYWEEKNO']) && $vars['FREQ'] != 'YEARLY') {
return false;
}
// Special case: BYSETPOS is only valid if another BY option is specified
if(isset($vars['BYSETPOS'])) {
$options = array('BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYDAY', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH');
$defined = array_keys($vars);
$common = array_intersect($options, $defined);
if(empty($common)) {
return false;
}
}
// OK, now simply check if each element has a valid value,
// unsetting them on the way. If at the end the array still
// has some elements, they are illegal.
if($vars['FREQ'] != 'SECONDLY' && $vars['FREQ'] != 'MINUTELY' && $vars['FREQ'] != 'HOURLY' &&
$vars['FREQ'] != 'DAILY' && $vars['FREQ'] != 'WEEKLY' &&
$vars['FREQ'] != 'MONTHLY' && $vars['FREQ'] != 'YEARLY') {
return false;
}
unset($vars['FREQ']);
// Set this, we may need it later
$weekdays = explode(',', RFC2445_WEEKDAYS);
if(isset($vars['UNTIL'])) {
if(rfc2445_is_valid_value($vars['UNTIL'], RFC2445_TYPE_DATE_TIME)) {
// The time MUST be in UTC format
if(!(substr($vars['UNTIL'], -1) == 'Z')) {
return false;
}
}
else if(!rfc2445_is_valid_value($vars['UNTIL'], RFC2445_TYPE_DATE_TIME)) {
return false;
}
}
unset($vars['UNTIL']);
if(isset($vars['COUNT'])) {
if(empty($vars['COUNT'])) {
// This also catches the string '0', which makes no sense
return false;
}
if(strspn($vars['COUNT'], '0123456789') != strlen($vars['COUNT'])) {
return false;
}
}
unset($vars['COUNT']);
if(isset($vars['INTERVAL'])) {
if(empty($vars['INTERVAL'])) {
// This also catches the string '0', which makes no sense
return false;
}
if(strspn($vars['INTERVAL'], '0123456789') != strlen($vars['INTERVAL'])) {
return false;
}
}
unset($vars['INTERVAL']);
if(isset($vars['BYSECOND'])) {
if($vars['BYSECOND'] == '') {
return false;
}
// Comma also allowed
if(strspn($vars['BYSECOND'], '0123456789,') != strlen($vars['BYSECOND'])) {
return false;
}
$secs = explode(',', $vars['BYSECOND']);
foreach($secs as $sec) {
if($sec == '' || $sec < 0 || $sec > 59) {
return false;
}
}
}
unset($vars['BYSECOND']);
if(isset($vars['BYMINUTE'])) {
if($vars['BYMINUTE'] == '') {
return false;
}
// Comma also allowed
if(strspn($vars['BYMINUTE'], '0123456789,') != strlen($vars['BYMINUTE'])) {
return false;
}
$mins = explode(',', $vars['BYMINUTE']);
foreach($mins as $min) {
if($min == '' || $min < 0 || $min > 59) {
return false;
}
}
}
unset($vars['BYMINUTE']);
if(isset($vars['BYHOUR'])) {
if($vars['BYHOUR'] == '') {
return false;
}
// Comma also allowed
if(strspn($vars['BYHOUR'], '0123456789,') != strlen($vars['BYHOUR'])) {
return false;
}
$hours = explode(',', $vars['BYHOUR']);
foreach($hours as $hour) {
if($hour == '' || $hour < 0 || $hour > 23) {
return false;
}
}
}
unset($vars['BYHOUR']);
if(isset($vars['BYDAY'])) {
if(empty($vars['BYDAY'])) {
return false;
}
// First off, split up all values we may have
$days = explode(',', $vars['BYDAY']);
foreach($days as $day) {
$daypart = substr($day, -2);
if(!in_array($daypart, $weekdays)) {
return false;
}
if(strlen($day) > 2) {
$intpart = substr($day, 0, strlen($day) - 2);
if(!rfc2445_is_valid_value($intpart, RFC2445_TYPE_INTEGER)) {
return false;
}
if(intval($intpart) == 0) {
return false;
}
}
}
}
unset($vars['BYDAY']);
if(isset($vars['BYMONTHDAY'])) {
if(empty($vars['BYMONTHDAY'])) {
return false;
}
$mdays = explode(',', $vars['BYMONTHDAY']);
foreach($mdays as $mday) {
if(!rfc2445_is_valid_value($mday, RFC2445_TYPE_INTEGER)) {
return false;
}
$mday = abs(intval($mday));
if($mday == 0 || $mday > 31) {
return false;
}
}
}
unset($vars['BYMONTHDAY']);
if(isset($vars['BYYEARDAY'])) {
if(empty($vars['BYYEARDAY'])) {
return false;
}
$ydays = explode(',', $vars['BYYEARDAY']);
foreach($ydays as $yday) {
if(!rfc2445_is_valid_value($yday, RFC2445_TYPE_INTEGER)) {
return false;
}
$yday = abs(intval($yday));
if($yday == 0 || $yday > 366) {
return false;
}
}
}
unset($vars['BYYEARDAY']);
if(isset($vars['BYWEEKNO'])) {
if(empty($vars['BYWEEKNO'])) {
return false;
}
$weeknos = explode(',', $vars['BYWEEKNO']);
foreach($weeknos as $weekno) {
if(!rfc2445_is_valid_value($weekno, RFC2445_TYPE_INTEGER)) {
return false;
}
$weekno = abs(intval($weekno));
if($weekno == 0 || $weekno > 53) {
return false;
}
}
}
unset($vars['BYWEEKNO']);
if(isset($vars['BYMONTH'])) {
if(empty($vars['BYMONTH'])) {
return false;
}
// Comma also allowed
if(strspn($vars['BYMONTH'], '0123456789,') != strlen($vars['BYMONTH'])) {
return false;
}
$months = explode(',', $vars['BYMONTH']);
foreach($months as $month) {
if($month == '' || $month < 1 || $month > 12) {
return false;
}
}
}
unset($vars['BYMONTH']);
if(isset($vars['BYSETPOS'])) {
if(empty($vars['BYSETPOS'])) {
return false;
}
$sets = explode(',', $vars['BYSETPOS']);
foreach($sets as $set) {
if(!rfc2445_is_valid_value($set, RFC2445_TYPE_INTEGER)) {
return false;
}
$set = abs(intval($set));
if($set == 0 || $set > 366) {
return false;
}
}
}
unset($vars['BYSETPOS']);
if(isset($vars['WKST'])) {
if(!in_array($vars['WKST'], $weekdays)) {
return false;
}
}
unset($vars['WKST']);
// Any remaining vars must be x-names
if(empty($vars)) {
return true;
}
foreach($vars as $name => $var) {
if(!rfc2445_is_xname($name)) {
return false;
}
}
// At last, all is OK!
return true;
break;
case RFC2445_TYPE_TEXT:
return true;
break;
case RFC2445_TYPE_TIME:
if(is_int($value)) {
if($value < 0) {
return false;
}
$value = "$value";
}
else if(!is_string($value)) {
return false;
}
if(strlen($value) == 7) {
if(strtoupper(substr($value, -1)) != 'Z') {
return false;
}
$value = substr($value, 0, 6);
}
if(strlen($value) != 6) {
return false;
}
$h = intval(substr($value, 0, 2));
$m = intval(substr($value, 2, 2));
$s = intval(substr($value, 4, 2));
return ($h <= 23 && $m <= 59 && $s <= 60);
break;
case RFC2445_TYPE_UTC_OFFSET:
if(is_int($value)) {
if($value >= 0) {
$value = "+$value";
}
else {
$value = "$value";
}
}
else if(!is_string($value)) {
return false;
}
if(strlen($value) == 7) {
$s = intval(substr($value, 5, 2));
$value = substr($value, 0, 5);
}
if(strlen($value) != 5 || $value == "-0000") {
return false;
}
if($value{0} != '+' && $value{0} != '-') {
return false;
}
$h = intval(substr($value, 1, 2));
$m = intval(substr($value, 3, 2));
return ($h <= 23 && $m <= 59 && $s <= 59);
break;
}
// TODO: remove this assertion
trigger_error('bad code path', E_USER_WARNING);
var_dump($type);
return false;
}
function rfc2445_do_value_formatting($value, $type) {
// Note: this does not only do formatting; it also does conversion to string!
switch($type) {
case RFC2445_TYPE_CAL_ADDRESS:
case RFC2445_TYPE_URI:
// Enclose in double quotes
$value = '"'.$value.'"';
break;
case RFC2445_TYPE_TEXT:
// Escape entities
$value = strtr($value, array("\n" => '\\n', '\\' => '\\\\', ',' => '\\,', ';' => '\\;'));
break;
}
return $value;
}
function rfc2445_undo_value_formatting($value, $type) {
switch($type) {
case RFC2445_TYPE_CAL_ADDRESS:
case RFC2445_TYPE_URI:
// Trim beginning and end double quote
$value = substr($value, 1, strlen($value) - 2);
break;
case RFC2445_TYPE_TEXT:
// Unescape entities
$value = strtr($value, array('\\n' => "\n", '\\N' => "\n", '\\\\' => '\\', '\\,' => ',', '\\;' => ';'));
break;
}
return $value;
}
// This is cheating: GUIDs have nothing to do with RFC 2445
function rfc2445_guid() {
// Implemented as per the Network Working Group draft on UUIDs and GUIDs
// These two octets get special treatment
$time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits
$clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits
// Need another 14 random octects
$pool = '';
for($i = 0; $i < 7; ++$i) {
$pool .= sprintf('%04x', mt_rand(0, 65535));
}
// time_low = 4 octets
$random = substr($pool, 0, 8).'-';
// time_mid = 2 octets
$random .= substr($pool, 8, 4).'-';
// time_high_and_version = 2 octets
$random .= $time_hi_and_version.substr($pool, 12, 2).'-';
// clock_seq_high_and_reserved = 1 octet
$random .= $clock_seq_hi_and_reserved;
// clock_seq_low = 1 octet
$random .= substr($pool, 13, 2).'-';
// node = 6 octets
$random .= substr($pool, 14, 12);
return $random;
}
?>
@@ -0,0 +1,91 @@
<?php
class iCal {
var $folders;
function iCal() {
$this->folders = 'cache/import/';
}
function iCalReader($filename,$root_directory='') {
$iCaltoArray = $this->iCalDecoder($filename,$root_directory);
return $iCaltoArray;
}
function iCalDecoder($file,$root_directory) {
$ical = file_get_contents($root_directory.$this->folders.$file);
preg_match_all('/BEGIN:VEVENT.*?END:VEVENT/si', $ical, $eventresult, PREG_PATTERN_ORDER);
preg_match_all('/BEGIN:VTODO.*?END:VTODO/si', $ical, $todoresult, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($eventresult[0]); $i++) {
$tmpbyline = explode("\r\n", $eventresult[0][$i]);
$begin = false;
$key=NULL;
foreach ($tmpbyline as $item) {
$tmpholderarray = explode(":",$item,2);
if (count($tmpholderarray) >1) {
if($tmpholderarray[0]=='BEGIN'){
if($begin==false){
$begin = true;
$majorarray['TYPE']=$tmpholderarray[1];
} else {
$majorarray[$tmpholderarray[1]]=array();
$key = $tmpholderarray[1];
}
} else if($tmpholderarray[0]=='END'){
if(!empty($key)){
$key = NULL;
}
} else {
if(!empty($key)){
$majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1];
} else {
$majorarray[$tmpholderarray[0]] = $tmpholderarray[1];
}
}
}
}
$icalarray[] = $majorarray;
unset($majorarray);
}
for ($i = 0; $i < count($todoresult[0]); $i++) {
$tmpbyline = explode("\r\n", $todoresult[0][$i]);
$begin = false;
$key=NULL;
foreach ($tmpbyline as $item) {
$tmpholderarray = explode(":",$item);
if (count($tmpholderarray) >1) {
if($tmpholderarray[0]=='BEGIN'){
if($begin==false){
$begin = true;
$majorarray['TYPE']=$tmpholderarray[1];
} else {
$majorarray[$tmpholderarray[1]]=array();
$key = $tmpholderarray[1];
}
} else if($tmpholderarray[0]=='END'){
if(!empty($key)){
$key = NULL;
}
} else {
if(!empty($key)){
$majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1];
} else {
$majorarray[$tmpholderarray[0]] = $tmpholderarray[1];
}
}
}
}
$icalarray[] = $majorarray;
unset($majorarray);
}
return $icalarray;
}
}
?>
@@ -0,0 +1,113 @@
<?php
define('_BENNU_VERSION', '0.1');
require_once('include/utils/utils.php');
require_once('modules/Calendar/CalendarCommon.php');
include('modules/Calendar/iCal/iCalendar_rfc2445.php');
include('modules/Calendar/iCal/iCalendar_components.php');
include('modules/Calendar/iCal/iCalendar_properties.php');
include('modules/Calendar/iCal/iCalendar_parameters.php');
//$ical_query = "SELECT * FROM vtiger_activity WHERE (( STATUS != 'Completed' AND STATUS != 'Deferred' ) OR STATUS IS NULL)
// AND (( eventstatus != 'Held' AND eventstatus != 'Not Held' ) OR eventstatus IS NULL )";
global $current_user,$adb,$default_timezone;
$filename = $_REQUEST['filename'];
$ical_query = "select vtiger_activity.*,vtiger_crmentity.description,vtiger_activity_reminder.reminder_time from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid " .
" LEFT JOIN vtiger_activity_reminder ON vtiger_activity_reminder.activity_id=vtiger_activity.activityid AND vtiger_activity_reminder.recurringid=0" .
" where vtiger_crmentity.deleted = 0 and vtiger_crmentity.smownerid = " . $current_user->id .
" and vtiger_activity.activitytype NOT IN ('Emails')";
$calendar_results = $adb->query($ical_query);
// Send the right content type and filename
header ("Content-type: text/calendar");
header('Content-Disposition: attachment; '."filename={$filename}.ics");
$todo_fields = getColumnFields('Calendar');
$event_fields = getColumnFields('Events');
$event = $todo = array();
$keys_to_replace = array(
'events'=>array('taskpriority'),
'todo'=>array('taskpriority','taskstatus')
);
$keyvals_to_replace = array(
'events'=>array('taskpriority'=>'priority'),
'todo'=>array('taskpriority'=>'priority','taskstatus'=>'status')
);
foreach($todo_fields as $key=>$val){
if(getFieldVisibilityPermission('Calendar',$current_user->id,$key)==0){
if(!in_array($key,$keys_to_replace['todo'])){
$todo[$key] = 'yes';
} else {
$todo[$keyvals_to_replace['todo'][$key]] = 'yes';
}
}
}
foreach($event_fields as $key=>$val){
if(getFieldVisibilityPermission('Events',$current_user->id,$key)==0){
if(!in_array($key,$keys_to_replace['events'])){
$event[$key] = 'yes';
} else {
$event[$keyvals_to_replace['events'][$key]] = 'yes';
}
}
}
$tz = new iCalendar_timezone;
if(!empty($default_timezone)){
$tzid = split('/',$default_timezone);
} else {
$default_timezone = date_default_timezone_get();
$tzid = split('/',$default_timezone);
}
if(!empty($tzid[1])){
$tz->add_property('TZID', $tzid[1]);
} else {
$tz->add_property('TZID', $tzid[0]);
}
$tz->add_property('TZOFFSETTO', date('O'));
if(date('I')==1){
$tz->add_property('DAYLIGHTC', date('I'));
} else {
$tz->add_property('STANDARDC', date('I'));
}
$myical = new iCalendar;
$myical->add_component($tz);
while (!$calendar_results->EOF) {
$this_event = $calendar_results->fields;
$id = $this_event['activityid'];
$type = $this_event['activitytype'];
if($type!='Task'){
$temp = $event;
foreach($temp as $key=>$val){
$temp[$key] = $this_event[$key];
}
$temp['id'] = $id;
$ev = new iCalendar_event;
$ev->assign_values($temp);
$al = new iCalendar_alarm;
$al->assign_values($temp);
$ev->add_component($al);
} else {
$temp = $todo;
foreach($temp as $key=>$val){
$temp[$key] = $this_event[$key];
}
$ev = new iCalendar_todo;
$ev->assign_values($temp);
}
$myical->add_component($ev);
$calendar_results->MoveNext();
}
// Print the actual calendar
echo $myical->serialize();
?>
@@ -0,0 +1,146 @@
<?php
define('_BENNU_VERSION', '0.1');
require_once('Smarty_setup.php');
include('modules/Calendar/iCal/iCalendar_rfc2445.php');
include('modules/Calendar/iCal/iCalendar_components.php');
include('modules/Calendar/iCal/iCalendar_properties.php');
include('modules/Calendar/iCal/iCalendar_parameters.php');
include('modules/Calendar/iCal/ical-parser-class.php');
require_once('include/Zend/Json.php');
require_once('modules/Import/UsersLastImport.php');
require_once('include/utils/utils.php');
require_once('data/CRMEntity.php');
global $import_dir,$current_user,$mod_strings,$app_strings,$currentModule;
if($_REQUEST['step']!='undo'){
$last_import = new UsersLastImport();
$last_import->mark_deleted_by_user_id($current_user->id);
$file_details = $_FILES['ics_file'];
$binFile = 'vtiger_import'.date('YmdHis');
$file = $import_dir.''.$binFile;
$filetmp_name = $file_details['tmp_name'];
$upload_status = move_uploaded_file($filetmp_name,$file);
$skip_fields = array(
'Events'=>array('duration_hours'),
'Calendar'=>array('eventstatus')
);
$required_fields = array();
$modules = array('Events','Calendar');
foreach($modules as $module){
$calendar = CRMEntity::getInstance('Calendar');
$calendar->initRequiredFields($module);
$val = array_keys($calendar->required_fields);
$required_fields[$module] = array_diff($val,$skip_fields[$module]);
}
$ical = new iCal();
$ical_activities = $ical->iCalReader($binFile);
$count['Events'] = $count['Calendar'] = $skip_count['Events'] = $skip_count['Calendar'] = 0;
for($i=0;$i<count($ical_activities);$i++){
if($ical_activities[$i]['TYPE'] == 'VEVENT'){
$activity = new iCalendar_event;
$module = 'Events';
} else {
$activity = new iCalendar_todo;
$module = 'Calendar';
}
$count[$module]++;
$calendar = CRMEntity::getInstance('Calendar');
$calendar->column_fields = $activity->generateArray($ical_activities[$i]);
$calendar->column_fields['assigned_user_id'] = $current_user->id;
foreach($required_fields[$module] as $key){
if(empty($calendar->column_fields[$key])){
$skip_count[$module]++;
break;
}
}
$calendar->save('Calendar');
$last_import = new UsersLastImport();
$last_import->assigned_user_id = $current_user->id;
$last_import->bean_type = 'Calendar';
$last_import->bean_id = $calendar->id;
$last_import->save();
if(!empty($ical_activities[$i]['VALARM'])){
$calendar->activity_reminder($calendar->id,$calendar->column_fields['reminder_time'],0,'','');
}
}
unlink($file);
$smarty->assign("IMAGE_PATH", $last_imported);
$smarty = new vtigerCRM_Smarty;
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMP", $import_mod_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$parent_tab = vtlib_purify($_SESSION['import_parenttab']);
if(empty($parent_Tab)){
$parent_tab = getParentTab();
}
$smarty->assign("MODULE", vtlib_purify($_REQUEST['module']));
$smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['module']));
$smarty->assign("CATEGORY", $parent_tab);
//@session_unregister("import_parenttab");
$smarty->display("Buttons_List1.tpl");
$imported_events = $count['Events'] - $skip_count['Events'];
$imported_tasks = $count['Calendar'] - $skip_count['Calendar'];
$message= "<b>".$mod_strings['LBL_SUCCESS']."</b>"
."<br><br>" .$mod_strings['LBL_SUCCESS_EVENTS_1']." $imported_events"
."<br><br>" .$mod_strings['LBL_SKIPPED_EVENTS_1'].$skip_count['Events']
."<br><br>" .$mod_strings['LBL_SUCCESS_CALENDAR_1']." $imported_tasks"
."<br><br>" .$mod_strings['LBL_SKIPPED_CALENDAR_1'].$skip_count['Calendar']
."<br><br>";
$smarty->assign("MESSAGE", $message);
$smarty->assign("RETURN_MODULE", $currentModule);
$smarty->assign("RETURN_ACTION", 'ListView');
$smarty->assign("MODULE", $currentModule);
$smarty->assign("MODULENAME", $currentModule);
$smarty->display("iCalImport.tpl");
} else {
$smarty->assign("IMAGE_PATH", $last_imported);
$smarty = new vtigerCRM_Smarty;
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMP", $import_mod_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$parent_tab = vtlib_purify($_SESSION['import_parenttab']);
if(empty($parent_Tab)){
$parent_tab = getParentTab();
}
$smarty->assign("MODULE", vtlib_purify($_REQUEST['module']));
$smarty->assign("SINGLE_MOD", vtlib_purify($_REQUEST['module']));
$smarty->assign("CATEGORY", $parent_tab);
//@session_unregister("import_parenttab");
$smarty->display("Buttons_List1.tpl");
$last_import = new UsersLastImport();
$ret_value = $last_import->undo($current_user->id);
if(!empty($ret_value)){
$message= "<b>".$mod_strings['LBL_SUCCESS']."</b>"
."<br><br>" .$mod_strings['LBL_LAST_IMPORT_UNDONE']." ";
} else {
$message= "<b>".$mod_strings['LBL_FAILURE']."</b>"
."<br><br>" .$mod_strings['LBL_NO_IMPORT_TO_UNDO']." ";
}
$smarty->assign("MESSAGE", $message);
$smarty->assign("UNDO", 'yes');
$smarty->assign("RETURN_MODULE", $currentModule);
$smarty->assign("RETURN_ACTION", 'ListView');
$smarty->assign("MODULE", $currentModule);
$smarty->assign("MODULENAME", $currentModule);
$smarty->display("iCalImport.tpl");
}
?>
@@ -436,7 +436,17 @@ $mod_strings = Array(
'LBL_SET_DATE'=>'Set Date',
'LBL_MINE' =>'Mine',
'LBL_SUCCESS_CALENDAR_1' => 'No. of Tasks Successfully Imported : ',
'LBL_SKIPPED_CALENDAR_1' => 'No. of Tasks Skipped as they were missing one or more required fields : ',
'LBL_SUCCESS_EVENTS_1' => 'No. of Events Successfully Imported : ',
'LBL_SKIPPED_EVENTS_1' => 'No. of Events Skipped as they were missing one or more required fields : ',
'LBL_FINISHED'=>'Finished',
'LBL_UNDO_LAST_IMPORT'=>'Undo Last Import',
'LBL_LAST_IMPORT'=>'Last Imported',
'LBL_LAST_IMPORT_UNDONE'=>'Your Last Import Was Undone',
'LBL_SUCCESS'=>'Success!',
'LBL_NO_IMPORT_TO_UNDO'=>'There was no import to undo.',
'LBL_FAILURE'=>'Failed!',
);
?>
?>
+6 -5
View File
@@ -742,15 +742,16 @@ function cal_navigation(type,urlstring,start)
$("status").style.display="inline";
if(type == 'event')
{
var OptionData = $('view_Option').options[$('view_Option').selectedIndex].value;
new Ajax.Request(
var users = document.getElementsByName('onlyforuser');
var onlyforusers = users[0].value;
var OptionData = $('view_Option').options[$('view_Option').selectedIndex].value;
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Calendar&action=CalendarAjax&file=ActivityAjax&ajax=true&n_type=nav&viewOption='+OptionData+url+start+'&subtab='+type,
postBody: 'module=Calendar&action=CalendarAjax&file=ActivityAjax&ajax=true&n_type=nav&viewOption='+OptionData+url+start+'&subtab='+type+'&onlyforuser='+encodeURIComponent(onlyforusers),
onComplete: function(response) {
//alert(response.responseText);
if(OptionData == 'listview')
if(OptionData == 'listview')
{
result = response.responseText.split('####');
$("total_activities").innerHTML = result[1];
@@ -68,6 +68,15 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') {
}
// END
$smarty->assign("RELATEDLISTS", $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
$relationId = vtlib_purify($_REQUEST['relation_id']);
RelatedListViewSession::addRelatedModuleToSession($relationId,
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
require_once('modules/CustomView/CustomView.php');
+194 -28
View File
@@ -129,6 +129,100 @@ class Campaigns extends CRMEntity {
}
// Mike Crowe Mod --------------------------------------------------------
/**
* Function to get Campaign related Accouts
* @param integer $id - campaignid
* returns related Accounts record in array format
*/
function get_accounts($id, $cur_tab_id, $rel_tab_id, $actions = false) {
global $log, $singlepane_view,$currentModule;
$log->debug("Entering get_accounts(".$id.") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once("modules/$related_module/$related_module.php");
$other = new $related_module();
$is_CampaignStatusAllowed = false;
global $current_user;
if(getFieldVisibilityPermission('Accounts', $current_user->id, 'campaignrelstatus') == '0') {
$other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus');
$other->list_fields_name['Status'] = 'campaignrelstatus';
$other->sortby_fields[] = 'campaignrelstatus';
$is_CampaignStatusAllowed = true;
}
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 = '';
// Send mail button for selected Accounts
$button .= "<input title='".getTranslatedString('LBL_SEND_MAIL_BUTTON')."' class='crmbutton small edit' value='".getTranslatedString('LBL_SEND_MAIL_BUTTON')."' type='button' name='button' onclick='rel_eMail(\"$this_module\",this,\"$related_module\")'>";
$button .= '&nbsp;&nbsp;&nbsp;&nbsp';
/* To get Accounts CustomView -START */
require_once('modules/CustomView/CustomView.php');
$ahtml = "<select id='".$related_module."_cv_list' class='small'><option value='None'>-- ".getTranslatedString('Select One')." --</option>";
$oCustomView = new CustomView($related_module);
$viewid = $oCustomView->getViewId($related_module);
$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid, false);
$ahtml .= $customviewcombo_html;
$ahtml .= "</select>";
/* To get Accounts CustomView -END */
$button .= $ahtml."<input title='".getTranslatedString('LBL_LOAD_LIST',$this_module)."' class='crmbutton small edit' value='".getTranslatedString('LBL_LOAD_LIST',$this_module)."' type='button' name='button' onclick='loadCvList(\"$related_module\",\"$id\")'>";
$button .= '&nbsp;&nbsp;&nbsp;&nbsp';
if($actions)
{
if(is_string($actions))
$actions = explode(',', strtoupper($actions));
if(in_array('SELECT', $actions) && isPermitted($related_module,4, '') == 'yes')
{
$button .= "<input title='".getTranslatedString('LBL_SELECT')." ". getTranslatedString($related_module). "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id&parenttab=$parenttab','test','width=640,height=602,resizable=0,scrollbars=0');\" value='". getTranslatedString('LBL_SELECT'). " " . getTranslatedString($related_module) ."'>&nbsp;";
}
if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes')
{
$button .= "<input title='".getTranslatedString('LBL_ADD_NEW'). " ". getTranslatedString($singular_modname) ."' class='crmbutton small create'" .
" onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$related_module\"' type='submit' name='button'" .
" value='". getTranslatedString('LBL_ADD_NEW'). " " . getTranslatedString($singular_modname) ."'>&nbsp;";
}
}
$query = "SELECT vtiger_account.*,
CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
vtiger_crmentity.*, vtiger_crmentity.modifiedtime, vtiger_campaignrelstatus.*, vtiger_accountbillads.*
FROM vtiger_account
INNER JOIN vtiger_campaignaccountrel ON vtiger_campaignaccountrel.accountid = vtiger_account.accountid
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
LEFT JOIN vtiger_accountbillads ON vtiger_accountbillads.accountaddressid = vtiger_account.accountid
LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaignaccountrel.campaignrelstatusid
WHERE vtiger_campaignaccountrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if($return_value == null)
$return_value = Array();
else if($is_CampaignStatusAllowed) {
$statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count.
$return_value = $this->add_status_popup($return_value, $statusPos, 'Accounts');
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_accounts method ...");
return $return_value;
}
/**
* Function to get Campaign related Contacts
* @param integer $id - campaignid
@@ -142,7 +236,17 @@ class Campaigns extends CRMEntity {
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once("modules/$related_module/$related_module.php");
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$is_CampaignStatusAllowed = false;
global $current_user;
if(getFieldVisibilityPermission('Contacts', $current_user->id, 'campaignrelstatus') == '0') {
$other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus');
$other->list_fields_name['Status'] = 'campaignrelstatus';
$other->sortby_fields[] = 'campaignrelstatus';
$is_CampaignStatusAllowed = true;
}
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
@@ -160,7 +264,7 @@ class Campaigns extends CRMEntity {
/* To get Leads CustomView -START */
require_once('modules/CustomView/CustomView.php');
$lhtml = "<select id='cont_cv_list' class='small'><option value='None'>-- ".getTranslatedString('Select One')." --</option>";
$lhtml = "<select id='".$related_module."_cv_list' class='small'><option value='None'>-- ".getTranslatedString('Select One')." --</option>";
$oCustomView = new CustomView($related_module);
$viewid = $oCustomView->getViewId($related_module);
$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid, false);
@@ -184,21 +288,28 @@ class Campaigns extends CRMEntity {
}
$query = "SELECT vtiger_contactdetails.accountid, vtiger_account.accountname,
CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name ,
vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title,
vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid,
vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
FROM vtiger_contactdetails
INNER JOIN vtiger_campaigncontrel ON vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
LEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid
WHERE vtiger_campaigncontrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0";
CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name ,
vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title,
vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid,
vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_campaignrelstatus.*
FROM vtiger_contactdetails
INNER JOIN vtiger_campaigncontrel ON vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
LEFT JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid
LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaigncontrel.campaignrelstatusid
WHERE vtiger_campaigncontrel.campaignid = ".$id." AND vtiger_crmentity.deleted=0";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if($return_value == null) $return_value = Array();
if($return_value == null)
$return_value = Array();
else if($is_CampaignStatusAllowed) {
$statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count.
$return_value = $this->add_status_popup($return_value, $statusPos, 'Contacts');
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_contacts method ...");
@@ -218,7 +329,17 @@ class Campaigns extends CRMEntity {
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once("modules/$related_module/$related_module.php");
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$is_CampaignStatusAllowed = false;
global $current_user;
if(getFieldVisibilityPermission('Leads', $current_user->id, 'campaignrelstatus') == '0') {
$other->list_fields['Status'] = array('vtiger_campaignrelstatus'=>'campaignrelstatus');
$other->list_fields_name['Status'] = 'campaignrelstatus';
$other->sortby_fields[] = 'campaignrelstatus';
$is_CampaignStatusAllowed = true;
}
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
@@ -236,7 +357,7 @@ class Campaigns extends CRMEntity {
/* To get Leads CustomView -START */
require_once('modules/CustomView/CustomView.php');
$lhtml = "<select id='lead_cv_list' class='small'><option value='None'>-- ".getTranslatedString('Select One')." --</option>";
$lhtml = "<select id='".$related_module."_cv_list' class='small'><option value='None'>-- ".getTranslatedString('Select One')." --</option>";
$oCustomView = new CustomView($related_module);
$viewid = $oCustomView->getViewId($related_module);
$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid, false);
@@ -260,19 +381,27 @@ class Campaigns extends CRMEntity {
}
$query = "SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid,vtiger_leadaddress.phone,vtiger_leadsubdetails.website,
CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
vtiger_crmentity.smownerid FROM vtiger_leaddetails
INNER JOIN vtiger_campaignleadrel ON vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id
LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid
WHERE vtiger_crmentity.deleted=0 AND vtiger_campaignleadrel.campaignid = ".$id;
CASE when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
vtiger_crmentity.smownerid, vtiger_campaignrelstatus.*
FROM vtiger_leaddetails
INNER JOIN vtiger_campaignleadrel ON vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id
LEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid
LEFT JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaignleadrel.campaignrelstatusid
WHERE vtiger_crmentity.deleted=0 AND vtiger_campaignleadrel.campaignid = ".$id;
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if($return_value == null) $return_value = Array();
if($return_value == null)
$return_value = Array();
else if($is_CampaignStatusAllowed) {
$statusPos = count($return_value['header']) - 2; // Last column is for Actions, exclude that. Also the index starts from 0, so reduce one more count.
$return_value = $this->add_status_popup($return_value, $statusPos, 'Leads');
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_leads method ...");
@@ -410,7 +539,40 @@ class Campaigns extends CRMEntity {
return $return_value;
}
/*
* Function populate the status columns' HTML
* @param - $related_list return value from GetRelatedList
* @param - $status_column index of the status column in the list.
* returns true on success
*/
function add_status_popup($related_list, $status_column = 7, $related_module)
{
global $adb;
if(!$this->campaignrelstatus)
{
$result = $adb->query('SELECT * FROM vtiger_campaignrelstatus;');
while($row = $adb->fetchByAssoc($result))
{
$this->campaignrelstatus[$row['campaignrelstatus']] = $row;
}
}
foreach($related_list['entries'] as $key => &$entry)
{
$popupitemshtml = '';
foreach($this->campaignrelstatus as $campaingrelstatus)
{
$camprelstatus = getTranslatedString($campaingrelstatus[campaignrelstatus],'Campaigns');
$popupitemshtml .= "<a onmouseover=\"javascript: showBlock('campaignstatus_popup_$key')\" href=\"javascript:updateCampaignRelationStatus('$related_module', '".$this->id."', '$key', '$campaingrelstatus[campaignrelstatusid]', '".addslashes($camprelstatus)."');\">$camprelstatus</a><br />";
}
$popuphtml = '<div onmouseover="javascript:clearTimeout(statusPopupTimer);" onmouseout="javascript:closeStatusPopup(\'campaignstatus_popup_'.$key.'\');" style="margin-top: -14px; width: 200px;" id="campaignstatus_popup_'.$key.'" class="calAction"><div style="background-color: #FFFFFF; padding: 8px;">'.$popupitemshtml.'</div></div>';
$entry[$status_column] = "<a href=\"javascript: showBlock('campaignstatus_popup_$key');\">[+]</a> <span id='campaignstatus_$key'>".$entry[$status_column]."</span>".$popuphtml;
}
return $related_list;
}
/*
* Function to get the secondary query part of a report
* @param - $module primary module name
@@ -437,6 +599,7 @@ class Campaigns extends CRMEntity {
$rel_tables = array (
"Contacts" => array("vtiger_campaigncontrel"=>array("campaignid","contactid"),"vtiger_campaign"=>"campaignid"),
"Leads" => array("vtiger_campaignleadrel"=>array("campaignid","leadid"),"vtiger_campaign"=>"campaignid"),
"Accounts" => array("vtiger_campaignaccountrel"=>array("campaignid","accountid"),"vtiger_campaign"=>"campaignid"),
"Potentials" => array("vtiger_potential"=>array("campaignid","potentialid"),"vtiger_campaign"=>"campaignid"),
"Calendar" => array("vtiger_seactivityrel"=>array("crmid","activityid"),"vtiger_campaign"=>"campaignid"),
"Products" => array("vtiger_campaign"=>array("campaignid","product_id")),
@@ -455,6 +618,9 @@ class Campaigns extends CRMEntity {
} elseif($return_module == 'Contacts') {
$sql = 'DELETE FROM vtiger_campaigncontrel WHERE campaignid=? AND contactid=?';
$this->db->pquery($sql, array($id, $return_id));
} elseif($return_module == 'Accounts') {
$sql = 'DELETE FROM vtiger_campaignaccountrel WHERE campaignid=? AND accountid=?';
$this->db->pquery($sql, array($id, $return_id));
} else {
$sql = 'DELETE FROM vtiger_crmentityrel WHERE (crmid=? AND relmodule=? AND relcrmid=?) OR (relcrmid=? AND module=? AND crmid=?)';
$params = array($id, $return_module, $return_id, $id, $return_module, $return_id);
@@ -463,4 +629,4 @@ class Campaigns extends CRMEntity {
}
}
?>
?>
@@ -81,6 +81,13 @@ if($singlepane_view == 'true')
{
$related_array = getRelatedLists($currentModule,$focus);
$smarty->assign("RELATEDLISTS", $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
}
$smarty->assign("SinglePane_View", $singlepane_view);
@@ -98,6 +105,12 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($
$focus->markAsViewed($current_user->id);
// END
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
// END
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
$smarty->display("DetailView.tpl");
@@ -41,5 +41,7 @@ if($ajaxaction == "DETAILVIEW")
{
echo ":#:FAILURE";
}
} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
require_once 'include/ListView/RelatedListViewContents.php';
}
?>
+29 -28
View File
@@ -58,17 +58,6 @@ $_SESSION['CAMPAIGN_ORDER_BY'] = $order_by;
$_SESSION['CAMPAIGN_SORT_ORDER'] = $sorder;
//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
{
list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
// we have a query
$url_string .="&query=true".$ustring;
$log->info("Here is the where clause for the list view: $where");
$smarty->assign("SEARCH_URL",$url_string);
}
//<<<<cutomview>>>>>>>
$oCustomView = new CustomView("Campaigns");
$viewid = $oCustomView->getViewId($currentModule);
@@ -142,22 +131,25 @@ $smarty->assign("SINGLE_MOD",'Campaign');
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if($viewid != "0")
{
$listquery = getListQuery("Campaigns");
$list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Campaigns");
}
else
{
$list_query = getListQuery("Campaigns");
global $current_user;
$queryGenerator = new QueryGenerator($currentModule, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
//<<<<<<<<customview>>>>>>>>>
if(isset($where) && $where != '')
{
$list_query .= ' and '.$where;
// Enabling Module Search
$url_string = '';
if($_REQUEST['query'] == 'true') {
$queryGenerator->addUserSearchConditions($_REQUEST);
$ustring = getSearchURL($_REQUEST);
$url_string .= "&query=true$ustring";
$smarty->assign('SEARCH_URL', $url_string);
}
$list_query = $queryGenerator->getQuery();
//sort by "assignedto" and default sort by "ticketid"(DESC)
if(isset($order_by) && $order_by != '')
{
@@ -208,13 +200,13 @@ if( $adb->dbType == "pgsql")
else
$list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
$smarty->assign('recordListRange',$recordListRangeMsg);
//mass merge for word templates -- *Raj*17/11
while($row = $adb->fetch_array($list_result))
{
$ids[] = $row["crmid"];
$ids[] = $row[$focus->table_index];
}
if(isset($ids))
{
@@ -225,13 +217,16 @@ if(isset($ids))
if($viewid !='')
$url_string .="&viewname=".$viewid;
$listview_header = getListViewHeader($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView);
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
$order_by);
$smarty->assign("LISTHEADER", $listview_header);
$listview_header_search = getSearchListHeaderValues($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView);
$listview_header_search = $controller->getBasicSearchFieldInfoList();
$smarty->assign("SEARCHLISTHEADER",$listview_header_search);
$listview_entries = getListViewEntries($focus,"Campaigns",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
$navigation_array);
$smarty->assign("LISTENTITY", $listview_entries);
$smarty->assign("SELECT_SCRIPT", $view_script);
@@ -242,7 +237,7 @@ $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";")
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Campaigns","index",$viewid);
$alphabetical = AlphabeticalSearch($currentModule,'index','campaignname','true','basic',"","","","",$viewid);
$fieldnames = getAdvSearchfields($module);
$fieldnames = $controller->getAdvancedSearchOptionString();
$criteria = getcriteria_options();
$smarty->assign("CRITERIA", $criteria);
$smarty->assign("FIELDNAMES", $fieldnames);
@@ -255,6 +250,12 @@ $smarty->assign("CHECK", $check_button);
$_SESSION[$currentModule.'_listquery'] = $list_query;
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
// END
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("ListViewEntries.tpl");
else
@@ -12,7 +12,7 @@
require_once('modules/CustomView/CustomView.php');
require_once('user_privileges/default_module_view.php');
global $singlepane_view;
global $singlepane_view, $adb;
$cvObj = new CustomView(vtlib_purify($_REQUEST["list_type"]));
$listquery = getListQuery(vtlib_purify($_REQUEST["list_type"]));
@@ -26,13 +26,19 @@ elseif($_REQUEST["list_type"] == "Contacts"){
$reltable = "vtiger_campaigncontrel";
$relid = "contactid";
}
while($row=$adb->fetch_array($rs)) {
$sql = "delete from $reltable where $relid = ? and campaignid = ?";
$adb->pquery($sql, array($row["crmid"], $_REQUEST['return_id']));
$adb->pquery("INSERT INTO ".$reltable." VALUES(?,?)", array($_REQUEST["return_id"], $row["crmid"]));
elseif($_REQUEST["list_type"] == "Accounts"){
$reltable = "vtiger_campaignaccountrel";
$relid = "accountid";
}
header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&record=".vtlib_purify($_REQUEST['return_id']));
while($row=$adb->fetch_array($rs)) {
$sql = "SELECT $relid FROM $reltable WHERE $relid = ? AND campaignid = ?";
$result = $adb->pquery($sql, array($row['crmid'], $_REQUEST['return_id']));
if ($adb->num_rows($result) > 0) continue;
$adb->pquery("INSERT INTO $reltable(campaignid, $relid,campaignrelstatusid) VALUES(?,?,1)", array($_REQUEST["return_id"], $row["crmid"]));
}
?>
header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&".
"record=".vtlib_purify($_REQUEST['return_id']));
?>
@@ -84,6 +84,11 @@ $mod_strings = Array(
//Module Sequence Numbering
'Campaign No'=>'Campaign No',
// status fields
'--None--'=>'--None--',
'Contacted - Successful' => 'Contacted - Successful',
'Contacted - Unsuccessful' => 'Contacted - Unsuccessful',
'Contacted - Never Contact Again' => 'Contacted - Never Contact Again'
// END
);
@@ -21,7 +21,7 @@
*---------------------------------------------
*/
$mod_strings=Array(
//Addedinrelease5.0
// Added in release 5.0
'LBL_CAMPAIGN_INFORMATION'=>'活动信息',
'LBL_CUSTOM_INFORMATION'=>'自订信息',
'LBL_DESCRIPTION_INFORMATION'=>'说明信息',
@@ -30,6 +30,10 @@ elseif($update_mod == 'Contacts')
{
$rel_table = 'vtiger_campaigncontrel';
}
elseif($update_mod == 'Accounts')
{
$rel_table = 'vtiger_campaignaccountrel';
}
$storearray = array();
if(!empty($_REQUEST['idlist'])) {
@@ -43,9 +47,9 @@ foreach($storearray as $id)
{
if($id != '')
{
if ($update_mod == 'Leads' || $update_mod == 'Contacts') {
$sql = "insert into $rel_table values(?,?)";
$adb->pquery($sql, array($forCRMRecord, $id));
if ($update_mod == 'Leads' || $update_mod == 'Contacts' || $update_mod == 'Accounts') {
$sql = "insert into $rel_table values(?,?,1)";
$adb->pquery($sql, array($forCRMRecord, $id));
} else {
$focus->save_related_module($currentModule, $forCRMRecord, $update_mod, $id);
}
@@ -54,4 +58,4 @@ foreach($storearray as $id)
header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab);
?>
?>
@@ -0,0 +1,52 @@
<?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.
*
********************************************************************************/
require_once('include/database/PearDatabase.php');
$rel_table = '';
$rel_field = '';
switch($_REQUEST['relatedmodule'])
{
case 'Accounts' : $rel_table = 'vtiger_campaignaccountrel'; $rel_field = 'accountid';
break;
case 'Contacts' : $rel_table = 'vtiger_campaigncontrel'; $rel_field = 'contactid';
break;
case 'Leads' : $rel_table = 'vtiger_campaignleadrel'; $rel_field = 'leadid';
break;
case 'Potentials' :
{
}
break;
default:
{
echo ":#:FAILURE";
exit;
}
break;
}
$sql = "UPDATE $rel_table SET campaignrelstatusid = ? WHERE campaignid = ? AND $rel_field = ?;";
$params = array($_REQUEST['campaignrelstatusid'], $_REQUEST['campaignid'], $_REQUEST['crmid']);
if($adb->pquery($sql, $params))
{
echo ":#:SUCCESS";
}
else
{
echo ":#:FAILURE";
}
exit;
?>
@@ -85,6 +85,15 @@ if($singlepane_view == 'true' && $_REQUEST['action'] == 'CallRelatedList') {
// END
$related_array = getRelatedLists($currentModule,$focus);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
$relationId = vtlib_purify($_REQUEST['relation_id']);
RelatedListViewSession::addRelatedModuleToSession($relationId,
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
$smarty->assign("RELATEDLISTS", $related_array);
$smarty->assign("MODULE",$currentmodule);
$smarty->assign("SINGLE_MOD",$app_strings['Contact']);
+20 -28
View File
@@ -110,12 +110,14 @@ class Contacts extends CRMEntity {
'Name' => Array('contactdetails'=>'lastname'),
'Title' => Array('contactdetails'=>'title'),
'Account Name'=>Array('contactdetails'=>'account_id'),
'Assigned To'=>Array('crmentity'=>'smownerid'),
);
var $search_fields_name = Array(
'Name' => 'lastname',
'Title' => 'title',
'Account Name'=>'account_id',
'Assigned To'=>'assigned_user_id'
);
// This is the list of vtiger_fields that are required
@@ -489,7 +491,7 @@ class Contacts extends CRMEntity {
left join vtiger_seactivityrel on vtiger_seactivityrel.activityid=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 = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
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_cntactivityrel.contactid=".$id."
and vtiger_crmentity.deleted = 0";
@@ -956,6 +958,7 @@ class Contacts extends CRMEntity {
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_contactdetails vtiger_contactdetails2
ON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto";
$query .= getNonAdminAccessControlQuery('Contacts',$current_user);
$where_auto = " vtiger_crmentity.deleted = 0 ";
if($where != "")
@@ -963,18 +966,7 @@ class Contacts extends CRMEntity {
else
$query .= " WHERE ".$where_auto;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
//we should add security check when the user has Private Access
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[4] == 3)
{
//Added security check to get the permitted records only
$query = $query." ".getListViewSecurityParameter("Contacts");
}
$log->info("Export Query Constructed Successfully");
$log->info("Export Query Constructed Successfully");
$log->debug("Exiting create_export_query method ...");
return $query;
}
@@ -1008,7 +1000,7 @@ function getColumnNames()
for($i=0; $i < $numRows;$i++)
{
$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
$custom_fields[$i] = preg_replace("/\s+/","",$custom_fields[$i]);
$custom_fields[$i] = strtoupper($custom_fields[$i]);
}
$mergeflds = $custom_fields;
@@ -1043,20 +1035,19 @@ function get_searchbyemailid($username,$emailaddress)
inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid
left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid
where vtiger_crmentity.deleted=0";
if(trim($emailaddress) != '')
$query .= " and ((vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) ."') or vtiger_contactdetails.lastname REGEXP REPLACE('".$emailaddress."',' ','|') or vtiger_contactdetails.firstname REGEXP REPLACE('".$emailaddress."',' ','|')) and vtiger_contactdetails.email != ''";
else
$query .= " and (vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) ."' and vtiger_contactdetails.email != '')";
$tab_id = getTabid("Contacts");
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
{
$sec_parameter=getListViewSecurityParameter("Contacts");
$query .= $sec_parameter;
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery('Contacts',$current_user);
$query .= "where vtiger_crmentity.deleted=0";
if(trim($emailaddress) != '') {
$query .= " and ((vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) .
"') or vtiger_contactdetails.lastname REGEXP REPLACE('".$emailaddress.
"',' ','|') or vtiger_contactdetails.firstname REGEXP REPLACE('".$emailaddress.
"',' ','|')) and vtiger_contactdetails.email != ''";
} else {
$query .= " and (vtiger_contactdetails.email like '". formatForSqlLike($emailaddress) .
"' and vtiger_contactdetails.email != '')";
}
$log->debug("Exiting get_searchbyemailid method ...");
return $this->plugin_process_list_query($query);
}
@@ -1118,6 +1109,8 @@ function get_contactsforol($user_name)
left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid
left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid
left join vtiger_campaigncontrel on vtiger_contactdetails.contactid = vtiger_campaigncontrel.contactid
left join vtiger_campaignrelstatus on vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaigncontrel.campaignrelstatusid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid
where vtiger_crmentity.deleted=0 and vtiger_users.user_name='".$user_name."'";
$log->debug("Exiting get_contactsforol method ...");
@@ -1374,7 +1367,6 @@ function get_contactsforol($user_name)
}
//End
}
?>
@@ -158,6 +158,13 @@ if($singlepane_view == 'true')
{
$related_array = getRelatedLists($currentModule,$focus);
$smarty->assign("RELATEDLISTS", $related_array);
require_once('include/ListView/RelatedListViewSession.php');
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
vtlib_purify($_REQUEST['selected_header']));
}
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
}
$smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar'));
$smarty->assign("CONTACT_PERMISSION",CheckFieldPermission('contact_id','Calendar'));
@@ -175,7 +182,7 @@ $focus->markAsViewed($current_user->id);
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW'), $customlink_params));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
@@ -14,7 +14,7 @@ global $adb;
$local_log =& LoggerManager::getLogger('ContactsAjax');
global $currentModule;
$cntObj = CRMEntity::getInstance($currentModule);
$modObj = CRMEntity::getInstance($currentModule);
$ajaxaction = $_REQUEST["ajxaction"];
if($ajaxaction == "DETAILVIEW")
@@ -25,19 +25,15 @@ if($ajaxaction == "DETAILVIEW")
$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
if($crmid != "")
{
$cntObj->retrieve_entity_info($crmid,"Contacts");
$cntObj->column_fields[$fieldname] = $fieldvalue;
$cntObj->id = $crmid;
$cntObj->mode = "edit";
$cntObj->save("Contacts");
if($cntObj->column_fields['notify_owner'] == 1 )
{
sendNotificationToOwner('Contacts',&$cntObj);
}
$email_res = $adb->pquery("select email from vtiger_contactdetails where contactid=?", array($cntObj->id));
$modObj->retrieve_entity_info($crmid,"Contacts");
$modObj->column_fields[$fieldname] = $fieldvalue;
$modObj->id = $crmid;
$modObj->mode = "edit";
$modObj->save("Contacts");
$email_res = $adb->pquery("select email from vtiger_contactdetails where contactid=?", array($modObj->id));
$email = $adb->query_result($email_res,0,'email');
$check_available = $adb->pquery("select * from vtiger_portalinfo where id=?", array($cntObj->id));
$check_available = $adb->pquery("select * from vtiger_portalinfo where id=?", array($modObj->id));
$update = '';
if($fieldname =='email')
{
@@ -48,7 +44,7 @@ if($ajaxaction == "DETAILVIEW")
$sql = "update vtiger_portalinfo set user_name=?,isactive=? where id=?";
$adb->pquery($sql, array($fieldvalue, $active, $crmid));
$email = $fieldvalue;
$result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($cntObj->id));
$result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($modObj->id));
$password = $adb->query_result($result,0,'user_password');
$update = true;
}
@@ -63,7 +59,7 @@ if($ajaxaction == "DETAILVIEW")
{
$password = makeRandomPassword();
$sql = "insert into vtiger_portalinfo (id,user_name,user_password,type,isactive) values(?,?,?,?,?)";
$params = array($cntObj->id, $email, $password, 'C', 1);
$params = array($modObj->id, $email, $password, 'C', 1);
$adb->pquery($sql, $params);
$insert = true;
@@ -71,10 +67,10 @@ if($ajaxaction == "DETAILVIEW")
elseif($confirm == 0 && $fieldvalue == 1)
{
$sql = "update vtiger_portalinfo set user_name=?, isactive=1 where id=?";
$params = array($email, $cntObj->id);
$params = array($email, $modObj->id);
$adb->pquery($sql, $params);
$result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($cntObj->id));
$result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($modObj->id));
$password = $adb->query_result($result,0,'user_password');
$update = true;
@@ -82,22 +78,19 @@ if($ajaxaction == "DETAILVIEW")
elseif($confirm == 1 && $fieldvalue == 0)
{
$sql = "update vtiger_portalinfo set isactive=0 where id=?";
$adb->pquery($sql, array($cntObj->id));
$adb->pquery($sql, array($modObj->id));
}
}
}
require_once("modules/Emails/mail.php");
global $current_user;
$data_array = Array();
$data_array['first_name'] = $cntObj->column_fields['firstname'];
$data_array['last_name'] = $cntObj->column_fields['lastname'];
$data_array['first_name'] = $modObj->column_fields['firstname'];
$data_array['last_name'] = $modObj->column_fields['lastname'];
$data_array['email'] = $email;
$data_array['portal_url'] = "<a href=".$PORTAL_URL."/login.php>".$mod_strings['Please Login Here']."</a>";
$contents = getmail_contents_portalUser($data_array,$password);
if($insert == true || $update == true)
send_mail('Contacts',$cntObj->column_fields['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents);
if($cntObj->id != "")
if($modObj->id != "")
{
echo ":#:SUCCESS";
}else
@@ -108,5 +101,7 @@ if($ajaxaction == "DETAILVIEW")
{
echo ":#:FAILURE";
}
} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
require_once 'include/ListView/RelatedListViewContents.php';
}
?>
?>
+39 -35
View File
@@ -68,19 +68,6 @@ $_SESSION['CONTACTS_ORDER_BY'] = $order_by;
$_SESSION['CONTACTS_SORT_ORDER'] = $sorder;
//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
if (!isset($where)) $where = "";
$url_string = ''; // assigning http url string
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
{
list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
// we have a query
$url_string .="&query=true".$ustring;
$log->info("Here is the where clause for the list view: $where");
$smarty->assign("SEARCH_URL",$url_string);
}
//<<<<cutomview>>>>>>>
$oCustomView = new CustomView("Contacts");
$viewid = $oCustomView->getViewId($currentModule);
@@ -149,24 +136,33 @@ if($viewnamedesc['viewname'] == 'All')
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if($viewid != "0")
{
$listquery = getListQuery("Contacts");
$list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Contacts");
}else
{
$list_query = getListQuery("Contacts");
global $current_user;
$queryGenerator = new QueryGenerator($currentModule, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
//<<<<<<<<customview>>>>>>>>>
if(isset($where) && $where != '')
{
$list_query .= " AND ".$where;
$_SESSION['export_where'] = $where;
}
else
unset($_SESSION['export_where']);
if (!isset($where)) $where = "";
$url_string = ''; // assigning http url string
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
$queryGenerator->addUserSearchConditions($_REQUEST);
$ustring = getSearchURL($_REQUEST);
// we have a query
$url_string .="&query=true".$ustring;
$smarty->assign("SEARCH_URL",$url_string);
}
$list_query = $queryGenerator->getQuery();
$where = $queryGenerator->getConditionalWhere();
if(isset($where) && $where != '') {
$_SESSION['export_where'] = $where;
} else {
unset($_SESSION['export_where']);
}
if(isset($order_by) && $order_by != '')
{
@@ -222,13 +218,13 @@ if( $adb->dbType == "pgsql")
else
$list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
$smarty->assign('recordListRange',$recordListRangeMsg);
//mass merge for word templates -- *Raj*17/11
while($row = $adb->fetch_array($list_result))
{
$ids[] = $row["crmid"];
$ids[] = $row[$focus->table_index];
}
if(isset($ids))
{
@@ -252,8 +248,7 @@ if(isPermitted("Contacts","Merge") == 'yes')
}
else
{
global $current_user;
require("user_privileges/user_privileges_".$current_user->id.".php");
require("user_privileges/user_privileges_".$current_user->id.".php");
if($is_admin == true)
{
$smarty->assign("MERGEBUTTON","<td><a href=index.php?module=Settings&action=upload&tempModule=".$currentModule."&parenttab=Settings>". $app_strings['LBL_CREATE_MERGE_TEMPLATE']."</td>");
@@ -266,13 +261,16 @@ if(isPermitted("Contacts","Merge") == 'yes')
if(!empty($viewid))
$url_string .="&viewname=".$viewid;
$listview_header = getListViewHeader($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView);
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
$order_by);
$smarty->assign("LISTHEADER", $listview_header);
$listview_header_search=getSearchListHeaderValues($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView);
$listview_header_search = $controller->getBasicSearchFieldInfoList();
$smarty->assign("SEARCHLISTHEADER", $listview_header_search);
$listview_entries = getListViewEntries($focus,"Contacts",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
$navigation_array);
$smarty->assign("LISTENTITY", $listview_entries);
$smarty->assign("SELECT_SCRIPT", $view_script);
@@ -286,7 +284,7 @@ $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";")
$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Contacts","index",$viewid);
$alphabetical = AlphabeticalSearch($currentModule,'index','lastname','true','basic',"","","","",$viewid);
$fieldnames = getAdvSearchfields($currentModule);
$fieldnames = $controller->getAdvancedSearchOptionString();
$criteria = getcriteria_options();
$smarty->assign("CRITERIA", $criteria);
$smarty->assign("FIELDNAMES", $fieldnames);
@@ -300,6 +298,12 @@ $smarty->assign("CHECK", $check_button);
$_SESSION[$currentModule.'_listquery'] = $list_query;
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
// END
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
$smarty->display("ListViewEntries.tpl");
else
+1 -1
View File
@@ -218,7 +218,7 @@ while($columnValues = $adb->fetch_array($result))
$actual_values[$x] = $value;
$actual_values[$x] = str_replace('"'," ",$actual_values[$x]);
//if value contains any line feed or carriage return replace the value with ".value."
if (preg_match ("/(\r\n)/", $actual_values[$x]))
if (preg_match ("/(\r?\n)/", $actual_values[$x]))
{
$actual_values[$x] = '"'.$actual_values[$x].'"';
}
+13 -9
View File
@@ -125,18 +125,25 @@ if($image_error=="false")
if(isset($_REQUEST['activity_mode']) && $_REQUEST['activity_mode'] != '') $activitymode = vtlib_purify($_REQUEST['activity_mode']);
$local_log->debug("Saved record with id of ".$return_id);
if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == "Campaigns")
{
if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
{
$campContStatusResult = $adb->pquery("select campaignrelstatusid from vtiger_campaigncontrel where campaignid=? AND contactid=?",array($_REQUEST['return_id'], $focus->id));
$contactStatus = $adb->query_result($campContStatusResult,0,'campaignrelstatusid');
$sql = "delete from vtiger_campaigncontrel where contactid = ?";
$adb->pquery($sql, array($focus->id));
$sql = "insert into vtiger_campaigncontrel values (?,?)";
$adb->pquery($sql, array($_REQUEST['return_id'], $focus->id));
if(isset($contactStatus) && $contactStatus!=''){
$sql = "insert into vtiger_campaigncontrel values (?,?,?)";
$adb->pquery($sql, array($_REQUEST['return_id'], $focus->id,$contactStatus));
}
else
{
$sql = "insert into vtiger_campaigncontrel values (?,?,1)";
$adb->pquery($sql, array($_REQUEST['return_id'], $focus->id));
}
}
}
//BEGIN -- Code for Create Customer Portal Users password and Send Mail
if($_REQUEST['portal'] == '' && $_REQUEST['mode'] == 'edit')
{
@@ -212,12 +219,9 @@ if($image_error=="false")
if($_REQUEST['return_viewname'] != '')$return_viewname=vtlib_purify($_REQUEST['return_viewname']);
$parenttab = getParentTab();
//Send notification mail to the assigned to owner about the contact creation
if($focus->column_fields['notify_owner'] == 1 || $focus->column_fields['notify_owner'] == 'on')
$status = sendNotificationToOwner('Contacts',$focus);
header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&activity_mode=$activitymode&viewname=$return_viewname&start=".vtlib_purify($_REQUEST['pagenumber']));
}
?>
?>
@@ -246,4 +246,4 @@ $mod_strings = Array(
);
?>
?>
@@ -41,7 +41,7 @@ foreach($storearray as $id)
if($dest_mod == 'Products')
$adb->pquery("insert into vtiger_seproductsrel values (?,?,?)", array($forCRMRecord, $id, 'Contacts'));
elseif($dest_mod == 'Campaigns')
$adb->pquery("insert into vtiger_campaigncontrel values(?,?)", array($id, $forCRMRecord));
$adb->pquery("insert into vtiger_campaigncontrel values(?,?,1)", array($id, $forCRMRecord));
elseif($dest_mod == 'Documents')
$adb->pquery("insert into vtiger_senotesrel values(?,?)", array($forCRMRecord,$id));
else {
@@ -52,4 +52,4 @@ foreach($storearray as $id)
header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab);
?>
?>
@@ -14,6 +14,7 @@ global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once('include/utils/utils.php');
require_once 'include/Webservices/Utils.php';
global $adv_filter_options;
@@ -54,6 +55,8 @@ class CustomView extends CRMEntity{
// Information as defined for this instance in the database table.
protected $_status = false;
protected $_userid = false;
protected $meta;
protected $moduleMetaInfo;
/** This function sets the currentuser id to the class variable smownerid,
* modulename to the class variable customviewmodule
@@ -67,8 +70,26 @@ class CustomView extends CRMEntity{
$this->escapemodule[] = $module."_";
$this->escapemodule[] = "_";
$this->smownerid = $current_user->id;
$this->moduleMetaInfo = array();
if($module != "" && $module != 'Calendar') {
$this->meta = $this->getMeta($module, $current_user);
}
}
/**
*
* @param String:ModuleName $module
* @return EntityMeta
*/
public function getMeta($module, $user) {
$db = PearDatabase::getInstance();
if (empty($this->moduleMetaInfo[$module])) {
$handler = vtws_getModuleHandlerFromName($module, $user);
$meta = $handler->getMeta();
$this->moduleMetaInfo[$module] = $meta;
}
return $this->moduleMetaInfo[$module];
}
/** To get the customViewId of the specified module
* @param $module -- The module Name:: Type String
@@ -78,7 +99,7 @@ class CustomView extends CRMEntity{
{
global $adb,$current_user;
$now_action = vtlib_purify($_REQUEST['action']);
if(isset($_REQUEST['viewname']) == false) {
if(empty($_REQUEST['viewname'])) {
if (isset($_SESSION['lvs'][$module]["viewname"]) && $_SESSION['lvs'][$module]["viewname"]!='') {
$viewid = $_SESSION['lvs'][$module]["viewname"];
}
@@ -206,6 +227,7 @@ class CustomView extends CRMEntity{
$ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%'))";
array_push($sparams, $current_user->id);
}
$ssql .= " ORDER BY viewname";
$result = $adb->pquery($ssql, $sparams);
while($cvrow=$adb->fetch_array($result))
{
@@ -278,12 +300,14 @@ class CustomView extends CRMEntity{
global $adb,$mod_strings,$app_strings;
$block_ids = explode(",", $block);
$tabid = getTabid($module);
global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
if (empty($this->meta) && $module != 'Calendar') {
$this->meta = $this->getMeta($module, $current_user);
}
if($tabid == 9)
$tabid ="9,16";
global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
$display_type = " vtiger_field.displaytype in (1,2,3)";
$display_type = " vtiger_field.displaytype in (1,2,3)";
if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
{
@@ -342,7 +366,9 @@ class CustomView extends CRMEntity{
if($module == 'Quotes' && $block == 51)
$module_columnlist['vtiger_crmentity:crmid::Quotes_Quote_No:I'] = $app_strings['Quote No'];
if ($module != 'Calendar') {
$moduleFieldList = $this->meta->getModuleFields();
}
for($i=0; $i<$noofrows; $i++)
{
$fieldtablename = $adb->query_result($result,$i,"tablename");
@@ -352,8 +378,15 @@ class CustomView extends CRMEntity{
$fieldtype = explode("~",$fieldtype);
$fieldtypeofdata = $fieldtype[0];
$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
//Here we Changing the displaytype of the field. So that its criteria will be displayed Correctly in Custom view Advance Filter.
$fieldtypeofdata=ChangeTypeOfData_Filter($fieldtablename,$fieldcolname,$fieldtypeofdata);
$field = $moduleFieldList[$fieldname];
if(!empty($field) && $field->getFieldDataType() == 'reference') {
$fieldtypeofdata = 'V';
} else {
//Here we Changing the displaytype of the field. So that its criteria will be
//displayed Correctly in Custom view Advance Filter.
$fieldtypeofdata=ChangeTypeOfData_Filter($fieldtablename,$fieldcolname,
$fieldtypeofdata);
}
if($fieldlabel == "Related To")
{
$fieldlabel = "Related to";
@@ -366,14 +399,8 @@ class CustomView extends CRMEntity{
}
$fieldlabel1 = str_replace(" ","_",$fieldlabel);
if($fieldname == 'account_id' && $fieldtablename != 'vtiger_account')//Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name . But for account member of we have to avoid this
$optionvalue = "vtiger_account:accountname:accountname:".$module."_".$fieldlabel1.":".$fieldtypeofdata;
else if($fieldname == 'contact_id' && $module != "Contacts")//Calendar,Documents,PurchaseOrder,SalesOrder,Quotes,and Invoice records sort by Contact Name
$optionvalue = "vtiger_contactdetails:lastname:lastname:".$module."_".$fieldlabel1.":".$fieldtypeofdata;
else if($fieldname == 'product_id' && ($module != 'Products' && $module != 'HelpDesk' && $module !="Faq"))//Campaign records sort by Product Name.
$optionvalue = "vtiger_products:productname:productname:".$module."_".$fieldlabel1.":".$fieldtypeofdata;
else
$optionvalue = $fieldtablename.":".$fieldcolname.":".$fieldname.":".$module."_".$fieldlabel1.":".$fieldtypeofdata;
$optionvalue = $fieldtablename.":".$fieldcolname.":".$fieldname.":".$module."_".
$fieldlabel1.":".$fieldtypeofdata;
//added to escape attachments fields in customview as we have multiple attachments
$fieldlabel = getTranslatedString($fieldlabel); //added to support i18n issue
if($module != 'HelpDesk' || $fieldname !='filename')
@@ -473,7 +500,7 @@ class CustomView extends CRMEntity{
{
$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid ";
$sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .")
and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2) ";
and vtiger_field.uitype in (5,6,23,70)";
$sql.= " and vtiger_field.presence in (0,2) order by vtiger_field.sequence";
$params = array($tabid, $blockids);
}
@@ -481,7 +508,7 @@ class CustomView extends CRMEntity{
{
$profileList = getCurrentUserProfileList();
$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
$sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .") and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2)";
$sql.= " where vtiger_field.tabid=? and vtiger_field.block in (". generateQuestionMarks($blockids) .") and vtiger_field.uitype in (5,6,23,70)";
$sql.= " and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)";
$params = array($tabid, $blockids);
@@ -1067,6 +1094,17 @@ class CustomView extends CRMEntity{
elseif($this->customviewmodule == "Documents" && $columns[1]=='folderid'){
$advfiltersql[] = "vtiger_attachmentsfolder.foldername".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
}
elseif($this->customviewmodule == "Assets"){
if($columns[1]=='account' ){
$advfiltersql[] = "vtiger_account.accountname".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
}
if($columns[1]=='product'){
$advfiltersql[] = "vtiger_products.productname".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
}
if($columns[1]=='invoiceid'){
$advfiltersql[] = "vtiger_invoice.subject".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
}
}
else
{
$advfiltersql[] = $this->getRealValues($columns[0],$columns[1],$advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
@@ -1926,7 +1964,7 @@ class CustomView extends CRMEntity{
elseif($status == CV_STATUS_PUBLIC)
{
$log->debug("Entering when status=3");
if($action == 'ListView' || $action == $module."Ajax" || $action == 'index')
if($action == 'ListView' || $action == $module."Ajax" || $action == 'index' || $action == 'DetailView')
{
$permission = "yes";
}
@@ -2016,4 +2054,4 @@ class CustomView extends CRMEntity{
}
}
?>
?>
@@ -72,16 +72,12 @@ function getKeyMetrics($maxval,$calCnt)
$log->info("Metrics :: Successfully got MetricList to be displayed");
if(isset($metriclists))
{
foreach ($metriclists as $key => $metriclist)
{
$listquery = getListQuery($metriclist['module']);
if($metriclist['module'] == 'Calendar')
$listquery .= " AND vtiger_activity.activitytype != 'Emails' ";
$oCustomView = new CustomView($metriclist['module']);
$metricsql = $oCustomView->getMetricsCvListQuery($metriclist['id'],$listquery,$metriclist['module']);
if($metriclist['module'] == "Calendar" and !$adb->isPostgres())
$metricsql.=" group by vtiger_activity.activityid ";
global $current_user;
foreach ($metriclists as $key => $metriclist) {
$queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
$queryGenerator->initForCustomViewById($metriclist['id']);
$metricsql = $queryGenerator->getQuery();
$metricsql = mkCountQuery($metricsql);
$metricresult = $adb->query($metricsql);
if($metricresult)
{
@@ -206,7 +206,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
'vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
'vtiger_contactdetails:title:title:Contacts_Title:V',
'vtiger_account:accountname:accountname:Contacts_Account_Name:V',
'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I',
'vtiger_contactdetails:email:email:Contacts_Email:E',
'vtiger_contactdetails:phone:phone:Contacts_Office_Phone:V',
'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
@@ -222,7 +222,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
'vtiger_contactdetails:title:title:Contacts_Title:V',
'vtiger_account:accountname:accountname:Contacts_Account_Name:V',
'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I',
'vtiger_contactdetails:email:email:Contacts_Email:E',
'vtiger_contactsubdetails:otherphone:otherphone:Contacts_Phone:V',
'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
@@ -272,20 +272,20 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
'vtiger_quotes:subject:subject:Quotes_Subject:V',
'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
'vtiger_account:accountname:accountname:Quotes_Account_Name:V',
'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:I',
'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
Array('vtiger_quotes:subject:subject:Quotes_Subject:V',
'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
'vtiger_account:accountname:accountname:Quotes_Account_Name:V',
'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D',
'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
Array('vtiger_quotes:subject:subject:Quotes_Subject:V',
'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
'vtiger_account:accountname:accountname:Quotes_Account_Name:V',
'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D',
'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
@@ -336,8 +336,8 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
Array('vtiger_salesorder:salesorder_no:salesorder_no:SalesOrder_SalesOrder_No:V',
'vtiger_salesorder:subject:subject:SalesOrder_Subject:V',
'vtiger_account:accountname:accountname:SalesOrder_Account_Name:V',
'vtiger_quotes:quoteid:quote_id:SalesOrder_Quote_Name:I',
'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I',
'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I',
'vtiger_salesorder:total:hdnGrandTotal:SalesOrder_Total:V',
'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V'),
@@ -400,7 +400,7 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_Invoice_No:V',
'vtiger_invoice:subject:subject:Invoice_Subject:V',
'vtiger_account:accountname:accountname:Invoice_Account_Name:V',
'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V',
@@ -408,14 +408,14 @@ $cvcolumns = Array(Array('vtiger_leaddetails:lead_no:lead_no:Leads_Lead_No:V',
Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_Invoice_No:V',
'vtiger_invoice:subject:subject:Invoice_Subject:V',
'vtiger_account:accountname:accountname:Invoice_Account_Name:V',
'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
'vtiger_invoiceshipads:ship_street:ship_street:Invoice_Shipping_Address:V',
'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V'),
Array( 'vtiger_salesorder:subject:subject:SalesOrder_Subject:V',
'vtiger_account:accountname:accountname:SalesOrder_Account_Name:V',
'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I',
'vtiger_salesorder:sostatus:sostatus:SalesOrder_Status:V',
'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V',
'vtiger_soshipads:ship_street:ship_street:SalesOrder_Shipping_Address:V',
+3 -3
View File
@@ -81,19 +81,19 @@ if($cvmodule != "") {
//<<<<<<<advancedfilter>>>>>>>>>
for ($i=0;$i<count($allKeys);$i++) {
$string = substr($allKeys[$i], 0, 4);
if($string == "fcol") {
if($string == "fcol" && !empty($_REQUEST[$allKeys[$i]])) {
$adv_filter_col[] = $_REQUEST[$allKeys[$i]];
}
}
for ($i=0;$i<count($allKeys);$i++) {
$string = substr($allKeys[$i], 0, 3);
if($string == "fop") {
if($string == "fop" && !empty($_REQUEST[$allKeys[$i]])) {
$adv_filter_option[] = $_REQUEST[$allKeys[$i]];
}
}
for ($i=0;$i<count($allKeys);$i++) {
$string = substr($allKeys[$i], 0, 4);
if($string == "fval") {
if($string == "fval" && !empty($_REQUEST[$allKeys[$i]])) {
//$adv_filter_value[] = htmlentities(trim($_REQUEST[$allKeys[$i]]));
$adv_filter_value[] = trim($_REQUEST[$allKeys[$i]]);
}
@@ -22,7 +22,11 @@ class CustomerPortal {
if($eventType == 'module.postinstall') {
$portalmodules = array("HelpDesk","Faq","Invoice","Quotes","Products","Services","Documents","Contacts","Accounts",);
$i=0;
$query = "SELECT max(sequence) AS max_tabseq FROM vtiger_customerportal_tabs";
$res = $adb->pquery($query,array());
$tabseq = $adb->query_result($res,0,'max_tabseq');
$i = ++$tabseq;
foreach($portalmodules as $modules) {
++$i;
$tabid = getTabid($modules);
@@ -63,4 +67,4 @@ class CustomerPortal {
}
}
}
?>
?>
@@ -1,34 +1,13 @@
<?xml version='1.0'?>
<schema>
<tables>
<table>
<name>vtiger_customerportal_tabs</name>
<sql><![CDATA[CREATE TABLE `vtiger_customerportal_tabs` (
`tabid` int(19) NOT NULL,
`visible` int(1) default '1',
`sequence` int(1) default NULL,
PRIMARY KEY (`tabid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
<table>
<name>vtiger_customerportal_fields</name>
<sql><![CDATA[CREATE TABLE `vtiger_customerportal_fields` (
`tabid` int(19) NOT NULL,
`fieldid` int(19) default NULL,
`visible` int(1) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
<table>
<name>vtiger_customerportal_prefs</name>
<sql><![CDATA[CREATE TABLE `vtiger_customerportal_prefs` (
`tabid` int(11) NOT NULL,
`prefkey` varchar(100) default NULL,
`prefvalue` int(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
<table>
<name>vtiger_customerportal_prefs</name>
<sql><![CDATA[ALTER TABLE vtiger_customerportal_prefs ADD INDEX tabid_idx(tabid)]]></sql>
`tabid` int(19) NOT NULL,
`fieldid` int(19) default NULL,
`visible` int(1) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
</table>
</tables>
</schema>
@@ -354,7 +354,7 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$
}
if($graph_for =="smownerid")
{
$name_val=get_assigned_user_name($mod_name);
$name_val=getOwnerName($mod_name);
if($name_val!="")
{
$mod_name=$name_val;
@@ -421,24 +421,30 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$
$search_str=$name_val;
}
}
if($graph_for =="contactid")
if($graph_for =="parent_id" || $graph_for =="related_to")
{
$query = "SELECT contact_no, lastname, firstname FROM vtiger_contactdetails WHERE contactid=?";
$result = $adb->pquery($query, array($mod_name));
$name_val = $adb->query_result($result,0,"lastname");
if($name_val!="")
{
if(getFieldVisibilityPermission('Contacts', $current_user->id,'firstname') == '0')
{
$first_name = '';
$first_name = $adb->query_result($result,0,"firstname");
if($first_name != '')
$name_val .= " ".$first_name;
$seType = getSalesEntityType($mod_name);
if($seType == 'Contacts') {
$query = "SELECT lastname, firstname FROM vtiger_contactdetails
WHERE contactid=?";
$result = $adb->pquery($query, array($mod_name));
$name_val = $adb->query_result($result,0,"lastname");
if($name_val!="") {
if(getFieldVisibilityPermission('Contacts', $current_user->id,
'firstname') == '0') {
$first_name = $adb->query_result($result,0,"firstname");
if($first_name != '') {
$name_val .= " ".$first_name;
}
}
}
$mod_name=$name_val;
$search_str=$adb->query_result($result, 0, "contact_no");
}
} else {
$query = "SELECT accountname FROM vtiger_account WHERE accountid=?";
$result = $adb->pquery($query, array($mod_name));
$name_val = $adb->query_result($result,0,"accountname");
}
$mod_name=$name_val;
$search_str=$name_val;
}
//Passing name to graph
$mod_name = str_replace(":", "&#58;", $mod_name);
@@ -458,9 +464,17 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$
}
//added to get valid url in dashbord for tickets by team
if($graph_for == "ticketgroupname" || $graph_for == "groupname") $graph_for = "smownerid";
if($graph_for == "accountid") $graph_for = "account_id";
if($graph_for == "smownerid"){
$searchField = "assigned_user_id";
} elseif($graph_for == 'category') {
$searchField = 'ticketcategories';
} elseif($graph_for == 'priority') {
$searchField = 'ticketpriorities';
} elseif($graph_for == "accountid") {
$searchField = "account_id";
} else{
$searchField = $graph_for;
}
$cvid = getCvIdOfAll($module);
if($module == "Home")
{
@@ -468,15 +482,13 @@ function module_Chart($user_id,$date_start="2000-01-01",$end_date="2017-01-01",$
$link_val="index.php?module=".$mod_name."&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner=".$current_user->user_name."&viewname=".$cvid;
}
else if($module == "Contacts" || ($module=="Products" && ($graph_for == "quoteid" || $graph_for == "invoiceid" || $graph_for == "purchaseorderid")))
$link_val="index.php?module=".$module."&action=ListView&from_dashboard=true&type=dbrd&query=true&".$graph_for."=".$id_name."&viewname=".$cvid;
$link_val="index.php?module=".$module."&action=ListView&from_dashboard=true&type=dbrd&query=true&".$searchField."=".$id_name."&viewname=".$cvid;
else {
$esc_search_str = urlencode($search_str);
//$esc_search_str = htmlentities($search_str, ENT_QUOTES, $default_charset);
$link_val="index.php?module=".$module."&action=index&from_dashboard=true&search_text=".$esc_search_str."&search_field=".$graph_for."&searchtype=BasicSearch&query=true&type=entchar&viewname=".$cvid;
$link_val="index.php?module=".$module."&action=index&from_dashboard=true&search_text=".$esc_search_str."&search_field=".$searchField."&searchtype=BasicSearch&query=true&type=entchar&operator=e&viewname=".$cvid;
}
if($graph_for == "account_id") $graph_for = "accountid";
//Adding the links to the graph
$link_val = str_replace(':', '&#58;', $link_val);
if($i==0)
@@ -76,7 +76,8 @@ $helpdesk_query=" select vtiger_troubletickets.status AS ticketstatus, vtiger_gr
//Query for Contacts by Campaign
$cont_Q = "select crmid from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_crmentity.deleted=0 ".dashboard_check("Contacts");
$contByCampaign = "select crmid from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_crmentity.deleted=0 ";
$cont_Q = getDashboardQuery($contByCampaign,"Contacts");
$result = $adb->pquery($cont_Q, array());
$num_conts = $adb->num_rows($result);
@@ -146,7 +147,7 @@ $graph_array = Array(
$graph_title= $mod_strings['leadsource'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
@@ -157,7 +158,7 @@ $graph_array = Array(
$graph_title= $mod_strings['leadstatus'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
if(!$is_admin)
$query .= ' and vtiger_leaddetails.leadsource '.picklist_check($module,$graph_by);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
@@ -169,7 +170,7 @@ $graph_array = Array(
$graph_title=$mod_strings['leadindustry'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Sales by Lead Source
@@ -179,38 +180,38 @@ $graph_array = Array(
$graph_title=$mod_strings['salesbyleadsource'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' ";
$query=$potential_query." ".dashboard_check($module);
$query=getDashboardQuery($potential_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Sales by Account
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0"))
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'related_to') == "0"))
{
$graph_by="accountid";
$graph_by="related_to";
$graph_title=$mod_strings['salesbyaccount'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' ";
$query=$potential_query." ".dashboard_check($module);
$query=getDashboardQuery($potential_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Sales by User
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyuser"))
{
$graph_by="smownerid";
$graph_title=$mod_strings['salesbyuser'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')";
$query=$potential_query." ".dashboard_check($module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
$graph_by="smownerid";
$graph_title=$mod_strings['salesbyuser'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname is NULL)";
$query=getDashboardQuery($potential_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Sales by team
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyteam"))
{
$graph_by="groupname";
$graph_title=$mod_strings['salesbyteam'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')";
$query=$potential_query." ".dashboard_check($module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
$graph_by="smownerid";
$graph_title=$mod_strings['salesbyteam'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like '%Closed Won%' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')";
$query=getDashboardQuery($potential_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Account by Industry
elseif ($profileTabsPermission[getTabid("Accounts")] == 0 && ($type == "accountindustry") && (getFieldVisibilityPermission('Accounts',$user_id,'industry') == "0"))
@@ -219,7 +220,7 @@ $graph_array = Array(
$graph_title=$mod_strings['accountindustry'];
$module="Accounts";
$where="";
$query=$account_query." ".dashboard_check($module);
$query=getDashboardQuery($account_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Products by Category
@@ -229,7 +230,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productcategory'];
$module="Products";
$where="";
$query=$product_category." ".dashboard_check($module);
$query=getDashboardQuery($product_category, $module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Products by Quantity in stock
@@ -239,7 +240,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyqtyinstock'];
$module="Products";
$where="";
$query=$products_query." ".dashboard_check($module);
$query=getDashboardQuery($products_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Products by PO
@@ -249,7 +250,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbypo'];
$module="Products";
$where="";
$query=$probyPO." ".dashboard_check($module);
$query=getDashboardQuery($probyPO,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Products by Quotes
@@ -259,7 +260,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyquotes'];
$module="Products";
$where="";
$query=$probyQ." ".dashboard_check($module);
$query=getDashboardQuery($probyQ, $module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Charts for Products by Invoice
@@ -269,7 +270,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyinvoice'];
$module="Products";
$where="";
$query=$probyInv." ".dashboard_check($module);
$query=getDashboardQuery($probyInv, $module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
@@ -280,7 +281,7 @@ $graph_array = Array(
$graph_title=$mod_strings['sobyaccounts'];
$module="SalesOrder";
$where="";
$query=$so_query." ".dashboard_check($module);
$query=getDashboardQuery($so_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Sales Order by Status
@@ -290,7 +291,7 @@ $graph_array = Array(
$graph_title=$mod_strings['sobystatus'];
$module="SalesOrder";
$where="";
$query=$so_query." ".dashboard_check($module);
$query=getDashboardQuery($so_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Purchase Order by Status
@@ -300,7 +301,7 @@ $graph_array = Array(
$graph_title=$mod_strings['pobystatus'];
$module="PurchaseOrder";
$where="";
$query=$po_query." ".dashboard_check($module);
$query=getDashboardQuery($po_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Quotes by Accounts
@@ -310,7 +311,7 @@ $graph_array = Array(
$graph_title= $mod_strings['quotesbyaccounts'];
$module="Quotes";
$where="";
$query=$quotes_query." ".dashboard_check($module);
$query=getDashboardQuery($quotes_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Quotes by Stage
@@ -320,7 +321,7 @@ $graph_array = Array(
$graph_title=$mod_strings['quotesbystage'];
$module="Quotes";
$where="";
$query=$quotes_query." ".dashboard_check($module);
$query=getDashboardQuery($quotes_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Invoice by Accounts
@@ -330,7 +331,7 @@ $graph_array = Array(
$graph_title=$mod_strings['invoicebyacnts'];
$module="Invoice";
$where="";
$query=$invoice_query." ".dashboard_check($module);
$query=getDashboardQuery($invoice_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Invoices by status
@@ -340,7 +341,7 @@ $graph_array = Array(
$graph_title=$mod_strings['invoicebystatus'];
$module="Invoice";
$where="";
$query=$invoice_query." ".dashboard_check($module);
$query=getDashboardQuery($invoice_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Status
@@ -350,7 +351,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbystatus'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Priority
@@ -360,7 +361,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbypriority'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Category
@@ -370,7 +371,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbycategory'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by User
@@ -379,18 +380,18 @@ $graph_array = Array(
$graph_by="smownerid";
$graph_title=$mod_strings['ticketsbyuser'];
$module="HelpDesk";
$where=" and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')";
$query=$helpdesk_query." ".dashboard_check($module);
$where=" and (vtiger_groups.groupname is NULL)";
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Team
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyteam"))
{
$graph_by="ticketgroupname";
$graph_by="smownerid";
$graph_title=$mod_strings['ticketsbyteam'];
$module="HelpDesk";
$where=" and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != ' ')";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Product
@@ -400,7 +401,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbyproduct'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Campaigns by Contact
@@ -410,27 +411,27 @@ $graph_array = Array(
$graph_title=$mod_strings['contactbycampaign'];
$module="Contacts";
$where="";
$query=$campaign_query." ".dashboard_check($module);
$query=getDashboardQuery($campaign_query,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Account
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
{
$graph_by="accountid";
$graph_by="parent_id";
$graph_title=$mod_strings['ticketsbyaccount'];
$module="HelpDesk";
$where="";
$query=$tickets_by_account." ".dashboard_check($module);
$query=getDashboardQuery($tickets_by_account,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
//Tickets by Contact
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
{
$graph_by="contactid";
$graph_by="parent_id";
$graph_title=$mod_strings['ticketsbycontact'];
$module="HelpDesk";
$where="";
$query=$tickets_by_contact." ".dashboard_check($module);
$query=getDashboardQuery($tickets_by_contact,$module);
return get_graph_by_type($graph_by,$graph_title,$module,$where,$query,"210","210","forhomepage");
}
else
@@ -450,7 +451,7 @@ $graph_array = Array(
$graph_title= $mod_strings['leadsource'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
//$html .= get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
@@ -461,7 +462,7 @@ $graph_array = Array(
$graph_title= $mod_strings['leadstatus'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
if(!$is_admin)
$query .= ' and vtiger_leaddetails.leadstatus '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -473,7 +474,7 @@ $graph_array = Array(
$graph_title=$mod_strings['leadindustry'];
$module="Leads";
$where="";
$query=$leads_query." ".dashboard_check($module);
$query=getDashboardQuery($leads_query,$module);
if(!$is_admin)
$query .= ' and vtiger_leaddetails.industry '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -485,19 +486,19 @@ $graph_array = Array(
$graph_title=$mod_strings['salesbyleadsource'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like 'Closed Won' ";
$query=$potential_query." ".dashboard_check($module);
$query=getDashboardQuery($potential_query,$module);
if(!$is_admin)
$query .= ' and vtiger_potential.leadsource '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Sales by Account
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0"))
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'related_to') == "0"))
{
$graph_by="accountid";
$graph_by="related_to";
$graph_title=$mod_strings['salesbyaccount'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like 'Closed Won' ";
$query=$potential_query." ".dashboard_check($module);
$query=getDashboardQuery($potential_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Sales by User
@@ -506,18 +507,18 @@ $graph_array = Array(
$graph_by="smownerid";
$graph_title=$mod_strings['salesbyuser'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')";
$query=$potential_query." ".dashboard_check($module);
$where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_groups.groupname is NULL)";
$query=getDashboardQuery($potential_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Sales by team
elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyteam"))
{
$graph_by="groupname";
$graph_by="smownerid";
$graph_title=$mod_strings['salesbyteam'];
$module="Potentials";
$where=" and vtiger_potential.sales_stage like 'Closed Won' and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != '')";
$query=$potential_query." ".dashboard_check($module);
$query=getDashboardQuery($potential_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Charts for Account by Industry
@@ -527,7 +528,7 @@ $graph_array = Array(
$graph_title=$mod_strings['accountindustry'];
$module="Accounts";
$where="";
$query=$account_query." ".dashboard_check($module);
$query=getDashboardQuery($account_query,$module);
if(!$is_admin)
$query .= ' and vtiger_account.industry '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -539,7 +540,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productcategory'];
$module="Products";
$where="";
$query=$product_category." ".dashboard_check($module);
$query=getDashboardQuery($product_category,$module);
if(!$is_admin)
$query .= ' and vtiger_products.productcategory '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -551,7 +552,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyqtyinstock'];
$module="Products";
$where="";
$query=$products_query." ".dashboard_check($module);
$query=getDashboardQuery($products_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Charts for Products by PO
@@ -561,7 +562,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbypo'];
$module="Products";
$where="";
$query=$probyPO." ".dashboard_check("PurchaseOrder");
$query=getDashboardQuery($probyPO,"PurchaseOrder");
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Charts for Products by Quotes
@@ -571,7 +572,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyquotes'];
$module="Products";
$where="";
$query=$probyQ." ".dashboard_check("Quotes");
$query=getDashboardQuery($probyQ,"Quotes");
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Charts for Products by Invoice
@@ -581,7 +582,7 @@ $graph_array = Array(
$graph_title=$mod_strings['productbyinvoice'];
$module="Products";
$where="";
$query=$probyInv." ".dashboard_check("Invoice");
$query=getDashboardQuery($probyInv,"Invoice");
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
@@ -592,7 +593,7 @@ $graph_array = Array(
$graph_title=$mod_strings['sobyaccounts'];
$module="SalesOrder";
$where="";
$query=$so_query." ".dashboard_check($module);
$query=getDashboardQuery($so_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Sales Order by Status
@@ -602,7 +603,7 @@ $graph_array = Array(
$graph_title=$mod_strings['sobystatus'];
$module="SalesOrder";
$where="";
$query=$so_query." ".dashboard_check($module);
$query=getDashboardQuery($so_query,$module);
if(!$is_admin)
$query .= ' and vtiger_salesorder.sostatus '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -614,7 +615,7 @@ $graph_array = Array(
$graph_title=$mod_strings['pobystatus'];
$module="PurchaseOrder";
$where="";
$query=$po_query." ".dashboard_check($module);
$query=getDashboardQuery($po_query,$module);
if(!$is_admin)
$query .= ' and vtiger_purchaseorder.postatus '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -626,7 +627,7 @@ $graph_array = Array(
$graph_title= $mod_strings['quotesbyaccounts'];
$module="Quotes";
$where="";
$query=$quotes_query." ".dashboard_check($module);
$query=getDashboardQuery($quotes_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Quotes by Stage
@@ -636,7 +637,7 @@ $graph_array = Array(
$graph_title=$mod_strings['quotesbystage'];
$module="Quotes";
$where="";
$query=$quotes_query." ".dashboard_check($module);
$query=getDashboardQuery($quotes_query,$module);
if(!$is_admin)
$query .= ' and vtiger_quotes.quotestage '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -648,7 +649,7 @@ $graph_array = Array(
$graph_title=$mod_strings['invoicebyacnts'];
$module="Invoice";
$where="";
$query=$invoice_query." ".dashboard_check($module);
$query=getDashboardQuery($invoice_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Invoices by status
@@ -658,7 +659,7 @@ $graph_array = Array(
$graph_title=$mod_strings['invoicebystatus'];
$module="Invoice";
$where="";
$query=$invoice_query." ".dashboard_check($module);
$query=getDashboardQuery($invoice_query,$module);
if(!$is_admin)
$query .= ' and vtiger_invoice.invoicestatus '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -670,7 +671,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbystatus'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
if(!$is_admin)
$query .= ' and vtiger_troubletickets.status '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -682,7 +683,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbypriority'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
if(!$is_admin)
$query .= ' and vtiger_troubletickets.priority '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -694,7 +695,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbycategory'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
if(!$is_admin)
$query .= ' and vtiger_troubletickets.category '.picklist_check($module,$graph_by);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
@@ -705,18 +706,18 @@ $graph_array = Array(
$graph_by="smownerid";
$graph_title=$mod_strings['ticketsbyuser'];
$module="HelpDesk";
$where=" and (vtiger_crmentity.smownerid != NULL || vtiger_crmentity.smownerid != ' ')";
$query=$helpdesk_query." ".dashboard_check($module);
$where=" and (vtiger_groups.groupname is NULL)";
$query=getDashboardQuery($helpdesk_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Tickets by Team
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyteam"))
{
$graph_by="ticketgroupname";
$graph_by="smownerid";
$graph_title=$mod_strings['ticketsbyteam'];
$module="HelpDesk";
$where=" and (vtiger_groups.groupname != NULL || vtiger_groups.groupname != ' ')";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Tickets by Product
@@ -726,7 +727,7 @@ $graph_array = Array(
$graph_title=$mod_strings['ticketsbyproduct'];
$module="HelpDesk";
$where="";
$query=$helpdesk_query." ".dashboard_check($module);
$query=getDashboardQuery($helpdesk_query,$module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Campaigns by Contact
@@ -736,27 +737,27 @@ $graph_array = Array(
$graph_title=$mod_strings['contactbycampaign'];
$module="Contacts";
$where="";
$query=$campaign_query." ".dashboard_check("Campaigns");
$query=getDashboardQuery($campaign_query,"Campaigns");
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Tickets by Account
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
{
$graph_by="accountid";
$graph_by="parent_id";
$graph_title=$mod_strings['ticketsbyaccount'];
$module="HelpDesk";
$where="";
$query=$tickets_by_account." ".dashboard_check($module);
$query=getDashboardQuery($tickets_by_account, $module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
//Tickets by Contact
elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
{
$graph_by="contactid";
$graph_by="parent_id";
$graph_title=$mod_strings['ticketsbycontact'];
$module="HelpDesk";
$where="";
$query=$tickets_by_contact." ".dashboard_check($module);
$query=getDashboardQuery($tickets_by_contact, $module);
echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
}
else
@@ -773,18 +774,13 @@ $graph_array = Array(
*Returns an string value
*/
function dashboard_check($module)
{
function getDashboardQuery($query, $module) {
global $current_user;
$sec_parameter = '';
$tab_id = getTabid($module);
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
{
$sec_parameter=getListViewSecurityParameter($module);
$secQuery = getNonAdminAccessControlQuery($module, $current_user);
if(strlen($secQuery) > 1) {
$query = appendFromClauseToQuery($query, $secQuery);
}
return $sec_parameter;
return $query;
}
/**This function generates the security parameters for a given user base picklist values
@@ -87,4 +87,4 @@ function dashboardDisplayCall($type,$Chart_Type,$from_page)
}
}
?>
?>
@@ -117,8 +117,6 @@ function horizontal_graph($referdata,$refer_code,$width,$height,$left,$right,$to
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white'));
elseif($theme == 'softed')
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white'));
elseif($theme == 'hawebs')
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white'));
else
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'black', 'white'));
@@ -43,7 +43,7 @@ function vertical_graph($referdata,$refer_code,$width,$height,$left,$right,$top,
else
$name=$datax[$i];
$pos = substr_count($name," ");
$alts[]=htmlentities($name,ENT_QUOTES,'UTF-8')."=%d";
$alts[]=htmlentities($name)."=%d";
//If the datax value of a string is greater, adding '\n' to it so that it'll cme inh 2nd line
if(strlen($name)>=15)
$name=substr($name, 0, 15);
@@ -117,8 +117,6 @@ function vertical_graph($referdata,$refer_code,$width,$height,$left,$right,$top,
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white'));
elseif($theme == 'softed')
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white'));
elseif($theme == 'hawebs')
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white'));
else
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'black', 'white'));
@@ -85,7 +85,7 @@ foreach($allblocks as $blocks)
{
foreach($blocks as $block_entries)
{
if($block_entries['File Name']['value'] != '' || isset($block_entries['File Name']['value']))
if(!empty($block_entries[getTranslatedString('File Name',$currentModule)]['value']))
$flag = 1;
}
}
@@ -168,6 +168,12 @@ if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($
$focus->markAsViewed($current_user->id);
// END
// Gather the custom link information to display
include_once('vtlib/Vtiger/Link.php');
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
// END
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
$smarty->display("DetailView.tpl");
@@ -41,5 +41,7 @@ if($ajaxaction == "DETAILVIEW")
{
echo ":#:FAILURE";
}
} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
require_once 'include/ListView/RelatedListViewContents.php';
}
?>
@@ -233,24 +233,13 @@ class Documents extends CRMEntity {
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " .
" LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid "
;
$where_auto=" vtiger_crmentity.deleted=0";
if($where != "")
$query .= " WHERE ($where) AND ".$where_auto;
else
$query .= " WHERE ".$where_auto;
$query .= getNonAdminAccessControlQuery('Documents',$current_user);
$where_auto=" vtiger_crmentity.deleted=0";
if($where != "")
$query .= " WHERE ($where) AND ".$where_auto;
else
$query .= " WHERE ".$where_auto;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
//we should add security check when the user has Private Access
$tabid = getTabid("Documents");
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tabid] == 3)
{
//Added security check to get the permitted records only
$query = $query." ".getListViewSecurityParameter("Documents");
}
$log->debug("Exiting create_export_query method ...");
return $query;
}

Some files were not shown because too many files have changed in this diff Show More