| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/onesupportdemo.onesolution.hk/job/views/ |
Upload File : |
<?php
session_start();
//clear session
unset($_SESSION['period']);
unset($_SESSION['targetdate']);
unset($_SESSION['customer_id']);
$allow_edit_mode = true;
//$allow_edit_mode = false;
/*
if (Util::isAdmin()) { // admin
$allow_edit_mode = true;
} else {
if (empty($job['id'])) { // new job
$allow_edit_mode = true;
} else {
if ($job['type'] == 4) { // remote service call
$allow_edit_mode = true;
}
}
}*/
$sql = "SELECT column_name FROM information_schema.columns WHERE table_schema = (SELECT DATABASE()) AND table_name = ?";
$parameters = array('sup_job_detail');
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}
$columns = $sth->fetchAll();
$defaultJobDetail = array();
foreach ($columns as $column) {
$column = $column['column_name'];
$defaultJobDetail[$column] = null;
}
$defaultJobDetail = array_merge($defaultJobDetail, array(
'status' => 1, // Open
'job_id' => $job['id'],
));
$sql5 = "select * from sup_task_category where deleted = 0 order by sort ASC";
if (!($sth5 = $dbh->prepare($sql5))) {
throw new Exception("sql prepare statement failure: $sql5");
}
if (!$sth5->execute()) {
throw new Exception("sql execute statement failure: $sql5");
}
$task_categories = $sth5->fetchAll();
$sql5 = "select * from sup_job_detail where deleted = 0 and job_id = ?";
if (!($sth5 = $dbh->prepare($sql5))) {
throw new Exception("sql prepare statement failure: $sql5");
}
if (!$sth5->execute(array($job['id']))) {
throw new Exception("sql execute statement failure: $sql5");
}
$job_detail = $sth5->fetchAll();
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ng="http://angularjs.org">
<head>
<?php require(__DIR__ . '/../../inc/_head_meta.php'); ?>
<?php require(__DIR__ . '/../../inc/_head_css.php'); ?>
<style type="text/css">
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
padding-bottom: 40px;
}
#showweek td{
text-align: center;
}
</style>
<?php require(__DIR__ . '/../../inc/_head_script.php'); ?>
<script type="text/javascript">
function JobDetailControl($scope) {
function resetModel() {
$.extend($scope, <?=json_encode($defaultJobDetail)?>);
}
resetModel();
$.extend($scope, {
addDetail: function () {
$scope.details.push({
<?php
// Example: title: $scope.title, remarks: $scope.remarks...
$tmp_values = array();
foreach ($defaultJobDetail as $key => $value) {
$tmp_values[] = $key.': $scope.'.$key;
}
echo implode(', ', $tmp_values);
?>
});
resetModel();
},
removeDetail: function (index) {
var detail = $scope.details[index];
if (!detail.id) {
$scope.details.splice(index, 1);
}
},
details: [ <?=isset($json_details) ? implode(', ', $json_details) : ''?> ],
});
}
function scrollToId(id) {
var $root = $('html, body'),
$body = $('body'),
$e = $('#' + id);
var paddingTop = $body.css('padding-top');
paddingTop = parseInt(paddingTop, 10);
paddingTop = isNaN(paddingTop) ? 0 : paddingTop;
$root.animate({
scrollTop: $e.offset().top - paddingTop
}, 500);
}
</script>
<script type="text/javascript">
function generate_date_list(rate) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("date_list").innerHTML = xmlhttp.responseText;
//recall the timepicker function
$('#actual_start_time, #actual_end_time, #start_time, #end_time, #call_time, .time').change(function (event) {
var $this = $(this),
val = $this.val();
if (val && val.length && val.length == 4) {
var number = parseInt(val, 10);
if (!isNaN(number)) {
$this.val([val.slice(0, 2), ':', val.slice(2)].join(''));
event.preventDefault();
$this.trigger('change');
}
}
});
<?php if ($job['status'] == 1): // open ?>
$('.date-picker').datetimepicker({ pickTime: false });
$('.date-picker').datetimepicker({ pickTime: false }).on('changeDate', function(ev){
updateweek( document.getElementById("period").value);
});
$('.time-picker').datetimepicker({ pickDate: false, pickSeconds: false });
<?php else: ?>
var $form = $('#form');
$('input, textarea, select', $form).prop('disabled', true);
<?php endif; ?>
//$('.select2').select2();
<?php if ($job['status'] == 1 && !Util::isAdmin() && $allow_edit_mode): ?>
$('#staff_id').select2('readonly', true);
$('#staff_id').select2('enable', true);
<?php endif; ?>
$('#form').validate();
}
}
var date_from = document.getElementById("date_from").value;
var date_to = document.getElementById("date_to").value;
var period = document.getElementById("period").value;
var frequency = document.getElementById("frequency").value;
if(date_from == "" || date_to == "" || period == "" || frequency == ""){
alert("Date From / Date To / Period / Frequency should not be empty!");
return;
}
var start_time_daily = document.getElementById("start_time_daily").value;
var end_time_daily = document.getElementById("end_time_daily").value;
//daily
//var data = "date_from=" + date_from + "&date_to=" + date_to+ "&period=" + period+ "&frequency=" + frequency;
if(period == "2" || period == "3"){
var selected_week = getSelectedChbox(this.form);
if(selected_week == "null" || selected_week == ""){
alert("Week should not be empty!");
return;
}
var start_time_weekly = [];
var end_time_weekly = [];
//console.log(selected_week);
for (var index_week = 0; index_week < selected_week.length; ++index_week) {
// var start_time_weekly_value = document.getElementById("start_time_weekly"+selected_week[index_week]).value;
// var end_time_weekly_value = document.getElementById("end_time_weekly"+selected_week[index_week]).value;
// if(start_time_weekly_value.length > 0){
// start_time_weekly.push(document.getElementById("start_time_weekly"+selected_week[index_week]).value);
// }
//
// if(end_time_weekly_value.length > 0){
// end_time_weekly.push(document.getElementById("end_time_weekly"+selected_week[index_week]).value);
// }
start_time_weekly.push(document.getElementById("start_time_weekly"+selected_week[index_week]).value);
end_time_weekly.push(document.getElementById("end_time_weekly"+selected_week[index_week]).value);
}
}
if(period == "3"){
var whichweek = document.getElementById("whichweek").value;
}
var customer_id = document.getElementById("customer_id").value;
xmlhttp.open("GET", "views/generate_date_list.php?date_from=" + date_from + "&date_to=" + date_to+ "&period=" + period+ "&frequency=" + frequency+"&selected_week=" + selected_week + "&start_time_weekly=" + start_time_weekly + "&end_time_weekly=" + end_time_weekly+"&whichweek=" + whichweek+"&customer_id=" + customer_id+"&start_time_daily=" + start_time_daily+"&end_time_daily=" + end_time_daily, true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function updateweek(periodnum){
var loopnum = document.getElementById("totalloop"+periodnum).value;
for(var i =0; i<loopnum; i++){
//alert(i);
var getdate = document.getElementById("date_"+i).value; //YYYY-MM-DD
var dateitem = getdate.split("-");
for(var j = 0; j<=2; j++){
dateitem[j] = parseInt(dateitem[j], 10);
}
//var newjdate = dateitem[1]+"/"+dateitem[2]+"/"+dateitem[0];
var d = new Date();
d.setDate(dateitem[2]);
d.setFullYear(dateitem[0]);
d.setMonth(dateitem[1]-1);
var weekday=new Array(7);
weekday[0]="Sun";
weekday[1]="Mon";
weekday[2]="Tue";
weekday[3]="Wed";
weekday[4]="Thu";
weekday[5]="Fri";
weekday[6]="Sat";
var _week = weekday[d.getDay()];
//alert(_week);*/
document.getElementById("week_"+i).innerHTML = _week;
}
}
</script>
<script>
function check_contract_calls(customer_id){
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("remain_calls").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","views/check_contract_calls.php?customer_id="+customer_id,true);
xmlhttp.send();
}
</script>
<script>
function get_teacher_info(id) {
//alert("Id selected is : " + id);
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
console.log(Object.entries(xmlhttp.responseText));
//$("#is_project").show();
//
//$result = xmlhttp.responseText;
//document.getElementById("project_list").innerHTML = xmlhttp.responseText;
var Data = JSON.parse(xmlhttp.responseText);
console.log(Data[0].staff_tel_no);
$("#staff_tel_no").val(Data[0].staff_tel_no);
}
}
xmlhttp.open("GET","views/getInfo.php?id="+id+"&actionCode=teacher" ,true);
xmlhttp.send();
};
function get_customer_id(customer_id) {
//alert(customer_id);
//var xmlhttp;
//if (window.XMLHttpRequest)
//{// code for IE7+, Firefox, Chrome, Opera, Safari
// xmlhttp=new XMLHttpRequest();
//}
//else
//{// code for IE6, IE5
// xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
//}
//xmlhttp.onreadystatechange=function()
//{
// if (xmlhttp.readyState==4 && xmlhttp.status==200)
// {
// if(xmlhttp.responseText == "0"){
// $("#is_project").hide();
// $(".belong_job").css("display", "inline-block");
// $(".belong_job").attr('disable', false);
//
// }else{
// $("#is_project").show();
//
// document.getElementById("project_list").innerHTML = xmlhttp.responseText;
//
// $('.select3').select2();
//
// }
// }
//}
//xmlhttp.open("GET","views/check_project.php?customer_id="+customer_id,true);
//xmlhttp.send();
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
console.log(Object.entries(xmlhttp.responseText));
//if(xmlhttp.responseText == "0"){
// $("#is_project").hide();
// $(".belong_job").css("display", "inline-block");
// $(".belong_job").attr('disable', false);
//
//}else{
// $("#is_project").show();
//
//$result = xmlhttp.responseText;
// document.getElementById("project_list").innerHTML = xmlhttp.responseText;
//
// $('.select3').select2();
//
//}
var Data = JSON.parse(xmlhttp.responseText);
//console.log(Data);
//console.log(Data[0].company_name);
$("#location").val(Data[0].billaddress);
$("#email1").val(Data[0].email);
$("#contact_person").val(Data[0].contact_person);
$("#contact_tel_no").val(Data[0].tel_no);
}
}
xmlhttp.open("GET","views/getInfo.php?id="+customer_id+"&actionCode=customer" ,true);
xmlhttp.send();
}
</script>
<?php if($_SESSION['webadmin']['role'] == 2 || $_SESSION['webadmin']['role'] == 3){?>
<script type="text/javascript">
$(function(){
$('.belong_project').css( 'display', 'none');
$('.belong_job').css( 'display', 'inline-block');
$('#more_days').hide();
$('#date_list2').show();
});
</script>
<?php } ?>
<script type="text/javascript">
$(function(){
$("#default_not_project").trigger("click");
});
</script>
<script type="text/javascript">
function isEmpty(str) {
return (!str || 0 === str.length);
}
<?php if($_SESSION['webadmin']['role'] != 1){ ?>
function check_form(){
var form_ok = true, error_msg = "";
if (isEmpty($("#actual_start_time").val())) {
form_ok = false;
error_msg += "Actual Start Time should not be empty.\n\n";
}
if (isEmpty($("#actual_end_time").val())) {
form_ok = false;
error_msg += "Actual End Time should not be empty.\n\n";
}
if(!check_email1()){
form_ok = false;
}
if( form_ok ){
$("#form").submit();
}else{
alert(error_msg);
}
}
<?php }else{ ?>
function check_form(){
$("#form").submit();
}
<?php } ?>
$(function () {
$('#other_staff_id').select2();
$("#other_staff_id").on("click", function () {
if($("#staff_id").val() == ""){
alert("Please select a staff first.");
$("#other_staff_id").select2("val", "");
}
});
function get_suggested_num(){
var call_num = 0;
var day_type = $("#day_type:checked").val();
var staff_id = $("#staff_id").val();
var other_staff_id = $("#other_staff_id").val();
if(day_type != "" && staff_id != ""){
if(other_staff_id != "" && other_staff_id != null){
var other_staff_count = other_staff_id.length;
}else{
var other_staff_count = 0;
}
call_num = (1+other_staff_count)*day_type;
$("#suggested_num_of_call").text(call_num);
<?php if (empty($job['id'])){ ?>
$("#call_num").val(call_num);
<?php } ?>
}
}
$("#day_type, #staff_id, #other_staff_id").on("change", function () {
get_suggested_num();
});
get_suggested_num();
})
</script>
</head>
<body>
<?php require(__DIR__ . '/../../inc/_navbar.php'); ?>
<div class="container">
<?php if (isset($message) && !empty($message)): ?>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<h5 class="alert-heading">Note:</h5>
<p><?= $message ?></p>
</div>
<?php endif; ?>
<?php if (isset($_SESSION["clash_job_array"]) && !empty($_SESSION["clash_job_array"])): ?>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<h5 class="alert-heading">Note:</h5>
<p>Job number:
<?php
foreach($_SESSION["clash_job_array"] as $key => $clash_job_array){
echo "<br>"."<a href='../job/modifyform.php?id=".$_SESSION["clash_job_id_array"][$key]."' target='_blank'>".$clash_job_array."</a>";
}
?>
<br><br>CLASH this added/modified Job!!
</p>
</div>
<?php endif; ?>
<?php if (empty($job['id'])): ?>
<h2>Add Job</h2>
<?php else: ?>
<div class="hidden">
<div class="control-group pull-right">
<div class="controls">
<code>Status: <?= h($statusOptions[$job['status']]) ?></code>
<?php //if (Util::isAdmin()): ?>
<?php if ($job['status'] == 1 && Util::isAdmin() && Job::allow_change_status_to_confirm($job['id'])): ?>
<button type="button" id="confirm_btn" class="btn btn-warning">Close</button>
<?php endif; ?>
<?php if ($job['status'] != 1 && Util::isAdmin()): ?>
<button type="button" id="reopen_btn" class="btn btn-warning">Reopen</button>
<?php endif; ?>
<?php if ($job['status'] == 1 && Util::isAdmin()): ?>
<button type="button" id="void_btn" class="btn btn-danger">Void</button>
<?php endif; ?>
<?php //endif; ?>
</div>
</div>
<?php if (Util::isAdmin()): ?>
<div style="display:none">
<form id="status_form" action="status.php" method="post">
<?php $attribute = 'id'; ?>
<input type="hidden" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>"/>
<?php $attribute = 'status'; ?>
<input type="hidden" id="status_form_<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>"/>
</form>
</div>
<script type="text/javascript">
$(function () {
var isDirty = false;
function changeStatus(statusText, status) {
if (isDirty) {
bootbox.alert('The form changed data, please save first or reopen this page.');
} else {
var message = 'Are you sure to change job status to ' + statusText + '? <br><br><span style="color: red;">Please make sure you have saved all changes before change the job status.</span>';
bootbox.confirm(message, 'No', 'Yes', function (result) {
if (result) {
$('#status_form_status').val(status);
$('#status_form').submit();
}
});
}
}
$('#confirm_btn').click(function (event) {
event.preventDefault();
changeStatus('CLOSE', '2');
});
$('#reopen_btn').click(function (event) {
event.preventDefault();
changeStatus('OPEN', '1');
});
$('#void_btn').click(function (event) {
event.preventDefault();
changeStatus('VOID', '3');
});
var value = null;
$('#form').on('focus', 'input, textarea, select', function () {
value = $(this).val();
});
$('#form').on('blur, change', 'input, textarea, select', function () {
if ($(this).val() != value) {
isDirty = true;
}
});
});
</script>
<?php endif; ?>
<button type="button" class="btn btn-link pull-right" onclick="scrollToId('goto_details')">Go to Tasks</button>
</div>
<h2 id="goto_top">
Edit Job: #<?= h($job['id']) ?>
</h2>
<?php endif; ?>
<form id="form" class="form-horizontal" method="post">
<?php if(!empty($job['id'])){ ?>
<?php $attribute = 'id'; ?>
<input type="hidden" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>"/>
<?php } ?>
<div class="control-group">
<?php $attribute = 'customer_id';
$label = 'Customer'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<?php
if(isset($_GET["contract_id"])){
$this_customer_id = (int)$_GET["customer_id"];
}else{
$this_customer_id = $job[$attribute];
}
?>
<?php if(empty($job["project_id"])){ ?>
<select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>" class="required select2"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> <?php if(Util::isAdmin()) echo'onchange="get_customer_id(this.value);"' ?>>
<option value=""></option>
<?php foreach ($customers as $customer): ?>
<option value="<?= h($customer['cust_id']) ?>"<?= $customer['cust_id'] == $this_customer_id ? ' selected="selected"' : '' ?> data-value="<?=h($customer['email_support'])?>"><?= $customer['enable'] == 1 ? '' : '[Disabled] ' ?><?= h($customer['company_name']) ?></option>
<?php endforeach; ?>
</select>
<?php }else{ ?>
<select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>" class="required select2" disabled="disabled" onchange="get_customer_id(this.value);">
<option value=""></option>
<?php foreach ($customers as $customer): ?>
<option value="<?= h($customer['cust_id']) ?>"<?= $customer['cust_id'] == $this_customer_id ? ' selected="selected"' : '' ?> data-value="<?=h($customer['email_support'])?>"><?= $customer['enable'] == 1 ? '' : '[Disabled] ' ?><?= h($customer['company_name']) ?></option>
<?php endforeach; ?>
</select>
<?php } ?>
<!-- ajax and get the contract call result-->
<?php if($allow_edit_mode && Util::isAdmin()){ ?>
<div class="hidden">
<div onclick="check_contract_calls($('#customer_id :selected').val())" class="btn belong_job" style="margin-top: 15px;">
Check Contract Calls
</div>
<div id="remain_calls">
</div>
</div>
<?php } ?>
<br>
<?php if(!empty($job['id'])){ ?>
<a href="../customer/view.php?id=<?=$job["customer_id"]?>" target="_blank"/>View Customer</a>
<?php } ?>
</div>
</div>
<?php $attribute = 'is_project';
$label = 'Is Project?'; ?>
<div class="control-group" id="<?=$attribute?>" style="display: none;">
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls" style="padding-top: 5px;">
<?php /*if (!empty($job['id'])): ?>
<input type="radio" name="<?=$attribute?>" value="99" <?php if(h($job[$attribute]) == "99") echo "checked"?> <?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> style="margin: 0;" onclick="$('.belong_project').css( 'display', 'inline-block');$('.belong_job').css( 'display', 'none');" required/> Yes
<input type="radio" name="<?=$attribute?>" value="0" <?php if(h($job[$attribute]) != "99") echo "checked"?> <?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> style="margin: 0;" onclick="$('.belong_project').css( 'display', 'none');$('.belong_job').css( 'display', 'inline-block');" required/> No
<?php else: */?>
<input type="radio" name="<?=$attribute?>" value="99" style="margin: 0;" onclick="$('.belong_project').css( 'display', 'inline-block');$('.belong_job').css( 'display', 'none');$('.belong_job').attr('disable', true);$( '#project_id' ).prop( 'disabled', false );" required/> Yes
<input type="radio" id="default_not_project" name="<?=$attribute?>" value="0" style="margin: 0;" onclick="$('.belong_project').css( 'display', 'none');$('.belong_job').css( 'display', 'inline-block');$('.belong_job').attr('disable', false);$( '#project_id' ).prop( 'disabled', true );" required/> No
<?php// endif; ?>
</div>
</div>
<?php if(!empty($job["project_id"])){ ?>
<div class="control-group">
<?php $label = 'Type'; ?>
<label class="control-label"><?= $label ?></label>
<div class="controls" style="padding: 5px 0 5px 0;">
Project
</div>
</div>
<?php } ?>
<!-- for add job-->
<div id="project_list">
</div>
<!-- for modify job -->
<?php if(!empty($job["project_id"])){
$sql = "SELECT * FROM sup_project WHERE status =? and id=? ";
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
if (!$sth->execute(array("1", $job["project_id"]))) {
throw new Exception("sql execute statement failure: $sql");
}
$project = $sth->fetch(PDO::FETCH_ASSOC);
?>
<?php $attribute = 'project_id';
$label = 'Project Name'; ?>
<div class="control-group">
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls" style="padding: 5px 0 5px 0;">
<?=$project["project_name"]?>
</div>
</div>
<?php $attribute = 'on_site';
$label = 'Project On-Site?'; ?>
<div class="control-group">
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls" style="padding: 5px 0 5px 0;">
<?php
if($job["on_site"] == 1)
echo "Yes";
else
echo "No";
?>
</div>
</div>
<?php } ?>
<?php if(isset($_GET["contract_id"]) || !empty($job["contract_id"])){ ?>
<div class="control-group">
<?php $attribute = 'contract_id';
$label = 'Contract ID'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" name="<?=$attribute?>" value="<?php if(!empty($job["contract_id"])) echo $job["contract_id"]; else echo $_GET["contract_id"]; ?>" readonly/>
<input type="hidden" name="contract_type" value="<?=$_GET["contract_type"]?>" />
<?php if (Util::isAdmin()){ ?>
<br>
<a href="../contract/modifyform.php?id=<?=$job["contract_id"]?>" target="_blank"/>View Contract</a>
<?php } ?>
</div>
</div>
<?php } ?>
<!--<div class="control-group" <?php if($_SESSION['webadmin']['role'] == 2) echo "style='display: none;'"?>> -->
<div class="control-group" >
<?php $attribute = 'location'; $label = 'Location'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<div class="input-append ">
<textarea id="<?=$attribute?>" name="<?=$attribute?>" value="<?=$job[$attribute]?>" class="span6" style="height: 80px;" <?=$allow_edit_mode ? '' : ' disabled="disabled"'?>><?=$job[$attribute]?></textarea>
</div>
<br>
<?php
$string = $job[$attribute];
$patterns = array();
$patterns[0] = '/,/';
$patterns[1] = '/ /';
$replacements = array();
$replacements[0] = '%2C';
$replacements[1] = '+';
//echo preg_replace($patterns, $replacements, $string);
?>
<?php if(!empty($job["id"])){ ?>
<a href="http://www.google.com.hk/maps/preview?q=<?=$string?>" target="_blank"/>View Location</a>
<?php } ?>
</div>
</div>
<div class="control-group belong_job">
<?php $attribute = 'email1';
$label = 'E-mail'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<?php if (!empty($job['id'])): ?>
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>" class="email span6" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php else: ?>
<input type="text" id="<?= $attribute ?>" placeholder="<?=$label?>" class="span6" />
<?php endif; ?>
<div style="color:red; font-size: 12px;">Use ";" semicolon to add multiple email. Example: demo01@gmail.com;demo02@gmail.com </div>
</div>
</div>
<!--<div class="control-group belong_job">
<?php /*$attribute = 'email2';
$label = 'E-mail 2'; */?>
<label class="control-label" for="<?/*= $attribute */?>"><?/*= $label */?></label>
<div class="controls">
<input type="text" id="<?/*= $attribute */?>" name="<?/*= $attribute */?>" value="<?/*= $job[$attribute] */?>" class="email span6" placeholder="<?/*= $label */?>"<?/*= $allow_edit_mode ? '' : ' disabled="disabled"' */?> />
</div>
</div>-->
<div class="control-group">
<?php $attribute = 'contact_person';
$label = 'Contact Person'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= $job[$attribute] ?>" class="span6" placeholder="<?= $label ?>"/>
</div>
</div>
<div class="control-group">
<?php $attribute = 'contact_tel_no';
$label = 'Contact Number'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= $job[$attribute] ?>" class="span6" placeholder="<?= $label ?>"/>
</div>
</div>
<div class="control-group">
<?php $attribute = 'staff_id';
$label = 'Teacher'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>" class="required select2"<?= Util::isAdmin() ? '' : ' disabled="disabled"' ?> onchange="get_teacher_info(this.value);">
<option value=""></option>
<?php foreach ($staffs as $staff): ?>
<option value="<?= h($staff['id']) ?>"<?= $staff['id'] == $job[$attribute] ? ' selected="selected"' : '' ?>><?= $staff['actived'] == 1 ? '' : '[Disabled] ' ?><?= h($staff['username']) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'staff_tel_no';
$label = 'Teacher Phone Number'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<?php if(empty($job[$attribute]) && 1==2){
foreach ($staffs as $staff):
if($staff['id'] == $job["staff_id"]){
?>
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= $staff[$attribute] ?>" class="span6" placeholder="<?= $label ?>"/>
<?php } ?>
<?php endforeach; } else { ?>
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= $job[$attribute] ?>" class="span6" placeholder="<?= $label ?>"/>
<?php } ?>
</div>
</div>
<div class="control-group hidden">
<?php $attribute = 'other_staff_id';
$label = 'Other Staff'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>[]" multiple placeholder="Select a <?= $label ?>" class="" <?= Util::isAdmin() ? '' : ' disabled="disabled"' ?>>
<!--<option value=""></option>-->
<?php
$other_staff_id_list = explode(",", $job[$attribute]);
foreach ($staffs as $staff):
foreach ($other_staff_id_list as $other_staff_id):
if($other_staff_id == $staff["id"]) {
$selected = "selected";
break;
} else {
$selected ="";
}
endforeach;
?>
<option value="<?= h($staff['id']) ?>" <?=$selected?>><?= $staff['actived'] == 1 ? '' : '[Disabled] ' ?><?= h($staff['username']) ?></option>
<?php endforeach; ?>
</select>
<br>
<p style="color: red;">Can select multiple staffs</p>
</div>
</div>
<div class="control-group hidden">
<?php $attribute = 'call_date';
$label = 'Call Date'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append date-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_date_string($job[$attribute])) ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group hidden">
<?php $attribute = 'call_time';
$label = 'Call Time'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_time_string($job[$attribute])) ?>" class="time" data-format="hh:mm" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<!-- for edit -->
<?php if (!empty($job['id']) && 1==2): ?>
<div class="control-group">
<?php $attribute = 'date';
$label = 'Job Date'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append date-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_date_string($job[$attribute])) ?>" class="required dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'start_time'; $label = 'Start Time'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="required time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'end_time'; $label = 'End Time'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="required time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'actual_start_time';
$label = 'Actual Start Time'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_time_string($job[$attribute])) ?>" class="<?= Util::isAdmin() ? '' : 'required ' ?>time" data-format="hh:mm" placeholder="<?= $label ?>" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'actual_end_time';
$label = 'Actual End Time'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_time_string($job[$attribute])) ?>" class="<?= Util::isAdmin() ? '' : 'required ' ?>time" data-format="hh:mm" placeholder="<?= $label ?>" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
</div>
<?php endif; ?>
<?php if(!empty($job["project_id"]) && Util::isAdmin()){ ?>
<!--
<div class="control-group belong_job">
<?php /*$attribute = 'type';
$label = 'Type'; ?>
<label class="control-label"><?= $label ?></label>
<div class="controls">
<?php foreach ($typeOptions as $value => $label): ?>
<label class="radio">
<input type="radio" name="<?= $attribute ?>"<?= $job[$attribute] == $value ? ' checked="checked"' : '' ?> placeholder="<?= $label ?>" value="<?= $value ?>" class="required"<?= Util::isAdmin() ? '' : ' disabled="disabled"' ?> />
<?= h($label) ?>
</label>
<?php endforeach; */?>
</div>
</div>
-->
<?php } else { ?>
<div class="control-group belong_job_? hidden" <?php if(!empty($job["id"])) echo "style='display: block_?;'"?>>
<?php $attribute = 'type';
$label = 'Type'; ?>
<label class="control-label"><?= $label ?></label>
<div class="controls hidden">
<?php if(!isset($_GET["contract_id"]) || !empty($job["contract_id"])){
foreach ($typeOptions as $value => $label){
if( Util::isAdmin()){
?>
<!--for add form-->
<label class="radio">
<input type="radio" name="<?= $attribute ?>"<?= $job[$attribute] == $value ? ' checked="checked"' : '' ?> placeholder="<?= $label ?>" value="<?= $value ?>" class="required" />
<?= h($label) ?>
</label>
<?php
}else{
?>
<!--for add form-->
<label class="radio">
<input type="radio" name="<?= $attribute ?>"<?= $job[$attribute] == $value ? ' checked="checked"' : '' ?> placeholder="<?= $label ?>" value="<?= $value ?>" class="required"<?= ($value != 1 ) ? '' : ' disabled="disabled"' ?> />
<?= h($label) ?>
</label>
<?php } } ?>
<?php }else{ ?>
<?php foreach ($typeOptions as $value => $label): ?>
<label class="radio">
<?php if($_GET["contract_type"] == 1){ ?>
<input type="radio" name="<?= $attribute ?>"<?= $value == 1 ? ' checked="checked"' : ' disabled="disabled"'; ?> placeholder="<?= $label ?>" value="<?= $value ?>" class="required" />
<?php }else{ ?>
<input type="radio" name="<?= $attribute ?>"<?= $job[$attribute] == $value ? ' checked="checked"' : '' ?> placeholder="<?= $label ?>" value="<?= $value ?>" class="required"<?= Util::isAdmin() ? '' : ' disabled="disabled"' ?> />
<?php } ?>
<?= h($label) ?>
</label>
<?php endforeach; ?>
<?php } ?>
</div>
</div>
<?php }?>
<?php if(Util::isAdmin() && 1==2){ ?>
<div class="control-group">
<?php $attribute = 'day_type';
$label = 'Day Type'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<label class="radio">
<input type="radio" class="required" id="<?= $attribute ?>" name="<?= $attribute ?>" value="1" <?=($job[$attribute] == 1 || empty($job[$attribute]))?"checked":""; ?>/> Half Day</label>
<label class="radio">
<input type="radio" class="required" id="<?= $attribute ?>" name="<?= $attribute ?>" value="2" <?=($job[$attribute] == 2 )?"checked":""; ?>/> Full Day</label>
</div>
</div>
<div class="control-group">
<?php $attribute = 'call_num';
$label = 'Num of Calls'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?if($job[$attribute] > 0 ) echo $job[$attribute]; else echo "1"; ?>" class="span1" /> (suggested num: <span id="suggested_num_of_call"></span>)
</div>
</div>
<?php } ?>
<?php
if($_SESSION['webadmin']['role'] == 2 || $_SESSION['webadmin']['role'] == 3){
echo '<input type="hidden" name="is_today" value="1" />' ;
}
if(empty($job["id"]) && Util::isAdmin()){
$attribute = 'is_today';
$label = 'Only Today?'; ?>
<div class="control-group hidden" id="<?=$attribute?>">
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls" style="padding-top: 5px;">
<?php if (!empty($job['id'])): ?>
<input type="radio" name="<?=$attribute?>" value="1" <?php if(h($job[$attribute]) == "99") echo "checked"?> <?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> style="margin: 0;" onclick="$('#more_days').hide();$('#date_list').hide();$('#date_list2').show();" checked required /> Yes
<input type="radio" name="<?=$attribute?>" value="0" <?php if(h($job[$attribute]) != "99") echo "checked"?> <?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> style="margin: 0;" onclick="$('#more_days').show();$('#date_list').show();$('#date_list2').hide();" required/> No
<?php else: ?>
<input type="radio" name="<?=$attribute?>" value="1" style="margin: 0;" onclick="$('#more_days').hide();$('#date_list').hide();$('#date_list2').show();" checked required/> Yes
<input type="radio" name="<?=$attribute?>" value="0" style="margin: 0;" onclick="$('#more_days').show();$('#date_list').show();$('#date_list2').hide();" required/> No
<?php endif; ?>
</div>
</div>
<?php } ?>
<?php if (empty($job['id'])): ?>
<div id="more_days">
<div class="control-group">
<?php $attribute = 'date_from';
$label = 'Date From'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append date-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_date_string($job[$attribute])) ?>" class="required dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'date_to';
$label = 'Date To'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<div class="input-append date-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h(Util::value_to_date_string($job[$attribute])) ?>" class="required dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group">
<?php
$attribute = 'period'; $label = 'Period';
$activeperiod = array();
$activeperiod = Job::activeperiod();
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" onchange="divdisplay(this.value);">
<option value="">Please Select One</option>
<?php foreach ($activeperiod as $key => $option): ?>
<option value="<?= $key ?>" ><?= $option ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php
$attribute = 'frequency'; $label = 'Frequency';
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" >
<option value="">Please Select One</option>
<?php for($i=1; $i<=30; $i++){?>
<option value="<?= $i ?>"><?= $i ?></option>
<?php } ?>
</select>
<br>
</div>
</div>
<div class="control-group" id="_start_time" style="display: none">
<?php $attribute = 'start_time_daily'; $label = 'Start Time'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
<div class="control-group" id="_end_time" style="display: none">
<?php $attribute = 'end_time_daily'; $label = 'End Time'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
<br>
<div id="daily_generator" onclick="generate_date_list();" class="btn" style="margin-top: 10px;display: none;">Generate Date</div>
</div>
</div>
</div>
<div class="control-group" id="_whichweek" style="display: none;">
<?php
$attribute = 'whichweek'; $label = 'Which Week';
$activeperiod = array();
$whichweek = Job::whichweek();
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" class="required">
<option value="">Please Select One</option>
<?php foreach ($whichweek as $key => $option): ?>
<option value="<?= $key ?>"><?= $option ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group" id="_week" style="display: none">
<label class="control-label">Week</label>
<div class="controls">
<table id="showweek" border='1' cellpadding='5' style="text-align: center;">
<tr>
<th><input type='button' id='toggle' value='All' onClick='do_this()' style="width: 50px;"/></th>
<th>Week</th>
<th>Start Time</th>
<th>End Time</th>
</tr>
<?php
$week = array();
$week = Job::week();
for($j = 1; $j <= 7; $j++){
?>
<tr>
<td>
<input type="checkbox" name="selected_week[]" value='<?=$j?>' class="checkall selected_week"/>
</td>
<td>
<?=$week[$j]?>
</td>
<td>
<?php $attribute = 'start_time_weekly'; $label = 'Start Time'; ?>
<div class="controls" style="padding: 0;margin: 0;">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute.$j?>" name="<?=$attribute."[".$j."]"?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</td>
<td>
<?php $attribute = 'end_time_weekly'; $label = 'End Time'; ?>
<div class="controls" style="padding: 0;margin: 0;">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute.$j?>" name="<?=$attribute."[".$j."]"?>" value="<?=h(Util::value_to_time_string($job[$attribute]))?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php
}
?>
</table>
<div id="weekmonth_generator" onclick="generate_date_list();" class="btn" style="margin-top: 10px;display: none;">Generate Date</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="control-group">
<label class="control-label">Date</label>
<div class="controls" id="date_list">
</div>
<div class="controls" id="date_list2">
<div class="controls" style="padding: 0;margin: 0;padding-bottom: 20px;" >
<div class="input-append date-picker">
<input type="text" name="today_selected_day" value="<?= $job["date"] == "" ? date("Y-m-d") : $job["date"] ;?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="Date" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
<?php $attribute = 'today_start_time'; $label = 'Start Time'; ?>
<div class="controls" style="padding: 0;margin: 0;padding-bottom: 20px;">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> value="<?= substr( $job["start_time"], 0, 5) ?>" />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
<?php $attribute = 'today_end_time'; $label = 'End Time'; ?>
<div class="controls" style="padding: 0;margin: 0;">
<div class="input-append time-picker">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> value="<?= substr( $job["end_time"], 0, 5) ?>" />
<?php if ($allow_edit_mode): ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'billing_amount';
$label = 'Billing Amount'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>" class="span2" pattern="^\d*(\.\d{0,2})?$" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
</div>
</div>
<div class="control-group">
<?php $attribute = 'cost_amount';
$label = 'Cost Amount'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" value="<?= h($job[$attribute]) ?>" class="span2" pattern="^\d*(\.\d{0,2})?$" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?> />
</div>
</div>
<div class="control-group">
<?php $attribute = 'remarks';
$label = 'Remarks'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6" placeholder="<?= $label ?>"<?= $allow_edit_mode ? '' : ' disabled="disabled"' ?>><?= h($job[$attribute]) ?></textarea>
</div>
</div>
<div class="control-group">
<?php $attribute = 'quotation';
$label = 'Quotation'; ?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6" placeholder="<?= $label ?>" <?= $allow_edit_mode ? '' : ' disabled="disabled"' ?>><?= h($job[$attribute]) ?></textarea>
</div>
</div>
<hr/>
<?php if (empty($job['id'])): ?>
<div class="control-group">
<div class="controls">
<!-- <button type="submit" class="btn btn-primary">Next</button> -->
<button type="submit" class="btn btn-danger">Save</button>
<button type="reset" class="btn btn-warning" onclick="location.reload();">Clear</button>
<button type="button" class="btn btn-default" onClick="history.go(-1);">Back</button>
</div>
</div>
<?php else: ?>
<div class="hidden">
<button type="button" class="btn btn-link pull-right" onclick="scrollToId('goto_top')">Go to Top</button>
<h4 id="goto_details">Tasks</h4>
<input type="button" id="monthlytask" value="Close Detail" class="btn add-detail-btn" style="float:right;"/>
</div>
<div class="hidden">
<div id="monthlytask_detail">
<div>
Status: Follow Up; Color: <span style="background-color: #F4FA58;">Yellow</span>
<br>
Status: Completed / Cancel; Color: <span style="background-color: #CEECF5;">Blue</span>
</div>
<table class="table table-striped" id="ng-app" ng:app="" ng:controller="JobDetailControl">
<thead>
<tr>
<th>Task Category</th>
<th>Title</th>
<th style="width: 400px;">Remarks</th>
<th style="width: 155px;">Status</th>
<th style="width: 115px;">Completed Date</th>
</tr>
</thead>
<tbody>
<?php
$sql2 = "select * from sup_period_task where customer_id = ? and deleted =? and status != ? and ? >= start_date and ? <= end_date order by start_date";
$parameters = array($job["customer_id"], "0", "3", date("Y-m-d"), date("Y-m-d"));
if (!($sth = $dbh->prepare($sql2))) {
throw new Exception("sql prepare statement failure: $sql2");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql2");
}
$row2_columns = $sth->fetchAll();
foreach ($row2_columns as $key => $row2) {
if(!empty($row2["completed_date"]) && $row2["completed_date"] != "0000-00-00" && $row2["status"] == 2){
$disabled = "disabled";
}else{
$disabled = "";
}
?>
<?php if($key == 0){ ?>
<tr>
<td colspan="6"><a href="../contract/modifyform.php?id=<?=$row2["contract_id"]?>" class="btn" style="margin-right: 15px;"><i class="icon-pencil"></i></a><b>Contract Number: #<?=$row2["contract_id"]?> -- Contract Tasks</b></td>
</tr>
<?php } ?>
<tr>
<td style="padding-left: 63px;">
<?php
foreach ($task_categories as $key => $task_category) {
if($row2["task_category_id"] == $task_category["task_category_id"])
echo $task_category["category_name"];
}
?>
</td>
<td><?=$row2["task_title"]?></td>
<td>
<textarea name="period_task_remarks[<?=$row2["ptask_id"]?>]" class="span4" placeholder="Remarks" <?=$disabled?>><?= h($row2["task_remarks"]); ?></textarea>
</td>
<td style="<?php if($row2["mtask_status"] == 2) echo "background-color: #CEECF5;";if($row2["mtask_status"] == 1 || $row2["mtask_status"] == 3) echo "background-color: #F4FA58;";?>">
<?php
$period_task_status = $row2["status"]; $_period_task_statusOption = period_task_statusOption::statusOptions();
foreach($_period_task_statusOption as $key => $option){
?>
<input type="radio" name="period_task_status[<?=$row2["ptask_id"]?>]" value="<?=$key?>" <?php if($row2["status"] == $key) echo "checked" ?> style="margin-top: -3px;" <?=$disabled?>/> <?=$option?>
<?php
}
?>
</td>
<td>
<?php
if($row2["status"] == 2){
echo $row2["completed_date"];
}
?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="6"><b>Current Job Tasks</b></td>
</tr>
<script type="text/javascript">
$(function(){
<?php
foreach($job_detail as $key1 => $task_detail){
foreach($task_categories as $key2 => $task_category){
?>
var value_selected = $("#<?=$task_detail["id"];?>_option_<?=$task_category["task_category_id"]?>").val();
var this_array = value_selected.split(",");
if(this_array[1] == "true"){
$("#<?=$task_detail["id"];?>_option_<?=$task_category["task_category_id"]?>").attr("selected", "selected");
}
<?php
}
}
?>
});
</script>
<?php
//follow up task here
$sql6 = "select job.*,job_detail.*, job_detail.remarks as job_detail_remarks, job_detail.id as job_detail_id, job_detail.status as job_detail_status from sup_job job, sup_job_detail job_detail where job.id = job_detail.job_id and job.customer_id = ? and job_detail.actived = 1 and job_detail.deleted = 0 and job_detail.status = 3 and job_detail.job_id != ? and job.status = ? and job.date >= ? and job_detail.follow_up_flag = ? group by job_detail_id";
if (!($sth6 = $dbh->prepare($sql6))) {
throw new Exception("sql prepare statement failure: $sql6");
}
$sth6->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth6->execute(array($job["customer_id"], $job["id"], 2, "2014-01-01", 0))) {
throw new Exception("sql execute statement failure: $sql6");
}
$pending_tasks = $sth6->fetchAll();
foreach($pending_tasks as $key => $pending_task){
?>
<tr>
<td>
<?php $attribute = 'task_category_id';
$label = 'Task Category'; ?>
<select name="pending_task_category_id[<?=$pending_task["job_detail_id"]?>]" class="span2" placeholder="<?= $label ?>">
<?php
foreach ($task_categories as $key22 => $task_category) {
?>
<option value="<?=$task_category["task_category_id"]?>" <?php if($task_category["task_category_id"] == $pending_task["task_category_id"]) echo "selected"; ?>><?=$task_category["category_name"]?></option>
<?php
}
?>
</select>
</td>
<td>
<input type="text" name="pending_task_title[<?=$pending_task["job_detail_id"]?>]" value="<?= h($pending_task["title"]); ?>" class="required" placeholder="Title"/>
</td>
<td>
<textarea name="pending_task_remarks[<?=$pending_task["job_detail_id"]?>]" class="span4 textarea_style" placeholder="Remarks"><?= h($pending_task["job_detail_remarks"]); ?></textarea>
</td>
<td style="<?php if($pending_task["job_detail_status"] == 2 ) echo "background-color: #CEECF5;";if($pending_task["job_detail_status"] == 1 || $pending_task["job_detail_status"] == 3) echo "background-color: #F4FA58;";?>">
<input type="hidden" name="pending_task_id[]" value="<?=$pending_task["job_detail_id"]?>" />
<?php foreach ($detailStausOptions as $value => $option){ ?>
<input type="radio" name="pending_task_status[<?=$pending_task["job_detail_id"]?>]" value="<?=$value?>" <?php if($pending_task["job_detail_status"] == $value) echo "checked" ?> style="margin-top: -3px;"/> <?=$option?>
<?php
}
?>
</td>
</tr>
<?php } ?>
<tr ng:repeat="detail in details">
<td>
<?php $attribute = 'job_id'; ?>
<input ng:disabled="!detail.id" type="hidden" name="job_detail[{{detail.id}}][<?= $attribute ?>]" value="{{detail.<?= $attribute ?>}}" id=""/>
<input ng:disabled="detail.id" type="hidden" name="new_job_detail[{{$index}}][<?= $attribute ?>]" value="{{detail.<?= $attribute ?>}}"/>
<?php $attribute = 'task_category_id';
$label = 'Category'; ?>
<select id="{{detail.id}}" ng:show="detail.id" ng:disabled="!detail.id" name="job_detail[{{detail.id}}][<?= $attribute ?>]" class="span2" placeholder="<?= $label ?>">
<?php
foreach ($task_categories as $key => $task_category) {
?>
<option id="{{detail.id}}_option_<?=$task_category["task_category_id"]?>" value="<?=$task_category["task_category_id"]?>,{{detail.<?= $attribute ?> == '<?=$task_category["task_category_id"]?>'}}" ><?=$task_category["category_name"]?></option>
<?php
}
?>
</select>
<select id="{{detail.id}}" ng:show="!detail.id" ng:disabled="detail.id" name="new_job_detail[{{$index}}][<?= $attribute ?>]" class="span2" placeholder="<?= $label ?>">
<?php
foreach ($task_categories as $key => $task_category) {
?>
<option id="{{detail.id}}_option_<?=$task_category["task_category_id"]?>" value="<?=$task_category["task_category_id"]?>" ><?=$task_category["category_name"]?>
</option>
<?php
}
?>
</select>
<!-- show pending job exist text-->
<button class="btn btn-primary" type="button" ng:show="detail.from_job_pending_id" style="margin-top: 10px;" onclick="task_history({{detail.id}})">
Task History
</button>
</td>
<td>
<?php $attribute = 'title';
$label = 'Title'; ?>
<input ng:show="detail.id" ng:disabled="!detail.id" type="text" name="job_detail[{{detail.id}}][<?= $attribute ?>]" value="{{detail.<?= $attribute ?>}}" class="required" placeholder="<?= $label ?>"/>
<input ng:show="!detail.id" ng:disabled="detail.id" type="text" name="new_job_detail[{{$index}}][<?= $attribute ?>]" value="{{detail.<?= $attribute ?>}}" class="required" placeholder="<?= $label ?>"/>
</td>
<td>
<?php $attribute = 'remarks';
$label = 'Remarks'; ?>
<textarea ng:show="detail.id" ng:disabled="!detail.id" name="job_detail[{{detail.id}}][<?= $attribute ?>]" class="span4 textarea_style" placeholder="<?= $label ?>">{{detail.<?= $attribute ?>
}}</textarea>
<textarea ng:show="!detail.id" ng:disabled="detail.id" name="new_job_detail[{{$index}}][<?= $attribute ?>]" class="span4 textarea_style" placeholder="<?= $label ?>">{{detail.<?= $attribute ?>
}}</textarea>
</td>
<td style="<?php if($row2["status"] == 2 ) echo "background-color: #CEECF5;";if($row2["status"] == 1 || $row2["status"] == 3) echo "background-color: #F4FA58;";?>">
<?php $attribute = 'status';
$label = 'Status'; ?>
<?php foreach ($detailStausOptions as $value => $label): ?>
<label class="radio inline" ng:show="detail.id" style="margin-left: 4px; float: left;">
<input ng:disabled="!detail.id" ng:checked="detail.<?= $attribute ?> == <?= $value ?>" type="radio" name="job_detail[{{detail.id}}][<?= $attribute ?>]" value="<?= $value ?>" class="required" placeholder="<?= $label ?>"/>
<?= $label ?>
</label>
<label class="radio inline" ng:show="!detail.id" style="margin-left: 4px; float: left;">
<input ng:disabled="detail.id" ng:checked="detail.<?= $attribute ?> == <?= $value ?>" type="radio" name="new_job_detail[{{$index}}][<?= $attribute ?>]" value="<?= $value ?>" class="required" placeholder="<?= $label ?>"/>
<?= $label ?>
</label>
<?php endforeach; ?>
</td>
<td colspan="2">
<button ng:show="!detail.id" type="button" ng:click="removeDetail($index)" class="btn btn-danger remove-detail-btn">
Delete
</button>
</td>
</tr>
<tr>
<td colspan="6">
<?php if ($job['status'] == 1): // open ?>
<button type="button" ng:click="addDetail()" class="btn add-detail-btn">Add Task</button>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php if(!empty($job['id'])){ ?>
<div class="control-group">
<div class="controls">
<!-- <button type="submit" class="btn btn-primary">Next</button> -->
<button type="submit" class="btn btn-danger" onclick="check_form();">Save</button>
<button type="button" class="btn btn-default" onClick="history.go(-1);">Back</button>
</div>
</div>
<div class="hidden" style="text-align: center;" id="submit_btn">
<?php if ($job['status'] == 1): // open ?>
<!--<button type="submit" class="btn btn-primary">Save</button>-->
<button type="button" class="btn btn-primary" onclick="check_form();">Save</button>
<button type="button" class="btn btn-default" onClick="history.go(-1);">Back</button>
<?php endif; ?>
<a href="../report.php?id=51236417<?=$job['id']?>" target="_blank" class="hidden">
<!--<a href="../job/services_report.php?id=<?/*=$job['id']*/?>" target="_blank">-->
<div class="btn btn-primary" style="margin-left: 20px;">Print</div>
</a>
<!--<button type="button" class="btn btn-primary" onclick="email_services_report();" style="margin-left: 20px;">Email Services Report-->
</div>
<?php } ?>
<div class="control-group hidden">
<div class="controls">
<button type="button" class="btn btn-link pull-right" onclick="scrollToId('goto_top')">Go to Top
</button>
</div>
</div>
<div class="hidden">
<!-- Previous Job-->
<hr/>
<button type="button" class="btn btn-link pull-right" onclick="scrollToId('goto_top')">Go to Top</button>
<h4>Previous Job
<button type="button" id="previousjobs" class="btn add-detail-btn" style="float:right; margin-left: 10px;">Close Detail</button>
<button type="button" id="task_remarks_toggle" class="btn btn-primary" style="float:right;" onclick="$('.task_remarks').toggle();">Show Task Remarks</button>
</h4>
<div id="previousjobs_detail">
<div>
Status: Open / Follow Up; Color: <span style="background-color: #F4FA58;">Yellow</span>
<br>
Status: Completed / Cancel; Color: <span style="background-color: #CEECF5;">Blue</span>
</div>
<table class="table table-striped">
<thead>
<tr>
<th> </th>
<th>Job ID</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th style="width: 100px;">Staff</th>
<th style="width: 100px;">Type</th>
<th style="width: 500px;">Task Detail</th>
</tr>
</thead>
<tbody>
<?php
$sql2 = "select * from sup_job where customer_id = (select customer_id from sup_job where id ='".$_GET["id"]."') and date >= (NOW() - INTERVAL 3 MONTH) and date <= NOW() order by id DESC;";
if (!($sth = $dbh->prepare($sql2))) {
throw new Exception("sql prepare statement failure: $sql2");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql2");
}
$row2_columns = $sth->fetchAll();
foreach ($row2_columns as $row2) {
?>
<tr>
<td><a href="modifyform.php?id=<?=$row2["id"]?>" class="btn"><i class="icon-pencil"></i></a></td>
<td>#<?=$row2["id"]?></td>
<td><?=$row2["date"]?></td>
<td><?=$row2["start_time"]?></td>
<td><?=$row2["end_time"]?></td>
<td>
<?php
$row2["staff_id"] = empty($row2["other_staff_id"])?$row2["staff_id"]:$row2["staff_id"].",".$row2["other_staff_id"];
$staff_array = explode(",", $row2["staff_id"]);
$response = "";
foreach ($staffs as $staff){
foreach ($staff_array as $staff2){
if($staff['id'] == $staff2){
$response .= h($staff['username']).", ";
}
}
}
echo substr_replace($response ,"",-2);
?>
</td>
<td>
<?php
if(empty($row2["project_id"])){
echo Job::typeOptions2($row2["type"]);
}else{
$sql2 = "select * from sup_project where id = ?";
if (!($sth1 = $dbh->prepare($sql2))) {
throw new Exception("sql prepare statement failure: $sql2");
}
if (!$sth1->execute(array($row2["project_id"]))) {
throw new Exception("sql execute statement failure: $sql2");
}
$project = $sth1->fetch(PDO::FETCH_ASSOC);
echo "Project - ".$project["project_name"];
}
?>
</td>
<td>
<?php
$sql3 = "select * from sup_job_detail where job_id = '".$row2["id"]."' and deleted = 0";
if (!($sth = $dbh->prepare($sql3))) {
throw new Exception("sql prepare statement failure: $sql3");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql3");
}
$row3_columns = $sth->fetchAll();
foreach ($row3_columns as $key => $row3) {
$tasknum = $key + 1;
if($row3["status"] == 1 || $row3["status"] == 3){ //open and follow up
$bg_color = "#F4FA58";
}else{
$bg_color = "#CEECF5";
}
echo "<span style='background-color:".$bg_color.";'>Task".$tasknum.": ".$row3["title"]." (Status: ".JobDetail::statusOptions2($row3["status"]).")</span>";
//check if has follow up task before
if(!empty($row3["from_job_pending_id"])){
echo '<button class="btn btn-primary" type="button" style="margin-left:10px; padding: 0 10px; margin-bottom: 5px;" onclick="task_history('.$row3["id"].')">Task History</button>';
}
echo "<br>";
echo "<div style='padding-left: 46px; display: none;' class='task_remarks'>".nl2br($row3["remarks"])."</div>";
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="control-group">
<div class="controls">
<button type="button" class="btn btn-link pull-right" onclick="scrollToId('goto_top')">Go to Top
</button>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</form>
<script type="text/javascript">
$(document).ready(function(){
<?php if ( !Util::isAdmin() ): ?>
$( "input, textarea, SELECT" ).prop( "disabled", true );
$("button.btn-danger").addClass("hidden");
newTitle = $("h2").text().replace("Edit","View")
$("h2").text(newTitle);
<?php endif; ?>
});
$(function () {
$('#actual_start_time, #actual_end_time, #start_time, #end_time, #call_time, #start_time_daily, #end_time_daily, .time').change(function (event) {
var $this = $(this),
val = $this.val();
if (val && val.length && val.length == 4) {
var number = parseInt(val, 10);
if (!isNaN(number)) {
$this.val([val.slice(0, 2), ':', val.slice(2)].join(''));
event.preventDefault();
$this.trigger('change');
}
}
});
<?php if ($job['status'] == 1): // open ?>
$('.date-picker').datetimepicker({ pickTime: false });
$('.time-picker').datetimepicker({ pickDate: false, pickSeconds: false });
<?php else: ?>
var $form = $('#form');
$('input, textarea, select', $form).prop('disabled', true);
<?php endif; ?>
$('.select2').select2();
<?php if ($job['status'] == 1 && !Util::isAdmin() && $allow_edit_mode): ?>
$('#staff_id').select2('readonly', true);
$('#staff_id').select2('enable', true);
<?php endif; ?>
<?php if($_GET["monthly"] == 1) {?>
$("#_week").show();
$("#_whichweek").show();
$("#weekmonth_generator").show();
<?php } ?>
$('#form').validate();
$('#previousjobs').click(function(event) {
event.preventDefault();
$('#previousjobs_detail').toggle();
if($('#previousjobs').val() == "Close Detail"){
document.getElementById("previousjobs").value = "Expand Detail";
}else{
document.getElementById("previousjobs").value = "Close Detail";
}
});
$('#monthlytask').click(function(event) {
event.preventDefault();
$('#monthlytask_detail').toggle();
if($('#monthlytask').val() == "Close Detail"){
document.getElementById("monthlytask").value = "Expand Detail";
}else{
document.getElementById("monthlytask").value = "Close Detail";
}
});
});
</script>
<script type="text/javascript">
function do_this() {
//var checkboxes = document.getElementsByName('selected_week[]');
var button = document.getElementById('toggle');
if (button.value == 'All') {
$(".checkall").attr('checked', true);
button.value = 'Clear'
} else {
$(".checkall").attr('checked', false);
button.value = 'All';
}
}
function available_date() {
//var checkboxes = document.getElementsByName('arraynum[]');
var button = document.getElementById('toggle2');
if (button.value == 'All') {
$(".checkall2").attr('checked', true);
button.value = 'Clear'
} else {
$(".checkall2").attr('checked', false);
button.value = 'All';
}
}
function divdisplay(period){
if(period == 1){ //daily
$("#_week").hide();
$("#_start_time").show();
$("#_end_time").show();
$("#daily_generator").show();
$("#weekmonth_generator").hide();
$("#_whichweek").hide();
}else if(period == 2 || period == 3){ //weekly or monthly
$("#_week").show();
$("#_start_time").hide();
$("#_end_time").hide();
$("#weekmonth_generator").show();
$("#daily_generator").hide();
$("#_whichweek").hide();
if(period == 3){
$("#_whichweek").show();
}
}else{}
}
function getSelectedChbox(frm) {
// JavaScript & jQuery Course - http://coursesweb.net/javascript/
var selchbox = []; // array that will store the value of selected checkboxes
// gets all the input tags in frm, and their number
var inpfields = frm.getElementsByClassName('selected_week');
var nr_inpfields = inpfields.length;
// traverse the inpfields elements, and adds the value of selected (checked) checkbox in selchbox
for(var i=0; i<nr_inpfields; i++) {
if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true) selchbox.push(inpfields[i].value);
}
return selchbox;
}
</script>
<?php require(__DIR__ . '/../../inc/_footer.php'); ?>
</div>
<!-- /container -->
<div id="task_history_container" style="display: none;"></div>
<link rel="stylesheet" type="text/css" href="<?='../js/fancybox/jquery.fancybox.css'?>" />
<script type="text/javascript" src="<?='../js/fancybox/jquery.fancybox.pack.js'?>"></script>
<script type="text/javascript">
function task_history(task_id) {
//ajax get task history and using fancy box pop up
$.ajax({
url: 'ajax.php',
type: 'POST',
data:{
scope:"task_history",
task_id:task_id
},
dataType: 'text',
timeout: 1000,
error: function(){
//alert('Error loading PHP document');
},
success: function(result){
//alert(result);
/*var json = result,
obj = JSON.parse(json);
console.log(obj);*/
$("#task_history_container").html(result);
//popup box
$.fancybox({
//settings
'type': 'inline',
'fitToView': false,
'width': '80%',
'height': '80%',
'autoSize': false,
'closeClick': false,
'openEffect': 'none',
'closeEffect': 'none',
'href': '#task_history_container'
});
}
});
}
$(function () {
//get email support
$('#customer_id').on('change', function () {
var email_support = $(this).find('option:selected').attr('data-value');
//if(!$('#email1').val()){
$('#email1').val(email_support);
//}
});
});
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function check_email1() {
var email = $('#email1').val();
if(email){
email = email.replace(/ /g, '');
//console.log(email);
$('#email1').val(email);
email_array = email.split(";");
//console.log(email_array);
var valid = true;
for (var key in email_array) {
if (validateEmail(email_array[key])) {
} else {
valid = false;
alert(email_array[key] + " is not valid.");
}
}
return valid;
}else{
return true;
}
}
function email_services_report() {
if(confirm("Confirm to send services report email? Make sure you have saved data before.")){
//check email first
if(!$('#email1').val()){
alert('E-mail is empty.');
}else{
if(check_email1()){
location.href='../job/services_report.php?email=1&id=<?=(int)$_GET['id']?>';
}
}
}
}
</script>
</body>
</html>
<?php
unset($_SESSION["clash_job_id_array"]);
unset($_SESSION["clash_job_array"]);
?>