<?php

$admin = 'campaign'; 
include ($PATH . 'globals/globals.php');
$adminAct = $_REQUEST['adminAct']; 

$fieldArray = array('campid','camp_date','camp_type','camp_name','camp_desc','camp_contacts','display','date_updated');
$excludeArray = array('camp_date','date_updated');

if ($adminAct == 'new') {
		
	$op = 'add';
	$editInpID = '<input type="hidden" name="op" value="'. $op .'" />'; 
	foreach($fieldArray as $value) { 
		if ($value == 'display')
			$$value = 1;
		elseif ($value == 'date_updated')
			$$value = $today;
		else 	
			$$value = '';
	}
	$subBtn = 'Add Campaign'; 
	$modalTitle = 'Create New Campaign';
} else {
	$op = '';
	$editID = $_REQUEST['editID']; 
	$editInpID = '<input type="hidden" name="campid" value="'. $editID .'" />';
		
	$query = 'SELECT * FROM marketing_campaigns WHERE campid=' . $editID; 
	$result = $con->query($query);
		
	while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
		foreach($fieldArray as $value) { 
			if ($value == 'date_updated')
				$$value = $today;
			else
				$$value = $row[''. $value .''];
		}
		if ($adminAct == 'react') {
			$op = 'react';
			$delConfirm = "";
			$subBtn = 'Reactivate Campaign';
			$modalTitle = 'Reactivate Campaign: '. $camp_name;
		} elseif ($adminAct == 'edit') {
			$op = 'edit';
			$delConfirm = ""; 
			$subBtn = 'Save Changes';
			$modalTitle = 'Edit Campaign: '. $camp_name;
		} elseif ($adminAct == 'delete') {
			$op = 'delete';
			$delConfirm = ' onSubmit="return sure()"';
			$subBtn = 'Deactivate Campaign';
			$modalTitle = 'Delete Campaign: '. $camp_name . '?';
		}
	}
}
$campaignTypes = get_campaignTypes($camp_type,$con);
$campContacts = get_campContacts($camp_contacts,$con);
	
include('form/campaign.php');

?>