Hello,
who can make this sql to v6 espocrm :
As you see.. some data is Hard coded .. .other come from search front-end
Thanks
@Yuri ?
who can make this sql to v6 espocrm :
As you see.. some data is Hard coded .. .other come from search front-end
PHP Code:
$sql = "SELECT c.national_number as cNationalNumber, s.type as sType, m.name as mName, m.date_start as mDateStart,
MOD(TIME_FORMAT(SEC_TO_TIME(s.seconds), '%H'),24) as hours,
TIME_FORMAT(SEC_TO_TIME(s.seconds), '%i') as minutes,
a.name as aName, a.billing_address_postal_code as aPostalCode, a.billing_address_city as aCity, cm.status as cmAccept, c.first_name as cFirstName, c.last_name as cLastName
FROM meeting m
LEFT JOIN contact_meeting cm ON cm.meeting_id = m.id
LEFT JOIN contact c on c.id = cm.contact_id
LEFT JOIN specification s ON m.id = s.entity_id
LEFT JOIN account a on a.id = m.account_id
WHERE m.deleted='0' AND cm.deleted='0' AND c.deleted='0' AND s.deleted='0'";
// isNotLinked, currentMonth, ...
foreach($data->where as $key){
if ($key->type == 'in')
{
$sql .= " AND ( m." .Util::toUnderScore($key->attribute) ." IN ( '" .implode("', '", $key->value) ."' ) )";
}
if ($key->type == 'between'){
$sql .= " AND ( m." .Util::toUnderScore($key->attribute) ." BETWEEN '" .$key->value[0] ."' AND '" .$key->value[1] ."' )";
}
}
$sql .= " GROUP BY c.national_number, s.type, m.name,m.type, s.seconds, m.date_start, hours, minutes, a.name, a.billing_address_postal_code , a.billing_address_city, cm.status, c.first_name, c.last_name ";
$sql .= "ORDER BY m.date_start ASC;";
@Yuri ?
Comment