Welcome Guest, Not a member yet? Register   Sign In
Chronological order of data base on the date
#3

(11-29-2018, 03:17 AM)Pertti Wrote: How do you do your DB query? If you are saying the last record of page 1 is showing up as first record of page 2, sounds like issue with calculating LIMIT attributes and you just need to pump figures up by one.

Code:
foreach($rows as $row)
         {
            $pdf->SetFont('Arial', '', 11);
            $pdf->SetX(10);
            
            //$pdf->Write(0, $row->id);
            $pdf->Cell(15,12, $row->id ,'1',0,'L',false);
            
            
            $pdf->SetX(29);
            //$pdf->Write(0, $row->lname.', '.$row->fname.''.$row->mname);
            $pdf->Cell(30,12, word_wrap($row->lname.', '.$row->fname.''.$row->mname, 10) ,'1',1,'L',false);
            
            
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetX(62);
            $pdf->Write(0, $row->sex);
            
            $pdf->SetX(75);
            //$pdf->Write(0, $row->company);
            $pdf->Write(0, $row->position);
            
            //$pdf->SetFont('Arial', '', 12);
            $pdf->SetX(160);
            $pdf->Write(0, $row->movement);
            
            //$pdf->SetX(150);
            //$pdf->Write(0, $row->salary_grade);
            
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetX(185);
            //$pdf->Write(0, $row->status);
            
            if ($row->govt_service == 1)
            {
                $row->govt_service = 'Yes';
            }
            else
            {
                $row->govt_service = 'No';
            }
            
            $pdf->SetX(190);
            //$pdf->Write(0, $row->govt_service);            
                          
            $pdf->SetFont('Arial', '', 12);    
            
            
            if ($i == 6 || $i == 10  || $i == 13 || $i == 16 || $i == 19 || $i == 22)
            {
                $pdf->Ln(8);
            }
            else
            {
                $pdf->Ln(7);
            }
            
            $i++;
            
         }
Code:
class Sr_preview extends MX_Controller
{
    var $pds = array();
    
    function __construct()
   {
       parent::__construct();
   }
    
