<script>
function Print() {
    window.print();
}
</script>
<?php
include_once 'main.php'; 
$op=$_GET['op'];
switch ($op) {
	case 'delDraft':
		//Delete Draft
		$drfid=sprintf("%d",$_GET['drfid']);
		if($draft->Delete($drfid)==1)
		{
			$success="پیش نویس موردنظر حذف شد";
			header("location: ./");
		}

		else
			$error="متاسفانه مشکلی در حذف این پیش نویس به وجود آمد";
		break;

	case 'print':


		$tskid=sprintf("%d",$_POST['tskid']);
		$taskinfo=$task->Getinfo('tskid',$tskid);
		$iid_array=$task->GetTaskIssues($tskid);
		$issueinfo=$issue->GetFullList();
		$printcolor=$_POST['printcolor'];
		$idetails=$_POST['idetails'];
		echo'
<!doctype html>
	<html>
			<head>
				<meta charset="utf-8">
				<title>Print</title>
			</head>
		<link rel="stylesheet" type="text/css" href="./themes/default/css/font-awesome.min.css">
		<style>
		@font-face {
		font-family: \'samim\';
		src: url(\'./themes/default/fonts/samim.eot\');
		src: url(\'./themes/default/fonts/samim.eot?#iefix\') format(\'embedded-opentype\'),
		url(\'./themes/default/fonts/samim.woff\') format(\'woff\'),
		url(\'./themes/default/fonts/samim.ttf\') format(\'truetype\');
		font-weight: normal;
		}
		.body{
			font-family: \'samim\', \'Open Sans\', sans-serif;
		}
		.header{
			'.($printcolor==1?'color:#d3004f;':'').'
			display:block;
			font-size:15px;
		}
		.text-center{
			text-align:center;
		}
		.tg{
			max-width:550px;
		}
		.button{
			font-size:20px;
		}

		
		</style>
		<body>
		';
		echo'
		<div class="body" dir="rtl">
		<center><button class="button" onclick="Print()"><i class="fa fa-print" aria-hidden="true"></i></button></center>
		<span class="header text-center">گزارشات ماموریت &rdquo; '.$taskinfo['0']['tsktitle'].' &ldquo;:</span>
		<style type="text/css">
		.tg  {border-collapse:collapse;border-spacing:0;}
		.tg td{font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
		.tg th{color:'.($printcolor==1?'white':'#555555').';background-color:'.($printcolor==1?'#428bca':'#eeeeee').';font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
		.tg .tg-yw4l{vertical-align:top}
		
		</style>
		<center>
		<table class="tg" width="550px">
		  <tr>
		    <th class="bgcl tg-yw4l">کد ماموریت<br></th>
		    <th class="tg-yw4l">عنوان ماموریت<br></th>
		    <th class="tg-yw4l">پروژه<br></th>
		    <th class="tg-yw4l">تاریخ درج<br></th>
		    <th class="tg-yw4l">انجام شده؟<br></th>
		    <th class="tg-yw4l">تاریخ انجام<br></th>
		  </tr>
		  <tr>
		    <td class="tg-yw4l" dir="ltr">'.$taskinfo['0']['tskcode'].'</td>
		    <td class="tg-yw4l">'.$taskinfo['0']['tsktitle'].'</td>
		    <td class="tg-yw4l">'.$taskinfo['0']['prjtitle'].'</td>
		    <td class="tg-yw4l" dir="ltr">'.G2J($taskinfo['0']['tskdate']).'</td>
		    <td class="tg-yw4l text-center">'.($taskinfo['0']['tskdone']==1?'<i style="color:'.($printcolor==1?'#00cf92':'').';" class="fa fa-check" aria-hidden="true"></i>':'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>').'</td>
		    <td class="tg-yw4l '.($taskinfo['0']['tskdone_date']==""?'text-center':'').' " dir="ltr" >'.($taskinfo['0']['tskdone_date']==""?'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>':''.G2JDATE($taskinfo['0']['tskdone_date']).'').'</td>
		  </tr>
		  <tr>
		    <td class="tg-yw4l" colspan="6"><span style="color:'.($printcolor==1?'#428bca':'#555555').';">توضیحات:</span><br>'.$taskinfo['0']['tskdesc'].'</td>
		  </tr>
		  <tr>
		    <td class="tg-yw4l" colspan="6"><span style="color:'.($printcolor==1?'#428bca':'#555555').';">یادداشت:</span><br>'.$taskinfo['0']['tskcomments'].'</td>
		  </tr>
		  <tr>
		    <td class="tg-yw4l" colspan="6"><span style="color:'.($printcolor==1?'#428bca':'#555555').';">مسئله های مربوط:</span><br>
		    ';
		    foreach ($issueinfo as $issuename) 
		    {
		    	if (in_array($issuename['iid'], $iid_array)) {
		    		echo '
		    		'.$issuename['ititle'].' '.($issuename['idone']==1?'<i style="color:'.($printcolor==1?'#00cf92':'').';" class="fa fa-check" aria-hidden="true"></i>':'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>').'
		    		';
		    	}
		    }
		    echo'
		    </td>
		  </tr>
		</table>
		';
		if ($idetails==1) 
		{
			echo'
			<span class="header text-center">گزارشات مسئله های مربوط به ماموریت &rdquo; '.$taskinfo['0']['tsktitle'].' &ldquo;:</span> ';
			foreach ($issueinfo as $issuename) 
			{
				if (in_array($issuename['iid'], $iid_array)) {
					echo '
					<table class="tg" width="550px">
					  <tr>
					    <th class="tg-yw4l">کد مسئله<br></th>
					    <th class="tg-yw4l">عنوان مسئله<br></th>
					    <th class="tg-yw4l">تاریخ درج<br></th>
					    <th class="tg-yw4l">انجام شده؟<br></th>
					    <th class="tg-yw4l">تاریخ انجام<br></th>
					    <th class="tg-yw4l">نسخه اجرا<br></th>
					  </tr>
					  <tr>
					    <td class="tg-yw4l" dir="ltr">'.$issuename['icode'].'</td>
					    <td class="tg-yw4l">'.$issuename['ititle'].'</td>
					    <td class="tg-yw4l" dir="ltr">'.G2J($issuename['idate']).'</td>
					    <td class="tg-yw4l text-center">'.($issuename['idone']==1?'<i style="color:'.($printcolor==1?'#00cf92':'').';" class="fa fa-check" aria-hidden="true"></i>':'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>').'</td>
					    <td class="tg-yw4l '.($issuename['idone_date']==""?'text-center':'').' " dir="ltr" >'.($issuename['idone_date']==""?'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>':''.G2JDATE($issuename['idone_date']).'').'</td>
					    <td class="tg-yw4l text-center" >'.($issuename['idone_version']==""?'<i style="color:'.($printcolor==1?'#d3004f':'').';" class="fa fa-times" aria-hidden="true"></i>':''.G2JDATE($issuename['idone_version']).'').'</td>
					  </tr>
					  <tr>
					    <td class="tg-yw4l" colspan="6"><span style="color:'.($printcolor==1?'#428bca':'#555555').';">توضیحات:</span><br>'.$issuename['idesc'].'</td>
					  </tr>
					  <tr>
					    <td class="tg-yw4l" colspan="6"><span style="color:'.($printcolor==1?'#428bca':'#555555').';">یادداشت:</span><br>'.$issuename['icomments'].'</td>
					  </tr>
					</table>

					';
				}
			} 
		}
		echo'
		</center>
		</div>
		';

	default:
		$error="صفحه موردنظر یافت نشد";
		break;
}
?>