/**
  * 	fillInTemplate
  *
  * 	fills the template with object data
  *
  * @param object $template
  * 	email template
  * @param string $object
  * 	object type
  *
  * @return object
  * 	the filled template
  */
 function fillInTemplate($template, $object)
 {
     if (!is_object($object)) {
         $template->body = str_replace('{messagebody}', $object, $template->body);
     } else {
         $fields = get_object_vars($object);
         foreach ($fields as $fname => $fvalue) {
             $value = (EasyContactFormsUtils::endsWith($fname, 'date') || EasyContactFormsUtils::endsWith($fname, 'deadline')) && is_numeric($fvalue) ? EasyContactFormsUtils::getDate($fvalue) : $fvalue;
             if (isset($template->ishtml) && $template->ishtml) {
                 $value = nl2br('' . $value);
             }
             if (isset($template->body)) {
                 $fldcheck = EasyContactFormsBackOffice::fldTemplateReplace($template->body, $fname, $value);
                 if (!$fldcheck) {
                     $template->body = str_replace('{' . $fname . '}', $value, $template->body);
                 } else {
                     $template->body = $fldcheck;
                 }
             }
             if (isset($template->subject)) {
                 $fldcheck = EasyContactFormsBackOffice::fldTemplateReplace($template->subject, $fname, $value);
                 if (!$fldcheck) {
                     $template->subject = str_replace('{' . $fname . '}', $value, $template->body);
                 } else {
                     $template->subject = $fldcheck;
                 }
             }
         }
     }
     return $template;
 }