| 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/onesolution.com.hk/onesupport/contract/views/ |
Upload File : |
<?php
if (!Util::isAdmin()){
header("Location: ../job/index.php" );
exit;
}
$allow_edit_mode = false;
if (Util::isAdmin()) { // admin
$allow_edit_mode = true;
} else {
if (empty($contract['id'])) { // new job
$allow_edit_mode = true;
} else {
/*if ($contract['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_contract_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;
}
if(!empty($_GET["id"])){
$sql = "SELECT * FROM sup_contract where contract_id='".(int)$_GET["id"]."'";
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute()) {
throw new Exception("sql execute statement failure: $sql");
}
$contract = $sth->fetch(PDO::FETCH_ASSOC);
$sql = "SELECT * FROM sup_period_task where contract_id = '".(int)$_GET["id"]."' and deleted = 0 order by start_date ASC";
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute()) {
throw new Exception("sql execute statement failure: $sql");
}
$period_task = $sth->fetchAll();
}
$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();
$task_categories_select_html = '<br>Task Category: <br><select name="task_category_id[]" class="span2">';
foreach($task_categories as $key => $task_category){
$task_categories_select_html.='<option value="'.$task_category["task_category_id"].'">'.$task_category["category_name"].'</option>';
}
$task_categories_select_html.='</select><br>';
?><!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;
}
.input_callnum{
width:30px;
margin-top: 5px;
}
</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() {
var addDiv = $('#addmoretask');
var i = $('#addmoretask #task_container').size() + 1;
$('#addNew').live('click', function() {
<?php
if(empty($contract["contract_id"])){
?>
$('<div id="task_container"><div class="controls" id="monthly_task_'+i+'"><b>New Task</b><?=$task_categories_select_html?>Title: <br><input type="text" name="task_title[]" class="span3" /><br>Remark: <br><textarea name="task_remarks[]" class="span3" style="height: 80px;"></textarea><br><a href="#" id="remNew" class="btn" style="margin:10px 0 10px 0;"> -Delete </a></div>').appendTo(addDiv);
<?php
}else{
?>
$('<div id="task_container"><div class="controls" id="monthly_task_'+i+'"><b>New Task</b><?=$task_categories_select_html?>Title: <br><input type="text" name="new_task_title[]" class="span3 required" /><br>Remark: <br><textarea name="new_task_remarks[]" class="span3" style="height: 80px;"></textarea><br><a href="#" id="remNew" class="btn" style="margin:10px 0 10px 0;"> -Delete </a></div>').appendTo(addDiv);
<?php
}
?>
i++;
return false;
});
$('#remNew').live('click', function() {
if( i > 1 ) {
$(this).parents('#task_container').remove();
i--;
}
return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#monthly").click(function(){
$("#div_monthly_task").show();
});
$("#package").click(function(){
$("#div_monthly_task").hide();
});
});
</script>
<script>
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.getElementsByTagName('input');
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;
}
function generate_task_period() {
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;
$('.date-picker').datetimepicker({ pickTime: false });
}
}
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 customer_id = document.getElementById("customer_id").value;
xmlhttp.open("GET", "views/generate_task_period.php?date_from=" + date_from + "&date_to=" + date_to+ "&period=" + period+ "&frequency=" + frequency+"&customer_id=" + customer_id, true);
xmlhttp.send();
}
</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 button2 = document.getElementById('toggle2');
if (button2.value == 'All') {
$(".checkall2").attr('checked', true);
button2.value = 'Clear'
} else {
$(".checkall2").attr('checked', false);
button2.value = 'All';
}
}
</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 (empty($contract["contract_id"])): ?>
<h2>Add Contract</h2>
<?php else: ?>
<div class="control-group pull-right">
<div class="controls">
<code>Status: <?=h($statusOptions[$contract['status']])?></code>
<?php if (Util::isAdmin()): ?>
<?php if ($contract['status'] == 1 && Job::allow_change_status_to_confirm($contract['id'])): ?>
<button type="button" id="confirm_btn" class="btn btn-warning">Close</button>
<?php endif; ?>
<?php if ($contract['status'] != 1): ?>
<button type="button" id="reopen_btn" class="btn btn-warning">Reopen</button>
<?php endif; ?>
<?php if ($contract['status'] == 1): ?>
<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 = 'contract_id'; ?>
<input type="hidden" name="<?=$attribute?>" value="<?=h($contract[$attribute])?>" />
<?php $attribute = 'status'; ?>
<input type="hidden" id="status_form_<?=$attribute?>" name="<?=$attribute?>" value="<?=h($contract[$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 contract status to ' + statusText + '?';
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', 'input, textarea, select', function() {
if ($(this).val() != value) {
isDirty = true;
}
});
});
</script>
<?php endif; ?>
<h2 id="goto_top">Edit Contract: #<?=h($contract['contract_id'])?></h2>
<?php endif; ?>
<form id="form" class="form-horizontal" method="post">
<div class="form-horizontal">
<?php $attribute = 'contract_id'; ?>
<input type="hidden" name="<?=$attribute?>" value="<?=h($contract[$attribute])?>" />
<div class="control-group">
<?php $attribute = 'customer_id'; $label = 'Customer'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<select id="<?=$attribute?>" name="<?=$attribute?>" placeholder="Select a <?=$label?>" class="required select2"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?>>
<option value=""></option>
<?php foreach ($customers as $customer): ?>
<option value="<?=h($customer['cust_id'])?>"<?=$customer['cust_id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$customer['enable'] == 1 ? '' : '[Disabled] '?><?=h($customer['company_name'])?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'maintenance_cost'; $label = 'Maintenance Cost'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
$
<div class="input-append ">
<input type="text" id="<?=$attribute?>" name="<?=$attribute?>" value="<?=$contract[$attribute]?>" class="span3" />
</div>
</div>
</div>
<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="<?=$contract[$attribute]?>" class="span6" style="height: 80px;" <?=$allow_edit_mode ? '' : ' disabled="disabled"'?>><?=$contract[$attribute]?></textarea>
</div>
</div>
</div>
<div class="control-group">
<?php $attribute = 'date_from';
$label = 'Contract 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($contract["contract_from"])) ?>" 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 = 'Contract 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($contract["contract_to"])) ?>" 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 = 'contract_type'; $label = 'Contract Type'; ?>
<label class="control-label"><?=$label?></label>
<div class="controls" <?php if(!empty($contract["contract_id"])) echo "style='padding-top:5px;'"; ?>>
<?php if(empty($contract["contract_id"])) { ?>
<label class="radio" style="width: 100px;">
<input id="monthly" type="radio" name="<?=$attribute?>" placeholder="<?=$label?>" value="1" class="required"<?=Util::isAdmin() ? '' : ' disabled="disabled"'?> <?=$contract[$attribute] == 1 ? ' checked="checked"' : ''?> <?php if(empty($contract["contract_id"])){?>onclick="$('.monthly').show();"<?php } ?> />
Monthly
</label>
<label class="radio" style="width: 100px;">
<input id="package" type="radio" name="<?=$attribute?>" placeholder="<?=$label?>" value="2" class="required"<?=Util::isAdmin() ? '' : ' disabled="disabled"'?> <?=$contract[$attribute] == 2 ? ' checked="checked"' : ''?> <?php if(empty($contract["contract_id"])){?>onclick="$('.monthly').hide();"<?php } ?> />
Package
</label>
<?php }else{
if($contract["contract_type"] == 1)
echo "Monthly";
else
echo "Package";
}
?>
</div>
</div>
<div class="control-group">
<?php $attribute = 'call_type'; $label = 'Call Type'; ?>
<label class="control-label"><?=$label?></label>
<div class="controls">
<?php foreach ($typeOptions as $value => $label): ?>
<?=h($label)?>
<?php
if($value == 1){ //schedule call
?>
<input type="text" name="schedule_call_3hrs" id="schedule_call_3hrs" class="input_callnum" value="<?=$contract["schedule_call_3hrs"]?>"/> (3hrs)
<br>
<input type="text" name="schedule_call_half_day" id="schedule_call_half_day" class="input_callnum" style="margin-left: 91px;" value="<?=$contract["schedule_call_half_day"]?>"/> (Half Day 4hrs)
<br>
<input type="text" name="schedule_call_full_day" id="schedule_call_full_day" class="input_callnum" style="margin-left: 91px;" value="<?=$contract["schedule_call_full_day"]?>"/> (Full Day 9hrs)
<br>
<?php
}else if($value == 2){ //service call
?>
<input type="text" name="service_call" id="service_call" class="input_callnum" value="<?=$contract["service_call"]?>"/>
<br>
<?php
}else if($value == 3){ //service call
?>
<input type="text" name="urgent_call" id="urgent_call" class="input_callnum" value="<?=$contract["urgent_call"]?>"/>
<br>
<?php
}else if($value == 4){ //service call
?>
<input type="text" name="remote_service_call" id="remote_service_call" class="input_callnum" value="<?=$contract["remote_service_call"]?>"/>
<br>
<?php
}else{
}
?>
<?php endforeach; ?>
</div>
</div>
<?php if(empty($contract["contract_id"])) { ?>
<div class="control-group monthly">
<?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 ?>" onchange="divdisplay(this.value);">
<option value="">Please Select One</option>
<?php
foreach ($activeperiod as $key => $option):
if($key != "1"){
?>
<option value="<?= $key ?>" ><?= $option ?></option>
<?php } endforeach; ?>
</select>
</div>
</div>
<div class="control-group monthly">
<?php
$attribute = 'frequency'; $label = 'Frequency';
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" >
<option value="">Please Select One</option>
<?php for($i=1; $i<=10; $i++){?>
<option value="<?= $i ?>"><?= $i ?></option>
<?php } ?>
</select>
<br>
<div id="weekmonth_generator" onclick="generate_task_period();" class="btn" style="margin-top: 10px;">Generate Date</div>
</div>
</div>
<div class="control-group monthly">
<label class="control-label">Scheduled Tasks</label>
<div class="controls" id="date_list">
</div>
</div>
<?php } ?>
<div class="control-group" id="div_monthly_task" <?php if(empty($contract["contract_id"]) || $contract["contract_type"] == 2) echo "style='display: none;'";?>>
<?php $attribute = 'monthly_task'; $label = 'Contract Task'; ?>
<?php if($contract["contract_type"] == 1){ ?>
<label class="control-label"><?=$label?>
<br>
<a href="add_task.php?id=<?=$contract["contract_id"]?>">
<div class="btn" style="margin: 10px 0 10px 0;"> +Add New Task </div>
</a>
</label>
<?php }else{ ?>
<label class="control-label"><?=$label?><br><div id="addNew" class="btn" style="margin: 10px 0 10px 0;"> +Add </div></label>
<?php } ?>
<div id="addmoretask">
<?php if(empty($contract["contract_id"])){ ?>
<div id="task_container">
<div class="controls">
Task Category: <br>
<select name="task_category_id[]" class="span2">
<?php foreach($task_categories as $key => $task_category){ ?>
<option value="<?=$task_category["task_category_id"]?>" <?php if($task["task_category_id"] == $task_category["task_category_id"]) echo "selected"; ?>><?=$task_category["category_name"]?></option>
<?php } ?>
</select>
<br>
Title: <br><input type="text" name="task_title[]" class="span3" /><br>
Remark: <br><textarea name="task_remarks[]" class="span3" style="height: 80px;"><?=$task["task_remarks"]?></textarea>
</div>
</div>
<?php }else{
//$current_month = 3;
foreach($period_task as $key => $task){
?>
<div id="task_container" style="margin-top: 10px;">
<div class="controls">
<b>(<?=$key+1?>) Date:
<div class="input-append date-picker">
<input style="width: 75px;" type="text" id="task_start_date_<?=$task["ptask_id"]?>" name="task_start_date[<?=$task["ptask_id"]?>]" value="<?= h(Util::value_to_date_string($task["start_date"])) ?>" class="required dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
to
<div class="input-append date-picker">
<input style="width: 75px;" type="text" id="task_end_date_<?=$task["ptask_id"]?>" name="task_end_date[<?=$task["ptask_id"]?>]" value="<?= h(Util::value_to_date_string($task["end_date"])) ?>" class="required dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
(Status:
<select name="task_status[<?=$task["ptask_id"]?>]" style="width: 115px;">
<?php
$monthly_statusOptions=monthly_task_statusOption::statusOptions();
foreach($monthly_statusOptions as $key1 => $mstatus_option){
?>
<option value="<?=$key1?>" <?php if($task["status"] == $key1) echo "selected"; ?>><?=$mstatus_option?></option>
<?php
}
?>
</select>
<?php if($task["status"] == 2){ //display the completed date?>
<?php $attribute = 'completed_date';
$label = 'Completed Date'; ?>
<div class="input-append date-picker">
<input style="width: 75px;" type="text" id="<?= $attribute ?>" name="task_<?= $attribute ?>[<?=$task["ptask_id"]?>]" value="<?= h(Util::value_to_date_string($task["completed_date"])) ?>" 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>
<?php } ?>
)</b>
<br>
Task Category: <br>
<select name="task_category_id[<?=$task["ptask_id"]?>]" class="span2" <?php if(($task["end_date"] < date("Y-m-d") || $task["status"] != 1) ) echo "readonly";?>>
<?php foreach($task_categories as $key => $task_category){ ?>
<option value="<?=$task_category["task_category_id"]?>" <?php if($task["task_category_id"] == $task_category["task_category_id"]) echo "selected"; ?>><?=$task_category["category_name"]?></option>
<?php } ?>
</select>
<br>
Title: <br><input type="text" name="task_title[<?=$task["ptask_id"]?>]" value="<?=$task["task_title"]?>" class="span3" <?php if(($task["end_date"] < date("Y-m-d") || $task["status"] != 1) ) echo "readonly"; ?> /><br>
Remark: <br><textarea name="task_remarks[<?=$task["ptask_id"]?>]" value="<?=$task["task_remarks"]?>" class="span3" style="height: 80px;" <?php if(($task["end_date"] < date("Y-m-d") || $task["status"] != 1) ) echo "readonly";?> ><?=$task["task_remarks"]?></textarea>
<input type="hidden" name="task_id[<?=$task["ptask_id"]?>]" value="<?=$task["ptask_id"]?>" />
<br>
<?php if($task["end_date"] >= date("Y-m-d")){ ?>
<div class="btn" style="margin: 10px 0 10px 0;" onclick="var r=confirm('Are you sure to delete this task?');
if (r==true)
{
$.ajax({url: 'modify.php',
type: 'POST',
data:{delete_task_id:<?=$task["ptask_id"]?>, contract_id:<?=$_GET["id"]?>},
dataType: 'text',
timeout: 1000,
error: function(){/*alert('Error loading PHP document');*/window.location.reload();},
success: function(result){}
});
}
; "> -Delete </div>
<?php } ?>
</div>
</div>
<?php
}
?>
<?php } ?>
</div>
</div>
<div class="control-group">
<?php $attribute = 'technician1'; $label = 'Technician 1'; ?>
<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"'?>>
<option value=""></option>
<?php foreach ($staffs as $staff): ?>
<option value="<?=h($staff['id'])?>"<?=$staff['id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$staff['actived'] == 1 ? '' : '[Disabled] '?><?=h($staff['username'])?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php for($i = 2; $i <= 3; $i++){ ?>
<div class="control-group">
<?php $attribute = 'technician'.$i; $label = 'Technician '.$i; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<button type="button" onclick="technician(<?=$i;?>, 1)" id="<?=$attribute?>_enable">Enable</button>
<select id="<?=$attribute?>" name="<?=$attribute?>" placeholder="Select a <?=$label?>" class="select2" disabled>
<option value=""></option>
<?php foreach ($staffs as $staff): ?>
<option value="<?=h($staff['id'])?>"<?=$staff['id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$staff['actived'] == 1 ? '' : '[Disabled] '?><?=h($staff['username'])?></option>
<?php endforeach; ?>
</select>
<button type="button" onclick="technician(<?=$i;?>, 2)" id="<?=$attribute?>_disable" style="display: none;">Disable</button>
</div>
</div>
<?php } ?>
<div class="control-group">
<?php $attribute = 'senior_technician'; $label = 'Senior Technician'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<select id="<?=$attribute?>" name="<?=$attribute?>" placeholder="Select a <?=$label?>" class="select2"<?=Util::isAdmin() ? '' : ' disabled="disabled"'?>>
<option value=""></option>
<?php foreach ($staffs as $staff): ?>
<option value="<?=h($staff['id'])?>"<?=$staff['id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$staff['actived'] == 1 ? '' : '[Disabled] '?><?=h($staff['username'])?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'network_engineer'; $label = 'Network Engineer'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<select id="<?=$attribute?>" name="<?=$attribute?>" placeholder="Select a <?=$label?>" class="select2"<?=Util::isAdmin() ? '' : ' disabled="disabled"'?>>
<option value=""></option>
<?php foreach ($staffs as $staff): ?>
<option value="<?=h($staff['id'])?>"<?=$staff['id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$staff['actived'] == 1 ? '' : '[Disabled] '?><?=h($staff['username'])?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'sales'; $label = 'Sales'; ?>
<label class="control-label" for="<?=$attribute?>"><?=$label?></label>
<div class="controls">
<select id="<?=$attribute?>" name="<?=$attribute?>" placeholder="Select a <?=$label?>" class="select2"<?=Util::isAdmin() ? '' : ' disabled="disabled"'?>>
<option value=""></option>
<?php foreach ($staffs as $staff): if($staff["is_sales"] == 1){ ?>
<option value="<?=h($staff['id'])?>"<?=$staff['id'] == $contract[$attribute] ? ' selected="selected"' : ''?>><?=$staff['actived'] == 1 ? '' : '[Disabled] '?><?=h($staff['username'])?></option>
<?php } endforeach; ?>
</select>
</div>
</div>
<?php if($contract["status"] == 1){ ?>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">Save</button>
<button type="reset" class="btn" onclick="location.reload();">Reset</button>
</div>
</div>
<?php } ?>
</div>
</form>
<script type="text/javascript">
$(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 ($contract['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 ($contract['status'] == 1 && !Util::isAdmin() && $allow_edit_mode): ?>
$('#staff_id').select2('readonly', true);
$('#staff_id').select2('enable', true);
<?php endif; ?>
$('#form').validate();
});
function divdisplay(period){
if(period == 1){ //daily
$("#_week").hide();
$("#_start_time").show();
$("#_end_time").show();
$("#daily_generator").show();
$("#weekmonth_generator").hide();
}else if(period == 2 || period == 3){ //weekly or monthly
$("#_week").show();
$("#_start_time").hide();
$("#_end_time").hide();
$("#weekmonth_generator").show();
$("#daily_generator").hide();
}else{}
}
</script>
<script type="text/javascript">
function technician(technician, action){
if(action == 1){ //technician enable
$('#technician'+technician+'_enable').hide();
//$('#s2id_technician'+technician).show();
$('#technician'+technician).attr('disabled', false).select2();
$('#technician'+technician).trigger('change');
$('#technician'+technician+'_disable').show();
}else { //technician disable
$('#technician'+technician+'_disable').hide();
//$('#technician'+technician).attr('disabled', false);
$('#technician'+technician).attr('disabled', true).select2();
$('#technician'+technician).val("").trigger('change');
//$('#s2id_technician'+technician).hide();
$('#technician'+technician+'_enable').show();
}
}
$(function () {
$('#s2id_technician2').hide();
$('#s2id_technician3').hide();
<?php
if(!empty($contract["technician2"])){
echo "technician(2, 1);";
}else{
echo "technician(2, 2);";
}
if(!empty($contract["technician3"])){
echo "technician(3, 1);";
}else{
echo "technician(3, 2);";
}
?>
});
</script>
<?php require( __DIR__ . '/../../inc/_footer.php'); ?>
</div> <!-- /container -->
</body>
</html>
<?php unset($_SESSION["clash_contract_array"]); ?>