<link rel="stylesheet" href="<?php echo base_url()?>public/css/offer.css">


<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">


<style>
.toggle .head h3 {
    padding: 0 25px 0 0!important;
}
.hidden h3, .hidden h3:hover {
    background-image: url(../images/txl/chevron-down.png);
}
.ui-widget button, .ui-widget input, .ui-widget select, .ui-widget textarea, body *
{font-family: none;
}
</style>

<link rel="stylesheet" href="<?php echo base_url()?>public/css/editor.css">


<div id="content" style="margin-left:30px">
  				<div>
  					  					<h1 id="page-heading">
  						Create Offer  					</h1>
  					  					<div class="clear"></div>
  				</div>



<form class="offersForm" id="OffersAddForm" method="post" action="/cig/offer/add" >

<!--  <script src="<?php //echo base_url()?>public/ckeditor/ckeditor.js"></script><textarea class="form-control" name="edt"></textarea>  <input type="hidden" name="_method" value="POST"><input type="hidden" name="data[_Token][key]" value="29568441b963501ad1fbc510d047b423ca91ade0" id="Token730061176">-->
<!--<input type="hidden" name="data[Offer][similar_offer_id]" value="" id="OfferSimilarOfferId"><div class="toggle">-->
<!--    <!-- select2 assets -->
<!--<link rel="stylesheet" type="text/css" href="/assets/css/select2-3.4.3/select2.css?1512070608">-->
<!--<link rel="stylesheet" type="text/css" href="/assets/css/report-filters.min.css?1477423577">-->
<!--<script type="text/javascript" src="/assets/js/select2-3.4.3/select2.min.js?1477423577"></script>-->
<!--<script type="text/javascript" src="/assets/shared/js/underscore/underscore-min.js?1477423577"></script>-->
<!--<script type="text/javascript" src="/assets/js/jquery.mousewheel.min.js?1477423577"></script>-->
<script src="<?php echo base_url()?>public/ckeditor/ckeditor.js"></script>
<div class="form grid_12">
	<div class="head">
		<h3 class="toggle">Details</h3>
	</div>
	<div class="body">
		<ol>
                        <li id="divAdvertiser">
                <label for="aid">Advertiser:</label>
                                <select name="aid"  class="select_large" id="aid" required>
								<option value=""></option>
								<?php
								foreach($advertiser as $avalue)
										{
											$adv_comp=$avalue['comp'];
											$adv_id=$avalue['id'];
											echo "<option value='$adv_id'>$adv_comp</option>";
										}
										?>

								</select>
                        </li>
						<li id="divName">
				<label for="aname">Name:</label>
				<input name="aname" type="text" class="input_big" value="" id="aname">			</li>
			<li id="divDescription">
				<label for="desc">Description:</label>
<!--				<textarea id="txtEditor" class="textarea_big"></textarea>		-->
                             <textarea name="desc" class="textarea_big" cols="35" id="txtEditor"></textarea>

							

            </li>

			<li id="divPreviewUrl">
				<label for="purl">Preview URL:</label>
				<input name="purl" type="text" class="input_large" value="" id="purl">				<p>Link to landing page with no geotargeting so Affiliates can see landing page example.</p>
			</li>

			<li id="divOfferUrl">
				<label for="ourl">Default Offer URL:</label>
				<input name="ourl" type="text" class="input_large" value="" id="ourl">								<span id="enableMatFields" class="matField" style="display: none;">
					<label for="enableMat" class="cbn">
						<input type="checkbox" name="enableMat" id="enableMat">
							Optimize TMC redirect					</label>
					<span id="matPrompt">
						<i class="fa fa-times"></i>
						You're using a TMC measurement URL. Check the box above to optimize your offer URL and reduce the redirect time. <a href="http://support.hasoffers.com/hc/en-us/articles/202441213-MobileAppTracking#network-creates-offer" target="_blank">Read our support article on TMC integration to learn more.</a>					</span>
				</span>
								<p>The Offer URL where traffic will be directed to. You must specify at least the Default Offer URL. The optional variables below can be used in Offer URLs. <a id="toggle-learn"  href="#">Learn More</a></p>
			</li>
			<li id="openlearnblock" style="display:none;">
				<label for="OfferOfferUrl">Optional Variables:</label>
				<p id="divAffiliateID">Affiliate ID: Add {affiliate_id} in the Offer URL and it will be replaced by the ID of the Affiliate promoting the offer.</p>
