SELECT sum( vtiger_cobropago.amount) as 'Soma Valor', sum(vtiger_cobropago.cost) as 'Soma Custos' , sum(vtiger_cobropago.benefit) as 'Soma Liquido',
COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)
FROM vtiger_cobropago INNER JOIN vtiger_crmentity ON vtiger_cobropago.cobropagoid = vtiger_crmentity.crmid LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid WHERE vtiger_crmentity.deleted=0 AND (( vtiger_crmentity.modifiedtime BETWEEN '2020-01-01 00:00:00' AND '2020-01-31 23:59:59') AND (( vtiger_cobropago.paid = '1') )) AND vtiger_cobropago.cobropagoid > 0 group BY COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)
Working in sql directly command, in mySQL but in SQL reports, not
01-30-2020, 12:22 AM (This post was last modified: 01-30-2020, 12:27 AM by rslemer.)
in payments I have tree user fields
created by
related user
assigned to
I do a link with modules, but user in modules not returned right
this command appears something wrong, field at cbemployees return null
SELECT vtiger_cobropago.reference, vtiger_cobropago.cyp_no, vtiger_cobropago.amount, vtiger_cobropago.cost, vtiger_cobropago.benefit, vtiger_cobropago.paid, vtiger_crmentity.smownerid, vtiger_cbemployeeparent_id.userid as cbemployeeuserid, vtiger_cobropago.comercialid, vtiger_crmentity.smcreatorid, vtiger_cbemployeeparent_id.nombre as cbemployeenombre, vtiger_crmentityparent_id.smownerid as smownercbemployee, vtiger_cobropago.cobropagoid FROM vtiger_cobropago INNER JOIN vtiger_crmentity ON vtiger_cobropago.cobropagoid = vtiger_crmentity.crmid LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT JOIN vtiger_users AS vtiger_usersreports_to_id ON vtiger_cobropago.comercialid = vtiger_usersreports_to_id.id LEFT JOIN vtiger_groups AS vtiger_groupsreports_to_id ON vtiger_cobropago.comercialid = vtiger_groupsreports_to_id.groupid LEFT JOIN vtiger_users AS vtiger_userscreated_user_id ON vtiger_crmentity.smcreatorid = vtiger_userscreated_user_id.id LEFT JOIN vtiger_groups AS vtiger_groupscreated_user_id ON vtiger_crmentity.smcreatorid = vtiger_groupscreated_user_id.groupid LEFT JOIN vtiger_cbemployee AS vtiger_cbemployeeparent_id ON vtiger_cbemployeeparent_id.cbemployeeid=vtiger_cobropago.parent_id LEFT JOIN vtiger_crmentity AS vtiger_crmentityparent_id ON vtiger_crmentityparent_id.crmid=vtiger_cobropago.parent_id WHERE vtiger_crmentity.deleted=0 AND vtiger_cobropago.cobropagoid > 0 ORDER BY CONCAT(vtiger_usersreports_to_id.first_name,' ',vtiger_usersreports_to_id.last_name) ASC
01-30-2020, 03:08 PM (This post was last modified: 01-30-2020, 03:38 PM by rslemer.)
All values in employee not return a any value in sql or in filter
example, assigned to in payments is the same in employee and my filter listing field both modules, but system returns only real values for one module ...
in image user, and valor considerado para meta return null, in query, but not correct...
correct user should be "João", "Maria", etc ... and in sql/filter always returned null
Perhaps, key of employes not a employeeid but is user (?)
I don't really understand what you are doing. If you want to match on assigned user on both modules, then compare the smownerid, not the parent_id
Sorry.