<?php include_once APP_PATH.'template/business/tplblocks/header.php';?>

<form method="post" class="jak_form" action="<?php echo $_SERVER['REQUEST_URI'];?>" enctype="multipart/form-data">
  <div class="container">
    <div class="row">
      <?php if ($limitreached) { ?>
        <div class="col-md-12">
          <div class="alert alert-info"><?php echo sprintf($jkl['hd115'], '<a href="'.JAK_rewrite::jakParseurl(JAK_CLIENT_URL).'">'.JAK_rewrite::jakParseurl(JAK_CLIENT_URL).'</a>');?></div>
        </div>
      <?php } else { ?>
        
        <div class="col-md-4">

          <div class="card card-profile no-transition" style="width: 20rem;">
            <div class="card-cover" style="background-image: url('<?php echo BASE_URL;?>/template/business/img/card-project4.jpg')">
            </div>
            <div class="card-avatar border-white">
              <a href="#avatar">
                <img src="<?php echo BASE_URL.JAK_FILES_DIRECTORY.(!empty($jakclient->getVar("picture")) ? $jakclient->getVar("picture") : '/standard.jpg');?>" alt="<?php echo (!empty($jakclient->getVar("name")) ? $jakclient->getVar("name") : $jkl['g51']);?>">
              </a>
            </div>
            <div class="card-body">
              <h4 class="card-title"><?php echo $jkl['hd157'];?></h4>
              <p><?php echo sprintf($jkl['hd158'], (!empty($jakclient->getVar("name")) ? $jakclient->getVar("name") : $jkl['g51']));?></p>
              <hr>

              <div class="form-group">
                <label for="content-editor"><?php echo $jkl['hd102'];?></label>
                <select name="jak_depid" id="jak_depid" class="form-control">
                  <option value="0"><?php echo $jkl['hd102'];?></option>
                  <?php foreach ($DEPARTMENTS_ALL as $d) {
                    echo '<option value="'.$d["id"].'">'.$d["title"].'</option>';
                  } ?>
                </select>
              </div>

              <div class="form-group" id="ticketpriority">
                <label for="email"><?php echo $jkl['hd12'];?></label>
                <select name="jak_priority" id="prioirty" class="form-control">
                </select>
              </div>

              <div class="form-group" id="ticketoption">
                <label for="email"><?php echo $jkl['hd98'];?></label>
                <select name="jak_toption" id="toption" class="form-control">
                </select>
              </div>

              <div class="form-group">
                <?php if (JAK_TICKET_PRIVATE_SHOW == 1) { ?>
                  <label for="email"><?php echo $jkl['hd109'];?></label>
                  <select name="jak_private" id="jak_private" class="form-control">
                    <option value="1"<?php if ((isset($_REQUEST["jak_private"]) && $_REQUEST["jak_private"] == 1) || (!isset($_REQUEST["jak_private"]) && JAK_TICKET_PRIVATE == 1)) echo ' selected';?>><?php echo $jkl["g72"];?></option>
                    <option value="0"<?php if ((isset($_REQUEST["jak_private"]) && $_REQUEST["jak_private"] == 0) || (!isset($_REQUEST["jak_private"]) && JAK_TICKET_PRIVATE == 0)) echo ' selected';?>><?php echo $jkl["g73"];?></option>
                  </select>
                <?php } else { ?>
                  <input type="hidden" name="jak_private" value="<?php echo JAK_TICKET_PRIVATE;?>">
                <?php } ?>
              </div>

              <div id="custom_fields"></div>

              <button type="submit" class="btn btn-lg btn-block btn-success" id="sendTM"><?php echo $jkl['hd108'];?> <i id="loader" class="fa fa-spinner fa-pulse"></i></button>
            </div>
          </div>
        </div>
        <div class="col-md-8">
          <br>
          <div class="card no-transition">
            <div class="card-body">
              <h4 class="card-title"><?php echo $jkl['hd47'];?></h4>
              <hr>
              <?php if (isset($paymsg) && !empty($paymsg)) { ?>
                <div class="message"><?php echo $paymsg;?></div>
              <?php } ?>

              <?php if ($errors) { ?>
                <div class="alert alert-danger alert-with-icon" data-notify="container">
                  <div class="container">
                    <div class="alert-wrapper">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <i class="fa fa-times"></i>
                      </button>
                      <div class="message"><?php if (isset($errors) && !empty($errors)) foreach ($errors as $e) { echo $e; }?></div>
                    </div>
                  </div>
                </div>
              <?php } ?>

              <?php if (isset($NEW_TICKET_HELP) && !empty($NEW_TICKET_HELP)) foreach ($NEW_TICKET_HELP as $th) { ?>

                <p><button class="btn btn-outline-info btn-sm btn-block faq-newticket" type="button" data-toggle="collapse" data-target="#newtickethelp<?php echo $th["id"];?>" aria-expanded="false" aria-controls="newtickethelp<?php echo $th["id"];?>">
                  <i class="<?php echo $th["icon"];?>"></i>
                  <?php echo $th["title"];?>
                </button></p>

                <div class="collapse" id="newtickethelp<?php echo $th["id"];?>">
                  <div class="card card-body no-transition">
                    <?php echo $th["content"];?>
                  </div>
                </div>

            <?php } if (isset($NEW_TICKET_HELP) && !empty($NEW_TICKET_HELP)) { ?>

              <hr>

            <?php } ?>

            <div class="form-group">
              <label for="subject"><?php echo $jkl['hd7'];?></label>
              <input type="text" class="form-control<?php if (isset($errors["e"])) echo " is-invalid";?>" maxlength="200" name="subject" id="subject" value="<?php if (isset($_REQUEST["subject"]) && !empty($_REQUEST["subject"])) echo $_REQUEST["subject"];?>">
            </div>

            <div id="similarArticle" style="display: none">
              <div class="card bg-info">
                <div class="card-body">
                  <h4 class="card-title"><?php echo $jkl['hd132'];?></h4>
                  <p><?php echo $jkl['hd133'];?></p>
                  <div id="loadsimArticle"></div>
                </div>
              </div>
            </div>

            <?php if (!JAK_CLIENTID) { ?>
              <div class="form-group">
                <label for="ntname"><?php echo $jkl['g4'];?></label>
                <input type="text" class="form-control<?php if (isset($errors["name"])) echo " is-invalid";?>" maxlength="100" name="name" id="ntname" value="<?php if (isset($_REQUEST["name"]) && !empty($_REQUEST["name"])) echo $_REQUEST["name"];?>">
              </div>

              <div class="form-group">
                <label for="ntemail"><?php echo $jkl['g5'];?></label>
                <input type="text" class="form-control<?php if (isset($errors["email"])) echo " is-invalid";?>" maxlength="200" name="email" id="ntemail" value="<?php if (isset($_REQUEST["email"]) && !empty($_REQUEST["email"])) echo $_REQUEST["email"];?>">
              </div>

              <div class="form-check">
                <label class="form-check-label">
                  <input class="form-check-input" type="checkbox" name="createaccount" value="1" checked<?php if (JAK_TICKET_ACCOUNT) echo ' disabled';?>> <?php echo $jkl["hd118"];?>
                  <span class="form-check-sign">
                    <span class="check"></span>
                  </span>
                </label>
              </div>
              <?php if (JAK_TICKET_ACCOUNT) { ?>
              <input type="hidden" name="createaccount" value="1">
              <?php } ?>

              <?php if (!empty(JAK_RECAP_CLIENT) && !JAK_CLIENTID) { ?>
                <div class="g-recaptcha my-3 ml-0" data-sitekey="<?php echo JAK_RECAP_CLIENT;?>"></div>
              <?php } ?>

            <?php } ?>

            <div class="form-group">
              <label for="content-editor"><?php echo $jkl['hd90'];?></label><br>
              <textarea name="content" id="content-editor" rows="5" class="form-control<?php if (isset($errors["subject"])) echo " is-invalid";?>"><?php if (isset($_REQUEST["content"]) && !empty($_REQUEST["content"])) { echo $_REQUEST["content"]; } else if (isset($JAK_EDIT_CONTENT) && !empty($JAK_EDIT_CONTENT)) { echo $JAK_EDIT_CONTENT;} else if (isset($JAK_PRE_CONTENT) && !empty($JAK_PRE_CONTENT)) { echo $JAK_PRE_CONTENT;}?></textarea>
            </div>

            <?php if ($uploadactive) { ?>
              <p><?php echo $jkl['hd117'];?></p>
              <div id="share-attachments" class="dropzone upload-ticket"></div>
              <span class="text-muted"><small><?php echo sprintf($jkl['hd168'], JAK_ALLOWED_FILES);?></small></span>
              <div class="clearfix"></div>
            <?php } ?>

          </div>
        </div>

        <input type="hidden" name="action" value="send_ticket">

      </div>
      
      
    <?php } ?>
  </div>
</div>
</form>

<?php include_once APP_PATH.'template/business/tplblocks/footer.php';?>
