<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=marketorders.ajax.sendmsg,marketorders.ajax.seller_check_order
 * [END_COT_EXT]
 */

defined('COT_CODE') or die('Wrong URL');

if ($tid > 0)
{
  require_once cot_incfile('mavatars', 'plug');

	$mavatar = new mavatar('marketorders', 'msg', $tid, 'edit', array(), $tid_to);
	$mavatar->update();
	$mavatar->upload();

  $mavatars_tags = $mavatar->tags();

  if(count($mavatars_tags) > 0) {
    $extramessage .= '<div class="track-files">';
    foreach($mavatars_tags as $mavtg) {
      $mavtg['FILEEXTICON'] = 'doc';
      if(cot_mavatar_is_photo($mavtg['FILEEXT'])) {
        $mavtg['FILEEXTICON'] = 'image';
      } elseif(cot_mavatar_is_audio($mavtg['FILEEXT'])) {
        $mavtg['FILEEXTICON'] = 'audio';
      } elseif($mavtg['FILEEXT'] == 'zip' || $mavtg['FILEEXT'] == 'rar') {
        $mavtg['FILEEXTICON'] = 'zip';
      }
      $extramessage .= '<div class="mb5 file-item">
                <a href="'.$mavtg['FILE'].'" target="_blank" class="dib color-text" style="width: calc(100% - 35px);">
                 <i class="ico-file-'.$mavtg['FILEEXTICON'].' dib v-align-m"></i>
                 <span class="v-align-m ml10 mw80p dib">'.$mavtg['FILEORIGNAME'].'.'.$mavtg['FILEEXT'].'</span>
                </a>
                <a href="" class="remove-file-link" onclick="deleteTrackFile($(this), '.$mavtg['ID'].', '.$tid.');return false;"></a>
               </div>';
    }
    $extramessage .= '</div>';
  }
}