<p id="divAffiliateID">Affiliate Name: Add {affiliate_name} in the Offer URL and it will be replaced by the name of the Affiliate promoting the offer.</p>
<p id="divAffiliateSource">Affiliate Source: Add {source} in the Offer URL and it will be replaced by the value of Affiliate Source passed in via an affiliate tracking link.</p>

<p id="divAffiliateSubID">Affiliate Sub: Add {aff_sub} in the Offer URL and it will be replaced by the value of Affiliate Sub passed in via an affiliate tracking link.</p>
<p id="divAffiliateSubID">Affiliate Sub 2: Add {aff_sub2} in the Offer URL and it will be replaced by the value of Affiliate Sub passed in via an affiliate tracking link.</p>
<p id="divAffiliateSubID">Affiliate Sub 3: Add {aff_sub3} in the Offer URL and it will be replaced by the value of Affiliate Sub passed in via an affiliate tracking link.</p>
<p id="divAffiliateSubID">Affiliate Sub 4: Add {aff_sub4} in the Offer URL and it will be replaced by the value of Affiliate Sub passed in via an affiliate tracking link.</p>
<p id="divAffiliateSubID">Affiliate Sub 5: Add {aff_sub5} in the Offer URL and it will be replaced by the value of Affiliate Sub passed in via an affiliate tracking link.</p>

<p id="divAffiliateClickID">Affiliate Click ID: Add {aff_click_id} in the Offer URL and it will be replaced by the value of Affiliate Click ID passed in via an affiliate tracking link.</p>
<p id="divAffiliateUnique1">Affiliate Unique 1: Add {aff_unique1} in the Offer URL and it will be replaced by the value of Affiliate Unique 1 passed in via an affiliate tracking link.</p>
<p id="divAffiliateUnique2">Affiliate Unique 2: Add {aff_unique2} in the Offer URL and it will be replaced by the value of Affiliate Unique 2 passed in via an affiliate tracking link.</p>
<p id="divAffiliateUnique3">Affiliate Unique 3: Add {aff_unique3} in the Offer URL and it will be replaced by the value of Affiliate Unique 3 passed in via an affiliate tracking link.</p>
<p id="divAffiliateUnique4">Affiliate Unique 4: Add {aff_unique4} in the Offer URL and it will be replaced by the value of Affiliate Unique 4 passed in via an affiliate tracking link.</p>
<p id="divAffiliateUnique5">Affiliate Unique 5: Add {aff_unique5} in the Offer URL and it will be replaced by the value of Affiliate Unique 5 passed in via an affiliate tracking link.</p>

<p id="divOfferID">Offer ID: Add {offer_id} in the Offer URL and it will be replaced by the ID of the Offer.</p>
<p id="divOfferID">Offer Name: Add {offer_name} in the Offer URL and it will be replaced by the name of the Offer.</p>
<p id="divOfferURLID">Offer URL ID: Add {offer_url_id} in the Offer URL and it will be replaced by the ID of the Offer URL used.</p>
<p id="divOfferURLID">File ID: Add {offer_file_id} in the Offer URL and it will be replaced by the ID of the Offer File used.</p>
<p id="divOfferURLID">File Name: Add {file_name} in the Offer URL and it will be replaced by the name of the Creative File used.</p>

<p id="divAdvertiserID">Advertiser ID: Add {advertiser_id} in the Offer URL and it will be replaced by the ID of the Advertiser of the offer.</p>
<p id="divCountryCode">Country Code: Add {country_code} in the Offer URL and it will be replaced by the user's country code (ISO 2-letter code, i.e. US).</p>
<p id="divCountryCode">Region Code: Add {region_code} in the Offer URL and it will be replaced by the user's region code (ISO 2-letter code, i.e. NY).</p>
<p id="divCustomVariableOption">Custom Variables: Add {params} in the Offer URL if the Custom Variables option above is enabled. {params} will be replaced by the extra variables passed by the Affiliate into the affiliate tracking link.</p>
<p id="divTransactionID">Transaction ID: Add {transaction_id} in the Offer URL to send a unique transaction number to the Advertiser. Use this when trying to verify individual leads, to enable cookieless client-based tracking, or when server response tracking is required.</p>
<p id="divdate">Date: Add {date} in the Offer URL and it will be replaced by current date formatted as YYYY-MM-DD.</p>
<p id="divdate">Time: Add {time} in the Offer URL and it will be replaced by current time formatted as HH:MM:SS.</p>
<p id="divdatetime">Date Time: Add {datetime} in the Offer URL and it will be replaced by current date and time formatted as YYYY-MM-DD HH:MM:SS.</p>
<p id="divip">IP: Add {ip} in the Offer URL and it will be replaced by IP address of the user clicking on the tracking link.</p>

<p id="divOfferReferenceID">Offer Reference ID: Add {offer_ref} in the Offer URL and it will be replaced by the Reference ID of the offer.</p>
<p id="divAffiliateReferenceID">Affiliate Reference ID: Add {affiliate_ref} in the Offer URL and it will be replaced by the Reference ID of the Affiliate promoting the offer.</p>
<p id="divAdvertiserrReferenceID">Advertiser Reference ID: Add {advertiser_ref} in the Offer URL and it will be replaced by the Reference ID of the Advertiser of the offer.</p>

			</li>
						<li id="divMatUrl" class="matField" style="display: none;">
				<label>TMC Server Side Click URL:</label>
				<input type="text" readonly="" name="clurl" id="clurl" class="input_large">
			</li>

			<script type="text/javascript">
			
			$(document).ready(function() {
				$('#toggle-OfferUrl-Replace-Options').click(function(){
					$('#OfferUrl-Replace-Options').toggle();
					$("#OfferUrl-Replace-Options").show();
					return false;
				});
			});
			if ( $("#OfferIsSeoFriendly301").length > 0 ) {
				$("#OfferIsSeoFriendly301").change(function(){
					if ( $(this).val() == 1 ) {
						$("#divOfferUrlReplaceOptions").hide();
					} else {
						$("#divOfferUrlReplaceOptions").show();
					}
				}).change();
			}
			</script>

			<li id="liProtocol">
				<label for="ctr">Conversion Tracking:</label>
								<select name="ctr" class="select_lrg valid" id="ctr">
<!--<option value="http">HTTP iFrame Pixel</option>
<option value="https">HTTPS iFrame Pixel</option>-->
<option value="http_img">HTTP Image Pixel</option>
<option value="https_img">HTTPS Image Pixel</option>
<option value="server">Server Postback w/ Transaction ID</option>
<!--<option value="server_affiliate">Server Postback w/ Affiliate ID</option>-->
</select>				                <p id="ProtocolWarning" style="display:none;color:red;font-weight:bold;">Warning: Modifying the tracking protocol could invalidate all current offer conversion pixels created by affiliates.</p>
				<p>iFrame and Image conversion pixels use client-based cookie or cookieless tracking while Server Postback uses server-based cookieless tracking URLs.&nbsp;<a id="toggle-Protocol-Notes" href="#">Learn More</a></p>
				<p id="Protocol-Notes" style="display:none;">Type of conversion tracking. HTTP and HTTPS iFrame conversion tracking pixels use client-based tracking using cookies (recommended tracking options). If HTTPS iFrame is selected, all affiliates pixels for the offer are required to be HTTPS. HTTP and HTTPS Image conversion tracking pixels allow your network to track conversions using client-based cookie tracking. If Image conversion tracking pixels are selected, affiliates can specify postback URLS that servers will call on conversion (these affiliate postback URLs cannot require cookies since its server-based).  Cookieless iFrame and Image conversion tracking can be enabled by adding the {transaction_id} param to the Offer Url and providing that Transaction Id in the Tracking URL.  For cookieless tracking via server calls to URLs, select one of two Postback tracking options. Postback with Transaction ID enable the advertiser to pass back only a unique Transaction ID to record conversions. All affiliate tracking information, affiliate source and affiliate subs, will be stored with the Transaction ID and registered with each conversion. Postback with Affiliate Info enable the advertiser to pass back the Affiliate ID to recorded conversions. The advertiser can pass back affiliate source and any of the affiliate subs, but they must maintain this information. For Server Postback tracking options, affiliates can specify postback URLS that servers will call on conversion. Mobile App Postback is specifically designed for tracking installs of applications for mobile devices including iPhone and Android app installs.</p>
			</li>
			<script type="text/javascript">
			$(document).ready(function() {
			   $('#toggle-Protocol-Notes').click(function(){
			     $('#Protocol-Notes').toggle();
			     return false;
			   });
			});
			</script>

			<li id="liMatProtocol" style="display:none;">
				<label for="MatProtocol">Conversion Tracking:</label>
				<select id="MatProtocol">
					<option>Server Postback w/ Transaction ID</option>
				</select>
			</li>

			<li id="divStatus">
				<label for="status">Status:</label><br>
				<select name="status" class="select_med" id="status">
				<option value="active">Active</option>
				<option value="paused">Paused</option>
				<option value="pending" selected="selected">Pending</option>
				<option value="deleted">Deleted</option>
				</select> 
				<p>
				Active allows all Affiliates to view the offer. Pending allows the offer to be tested as if it were active except Affiliates won't be able to see it. Conversion pixels can be tested with the pending status. Paused removes the offer for Affiliates to view and redirects traffic to the redirect offer if set. Deleted causes all jump links to return dead.
				</p>
			</li>
			
			<li id="divExpirationDate">
				<label for="om">Expiration Date:</label><br>
				<select name="om" class="select_sm" id="om" style="width:50px">
				<option value="01" selected="selected">January</option>
				<option value="02">February</option>
				<option value="03">March</option>
				<option value="04">April</option>
				<option value="05">May</option>
				<option value="06">June</option>
				<option value="07">July</option>
				<option value="08">August</option>
				<option value="09">September</option>
				<option value="10">October</option>
				<option value="11">November</option>
				<option value="12">December</option>
				</select>
				
				<select name="od" class="select_sm" id="od" style="width:50px">
				<option value="01">1</option>
				<option value="02">2</option>
				<option value="03" selected="selected">3</option>
				<option value="04">4</option>
				<option value="05">5</option>
				<option value="06">6</option>
				<option value="07">7</option>
				<option value="08">8</option>
				<option value="09">9</option>
				<option value="10">10</option>
				<option value="11">11</option>
				<option value="12">12</option>
				<option value="13">13</option>
				<option value="14">14</option>
				<option value="15">15</option>
				<option value="16">16</option>
				<option value="17">17</option>
				<option value="18">18</option>
				<option value="19">19</option>
				<option value="20">20</option>
				<option value="21">21</option>
				<option value="22">22</option>
				<option value="23">23</option>
				<option value="24">24</option>
				<option value="25">25</option>
				<option value="26">26</option>
				<option value="27">27</option>
				<option value="28">28</option>
				<option value="29">29</option>
				<option value="30">30</option>
				<option value="31">31</option>
				</select>				
				
				<select name="oy" class="select_sm" id="oy" style="width:50px">
				<option value="2018">2018</option>
				<option value="2019" selected="selected">2019</option>
				<option value="2020">2020</option>
				<option value="2021">2021</option>
				<option value="2022">2022</option>
				<option value="2023">2023</option>
				</select>				
				
				<p>Offer will expire at 11:59 pm of selected date.</p>
			</li>

				<li id="divCategories">
					<label for="OffersOfferCategory">Categories:</label>
					<select name="cat"  class="select_large" id="aid">
					<option value=""></option>
					<?php
						foreach($category as $cvalue)
						{
							$cat_name=$cvalue['cat'];
							$cat_id=$cvalue['id'];
							echo "<option value='$cat_id'>$cat_name</option>";
						}
					?>

					</select>
					<p>Categorize offer for Affiliates to search and group by.</p>
				</li>
			
				<li id="divRefId">
					<label for="refid">Reference ID:</label>
					<input name="refid" type="text" class="input_big" value="" id="refid">					
					<p>Assign a reference ID to this offer and pass this value into Offer URLs.</p>
				</li>
				<li id="divNote">
					<label for="onote">Note:</label>
					<textarea name="onote" class="textarea_big" cols="35" rows="8" id="onote"></textarea>					
					<p>The contents of this note will not be displayed to Affiliates</p>
				</li>
					</ol>

		
	<div class="clear"></div>
	</div>
</div>

</div>


<div class="clear"></div>
<div class="form-footer grid_12 " style="margin: 0 400px 20px;">
    
	<button type="submit" id="addOffer"  onlick="postForm()" class="btn btn-info">Add Offer</button>
</div>
</form>
<script type="text/javascript">
//$(document).ready(function(){
//    $('#addOffer').click(function(){
//        if(typeof window['Intercom'] !== "undefined"){
//            Intercom('trackEvent','offer-create');
//        }

//    });
//});
//<script type="text/javascript">
    // $(document).ready(function() {
        // $('#txtEditor').textarea_big({
            // height: "500px"
        // });
    // });
var postForm = function() {
    var content = $('textarea[name="desc"]').html($('#txtEditor').code());
}
</script>
<script>CKEDITOR.replace('desc');</script>


  				  				<div class="clear"></div>
</div>
