需要帮助编码搜索使用区域,文件号,申请人和申请状态

时间:2016-06-10 03:23:07

标签: php

我在办公室有一个用于注册项目申请的申请。它是使用MVC的代码点火器框架开发的。该应用程序可用于仅根据区域和应用程序状态搜索文件。但是有4个搜索项目,即区域,文件号,申请人和申请状态。现在我想使用区域搜索和文件号。或申请人姓名。以下是现有代码:

模型代码

    public function carian()
{

    /*

    This function is used to allow the user to search the database record for any one of the matching criteria 
    of the application including the mukim, file holding person, status and etc.

    */

    $data['mukim_id'] = 0; // default selectbox index
    $data['status'] = "0"; // default selectbox status

    $data['isResult'] = false;  
    $this->load->view('view-carian',$data);
}

public function hasilcarian()
{
    /*

    Render a record found view for the carian function.

    */


    $data['mukim_id'] = $_POST['mukim_id']; /*'mukim_id is area */
    $data['status'] = $_POST['status'];     /*'status is application status. i want to add 'no_fail' (file no.) and 'pemohon'(applicant) so i can search file using these from database */
    $data['isResult'] = true;

    $data['list'] = $this->modelpermohonan->hasilCarianPermohonan();

    if($data['list'] == false)
    {
        $data['isResult'] = false;
        $this->session->set_flashdata('mesej', '<span class="label label-info">Tiada rekod yang sepadan dijumpai!</span> ');
    }

    $this->load->view('view-carian',$data);

}

控制器代码

    <?php echo $this->navigasi->top(); ?>

<div class="container">
    <br>
    <h4 style="margin:0 auto;width:650px;color:white;">Carian Permohonan</h4>
    <br>
    <form class="form-horizontal the-form" action="<?php echo base_url(); ?>permohonan/hasilcarian/" method="post">
      <div class="control-group">
            <label class="control-label">Mukim:</label>
            <div class="controls">
              <select name="mukim_id" class="span3" id="mukim_id">
                <option value="%" <?php if($mukim_id == 0) { echo "selected"; } ?>>-- Semua Mukim --</option>
                <option value="1" <?php if($mukim_id == 1) { echo "selected"; } ?>>Hulu Langat</option>
                <option value="2" <?php if($mukim_id == 2) { echo "selected"; } ?> >Kajang</option>
                <option value="3" <?php if($mukim_id == 3) { echo "selected"; } ?>>Cheras</option>
                <option value="4" <?php if($mukim_id == 4) { echo "selected"; } ?>>Beranang</option>
                <option value="5" <?php if($mukim_id == 5) { echo "selected"; } ?>>Semenyih</option>
                <option value="6" <?php if($mukim_id == 6) { echo "selected"; } ?>>Hulu Semenyih</option>

              </select>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">No. Fail Jabatan:</label>
            <div class="controls">
                <input name="no_fail" type="text" class="input-xlarge" placeholder="No. Fail Jabatan" id="no_fail">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Nama Pemohon:</label>
            <div class="controls">
              <input name="pemohon" type="text" class="input-xlarge" placeholder="Nama Pemohon" id="pemohon">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Status:</label>
            <div class="controls">
                <select name="status" class="span3" id="status">
                  <option value="%" <?php if($status == 0) { echo "selected"; } ?>>-- Semua Status --</option>
                  <option value="Dalam Proses"  <?php if($status == "Dalam Proses") { echo "selected"; } ?>>Dalam Proses</option>
                  <option value="Lulus" <?php if($status == "Lulus") { echo "selected"; } ?>>Lulus</option>
                  <option value="Tangguh" <?php if($status == "Tangguh") { echo "selected"; } ?>>Tangguh</option>
                  <option value="Tolak" <?php if($status == "Tolak") { echo "selected"; } ?>>Tolak</option>
                </select>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls">
            <button class="btn btn-primary" type="submit"><i class="icon-white icon-ok"></i> Cari Rekod</button>
            </div>
        </div>
    </form>
    <br><br>

    <!-- Keputusan Carian !-->
    <center><?php echo $this->session->flashdata('mesej'); ?></center>
    <?php if($isResult == true) { ?>

    <table class="table table-bordered" style="background:#fff;">
          <thead>
            <tr>
              <th>Bil.</th>
              <th>No. Fail</th>
              <th>Pemohon</th>
              <th>Alamat Premis</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>
          <?php $i = 1; foreach($list as $a) { ?>
            <tr>
              <td><?php echo $i; ?>.</td>
              <td><a href="<?php echo base_url(); ?>maklumat/<?php echo $a->app_id; ?>"><?php echo $a->no_fail; ?></a></td>
              <td><?php echo $a->pemohon; ?></td>
              <td><?php echo $a->alamat_premis; ?></td>
              <td><?php echo $a->status; ?></td>
            </tr>
            <?php $i++; } ?>
          </tbody>
        </table>

      <?php } ?>
      <!-- Keputusan Carian !-->

</div> <!-- /container -->

查看代码

printf("\n%s",&c[0]);

1 个答案:

答案 0 :(得分:0)

我认为MVC框架id是为了使你的代码足够灵活,适合大型应用程序。

您必须编写另一个模型和另一个为您的视图生成列表的控制器。这就是主意。