{$current_date = waDateTime::format('date')} {function name="_renderChatTime" _date='' } {$message_date = waDateTime::format('date', $_date)} {$now = time()} {$your_date = strtotime($_date)} {$datediff = round(($now - $your_date) / (60 * 60 * 24))} {$now_year = waDateTime::date('Y', $now)} {$chat_date = substr($_date|wa_datetime:'humandatetime', 0, -5)} {$chat_date = str_replace($now_year, '', $chat_date)} {$week_day = date('N', $your_date)} {if $datediff > 1 && $datediff < 6} {$week_days = waDateTime::getWeekdayNames()} {$chat_date =$week_days[$week_day]} {/if} {if $current_date != $message_date}
{/if} {/function} {function name="_renderFromContact" _contact=[]} {$_contact.name|escape} {/function} {function _renderMessageBody message = []} {strip} {if !empty($message.body_formatted)} {$body_formatted = $message.body_formatted} {elseif !empty($message.body_sanitized)} {$body_formatted = $message.body_sanitized} {else} {$body_formatted = $message.body|escape|nl2br} {/if} {/strip} {/function} {$current_user_id = $wa->userId()} {if $message.transport == 'EMAIL'} {_renderChatTime _date = $message.create_datetime} {$message_date = waDateTime::format('date', $message.create_datetime)} {$current_date = $message_date} {$is_another_user = ($message.direction == crmMessageModel::DIRECTION_OUT && $message.creator_contact_id !== $current_user_id)} {if $message.direction == crmMessageModel::DIRECTION_OUT} {if isset($message.from_formatted)} {$_contact_name = $message.from_formatted} {else} {$_contact_name = $message.from|escape} {/if} {if !empty($contact)} {capture assign=_contact_name}{_renderFromContact _contact=$contact}{/capture} {/if} {/if} {elseif $message.transport == 'IM'} {_renderChatTime _date = $message.create_datetime} {$message_date = waDateTime::format('date', $message.create_datetime)} {$current_date = $message_date} {$_contact_name = null} {$is_another_user = ($message.direction == crmMessageModel::DIRECTION_OUT && $message.creator_contact_id !== $current_user_id)} {if $message.direction == crmMessageModel::DIRECTION_OUT} {if isset($message.from_formatted)} {$_contact_name = $message.from_formatted} {else} {$_contact_name = $message.from|escape} {/if} {if !empty($contact)} {capture assign=_contact_name}{_renderFromContact _contact=$contact}{/capture} {/if} {/if} {/if}