/** Function to export the notes in CSV Format
* @param reference variable - where condition is passed when the query is executed
* Returns Export Documents Query.
*/
function create_export_query($where)
{
global $log, $current_user;
$log->debug("Entering create_export_query(" . $where . ") method ...");
include "include/utils/ExportUtils.php";
//To get the Permitted fields query and the permitted fields list
$sql = getPermittedFieldsQuery("Documents", "detail_view");
$fields_list = getFieldsListFromQuery($sql);
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "SELECT {$fields_list}, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name" . " FROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity\n\t\t\t\t\ton vtiger_crmentity.crmid=vtiger_notes.notesid\n\t\t\t\tLEFT JOIN `vtiger_trees_templates_data` on vtiger_notes.folderid=`vtiger_trees_templates_data`.tree\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " . " LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
$query .= getNonAdminAccessControlQuery('Documents', $current_user);
$where_auto = " vtiger_crmentity.deleted=0";
if ($where != "") {
$query .= " WHERE ({$where}) AND " . $where_auto;
} else {
$query .= " WHERE " . $where_auto;
}
$log->debug("Exiting create_export_query method ...");
return $query;
}
/** function to get report query for the given module
* @ param $module : type String
* this returns join query for the given module
*/
function getReportsQuery($module)
{
global $log, $current_user;
$secondary_module = "'";
$secondary_module .= str_replace(":", "','", $this->secondarymodule);
$secondary_module .= "'";
if ($module == "Leads") {
$query = "from vtiger_leaddetails \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid \n inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid \n inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid \n inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid \n left join vtiger_groups as vtiger_groupsLeads on vtiger_groupsLeads.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0 and vtiger_leaddetails.converted=0";
} else {
if ($module == "Accounts") {
$query = "from vtiger_account \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid \n inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid \n inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid \n inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid \n left join vtiger_groups as vtiger_groupsAccounts on vtiger_groupsAccounts.groupid = vtiger_crmentity.smownerid\n left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid\n left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0 ";
} else {
if ($module == "Contacts") {
$query = "from vtiger_contactdetails\n inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid \n inner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid \n inner join vtiger_customerdetails on vtiger_customerdetails.customerid = vtiger_contactdetails.contactid\n inner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid \n inner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid \n left join vtiger_groups vtiger_groupsContacts on vtiger_groupsContacts.groupid = vtiger_crmentity.smownerid\n left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto\n left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid \n left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module == "Potentials") {
$query = "from vtiger_potential \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid \n inner join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid\n left join vtiger_account as vtiger_accountPotentials on vtiger_potential.related_to = vtiger_accountPotentials.accountid\n left join vtiger_contactdetails as vtiger_contactdetailsPotentials on vtiger_potential.related_to = vtiger_contactdetailsPotentials.contactid \n left join vtiger_campaign as vtiger_campaignPotentials on vtiger_potential.campaignid = vtiger_campaignPotentials.campaignid\n left join vtiger_groups vtiger_groupsPotentials on vtiger_groupsPotentials.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentity.smownerid \n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid \n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0 ";
} else {
if ($module == "Products") {
$query = "from vtiger_products \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid \n left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid \n left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_products.handler \n left join vtiger_vendor as vtiger_vendorRelProducts on vtiger_vendorRelProducts.vendorid = vtiger_products.vendor_id \n LEFT JOIN (\n SELECT vtiger_products.productid, \n (CASE WHEN (vtiger_products.currency_id = 1 ) THEN vtiger_products.unit_price\n ELSE (vtiger_products.unit_price / vtiger_currency_info.conversion_rate) END\n ) AS actual_unit_price\n FROM vtiger_products\n LEFT JOIN vtiger_currency_info ON vtiger_products.currency_id = vtiger_currency_info.id\n LEFT JOIN vtiger_productcurrencyrel ON vtiger_products.productid = vtiger_productcurrencyrel.productid\n AND vtiger_productcurrencyrel.currencyid = " . $current_user->currency_id . "\n ) AS innerProduct ON innerProduct.productid = vtiger_products.productid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module == "HelpDesk") {
$query = "from vtiger_troubletickets \n inner join vtiger_crmentity \n on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid \n inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid\n left join vtiger_crmentity as vtiger_crmentityRelHelpDesk on vtiger_crmentityRelHelpDesk.crmid = vtiger_troubletickets.parent_id\n left join vtiger_account as vtiger_accountRelHelpDesk on vtiger_accountRelHelpDesk.accountid=vtiger_crmentityRelHelpDesk.crmid \n left join vtiger_contactdetails as vtiger_contactdetailsRelHelpDesk on vtiger_contactdetailsRelHelpDesk.contactid= vtiger_crmentityRelHelpDesk.crmid\n left join vtiger_products as vtiger_productsRel on vtiger_productsRel.productid = vtiger_troubletickets.product_id \n left join vtiger_groups as vtiger_groupsHelpDesk on vtiger_groupsHelpDesk.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersHelpDesk on vtiger_crmentity.smownerid=vtiger_usersHelpDesk.id \n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id \n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0 ";
} else {
if ($module == "Calendar") {
$query = "from vtiger_activity \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid\n left join vtiger_activitycf on vtiger_activitycf.activityid = vtiger_crmentity.crmid\n left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid \n left join vtiger_contactdetails as vtiger_contactdetailsCalendar on vtiger_contactdetailsCalendar.contactid= vtiger_cntactivityrel.contactid\n left join vtiger_groups as vtiger_groupsCalendar on vtiger_groupsCalendar.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersCalendar on vtiger_usersCalendar.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid\n left join vtiger_activity_reminder on vtiger_activity_reminder.activity_id = vtiger_activity.activityid\n left join vtiger_recurringevents on vtiger_recurringevents.activityid = vtiger_activity.activityid\n left join vtiger_crmentity as vtiger_crmentityRelCalendar on vtiger_crmentityRelCalendar.crmid = vtiger_seactivityrel.crmid\n left join vtiger_account as vtiger_accountRelCalendar on vtiger_accountRelCalendar.accountid=vtiger_crmentityRelCalendar.crmid\n left join vtiger_leaddetails as vtiger_leaddetailsRelCalendar on vtiger_leaddetailsRelCalendar.leadid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_potential as vtiger_potentialRelCalendar on vtiger_potentialRelCalendar.potentialid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_quotes as vtiger_quotesRelCalendar on vtiger_quotesRelCalendar.quoteid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_purchaseorder as vtiger_purchaseorderRelCalendar on vtiger_purchaseorderRelCalendar.purchaseorderid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_invoice as vtiger_invoiceRelCalendar on vtiger_invoiceRelCalendar.invoiceid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_salesorder as vtiger_salesorderRelCalendar on vtiger_salesorderRelCalendar.salesorderid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_troubletickets as vtiger_troubleticketsRelCalendar on vtiger_troubleticketsRelCalendar.ticketid = vtiger_crmentityRelCalendar.crmid\n left join vtiger_campaign as vtiger_campaignRelCalendar on vtiger_campaignRelCalendar.campaignid = vtiger_crmentityRelCalendar.crmid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype != 'Emails')";
} else {
if ($module == "Quotes") {
$query = "from vtiger_quotes \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid \n inner join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid \n inner join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid\n left join vtiger_inventoryproductrel as vtiger_inventoryproductrelQuotes on vtiger_quotes.quoteid = vtiger_inventoryproductrelQuotes.id\n left join vtiger_products as vtiger_productsQuotes on vtiger_productsQuotes.productid = vtiger_inventoryproductrelQuotes.productid \n left join vtiger_service as vtiger_serviceQuotes on vtiger_serviceQuotes.serviceid = vtiger_inventoryproductrelQuotes.productid\n left join vtiger_quotescf on vtiger_quotes.quoteid = vtiger_quotescf.quoteid\n left join vtiger_groups as vtiger_groupsQuotes on vtiger_groupsQuotes.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager\n left join vtiger_potential as vtiger_potentialRelQuotes on vtiger_potentialRelQuotes.potentialid = vtiger_quotes.potentialid\n left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid\n left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module == "PurchaseOrder") {
$query = "from vtiger_purchaseorder \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid \n inner join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid \n inner join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid\n left join vtiger_inventoryproductrel as vtiger_inventoryproductrelPurchaseOrder on vtiger_purchaseorder.purchaseorderid = vtiger_inventoryproductrelPurchaseOrder.id\n left join vtiger_products as vtiger_productsPurchaseOrder on vtiger_productsPurchaseOrder.productid = vtiger_inventoryproductrelPurchaseOrder.productid \n left join vtiger_service as vtiger_servicePurchaseOrder on vtiger_servicePurchaseOrder.serviceid = vtiger_inventoryproductrelPurchaseOrder.productid\n left join vtiger_purchaseordercf on vtiger_purchaseorder.purchaseorderid = vtiger_purchaseordercf.purchaseorderid\n left join vtiger_groups as vtiger_groupsPurchaseOrder on vtiger_groupsPurchaseOrder.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentity.smownerid \n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid \n left join vtiger_vendor as vtiger_vendorRelPurchaseOrder on vtiger_vendorRelPurchaseOrder.vendorid = vtiger_purchaseorder.vendorid \n left join vtiger_contactdetails as vtiger_contactdetailsPurchaseOrder on vtiger_contactdetailsPurchaseOrder.contactid = vtiger_purchaseorder.contactid \n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n\t\t\t\twhere vtiger_crmentity.deleted=0";
} else {
if ($module == "Invoice") {
$query = "from vtiger_invoice \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid \n inner join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid \n inner join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid\n left join vtiger_inventoryproductrel as vtiger_inventoryproductrelInvoice on vtiger_invoice.invoiceid = vtiger_inventoryproductrelInvoice.id\n left join vtiger_products as vtiger_productsInvoice on vtiger_productsInvoice.productid = vtiger_inventoryproductrelInvoice.productid\n left join vtiger_service as vtiger_serviceInvoice on vtiger_serviceInvoice.serviceid = vtiger_inventoryproductrelInvoice.productid\n left join vtiger_salesorder as vtiger_salesorderInvoice on vtiger_salesorderInvoice.salesorderid=vtiger_invoice.salesorderid\n left join vtiger_invoicecf on vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid \n left join vtiger_groups as vtiger_groupsInvoice on vtiger_groupsInvoice.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n left join vtiger_account as vtiger_accountInvoice on vtiger_accountInvoice.accountid = vtiger_invoice.accountid\n left join vtiger_contactdetails as vtiger_contactdetailsInvoice on vtiger_contactdetailsInvoice.contactid = vtiger_invoice.contactid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module == "SalesOrder") {
$query = "from vtiger_salesorder \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid \n inner join vtiger_sobillads on vtiger_salesorder.salesorderid=vtiger_sobillads.sobilladdressid \n inner join vtiger_soshipads on vtiger_salesorder.salesorderid=vtiger_soshipads.soshipaddressid\n left join vtiger_inventoryproductrel as vtiger_inventoryproductrelSalesOrder on vtiger_salesorder.salesorderid = vtiger_inventoryproductrelSalesOrder.id\n left join vtiger_products as vtiger_productsSalesOrder on vtiger_productsSalesOrder.productid = vtiger_inventoryproductrelSalesOrder.productid \n left join vtiger_service as vtiger_serviceSalesOrder on vtiger_serviceSalesOrder.serviceid = vtiger_inventoryproductrelSalesOrder.productid\n left join vtiger_contactdetails as vtiger_contactdetailsSalesOrder on vtiger_contactdetailsSalesOrder.contactid = vtiger_salesorder.contactid\n left join vtiger_quotes as vtiger_quotesSalesOrder on vtiger_quotesSalesOrder.quoteid = vtiger_salesorder.quoteid\t\t\t\t\n left join vtiger_account as vtiger_accountSalesOrder on vtiger_accountSalesOrder.accountid = vtiger_salesorder.accountid\n left join vtiger_potential as vtiger_potentialRelSalesOrder on vtiger_potentialRelSalesOrder.potentialid = vtiger_salesorder.potentialid \n left join vtiger_invoice_recurring_info on vtiger_invoice_recurring_info.salesorderid = vtiger_salesorder.salesorderid\n left join vtiger_groups as vtiger_groupsSalesOrder on vtiger_groupsSalesOrder.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersSalesOrder on vtiger_usersSalesOrder.id = vtiger_crmentity.smownerid \n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid \n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module == "Campaigns") {
$query = "from vtiger_campaign\n inner join vtiger_campaignscf as vtiger_campaignscf on vtiger_campaignscf.campaignid=vtiger_campaign.campaignid \n inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_campaign.campaignid\n left join vtiger_products as vtiger_productsCampaigns on vtiger_productsCampaigns.productid = vtiger_campaign.product_id\n left join vtiger_groups as vtiger_groupsCampaigns on vtiger_groupsCampaigns.groupid = vtiger_crmentity.smownerid\n left join vtiger_users as vtiger_usersCampaigns on vtiger_usersCampaigns.id = vtiger_crmentity.smownerid\n left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . "\n where vtiger_crmentity.deleted=0";
} else {
if ($module != '') {
//fixing the bug of missing join to related tables
$focus = CRMEntity::getInstance($module);
$query = $this->generateReportsQuery($module);
if ($module == "Cashflow4You" && $this->secondarymodule == "Invoice") {
$query .= " left join its4you_cashflow4you_associatedto on its4you_cashflow4you_associatedto.cashflow4youid = vtiger_crmentity.crmid ";
}
$query .= $this->getRelatedModulesQuery($module, $this->secondarymodule);
if ($module == "Cashflow4You" && $this->secondarymodule == "Invoice") {
$query = str_replace("left join vtiger_invoice on its4you_cashflow4you.relationid=vtiger_invoice.invoiceid", "left join vtiger_invoice on its4you_cashflow4you.relationid=vtiger_invoice.invoiceid or its4you_cashflow4you_associatedto.cashflow4you_associated_id = vtiger_invoice.invoiceid", $query);
}
switch ($this->secondarymodule) {
//case "HelpDesk":
// $query .= " left join vtiger_ticketcomments on vtiger_ticketcomments.ticketid=vtiger_troubletickets.ticketid ";
// break;
case "Faq":
$query .= " left join vtiger_products as vtiger_productsfaq on vtiger_productsfaq.productid=vtiger_faq.product_id \n left join vtiger_faqcomments on vtiger_faqcomments.faqid=vtiger_faq.id ";
break;
}
$query .= getNonAdminAccessControlQuery($this->primarymodule, $current_user) . " WHERE vtiger_crmentity.deleted=0";
}
}
}
}
}
}
}
}
}
}
}
}
}
// ITS4YOU MaJu
if ($module == 'PriceBooks' && $this->secondarymodule == 'Products') {
$query = str_replace('left join vtiger_crmentity as vtiger_crmentityProducts', 'inner join vtiger_crmentity as vtiger_crmentityProducts', $query);
} elseif ($module == "Potentials" && $this->secondarymodule == "Contacts") {
$query = str_replace("left join vtiger_contactdetails as vtiger_contactdetailsPotentials on vtiger_potential.related_to = vtiger_contactdetailsPotentials.contactid", "left join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid\n left join vtiger_contactdetails as vtiger_contactdetailsPotentials on vtiger_contpotentialrel.contactid = vtiger_contactdetailsPotentials.contactid ", $query);
$query = str_replace("on vtiger_potential.related_to=vtiger_contactdetails.contactid", "on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid", $query);
}
// ITS4YOU-END
$log->info("ReportRun :: Successfully returned getReportsQuery" . $module);
$sdpos = strpos($query, "vtiger_crmentity" . $this->secondarymodule . ".");
if ($sdpos !== false) {
$query .= " AND vtiger_crmentity" . $this->secondarymodule . ".deleted= '0'";
}
$query .= " AND vtiger_crmentity.crmid= '" . $this->crmid . "'";
return $query;
}
请发表评论