<?php 
	require "models/rivermedia.php";
	$rivermedia = new RIVERMEDIA;
	$rivermedia->auth();
	$rivermedia->edit_product();
?>

<form name="edit_product_form" id="edit_product_form" action="javascript:void(0);" method="post">
<div class="col-md-4 col-sm-4 col-xs-12" id="product_image_area" style="padding:0!important;">
 <iframe id="image_upload_frame" frameborder="0" scrolling="no" height="300" src="image_upload?guid=<?php echo str_replace("}", "", str_replace("{", "", $_SESSION['edit_product'][12])); ?>">
 
 
 </iframe>
<?php $rivermedia->image_upload(); ?>
 
 </div>
<div class="col-md-8 col-sm-8 col-xs-12">
  <div class="form-group">
    <div class="col-md-12 col-sm-12 col-xs-12">
      <label class="control-label" for="edit_product_name">Product name <span class="required">*</span> </label>
      <input type="text" id="edit_product_name" name="edit_product_name" required class="form-control col-md-7 col-xs-12" value="<?php echo $_SESSION['edit_product'][1]; ?>" >
    </div>
  </div>
  <div class="clearfix"></div>
  <br />
  <div class="form-group">
    <div class="col-md-12 col-sm-12 col-xs-12">
      <label class="control-label" for="edit_product_description">Product description </label>
      <textarea id="edit_product_description" maxlength="1000" class="form-control" name="edit_product_description"><?php echo $_SESSION['edit_product'][2]; ?></textarea>
      <h6 class="pull-right" id="edit_product_description_length">0/1000</h6>
    </div>
  </div>
</div>
<div class="form-group">
  <div class="col-md-3 col-sm-3 col-xs-12 pull-right">
    <label class="control-label" for="edit_select_media_type">Media type </label>
    <select name="edit_edit_select_media_type" id="edit_select_media_type" class="form-control">
      <?php $rivermedia->selectfield_media_type(); ?>
    </select>
  </div>
  <div class="col-md-4 col-sm-4 col-xs-12 pull-right">
    <label class="control-label" for="edit_select_media_origin">Media origin </label>
    <select name="edit_select_media_origin" id="edit_select_media_origin" class="form-control">
      <?php $rivermedia->selectfield_media_origin(); ?>
    </select>
  </div>
  <div class="col-md-3 col-sm-3 col-xs-12 pull-right">
    <label class="control-label" for="edit_select_media_event">Event </label>
    <select name="edit_select_media_event" id="edit_select_media_event" class="form-control">
      <option value="N/A">N/A</option>
      <?php $rivermedia->selectfield_event(); ?>
    </select>
  </div>
  <div class="clearfix"></div>
  <div class="ln_solid"></div>
  <div id="edit_cb_physmed" class="col-md-6 col-sm-6 col-xs-12">
    <div class="control-label pull-left"><b>Available on physical medium</b></div>
    <div class="clearfix"></div>
    <?php $rivermedia->selectfield_physical_medium(); ?>
    <div class="clearfix"></div>
    <input type="hidden" name="edit_arr_phys_med" id="edit_arr_phys_med" class="form-control" value="<?php echo $_SESSION['edit_product'][6]; ?>" />
    <br />
    <div>
        <label class="control-label" for="reference">Reference</label>
        <input type="text" class="form-control" id="edit_reference" name="edit_reference" maxlength="20" value="<?php echo $_SESSION['edit_product'][13]; ?>" />
    </div>
  </div>
  <div class="col-md-6 col-sm-6 col-xs-12">
    <div class="display_price_box" id="disp_price_wrapper">
      <h4>&nbsp;&nbsp;PRICING</h4>
      <div class="fa_tools"><a href="javascript:void(0);" data-toggle="tooltip" title="View&nbsp;price&nbsp;history"><i class="fa fa-history" aria-hidden="true"></i></a></div>
      <div class="clearfix"></div>
      <div class="ln_solid" style="margin-top:-7px;"></div>
      <div class="form-group col-md-6 col-sm-6 col-xs-12">
        <div>Price Ex VAT</div>
        <?php $priceArray = explode("|", $rivermedia->show_price()); ?>
        <div class="price_display" id="display_price_ex_vat">R<span><?php echo $priceArray[0]; ?></span></div>
      </div>
      <div class="form-group col-md-6 col-sm-6 col-xs-12">
        <div class="display_vat_rate_label">Price Inc <span></span> VAT</div>
        <div class="price_display" id="display_price_inc_vat">Calculating...</div>
      </div>
      <div class="clearfix"></div>
      &nbsp;&nbsp;
      <button type="button" class="btn btn-primary btn-xs" id="btn_change_price">Change Price</button>
      &nbsp;&nbsp;<span id="pricelastupdated">Last updated: <?php echo $priceArray[1]; ?></span> <br />
      <div id="add_new_price_popup" class="col-md-12 col-sm-12 col-xs-12">
        <div class="clearfix"></div>
        &nbsp;&nbsp;<button type="button" class="close" aria-hidden="true" style="right:-12px!important;">&times;</button>
        <div class="clearfix"></div>
        <div class="ln_solid" style="margin-top:-7px;"></div>
        &nbsp;&nbsp;<label class="control-label" for="new_price_ex_vat">New Price (excl VAT)<span class="required">*</span> </label>
        <div class="clearfix"></div>
        &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="new_price_ex_vat" name="new_price_ex_vat" data-thousands=" " data-decimal="." data-prefix="R " maxlength="10" placeholder="R 0.00" required style="width:200px; margin-left:16px;" class="form-control col-sm-6 col-md-6 col-xs-12 col-lg-6 col-xl-6 price_fields" value="R <?php echo $priceArray[0]; ?>" >
        <input type="hidden" name="pricecompare" id="pricecompare" value="R <?php echo $priceArray[0]; ?>" />
        <div class="clearfix"></div>
        <br />
        &nbsp;&nbsp;<button type="button" class="btn btn-success btn-xs" id="btn_save_price">Save</button>&nbsp;&nbsp;<span id="ajax_add_price"></span>
        <div class="clearfix"></div>
        <br />
        <div class="clearfix"></div>
      </div>
    </div>
    <div class="clearfix"></div>
    <h4>&nbsp;&nbsp;DIMENSIONS and WEIGHT</h4>
    <div class="form-group col-md-4 col-sm-4 col-xs-12">
      <label class="control-label" for="edit_width">Width (cm)</label>
      <input type="text" id="edit_width" name="edit_width" data-thousands=" " data-decimal="." data-prefix="" maxlength="7" placeholder="0.00" required value="<?php echo number_format((float)$_SESSION['edit_product'][7], 2, '.', ''); ?>" class="form-control col-md-12 col-xs-12 dimensions" >
    </div>
    <div class="form-group col-md-4 col-sm-4 col-xs-12">
      <label class="control-label" for="edit_height">Height (cm) </label>
      <input type="text" id="edit_height" name="edit_height" data-thousands=" " data-decimal="." data-prefix="" maxlength="7" placeholder="0.00" required value="<?php echo number_format((float)$_SESSION['edit_product'][8], 2, '.', ''); ?>" class="form-control col-md-12 col-xs-12 dimensions" >
    </div>
    <div class="form-group col-md-4 col-sm-4 col-xs-12">
      <label class="control-label" for="edit_depth">Depth (cm) </label>
      <input type="text" id="edit_depth" name="edit_depth" data-thousands=" " data-decimal="." data-prefix="" maxlength="7" placeholder="0.00" required value="<?php echo number_format((float)$_SESSION['edit_product'][9], 2, '.', ''); ?>" class="form-control col-md-12 col-xs-12 dimensions" >
    </div>
    <div class="form-group col-md-6 col-sm-6 col-xs-12">
      <label class="control-label" for="edit_weight">Weight (kg) </label>
      <input type="text" id="edit_weight" name="edit_weight" data-thousands=" " data-decimal="." data-prefix="" maxlength="7" placeholder="0.000000" required value="<?php echo $_SESSION['edit_product'][10]; ?>" class="form-control col-md-12 col-xs-12 weight" >
    </div>
  </div>
  <div class="clearfix"></div>
  <div class="ln_solid"></div>
  <div class="form-group col-md-3 col-sm-3 col-xs-12">
    <div class="checkbox checkbox-primary">
      <input name="edit_kids_item" id="edit_kids_item" type="checkbox" value="Y"<?php if ($_SESSION['edit_product'][11] === "Y") {echo " checked";}; ?>>
      <label for="edit_kids_item">Is this a kids' item?</label>
    </div>
    <div class="checkbox checkbox-primary">
      <input name="edit_dynamis_item" id="edit_dynamis_item" type="checkbox" value="Y"<?php if ($_SESSION['edit_product'][14] === "Y") {echo " checked";}; ?>>
      <label for="edit_dynamis_item">Dynamis product</label>
    </div>
  </div>

  <div class="col-md-9 col-sm-9 col-xs-12">
    <div class="form-group">
      <label class="control-label" for="edit_external_url_text">External link text </label>
      <input type="text" class="form-control" id="edit_external_url_text" name="edit_external_url_text" maxlength="30" value="<?php echo $_SESSION['edit_product'][15]; ?>" />
    </div>
    <div class="form-group">
      <label class="control-label" for="edit_external_url">External link url </label>
      <input type="text" class="form-control" id="edit_external_url" name="edit_external_url" maxlength="255" value="<?php echo $_SESSION['edit_product'][16]; ?>" />
    </div>
  </div>
                    
</div>
<input type="hidden" name="edit_vat_rate" id="edit_vat_rate" class="form-control" value="<?php echo $rivermedia->get_vat(); ?>" />
<input type="hidden" name="edit_product_id" id="edit_product_id" value="<?php echo $_SESSION['edit_product'][0]; ?>" />
<input type="hidden" name="edit_guid" id="edit_guid" value="<?php echo $_SESSION['edit_product'][12]; ?>"/>
<div class="clearfix"></div>
<div id="ajax_update_product" class=""></div>
<div id="statusmessage_success" class="status_messages">
  <?php if (isset($_SESSION['statusmessage_success'])) {echo "<i class=\"fa fa-check\"></i> ".$_SESSION['statusmessage_success']; unset($_SESSION['statusmessage_success']);};?>
</div>
<div id="statusmessage_fail" class="status_messages">
  <?php if (isset($_SESSION['statusmessage_fail'])) {echo "<i class=\"fa fa-times\"></i> ".$_SESSION['statusmessage_fail']; unset($_SESSION['statusmessage_fail']);};?>
</div>
<?php
unset($_SESSION['edit_product']);
unset($_SESSION['display_price']);
unset($_SESSION['status_message']);
?>