    function preview($employee_id)
    {
        
        $this->load->helper('settings');
        
        $this->load->library('fpdf');
        
        //define('FPDF_FONTPATH',$this->config->item('fonts_path'));
                    
        $this->load->library('fpdi');
        
        //$pi = new Personal();
        //$pi->get_by_employee_id( $employee_id );
        
        //print_r($personal_info);    
        // initiate FPDI  
        $pdf = new FPDI('P','mm','Letter');
        
        // add a page
        $pdf->AddPage();
        // set the sourcefile
        //$pdf->setSourceFile('dtr/template/service_record/service_record.pdf');
        // import page 1
        //$tplIdx = $pdf->importPage(1);
        // use the imported page and place it at point 10,10 with a width of 100 mm
        //$pdf->useTemplate($tplIdx, 1, 1, 210);
        // now write some text above the imported page
        $pdf->SetFont('Arial');
        $pdf->SetTextColor(0,0,0);
        
        $pdf->SetXY(15, 60);
        
        $pdf->SetFont('Arial', '', 16);    
        
        $pdf->Cell(0,3,"Employee's Service Record" ,'',1,'C',false);
        
        $pdf->Ln(4);
        
        $e = new Employee_m();
        
        $e->get_by_id( $employee_id );
        
        $pdf->SetFont('Arial', '', 12);    
        $pdf->Cell(0,8,"Employee No.:".$e->employee_id ,'',1,'L',false);
        $pdf->Ln(2);
        $pdf->SetFont('Arial', '', 12);    
        $pdf->Cell(0,8,"Employee Name:".$e->lname.', '.$e->fname.' '.$e->mname ,'',1,'L',false);
        
        $pdf->Ln(4);
        
        $pdf->Cell(0,8,"Date From Date To   Position                               Department                        Movement Status   Status" ,'1',1,'L',false);
        
        $pdf->Ln(4);
        
        $work = new Work();
        
        $work->where('govt_service', '1');
        $work->order_by('inclusive_date_from', 'DESC');
        
        $works = $work->get_by_employee_id($employee_id);
        
        
        $i = 1;
        
        $this->load->helper('text');
        
         foreach($works as $work)
         {
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetX(10);
            
            list($year, $month, $day) = explode('-', $work->inclusive_date_from);
            
            $inclusive_date_from = $month.'/'.$day.'/'.$year;
            
            $pdf->Write(0, $inclusive_date_from);
            
            list($year, $month, $day) = explode('-', $work->inclusive_date_to);
            
            $inclusive_date_to = $month.'/'.$day.'/'.$year;
            
            if ($work->inclusive_date_to == 'Present')
            {
                $inclusive_date_to = 'Present';
            }
            
            $pdf->SetX(29);
            $pdf->Write(0, $inclusive_date_to);
            
            
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetX(50);
            $pdf->Write(0, str_replace('…', '..', character_limiter($work->position, 35)));
            
            $pdf->SetX(100);
            //$pdf->Write(0, $work->company);
            $pdf->Write(0, str_replace('…', '..', character_limiter($work->company, 35)));
            
            //$pdf->SetFont('Arial', '', 12);
            $pdf->SetX(160);
            $pdf->Write(0, $work->movement);
            
            //$pdf->SetX(150);
            //$pdf->Write(0, $work->salary_grade);
            
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetX(185);
            $pdf->Write(0, $work->status);
            
            $work->govt_service = ($work->govt_service == 1) ? 'Yes' : 'No';
            
            $pdf->SetX(190);
            //$pdf->Write(0, $work->govt_service);            
                          
            $pdf->SetFont('Arial', '', 12);    
            
            
            if ($i == 7 || $i == 10  || $i == 13 || $i == 16 || $i == 19 || $i == 22)
            {
                $pdf->Ln(8);
            }
            else
            {
                $pdf->Ln(7);
            }
            
            $i++;
            
         }
PHP Code:
class Search_result_preview extends MX_Controller
{
    var 
$pds = array();
    
    function 
__construct()
 
   {
 
       parent::__construct();
 
   }
    
    function 
preview$rows $report_name '' )
    {
        
$html '
        
        <table width="100%" border="0">
      <tr>
        <td colspan="3" align="center">'
.$report_name.'</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
            
    <table width="100%" border="1">
    <tbody><tr>
      <td width="10%"><strong>Employee ID</strong></td>
      <td width="9%"><strong>Name</strong></td>
      <td width="4%"><strong>Sex</strong></td>
      <td width="10%"><strong>Position/<br />
        Designation</strong></td>
      <td width="13%"><strong>Office / Department</strong></td>
      <td width="11%"><strong>Employment Status</strong></td>
      <td width="6%"><strong>Salary Grade</strong></td>
      <td width="9%"><strong>Eligibility</strong></td>
      <td width="11%"><strong>Education</strong></td>
      <td width="8%"><strong>Birthday</strong></td>
      <td width="9%"><strong>Address</strong></td></tr>'
;
        
        
$params = array('format' => 'Letter-L');
        
        
$this->load->library('mpdf'$params);
        
// LOAD a stylesheet
        
$stylesheet file_get_contents(base_url().'css/mpdf/mpdfstyletables.css');
        
$this->mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text
        
$this->mpdf->WriteHTML($html);
        
        
        
$office = new Office_m();
        
        foreach(
$rows as $row)
        {
            
$office->get_by_office_id($row->office_id);
            
$type_employment $this->options->type_employment();
            
            
$birth_date $row->birth_date;
            
            if ( 
$row->birth_date == '0000-00-00')
            {
                
$birth_date '';
            }
            
            
$entry='
            <tr>
                <td>'
.$row->id.'</td>
                 <td>'
.$row->lname.','$row->fname.' '.$row->mname.'</td>
                 <td>'
.$row->sex.'</td>
                 <td>'
.$row->position.'</td>
                 <td>'
.$office->office_name.'</td>
                 <td>'
.$type_employment[$row->permanent].'</td>
                 <td>'
.$row->salary_grade.'-'.$row->step.'</td>
                 <td>'
.$row->eligibility.'</td>
                 <td>'
.$row->education.'</td>
                 <td>'
.$birth_date.'</td>
                 <td>'
.$row->res_address.'</td>
            </tr>'
;
            
            
$this->mpdf->WriteHTML($entry);
        }
        
        
        
    
$signatories='
    <tr><td><p>&nbsp;</p></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td><td>&nbsp;</td></tr>
    </tbody></table>'
;


    
// Signatories
    
$sr_prepared             $this->Settings->get_selected_field'sr_prepared' );
    
$sr_prepared_position     $this->Settings->get_selected_field'sr_prepared_position' );
    
$sr_certified             $this->Settings->get_selected_field'sr_certified' );
    
