<?php

ob_start();

//include my own function
include 'includes/functions.php';

//customly collect the id and session
if (isset($_GET['u'])) {
    $u = $_GET['u'];
} else {
    header("Location:dashboard.php?sms=rules");
}
//collect other dinfo
$dept_id = get_user_department_id($u);
$programme_id = get_user_programme_id($u); //get programme if for a suer
$level = get_user_level($u); //get user level
$programme_type = get_user_programme_type_id($u); //programme type

$session = get_current_session($id = '1'); //current session is always

//for imge
$image = get_user_image($u); //get image

//get logo
//$logo = 'images/ibb.png';

// Include the main TCPDF library (search for installation path).
require_once 'tcpdf/tcpdf_include.php';

// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF
{

    //Page header
    public function Header()
    {
        // Logo
        $image_file = K_PATH_IMAGES.'logo.jpg';
        $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
        // Set font
        $this->SetFont('helvetica', 'B', 14);
        // Title
        //$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M'); original commented
        //$this->Cell(0, 15, 'IBBU CONSULT & SERVICES', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }
    // Page footer
    public function Footer()
    {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 10, "SOURCE: http://accommodation.coeminna-edu.ng  - ACCOMMODATION Portal,  Page " . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

//customly collect the title
$title = str_replace('/', '_', get_user_mat_no($u)) . '-EC';
$title = strtoupper($title);
$author = get_user_fullname($u) . '_ COE MX';

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($title);
$pdf->SetSubject('Hostel Rule and Regulation');
$pdf->SetKeywords('COE Minna, PDF, Rules, Regulation, slip');

// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
    require_once dirname(__FILE__) . '/lang/eng.php';
    $pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
//$pdf->SetFont('times', 'BI', 12) original;
$pdf->SetFont('times', '', 13);

// add a page
$pdf->AddPage();

//collect other dinfo
$dept_id = get_user_department_id($u);
$level = get_user_level($u); //get user level
$name = strtoupper(get_user_fullname($u));
$mat_no = strtoupper(get_user_mat_no($u));

//collect academic info
$pt = "<strong>" . strtoupper(show_programme_type(get_user_programme_type($u))) . "</strong>";
$study_mode = strtoupper(show_study_mode(get_user_study_mode($u)));
$department = strtoupper(get_department_title(get_user_department_id($u)));
//$programme = strtoupper(get_programme_title(get_user_actual_programme_id($u)));

$st = get_session_title($session);

//set the content //this is my own function
$output0 = '';
$output0 = '<div class="text-center"><img src="images/coe.png" height="80"  width="80"/></div>';

//$output0 .= '<span align="center"> <img  src="' . $logo . '" border="0" height="79" width="80" /></span>';
$output0 .= '<h3 style="line-height:0.5">NIGER STATE COLLEGE OF EDUCATION MINNA</h3>';
//$output0 .= '<h5  style="color:#00000; font-weight:normal" >ACCOMMODATION RULES & REGULATIONS</h5>';
$output0 .= '<h6   style="color:#FF0000; font-weight:normal"> ' . $st . ' ACADEMIC SESSION.</h6>';
$output0 .= '<h5  style="color:#FFFFFF; font-weight:bold;background-color:green;"  > HOSTEL RULES AND REGULATION  </h5>';
$output = '';

// <td width="50%"> <b>PROGRAMME :</b> $programme</td>

// set some text to print
$txt = <<<EOD


<br/>
<div align="center"> $output0 </div>

<br><br>
<strong style="line-height:0.5">PLEASE READ THE INSTRUCTIONS BELOW VERY CAREFUL, IGNORANCE IS NEVER AN EXCUSE</strong><br>
<p style="font-size:12px;">
<h2>HOSTEL REGULATIONS</h2><br/>
<p>All students officially allocated bed spaces in Hall of residence are made to sign an
 undertaking to be of good conduct and to abide by the following College rules and regulations:</p><br/>
 <p>
 <strong >a.</strong> College authority is not under any obligation to provide students with hostel accommodation. Hence, allocation of bed space in Hall of residence is therefore a privilege and not a right.<br/>
 <strong >b.</strong>	Rooms may be occupied on the day before the beginning of lectures, and through to the last day of the session.<br/>
 <strong >c.</strong>	Rooms are rented on sessional basis. All rents are payable after allocation to the room(s).<br/>
 <strong >d.</strong>	Students who withdraw from the Hostel for any reason or who are dismissed or are requested to withdraw from the College for any reason whatsoever after the beginning of the session are not entitled to return to the hall or to any refund of accommodation fees or any other required charges.<br/>
 <strong >e.</strong>	The right to room is not transferable. It is an offence punishable by fine and/or by expulsion from the hostel to make such transfer.<br/>
 <strong >f.</strong>	Students are held liable for any careless or willful destruction or damage of College property. Repair cost for proven damages/destruction will be charged to the student. Any damage to common room facilities shall be the collective responsibility of the students concerned.<br/>
 <strong >g.</strong>	At the close of the session, expulsion from hostel or upon severance of their connection with any part of the work of College, students are required to return immediately all keys and other College property in their possession to the appropriate officer.<br/>
 <strong >h.</strong>	Willful failure to submit keys at close of session attracts strict penalty.<br/>
</p><br/>
<h2>HOSTEL SANITATION</h2><br/>
<p>The Students' Welfare Committee shall at its discretion visit the students' hostel and
rooms for inspection purposes. Thrashes, wastes, sanitary pads, etc; should be placed
in the dustbins / receptacles provided in the hostel and toilets. On no account should
these be thrown into the sinks. A Hostel is a center of a community life. All resident
students are expected to contribute their quota to make it a happy home. Each student is
also required to exercise the greatest discretion and self discipline in relation to other
students, hostel authorities and staff as well as the general public.</p><br/>
<h2>APPROVED HOSTEL FUNCTIONS</h2><br/>
<p>The hall master/mistress must be notified of students’ meeting or any functions taking place
in the hostel. Application for approval to hold a function in the hostel must be obtained
from the applicants within 48 hours of that function. Any visitor attending such meeting or
function must sign visitors' book<br/><br/><br/><br/><br/><br/></p><br/><br/><br/><br/>
<strong>NOISE, ELECTRICAL APPLIANCES, FIRE AND FIRE PREVENTION</strong><br/>
<p><br/>
<strong>a.</strong>	In the interest of hostel residents, noise must be kept to the minimum. Wireless sets, radios, stereo sets are to be used not later than 10:00 p.m. each day. These instruments should not, however, be played in such a manner as to cause disturbance to others.<br/>
<strong>b.</strong>	No appliance may, on any account, be connected to the lighting circuit.<br/>
<strong>c.</strong> Students must not tamper with or alter in any way electrical installations in their rooms or any part of the hostel.<br/>
<strong>d.</strong>	The installation and/or use of cookers, toasters, immersion heaters, refrigerators, cooking rings, etc;  is not allowed in students' rooms.<br/><br/><br/><br/>
<strong>e.</strong>	Any incident of fire shall be investigated by the Students’ Affairs/Advisory Committee and reported to the Provost. Both the national fire codes and the College regulation will govern the criminal and/or disciplinary action to be taken against person(s) found responsible for the fire out break.<br/>
<strong>f.</strong>	When there is no electricity and students make their own arrangements 	to buy and use candles, great caution must be exercised to avoid any possible fire out-break.<br/>
<strong>g.</strong>	Smoking of cigarettes is not allowed in the rooms.<br/>
<strong>h.</strong>	Students are responsible for all items or furniture and other school 	properties in their rooms.<br/>
<strong>I.</strong>	Students leaving their rooms on vacation or finally on completion of their courses must be properly checked out by the Porters/Portresses before they leave. The College will not be responsible for personal effects left behind by students.<br/>
<strong>j.</strong>	Students causing a local electrical power failure in a part of the  hostel or even the whole hostel will be charged with the cost of restoration of 	power and may face further disciplinary action.<br/>
<strong>k.</strong>	All fixtures; fittings and furnishing must not be tampered or modified in anyway whatsoever.<br/>
<strong>l.</strong>	No posters, post cards, newspaper/magazine cuttings, etc; shall the displayed on the walls, doors or windows of hostel rooms.<br/>
<strong>m.</strong>	Permission must be obtained from the appropriate authority for the use of halls or classrooms for extra curricula activities.<br/>
<strong>n.</strong>	Students must leave the hostel not later than 12 noon of the following day of the day on which the College officially closes except on permission by the College authorities.<br/>
<strong>o.</strong>	No meal, cookery or cutlery shall be removed out of the cafeteria except for students issued with medical certificates of unfitness to walk to or to feed at the cafeteria.<br/>
<strong>p.</strong>	All complaints relating to meals or cafeteria services shall be directed to the Students' Union Welfare Officer or the President of the Students’ Union.<br/>
<strong>q.</strong>	Under no circumstances shall meals be cooked within students’ rooms or along corridors. Any student found guilty of this offence shall be suspended from the hostel for up to one academic year.<br/>
<strong>r.</strong>	It is an offence punishable by expulsion from the hostel for any student to sublet accommodation to any visitor overnight or permit a squatter in his/her room without written approval of the Student Affairs Officer.<br/>
<strong>s.</strong>	If an already ejected Landlord or squatter is caught again pirating or squatting with another student in hostel, the second offender shall be suspended from the College for up to one academic year, while the first offender (the new Landlord) forfeits his/her room allocation without any 	refund.<br/>
</p><br/>
h3>TRANSFERS FROM ONE HALL TO ANOTHER</h3><br/>
<p>A  student, once allocated to a hall, is not normally permitted to transfer
	to another one except on medical grounds and/or for any other good reasons
	acceptable to the Student Welfare Committee. Application for such a transfer
	should be made on the approved form obtainable from the office of the Students’
	Affairs Officer. Once application is approved, it is the responsibility of the
	student to transfer himself/herself. The College, however, reserves the right to
	make changes in room assignments or transfer students from one Hall to another during the session.</p><br/>

 <h3>VACATION  RESIDENCE</h3><br/>
<p>The Halls of residence is used during the long vacations for conference and Seminar.
Application forms for permission to stay in residence during the long vacation must be
filled and returned to the Student Affairs Officer not later than one week before the
end of the second semester. Students staying in halls of residence during the long vacation
are required to pay rent in advance. Students who are permitted to stay in Halls of residence
for the vacation must move to the Hall currently assigned for that purpose.<br/></p>
<br/>
<br/>
<strong><center>UNDERTAKING</center></strong>
<p>I, <b>$name</b> of Department <b>$department</b> with
Matric. No.: <b>$mat_no</b> Accept Residence,  In .... Hall.
Consequent upon this acceptance, I Solemenly swear to abide by the regolation governing my
residence and i accept liability in the event of breach of any of the regolations</p><br/><br/>
______________________________________<br>Students Signature<br><br/><br/>

______________________________________<br>Hall Administrator Signature/Date<br><br/><br/>

______________________________________<br>Dean of Students Signature/Date<br>


EOD;

$pdf->writeHTML($txt, true, false, false, false, '');

// ---------------------------------------------------------

//Close and output PDF document
//$pdf->Output('example_003.pdf', 'I');
$pdf->Output($title . '.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+
