| Current Path : /home2/wtmwscom/public_html/member/ |
| Current File : /home2/wtmwscom/public_html/member/task_today.php |
<?php
$title = "Todays Task";
include 'header.php';
$uid = $_SESSION['userid'];
$plan_type = $_SESSION['plan_type'];
$user = mysqli_fetch_object(mysqli_query($connection, "SELECT uid, date(reg_date) AS reg_date, type, plan_type, is_paid, hold_payment, block_task FROM user WHERE uid = '$uid'"));
//include_once('lib/ps_pagination.php');
$holiday_array = array("2017-01-26" => "Repblic day holiday", "2017-02-24" => "Maha Shivaratri holiday", "2017-04-05" => "Ram Navmi holiday");
$today_day = date('l');
$today_date = date('Y-m-d');
/*if($user->is_paid==0){
$date_today = new DateTime($today_date);
$date_reg = new DateTime($user->reg_date);
$free_task_expire = $date_today->diff($date_reg)->format("%a") > 5 ? TRUE : FALSE;
}*/
$current_time = DateTime::createFromFormat('H:i:s', date('H:i:s'));
$start_time = DateTime::createFromFormat('H:i:s', "00:00:00");
$end_time = DateTime::createFromFormat('H:i:s', "01:00:00");
if ($user->block_task == 1) {
setMessage("Tasks could not be assigned. Thankyou!", 'alert-msg success');
$isTaskStop = TRUE;
}elseif ($user->is_paid==0) {
setMessage("Free Id's tasks could not be assigned. Thankyou!", 'alert-msg success');
$isTaskStop = TRUE;
}elseif ($today_day == "Sunday" || $today_day == "Saturday") {
setMessage("Today is $today_day. Thankyou!", 'alert-msg success');
$isTaskStop = TRUE;
} elseif (array_key_exists($today_date, $holiday_array)) { // check current time inbetween 12am and 3am
setMessage("Today is " . $holiday_array[$today_date] . ". Thankyou!", 'alert-msg success');
$isTaskStop = TRUE;
} elseif ($current_time > $start_time && $current_time < $end_time) { // check current time inbetween 12am and 3am
setMessage("Your task starts from 1:00 AM. Thankyou!", 'alert-msg success');
$isTaskStop = TRUE;
} else {
$isTaskStop = FALSE;
$result = mysqli_query($connection, "SELECT e1.* FROM campaign_user e1 WHERE e1.uid = '$uid' AND date(e1.datetime) = '" . date('Y-m-d') . "'");
if (mysqli_num_rows($result) == 0) {
insert_today_task($uid);
}
$sql = "SELECT e1.id AS campaign_user_id, e1.uid as uid, e1.status as status, e2.id as campaign_id, e2.page_title as page_title,"
. " e2.page_url as page_url, e2.page_description as page_description FROM campaign_user e1 INNER JOIN campaign e2 ON e1.campaign_id = e2.id WHERE e1.uid = '$uid' AND date(e1.datetime) = '" . date('Y-m-d') . "'";
$result1 = mysqli_query($connection, $sql);
}
?>
<h1>Today's Promotion</h1>
<?php echo getMessage(); ?>
<section>
<?php if (!$isTaskStop) : ?>
<form method="post" action="campaign_user_status_bulk.php">
<table style="width: 100%;">
<thead>
<tr>
<th>S. No.</th>
<?php if ($plan_type >= 4) : ?><th>Check</th><?php endif; ?>
<th>Page Title</th>
<th>Page URL</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
//$rs = mysqli_fetch_object($result1);
while ($row = mysqli_fetch_object($result1)) {
?>
<tr <?php
if ($i % 2) {
echo "class='light'";
} else {
echo "class='dark'";
}
?>>
<td><?php echo $i; ?></td>
<?php if ($plan_type >= 4) : ?>
<td>
<input type="checkbox" class="id_list" name="id_list[]" onchange="checkSelectedCounter(this)" value="<?php echo $row->campaign_user_id; ?>" disabled="disabled" style="width: auto;" />
</td>
<?php endif; ?>
<td title="<?php echo $row->page_description; ?>"><?php echo $row->page_title; ?></td>
<td> <a href="<?php echo $row->page_url; ?>" target="_blank"><?php echo $row->page_url; ?></a> </td>
<td><?php if ($row->status == 0) echo "Pending"; elseif ($row->status == 1) echo "Viewed"; elseif ($row->status == 2) echo "Skipped"; ?></td>
<td><?php if ($row->status == 0) { ?>
<input type="button" onclick="updateCampaignStatus(<?php echo $row->campaign_user_id ?>, 1, '<?php echo $row->page_url; ?>')" value="View" />
<!-- <button onclick="updateCampaignStatus(<?php echo $row->campaign_user_id ?>, 2, '<?php echo $row->page_url; ?>')">Skip</button>-->
<?php } ?></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
<div class="row">
<!-- <a href="javascript:;" onclick="$('.id_list').attr({'checked':true})">Select All</a>-->
<?php //if ($plan_type >= 4) : ?> <!--<input type="submit" name="submit" value="View selected campaigns" class="btn btn-success" /> --><?php //endif; ?>
</div>
</form>
<?php endif; ?>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Please wait ...</h4>
</div>
<div class="modal-body">
<h1 id="countdown" style="text-align: center; color: red; font-size: larger">
</h1>
<!-- <img src="images/product/popUp2.jpg" width="550" />-->
<!--<p>No Cutting till 31st May 2016</p>-->
</div>
</div>
</div>
</div>
</section>
<script>
function updateCampaignStatus(campaign_user_id, status, page_url) {
//var r = confirm("Do you want to view link has record id " + campaign_user_id);
var r = true;
$('#myModal').modal({backdrop: "static"});
processCountDown();
if (r) {
$.post("campaign_user_status.php", {campaign_user_id: campaign_user_id, status: status, }, function(data) {
//alert(data);
//$( "#myModal" ).dialog( "open" );
//location.reload();
});
}
if (status == 1) {
//var win = window.open(page_url, '_blank');
var win = window.open(page_url);
win.focus();
}
}
var countDownSecond = 5;
// get tag element
var countdown = document.getElementById('countdown');
// update the tag with id "countdown" every 1 second
function processCountDown() {
setInterval(function() {
// format countdown string + set tag value
countdown.innerHTML = '<span class="seconds">' + countDownSecond + ' </span>';
if (countDownSecond == 0) {
//alert(" clearInterval() called")
$('#myModal').modal('hide');
clearInterval();
location.reload();
}
countDownSecond = countDownSecond - 1;
}, 1000);
}
var idListCounter = 0;
var maxCheckLimit = 10;
function checkSelectedCounter(thisObj) {
if (idListCounter >= maxCheckLimit) {
$(thisObj).prop("checked", false);
alert("You can select maximum " + maxCheckLimit + " ads in one shot!");
} else {
idListCounter += 1;
}
// if(idListCounter < maxCheckLimit && $(thisObj).prop("checked")){
// idListCounter +=1;
// } else if(! $(thisObj).prop("checked")) {
// idListCounter -=1;
// }
//alert(" counter"+idListCounter);
}
</script>
<?php include 'footer.php'; ?>