$sr_certified_position     $this->Settings->get_selected_field'sr_certified_position' );

    
$signatories.='
    <table width="100%" border="0">
      <tr>
        <td width="38%">&nbsp;</td>
        <td width="23%">&nbsp;</td>
        <td width="39%">&nbsp;</td>
      </tr>
      <tr>
        <td align="center">PREPARED BY:</td>
        <td>&nbsp;</td>
        <td align="center">CERTIFIED CORRECT:</td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td align="center">'
.$sr_prepared.'</td>
        <td>&nbsp;</td>
        <td align="center">'
.$sr_certified.'</td>
      </tr>
      <tr>
        <td align="center">'
.$sr_prepared_position.'</td>
        <td>&nbsp;</td>
        <td align="center">'
.$sr_certified_position.'</td>
      </tr>
    </table>
    '
;
    
        
$this->mpdf->WriteHTML($signatories);
        
        
$this->mpdf->Output('dtr/template/pds/archives/pds_'.date('Y_m_d').'.pdf''F');
        return 
'dtr/template/pds/archives/pds_'.date('Y_m_d').'.pdf';
        exit;
        
        
        
        
$this->load->helper('settings');
        
        
$this->load->library('fpdf');
        
        
//define('FPDF_FONTPATH',$this->config->item('fonts_path'));
                    
        
$this->load->library('fpdi');
        
        
// initiate FPDI   
        
$pdf = new FPDI('L','mm','Letter');
        
        
// add a page
        
$pdf->AddPage();
        
// set the sourcefile
        //$pdf->setSourceFile('dtr/template/service_record/service_record.pdf');
        // import page 1
        //$tplIdx = $pdf->importPage(1);
        // use the imported page and place it at point 10,10 with a width of 100 mm
        //$pdf->useTemplate($tplIdx, 1, 1, 210);
        // now write some text above the imported page
        
$pdf->SetFont('Arial');
        
$pdf->SetTextColor(0,0,0);
        
        
$pdf->SetXY(1560);
        
        
$pdf->SetFont('Arial'''16);    
        
        
$pdf->Cell(0,3,"Report Name" ,'',1,'C',false);
        
        
//$pdf->Ln(4);
        
        //$e = new Employee_m();
        
        //$e->get_by_employee_id( $employee_id ); 
        
        
$pdf->SetFont('Arial'''12);    
        
//$pdf->Cell(0,8,"Employee No.:".$e->id ,'',1,'L',false);
        //$pdf->Ln(2);
        //$pdf->SetFont('Arial', '', 12);    
        //$pdf->Cell(0,8,"Employee Name:".$e->lname.', '.$e->fname.' '.$e->mname ,'',1,'L',false);
        
        
        
        
$pdf->Ln(4);
        
        
$pdf->Cell(0,8,"Emp ID    Name                  Sex     Position/Designation    Office    Employment Status     Salary Grade Eligibility Education Birth Day   Address" ,'1',1,'L',false);
        
        
$pdf->Ln(4);
        
        
$i 1;
        
        
$this->load->helper('text');
        
        
//$pdf->Cell(30,12, word_wrap('msayado maahhn ndhah ahhhehe so ano gagawin mo now', 10) ,'1',1,'L',false);
        //$pdf->MultiCell(30,3,word_wrap("hello this is a sample nlong text with line break ", 15) ,'1',1,'L',false);
        //$pdf->MultiCell(30,3,word_wrap("hello this is a sample nlong text with line break ", 15) ,'0',1,'L',false);
        
         
foreach($rows as $row)
         {
            
$pdf->SetFont('Arial'''11);
            
$pdf->SetX(10);
            
            
//$pdf->Write(0, $row->id);
            
$pdf->Cell(15,12$row->id ,'1',0,'L',false);
            
            
            
$pdf->SetX(29);
            
//$pdf->Write(0, $row->lname.', '.$row->fname.''.$row->mname);
            
$pdf->Cell(30,12word_wrap($row->lname.', '.$row->fname.''.$row->mname10) ,'1',1,'L',false);
            
            
            
$pdf->SetFont('Arial'''8);
            
$pdf->SetX(62);
            
$pdf->Write(0$row->sex);
            
            
$pdf->SetX(75);
            
//$pdf->Write(0, $row->company);
            
$pdf->Write(0$row->position);
            
            
//$pdf->SetFont('Arial', '', 12);
            
$pdf->SetX(160);
            
$pdf->Write(0$row->movement);
            
            
//$pdf->SetX(150);
            //$pdf->Write(0, $row->salary_grade);
            
            
$pdf->SetFont('Arial'''8);
            
$pdf->SetX(185);
            
//$pdf->Write(0, $row->status);
            
            
if ($row->govt_service == 1)
            {
                
$row->govt_service 'Yes';
            }
            else
            {
                
$row->govt_service 'No';
            }
            
            
$pdf->SetX(190);
            
//$pdf->Write(0, $row->govt_service);            
             
              
            $pdf
->SetFont('Arial'''12);    
            
            
            if (
$i == || $i == 10  || $i == 13 || $i == 16 || $i == 19 || $i == 22)
            {
                
$pdf->Ln(8);
            }
            else
            {
                
$pdf->Ln(7);
            }
            
            
$i++;
            
         } 
