<?PHP 

include("config.php");

if(!is_admin($user)){
  header('Location:'.$site_url.'/');
}

$campaign_idhere = mysql_escape_string($_GET[campaign_id]);
$results = mysql_query("SELECT * FROM io_campaign WHERE campaign_id=".$campaign_idhere." LIMIT 1");
$row = mysql_fetch_array($results);
if (!$row){header('Location: '.$site_url.'/?error=invalid_id');}

// set the page title
$pagetitle = $row[campaign_advertiser];

// set meta tags

?>

<? include("include_common_head.php"); ?>

<body class="listings">
  <? include($common_path . "/ads/ad_wallpaper.html"); ?>

  <div class="container">
    <? include($common_path . "/templates/include_header.php"); ?>
    <div class="main">
      <div class="contentwrapper clearfix">
        <? include("include_breadcrumb.php"); ?>

        <section class="section listings section-has-widgets section-static remove-sidebar">
          <div class="sidebar-b">
            <? include("include_sidebar.php"); ?>
          </div>

          <div class="content content-has-widgets">
            <div class="grid">

              <div class="clearfix">
                <h1 class="float-left">Campaigns: Individual Campaigns</h1>
                <? if ($user) { ?>
                <form method="post" action="campaign_edit.php?campaign_id=<? echo $row[campaign_id] ?>">
                  <input type="submit" value="Edit" class="nobutton btn btn-white float-right">
                </form>
                <? } ?>
                <a href="" class="btn btn-white float-right">Back</a>
                <hr class="line" />
                <div class="details grid">
                  <div class="col-6-12">
                    <h2><? echo stripslashes(stripslashes($row[campaign_name])) ; echo " "; ?></h2>
                  </div>
                  <div class="col-6-12 address">
                  </div>
                  <div class="col-6-12 contact">
                    
                  </div>
                  <div class="clearfix"></div>
                  
                  <br />
                  <div class="col-1-1">
                    <? include("include_buttons.php"); ?>
                  </div>
                  <div class="col-1-1 detail-block">
                    <h3>Advertiser</h3>
                    <div class="highlight-block">
                      <? 
                      	$acc_results = mysql_query("SELECT * FROM io_account WHERE account_id = '".$row[campaign_account_id_fk]."' LIMIT 1");
                      	$acc_row = mysql_fetch_array($acc_results);	
                      ?>
                      Advertiser: <? echo stripslashes(htmlspecialchars($acc_row[account_advertiser])); ?>
                      <br />
                      Primary Contact: <? echo stripslashes(htmlspecialchars($acc_row[account_contact])); ?>
                      <br />
                      Email: <a href="mailto:<? echo $acc_row[account_email]; ?>"><? echo stripslashes(htmlspecialchars($row[account_email])); ?></a><br />
                      Phone: <? echo stripslashes(htmlspecialchars($row[account_phone])); ?>
                    </div>
                  </div>
                  <div class="col-1-1 detail-block">
                    <h3>Ad Units</h3>
                    <div class="highlight-block">
                     <? 
                       if ($row[campaign_300x250] == 1) { echo ("300x250: ".$row[campaign_300x250_impression]."<br />"); }
                       if ($row[campaign_728x90] == 1) { echo ("728x90: ".$row[campaign_728x90_impression]."<br />"); }
                       if ($row[campaign_300x600] == 1) { echo ("300x600: ".$row[campaign_300x600_impression]."<br />"); }
                       if ($row[campaign_970x250] == 1) { echo ("970x250: ".$row[campaign_970x250_impression]."<br />"); }
                       if ($row[campaign_wallpaper] == 1) { echo ("wallpaper: ".$row[campaign_wallpaper_impression]."<br />"); }
      				 ?>
                    </div>
                  </div>
                  <div class="col-1-1 detail-block">
                    <h3>Campaign Dates</h3>
                    <div class="highlight-block">
                     <? 
                       echo ("Start Date: ".date_format(date_create($row[campaign_date]), 'Y-m-d')."<br />");
      				   echo ("Repeat Date: ".date_format(date_create($row[campaign_date_repeat]), 'Y-m-d')."<br />"); 
      				 ?>
                    </div>
                  </div>
                  <div class="col-1-1 detail-block">
                    <h3>Campaign Status</h3>
                    <div class="highlight-block">
                      <strong>Signed: </strong><? if (isset($row[campaign_signature_timestamp]) && $row[campaign_signature_timestamp] != "" && $row[campaign_signature_timestamp] != 0) { echo "Yes, by: ".$row[campaign_signature]." on: ".date_format(date_create($row[campaign_signature_timestamp]), 'Y-m-d')."<br />";} else { echo "No<br />"; } ?>
                      <strong>Deployed: </strong><? if (isset($row[campaign_deploy_timestamp]) && $row[campaign_deploy_timestamp] != "" && $row[campaign_deploy_timestamp] != 0) { echo "Yes, on: ".date_format(date_create($row[campaign_deploy_timestamp]), 'Y-m-d')."<br />";} else { echo "No<br />"; } ?>
                      <strong>Screenshot: </strong><? if (isset($row[campaign_screenshot_timestamp]) && $row[campaign_screenshot_timestamp] != "" && $row[campaign_screenshot_timestamp] != 0) { echo "Yes, on: ".date_format(date_create($row[campaign_screenshot_timestamp]), 'Y-m-d')."<br />";} else { echo "No<br />"; } ?>
                      <strong>Invoice: </strong><? if (isset($row[campaign_invoice_timestamp]) && $row[campaign_invoice_timestamp] != "" && $row[campaign_invoice_timestamp] != 0) { echo "Yes, on: ".date_format(date_create($row[campaign_invoice_timestamp]), 'Y-m-d')."<br />";} else { echo "No<br />"; } ?>
                      <strong>Active or Archived: </strong><? 	
						$temp[] = $row[campaign_archive];
						foreach($temp as $value) {
							if ($value == "0") echo ("Active");
							if ($value == "1") echo ("Archived on ".date_format(date_create($row[campaign_archive_timestamp]), 'Y-m-d')."<br />");
						}; 
					  ?>      
                    </div>
                  </div>
                  <div class="col-1-1 detail-block">
                    <h3>Campaign Notes</h3>
                    <div class="highlight-block">
                      <strong>Notes:</strong> <? echo stripslashes(htmlspecialchars($row[campaign_notes])); ?><br />
                    </div>
                  </div>
                </div>

                <div class="content-divider-bottom"></div>
                <? include ('comments_show.php'); ?>

              </div><!-- end col-2/3 -->

            </div><!-- end grid -->
          </div><!-- end content -->
        </section>

      </div><!-- end contentwrapper -->
    </div> <!-- end main -->

  <? include($common_path . "/templates/include_footer.php") ?>
  </div> <!-- container  -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>
