| 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/job/views/ |
Upload File : |
<?php
//echo $_GET["customer_id"];
include ('../../inc/configure.php');
$customer_id = (int)$_GET["customer_id"];
/*$sql = "SELECT * FROM sup_contract where status = 1 and customer_id = '$customer_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_calls = $sth->fetchAll();
*/
$nowdate = date("Y-m-d");
$num_schedule_call = 0;
$num_services_call = 0;
$num_urgent_call = 0;
$num_remote_call = 0;
$total_job = 0;
//get contract data
$sql3 = "SELECT * FROM sup_contract WHERE ? <= contract_to and customer_id = ? and status = ?";
if (!($sth = $dbh->prepare($sql3))) {
throw new Exception("sql prepare statement failure: $sql3");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute(array($nowdate,$customer_id, "1"))) {
throw new Exception("sql execute statement failure: $sql3");
}
$contract = $sth->fetch(PDO::FETCH_ASSOC);
if(!empty($contract)){ //search time and contract time overlap
$search_date_range = dateRange( '2000-01-01', $nowdate, '+1 month');
$contract_date_range = dateRange( $contract["contract_from"], $contract["contract_to"], '+1 month');
$overlap_month = array();
foreach($search_date_range as $search_date){
foreach($contract_date_range as $contract_date){
if($search_date == $contract_date){ //overlap month
$overlap_month[] = $search_date;
}
}
}
if($contract["contract_type"] == 1){ //monthly
$size_of_overlap_month = sizeof($overlap_month);
if(!empty($contract['schedule_call_3hrs'])){
$schedule_call_type = "(3hrs)";
$contract_schedule_call = $contract['schedule_call_3hrs']*$size_of_overlap_month;
}else if(!empty($contract['schedule_call_half_day'])){
$schedule_call_type = "(4hrs)";
$contract_schedule_call = $contract['schedule_call_half_day']*$size_of_overlap_month;
}else if(!empty($contract['schedule_call_full_day'])){
$schedule_call_type = "(9hrs)";
$contract_schedule_call = $contract['schedule_call_full_day']*$size_of_overlap_month;
}else{
$contract_schedule_call = 0;
}
$contract_service_call = $contract['service_call']*$size_of_overlap_month;
$contract_urgent_call = $contract['urgent_call']*$size_of_overlap_month;
$contract_remote_call = $contract['remote_service_call']*$size_of_overlap_month;
$total_call = $contract_schedule_call+$contract_service_call+$contract_urgent_call+$contract_remote_call;
}else{ //package
if(!empty($contract['schedule_call_3hrs'])){
$contract_schedule_call = $contract['schedule_call_3hrs'];
}else if(!empty($contract['schedule_call_half_day'])){
$contract_schedule_call = $contract['schedule_call_half_day'];
}else if(!empty($contract['schedule_call_full_day'])){
$contract_schedule_call = $contract['schedule_call_full_day'];
}else{}
$contract_service_call = $contract['service_call'];
$contract_urgent_call = $contract['urgent_call'];
$contract_remote_call = $contract['remote_service_call'];
$total_call = $contract_schedule_call+$contract_service_call+$contract_urgent_call+$contract_remote_call;
}
}else{
$contract_schedule_call = 0;
$contract_service_call = 0;
$contract_urgent_call = 0;
$contract_remote_call = 0;
$total_call = 0;
}
$sql2 = "
SELECT job.*,customer.*, job.id as job_id
FROM sup_job job, v_cm_customer_support customer
WHERE job.customer_id = customer.cust_id
AND (COALESCE(LENGTH(?), 0) = 0 OR job.customer_id = ?)
AND (COALESCE(LENGTH(?), 0) = 0 OR job.`date` >= ?)
AND (COALESCE(LENGTH(?), 0) = 0 OR job.`date` <= ?)
ORDER BY customer.company_name ASC,job.id ASC
";
$parameters2 = array(
$customer_id, $customer_id,
$contract["contract_from"], $contract["contract_from"],
$contract["contract_to"], $contract["contract_to"],
);
if (!($sth = $dbh->prepare($sql2))) {
throw new Exception("sql prepare statement failure: $sql2");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters2)) {
throw new Exception("sql execute statement failure: $sql2");
}
$this_company = $sth->fetchAll();
foreach($this_company as $company){
$total_job++;
if($company["type"] == 1)
$num_schedule_call++;
else if($company["type"] == 2)
$num_services_call++;
else if($company["type"] == 3)
$num_urgent_call++;
else if($company["type"] == 4)
$num_remote_call++;
else {}
}
if($total_call != 0){
?>
<table class="table table-striped" style="width:550px;">
<caption class="text-left"><strong>Up to Today, this <?php if($contract["contract_type"] == 1) echo "Monthly Contract "; else echo "Package ";?>remain calls:</strong></caption>
<thead>
<tr>
<th>Schedule Call<?=$schedule_call_type?></th>
<th>Services Call</th>
<th>Urgent Call</th>
<th>Remote Call</th>
<th>Total Call</th>
</tr>
</thead>
<tr>
<td <?php if ($num_schedule_call > $contract_schedule_call) echo "style='background-color: #FA5858;'" ?>><?= $num_schedule_call . " / " . $contract_schedule_call ?></td>
<td <?php if ($num_services_call > $contract_service_call) echo "style='background-color: #FA5858;'" ?>><?= $num_services_call . " / " . $contract_service_call ?></td>
<td <?php if ($num_urgent_call > $contract_urgent_call) echo "style='background-color: #FA5858;'" ?>><?= $num_urgent_call . " / " . $contract_urgent_call ?></td>
<td <?php if ($num_remote_call > $contract_remote_call) echo "style='background-color: #FA5858;'" ?>><?= $num_remote_call . " / " . $contract_remote_call ?></td>
<td><?= "( ".$total_job."/".$total_call." )" ?></td>
</tr>
</table>
<?php
}else{
echo "No Contract";
}
?>