PHP Code:
'.$service;
    
        
        $s = new Service_record();
        
        $s->order_by('
date_from');
        
        $rows = $s->get_by_employee_id($employee_id);
    
    $i = 0; 
    

    //for ($i ==0; $i != 70; $i ++)
    foreach ($rows as $row)
    {
    
        $number_character = strlen( $row->designation.$row->salary.$row->salary.
                            $row->office_entity.$row->lwop.$row->separation_date.$row->separation_cause );
        
        $html .='
<tr>
                <
td align="center">'.$row->date_from.'</td>
                <
td align="center">'.$row->date_to.'</td>
                <
td align="left">'.$row->designation.'</td>
                <
td align="left">'.$row->status.'</td>
                <
td align="right">'.$row->salary.'</td>
                <
td align="left">'.$row->office_entity.'</td>
                <
td align="left">'.$row->lwop.'</td>
                <
td align="left">'.$row->separation_date.'</td>
                <
td align="left" style="font-size:7">'.$row->separation_cause.'</td>
             
 </tr>';
          
        // Second page
          if ( $i == 18)
        {
            $html .='
</table>'; // close the table
            $html .='
<pagebreak />'.$service;
            
            $html .='
<tr>
                <
td align="center">'.$row->date_from.'</td>
                <
td align="center">'.$row->date_to.'</td>
                <
td align="left">'.$row->designation.'</td>
                <
td align="left">'.$row->status.'</td>
                <
td align="right">'.$row->salary.'</td>
                <
td align="left">'.$row->office_entity.'</td>
                <
td align="left">'.$row->lwop.'</td>
                <
td align="left">'.$row->separation_date.'</td>
                <
td align="left">'.$row->separation_cause.'</td>
             
 </tr>';
            
        }
        
        // If there is third page
        if ( $i == 37)
        {
            $html .='
</table>'; // close the table
            $html .='
<pagebreak />'.$service;
            
            $html .='
<tr>
                <
td align="center">'.$row->date_from.'</td>
                <
td align="center">'.$row->date_to.'</td>
                <
td align="left">'.$row->designation.'</td>
                <
td align="left">'.$row->status.'</td>
                <
td align="right">'.$row->salary.'</td>
                <
td align="left">'.$row->office_entity.'</td>
                <
td align="left">'.$row->lwop.'</td>
                <
td align="left">'.$row->separation_date.'</td>
                <
td align="left">'.$row->separation_cause.'</td>
             
 </tr>';
            
        }
    
        $i++;  
    
    }
    
  
  $html .='
</table>';

//$html.='
//<pagebreak />
//'.$service.'</table>


//<pagebreak />


//';
        
$params = array('format' => 'Letter');
        
        
$this->load->library('mpdf'$params);
        
        
//$mpdf=new mPDF('c','Letter'); 

        
$this->mpdf->mirrorMargins 1;    // Use different Odd/Even headers and footers and mirror margins
        
        
$stylesheet file_get_contents(base_url().'css/mpdf/mpdfstyletables.css');
        
$this->mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no
        
        
        
$this->mpdf->WriteHTML($html);
        
        
$this->mpdf->Output();
        
    }
    
    
// --------------------------------------------------------------------
    
    
function employees($office_id '')
    {
        
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
        
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
        
        
$profile     = new Profile();
        
        
$profile->order_by('lname');
            
        
$employees     $profile->get_by_office_id$office_id );
        
        
$json         = array();
        
        foreach (
$employees as $employee)
        {
            
//$personal->get_by_id( $employee->employee_id );
            
            
$json[$employee->id] = $employee->lname.', '.$employee->fname;
        }
        
        
//$json = sort($json);
        
        
echo json_encode($json);
        
        
        
    }
    
    function 
change_employee($office_id '')
    {
        
        echo 
$this->input->post('employee_id');
        
        
        
        
    }
    
    



Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
RE: Chronological order of data base on the date - by jelz2018 - 12-02-2018, 07:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB