Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
Hello!

I have two templates, viz.:
1. students.php
2. fees.php

The students.php template is a DBF to create a student. The fees.php template is a DBF to create a month and the fees of the month.

I have also created a third template named fees-payment.php. I intend to use this template to generate a receipt of fees payment, i.e. if student X pays fees for January a receipt stating the same should be generated. And once the student X has paid the fees for January, when she returns for paying the fees, the month of January should not appear on the fees-payment.php.

How can this be done?

My codes for the templates are:

students.php
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Students' clonable='1'>
   <!-- k_page_title == Student Name -->
   <cms:editable name='smobile' label='Student Mobile Number' type='text' required='1' validator='exact_len=10 | non_negative_integer' order='1' />   
   <cms:editable name='semail' label='Student Email Id' type='text' required='1' validator='email' order='2' />

   <cms:editable name='student_feesmonth' label='Paid Months' desc='will appear selected' type='relation' masterpage='fees.php' reverse_has='many' order='3' />
</cms:template>
<html>
   <head>
      <title>Students</title>
      <link href="assets/css/bootstrap.css" rel="stylesheet" />
      <link href="assets/css/font-awesome.css" rel="stylesheet" />
      <style>
         body {
            margin: 0;
            padding: 0;
         }
         table > thead > tr > th,
         table > tbody > tr > td {
            padding: 5px 10px;
         }
         table > thead > tr > th {
            background-color: rgba(0,0,0,0.8);
            color: white;
         }
         .gxcpl-ptop-10 {
            padding-top: 10px;
         }
         input {
            padding: 5px 10px;
            border: 1px solid #ccc;
            width: 100%;
         }
         button.gxcpl-btn-text {
            text-transform: uppercase;
            font-weight: bold;
            letter-spacing: 1px;
         }
         a {
            cursor: pointer;
            color: #212121;
            font-weight: bold;
         }
         a:hover {
            text-decoration: none;
            color: #2980b9;
         }

         /* Paginator */
         div.pagination {
             padding: 5px;
             margin: 5px;
         }
         div.pagination a {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             zoom: 100%;
             text-decoration: none; /* no underline */
             color: rgba(0,0,0,0.8);
         }
         div.pagination a:hover, div.pagination a:active {
             border: 1px solid rgba(0,0,0,0.8);
             color: rgba(0,0,0,0.8);
         }
         div.pagination span.page_current {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             * zoom: 100%;
             font-weight: bold;
             background-color: rgba(0,0,0,0.8);
             color: #FFF;
         }
         div.pagination span.page_disabled {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid #ccc;
             * zoom: 100%;
             color: #ccc;
         }
         * span.elipsis {zoom:100%}
         /* Paginator */
      </style>
   </head>

   <body>
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <h1>
                  Student
               </h1>
            </div>
         </div>
      </div>

      <hr>

      <!-- FORM -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <cms:set submit_success="<cms:get_flash 'submit_success' />" />
               <cms:if submit_success >
                  <h4>Success: Student data saved.</h4>
               </cms:if>
               <cms:form masterpage=k_template_name mode='create' enctype='multipart/form-data' method='post' anchor='0'>
                  <cms:if k_success >
                     <cms:db_persist_form
                          _invalidate_cache='0'
                          k_page_title=frm_k_page_title
                          k_page_name=random_name
                      />
                     <cms:if k_success>
                        <cms:set_flash name='submit_success' value='1' />
                        <cms:redirect k_page_link />
                     </cms:if>
                  </cms:if>
                  <cms:if k_error >
                     <div class="error">
                        <cms:each k_error >
                           <br><cms:show item />
                        </cms:each>
                     </div>
                  </cms:if>
                  <div class="row">
                     <div class="col-md-2">
                        <label for='k_page_title'>Full Name</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <cms:input class="form-control" name='k_page_title' type='bound' />
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2">
                        <label for='smobile'>Mobile Number</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <cms:input class="form-control" name='smobile' type='bound' />
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2">
                        <label for='semail'>Email</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <cms:input class="form-control" name='semail' type='bound' />
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-12">
                        <center>
                           <button type='submit' class="btn btn-danger gxcpl-btn-text">
                              <i class="fa fa-save"></i> SAVE
                           </button>
                        </center>
                     </div>
                  </div>
               </cms:form>
               <!-- FORM -->
            </div>
         </div>
      </div>

      <hr>
      <br>
      
      <!-- Student List -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <table border='1' style="width: 90%; margin: auto;">
                  <thead>
                     <tr>
                        <th width='5%' style="text-align: center;">
                           Sr. No.
                        </th>
                        <th width='5%' style="text-align: center;">
                           Student Id
                        </th>
                        <th width='25%' style="text-align: center;">
                           Full Name
                        </th>
                        <th width='15%' style="text-align: center;">
                           Mobile Number
                        </th>
                        <th width='20%' style="text-align: center;">
                           Email Id
                        </th>
                        <th width='30%' style="text-align: center;">
                           Actions
                        </th>
                     </tr>
                  </thead>
                  <tbody>
                     <cms:pages masterpage=k_template_name order='asc' paginate='1' limit='10' show_future_entries='1'>
                     <cms:no_results>
                     <tr>
                        <td colspan="5" class="text-center">
                           - No Student Data Available -
                        </td>
                     </tr>
                     </cms:no_results>
                     <tr>
                        <td style="text-align: center;">
                           <cms:show k_current_record />
                        </td>
                        <td style="text-align: center;">
                           <cms:show k_page_id />
                        </td>
                        <td>
                           <cms:show k_page_title />
                        </td>
                        <td style="text-align: center;">
                           <cms:show smobile />
                        </td>
                        <td>
                           <cms:show semail />
                        </td>
                        <td style="text-align: center;">
                           <a data-toggle="modal" data-target="#myModal-<cms:show k_page_id />"><i class="fa fa-eye"></i> View</a> &nbsp; <a href="#!"><i class="fa fa-edit"></i> Edit</a> &nbsp; <a href="#!"><i class="fa fa-inr"></i> Fees</a> &nbsp; <a href="#!"><i class="fa fa-times"></i> Delete</a>
                        </td>
                     </tr>
                     </cms:pages>
                  </tbody>
               </table>
            </div>
            <div class="col-md-12">
               <div class="gxcpl-ptop-10"></div>
               <cms:pages masterpage=k_template_name show_future_entries='1' paginate='1' limit='10'>
                  <center>
                     <cms:paginator />
                  </center>
               </cms:pages>
            </div>
         </div>
      </div>
      <!-- Student List -->

      <div class="gxcpl-ptop-10"></div>

      <!-- Scripts -->
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/jquery-1.11.1.js"></script>
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/bootstrap.js"></script>
      <!-- Scripts -->

      <!-- View Student Details Modal -->
      <cms:pages masterpage=k_template_name>
      <div class="modal fade" id="myModal-<cms:show k_page_id />" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
         <div class="modal-dialog" role="document">
            <div class="modal-content">
               <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  <h4 class="modal-title" id="myModalLabel">Student Details</h4>
               </div>
               <div class="modal-body">
                  <table border='1' style="width: 100%;">
                     <tr>
                        <th style="padding-left: 10px;">
                           Full Name
                        </th>
                        <td>
                           <cms:show k_page_title />
                        </td>
                     </tr>
                     <tr>
                        <th style="padding-left: 10px;">
                           Mobile
                        </th>
                        <td>
                           <cms:show smobile />
                        </td>
                     </tr>
                     <tr>
                        <th style="padding-left: 10px;">
                           Email Id
                        </th>
                        <td>
                           <cms:show semail />
                        </td>
                     </tr>
                  </table>
               </div>
               <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
               </div>
            </div>
         </div>
      </div>
      </cms:pages>
      <!-- View Student Details Modal -->
   </body>
</html>
<?php COUCH::invoke(); ?>


fees.php
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Fees' clonable='1' >
   <cms:editable name='fees' label='Fees' type="text" required='1' validator='non_negative_integer' order='1' />
   
</cms:template>
<html>
   <head>
      <title>Fees</title>
      <link href="assets/css/bootstrap.css" rel="stylesheet" />
      <link href="assets/css/font-awesome.css" rel="stylesheet" />
      <style>
         body {
            margin: 0;
            padding: 0;
         }
         table > thead > tr > th,
         table > tbody > tr > td {
            padding: 5px 10px;
         }
         table > thead > tr > th {
            background-color: rgba(0,0,0,0.8);
            color: white;
         }
         .gxcpl-ptop-10 {
            padding-top: 10px;
         }
         input, select, option {
            padding: 5px 10px;
            border: 1px solid #ccc;
            width: 100%;
         }
         button.gxcpl-btn-text {
            text-transform: uppercase;
            font-weight: bold;
            letter-spacing: 1px;
         }
         a {
            cursor: pointer;
            color: #212121;
            font-weight: bold;
         }
         a:hover {
            text-decoration: none;
            color: #2980b9;
         }
      </style>
   </head>

   <body>
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <h1>
                  Fees
               </h1>
            </div>
         </div>
      </div>

      <hr>

      <!-- FORM -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <cms:set submit_success="<cms:get_flash 'submit_success' />" />
               <cms:if submit_success >
                   <h4>Success: Month and fees saved.</h4>
               </cms:if>
               <cms:form masterpage=k_template_name mode='create' enctype='multipart/form-data' method='post' anchor='0' >
                   <cms:if k_success >
                       <cms:db_persist_form
                           _invalidate_cache='0'
                          k_page_title=frm_k_page_title
                          k_page_name=random_name
                       />
                       <cms:if k_success >
                          <cms:set_flash name='submit_success' value='1' />
                          <cms:redirect k_page_link />
                      </cms:if>
                   </cms:if>

                   <cms:if k_error >
                       <div class="error">
                           <cms:each k_error >
                               <br><cms:show item />
                           </cms:each>
                       </div>
                   </cms:if>
                  <div class="row">
                     <div class="col-md-2">
                        <label for="month">Month</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <cms:hide>
                           <cms:input name='k_page_title' type='bound' class='form-control' />
                        </cms:hide>
                        <select class="form-control" name="f_k_page_title">
                           <option value="Select">
                              Select
                           </option>
                           <option value="January">
                              January
                           </option>
                           <option value="February">
                              February
                           </option>
                           <option value="March">
                              March
                           </option>
                           <option value="April">
                              April
                           </option>
                           <option value="May">
                              May
                           </option>
                           <option value="June">
                              June
                           </option>
                           <option value="July">
                              July
                           </option>
                           <option value="August">
                              August
                           </option>
                           <option value="September">
                              September
                           </option>
                           <option value="October">
                              October
                           </option>
                           <option value="November">
                              November
                           </option>
                           <option value="December">
                              December
                           </option>
                        </select>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2">
                        <label for="fees">Fees</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <div class="input-group">
                           <span class="input-group-addon" id="basic-addon1"><i class="fa fa-inr"></i></span>
                           <cms:input name='fees' type="bound" class="form-control" placeholder="Monthly Fees Amount" aria-describedby="basic-addon1" />
                        </div>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2 col-md-offset-5">
                        <center>
                           <button type="submit" class="btn btn-danger gxcpl-btn-text">
                              <i class="fa fa-save"></i> Save
                           </button>
                        </center>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                  </div>
               </cms:form>
            </div>
         </div>
      </div>

      <hr>
      <br>
      
      <!-- Fees List -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <table border='1' style="width: 90%; margin: auto;">
                  <thead>
                     <tr>
                        <th width='10%' style="text-align: center;">
                           Sr. No.
                        </th>
                        <th width='10%' style="text-align: center;">
                           Fees Id
                        </th>
                        <th width='25%' style="text-align: center;">
                           Month
                        </th>
                        <th width='15%' style="text-align: center;">
                           Amount
                        </th>
                        <th width='40%' style="text-align: center;">
                           Actions
                        </th>
                     </tr>
                  </thead>
                  <tbody>
                     <cms:pages masterpage=k_template_name order='asc' show_future_entries='1'>
                     <cms:no_results>
                     <tr>
                        <td colspan="5" class="text-center">
                           - No Fees Data Available -
                        </td>
                     </tr>
                     </cms:no_results>
                     <tr>
                        <td style="text-align: center;">
                           <cms:show k_current_record />
                        </td>
                        <td style="text-align: center;">
                           <cms:show k_page_id />
                        </td>
                        <td>
                           <cms:show k_page_title />
                        </td>
                        <td style="text-align: center;">
                           <i class="fa fa-inr"></i> <cms:show fees />
                        </td>
                        <td style="text-align: center;">
                           <a href="#!"><i class="fa fa-edit"></i> Edit</a> &nbsp; <a href="#!"><i class="fa fa-times"></i> Delete</a>
                        </td>
                     </tr>
                     </cms:pages>
                  </tbody>
               </table>
            </div>
         </div>
      </div>
      <!-- Fees List -->

      <div class="gxcpl-ptop-10"></div>
      <div class="gxcpl-ptop-10"></div>
      <div class="gxcpl-ptop-10"></div>

      <!-- Scripts -->
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/jquery-1.11.1.js"></script>
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/bootstrap.js"></script>
      <!-- Scripts -->
   </body>
</html>            
<?php COUCH::invoke(); ?>


fees-payment.php:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Fees Payment' clonable='1'>
   
</cms:template>
<html>
   <head>
      <title>Fees Payment</title>
      <link href="<cms:show k_site_link />assets/css/bootstrap.css" rel="stylesheet" />
      <link href="<cms:show k_site_link />assets/css/bootstrap-select.min.css" rel="stylesheet" />
      <link href="assets/css/font-awesome.css" rel="stylesheet" />
      <style>
         body {
            margin: 0;
            padding: 0;
         }
         table > thead > tr > th,
         table > tbody > tr > td {
            padding: 5px 10px;
         }
         table > thead > tr > th {
            background-color: rgba(0,0,0,0.8);
            color: white;
         }
         .gxcpl-ptop-10 {
            padding-top: 10px;
         }
         input, select {
            padding: 5px 10px;
            border: 1px solid #ccc;
            width: 100%;
         }
         button.gxcpl-btn-text {
            text-transform: uppercase;
            font-weight: bold;
            letter-spacing: 1px;
         }
         a {
            cursor: pointer;
            color: #212121;
            font-weight: bold;
         }
         a:hover {
            text-decoration: none;
            color: #2980b9;
         }

         /* Paginator */
         div.pagination {
             padding: 5px;
             margin: 5px;
         }
         div.pagination a {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             zoom: 100%;
             text-decoration: none; /* no underline */
             color: rgba(0,0,0,0.8);
         }
         div.pagination a:hover, div.pagination a:active {
             border: 1px solid rgba(0,0,0,0.8);
             color: rgba(0,0,0,0.8);
         }
         div.pagination span.page_current {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             * zoom: 100%;
             font-weight: bold;
             background-color: rgba(0,0,0,0.8);
             color: #FFF;
         }
         div.pagination span.page_disabled {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid #ccc;
             * zoom: 100%;
             color: #ccc;
         }
         * span.elipsis {zoom:100%}
         /* Paginator */
      </style>
   </head>

   <body>
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <h1>
                  Fees Payment
               </h1>
            </div>
         </div>
      </div>

      <hr>

      <!-- FORM -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <form method="post">
                  <div class="row">
                     <div class="col-md-2">
                        <label for='student'>Student Name</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <select name="student" class="selectpicker" data-show-subtext="false" data-live-search="true">
                             <option data-subtext="">Select Student</option>
                             <option>
                                <!-- Student Name Dropdown -->
                             </option>
                          </select>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2">
                        <label for="month">Month</label>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-10">
                        <select name="month">
                           <option>
                              Select Month
                           </option>
                           <option>
                              <!-- Only months for which student has not paid the fees should appear here -->
                           </option>
                        </select>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                     <div class="col-md-2 col-md-offset-5">
                        <center>
                           <button type="submit" class="btn btn-danger gxcpl-btn-text">
                              <i class="fa fa-save"></i> Save
                           </button>
                        </center>
                        <div class="gxcpl-ptop-10"></div>
                     </div>
                  </div>
               </form>
            </div>
         </div>
      </div>

      <hr>
      <br>
      
      <!-- Student List -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <table border='1' style="width: 90%; margin: auto;">
                  <thead>
                     <tr>
                        <th width='10%' style="text-align: center;">
                           Sr. No.
                        </th>
                        <th width='10%' style="text-align: center;">
                           Receipt Id
                        </th>
                        <th width='25%' style="text-align: center;">
                           Student Name
                        </th>
                        <th width='15%' style="text-align: center;">
                           Month
                        </th>
                        <th width='15%' style="text-align: center;">
                           Amount Paid
                        </th>
                        <th width='25%' style="text-align: center;">
                           Actions
                        </th>
                     </tr>
                  </thead>
                  <tbody>
                     <cms:pages masterpage=k_template_name order='asc' paginate='1' limit='10' show_future_entries='1'>
                     <cms:no_results>
                     <tr>
                        <td colspan="6" class="text-center">
                           - No Student Data Available -
                        </td>
                     </tr>
                     </cms:no_results>
                     <tr>
                        <td style="text-align: center;">
                           <cms:show k_current_record />
                        </td>
                        <td style="text-align: center;">
                           <cms:show k_page_id />
                        </td>
                        <td>
                           <cms:show k_page_title />
                        </td>
                        <td style="text-align: center;">
                           <cms:show smobile />
                        </td>
                        <td>
                           <cms:show semail />
                        </td>
                        <td style="text-align: center;">
                           <a data-toggle="modal" data-target="#myModal-<cms:show k_page_id />"><i class="fa fa-eye"></i> View</a> &nbsp; <a href="#!"><i class="fa fa-edit"></i> Edit</a> &nbsp; <a href="#!"><i class="fa fa-inr"></i> Fees</a> &nbsp; <a href="#!"><i class="fa fa-times"></i> Delete</a>
                        </td>
                     </tr>
                     </cms:pages>
                  </tbody>
               </table>
            </div>
            <div class="col-md-12">
               <div class="gxcpl-ptop-10"></div>
               <cms:pages masterpage=k_template_name show_future_entries='1' paginate='1' limit='10'>
                  <center>
                     <cms:paginator />
                  </center>
               </cms:pages>
            </div>
         </div>
      </div>
      <!-- Student List -->

      <div class="gxcpl-ptop-10"></div>

      <!-- Scripts -->
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/jquery-1.11.1.js"></script>
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/bootstrap.js"></script>
      <script type="text/javascript"> src="<cms:show k_site_link />assets/js/bootstrap-select.min.js"></script>
      <!-- Scripts -->
   </body>
</html>
<?php COUCH::invoke(); ?>


Any help would be more than appreciated.

Regards,
GenXCoders
Image
where innovation meets technology
What I am actually expecting to achieve is that, when a student pays her fees, the month in the student_feesmonth relation should be marked when a receipt is generated.

I guess so! :?

I dont know if I am thinking straight or not.

Please suggest!
Image
where innovation meets technology
I think you can do this without using the third template - just students.php and fees.php should suffice.
Create a many-to-one relation in fees.php relating it to students.php and every time the student pays her fee, create a cloned page in fees.php.

One way of marking which month the fee is for is to use the publish date. Explicitly save that date with the month and year representing the fees period (the day is not important and can be fixed to '01').

This way it would be a simple case of using cms:pages to fetch pages (fees) belonging to a particular period and related to a particular student to see all relevant data.

How does that sound?
@KK Sir,

As suggested by you, I did the following:

1. Added a Many-to-One relation in fees.php relating it to students.php using the code:
Code: Select all
<cms:editable type='relation' name='feesmonth_student' masterpage='students.php' has='one' />


Now what I can see in the backend is:
fees.png
fees.png (19.16 KiB) Viewed 16240 times


But now what concerns me is that, I had created the fees.php originally for the super-user to create the months and fees manually and then provide it to a admin-user to just login and collect the fees (as per the requirement). But I wont be able to do that as far as i can make out as the fees is a blank text box.

Regards,
Priya
Image
where innovation meets technology
OK, so maybe we'll need one more template (say, payment.php).
Please revert back to the original structure of your fees.php (and use it ti create months and amounts).

Create a many-to-one from payment.php to students.php and another many-to-one to fees.php.
While accepting payment, the user will select the student (use advanced relation GUI if the number is large) and will select the month.

Use the month/year to craft a publish_date for payment as discussed before (if required create a custom validator that makes sure the same student cannot be posted to the same month twice).

Would this help?
@KK Sir.

I hope you find yourself in the best of health and are all recovered.

As you have suggested, I have the done the following as you suggested:

Please revert back to the original structure of your fees.php (and use it ti create months and amounts).

DONE

Create a many-to-one from payment.php to students.php

Done using the code:
Code: Select all
<cms:editable type='relation' name='feespay_student' label='Student Name' masterpage='students.php' has='one' order='1' />


another many-to-one to fees.php.

Done using the following code:
Code: Select all
<cms:editable type='relation' name='feespay_month' label='Month' masterpage='fees.php' has='one' order='2' />


Now the student list and the month list are available in the fees-payment.php template in the back end. I am trying to get the same displayed at the front end to achieve the following:
While accepting payment, the user will select the student (use advanced relation GUI if the number is large) and will select the month.

using related_pages and reverse_related_pages. But to no luck.

For populating the front end student list i tried (i am using a dropdown):
Code: Select all
<select name='feespay_student'>
                            <option>
                               Select Student
                            </option>   
                            <cms:pages masterpage='students.php' id='<cms:show k_page_id />' >
                            <cms:reverse_related_pages 'feespay_student' masterpage='fees-payment.php'>
                            <option>
                               <cms:show k_page_title />
                            </option>
                            </cms:reverse_related_pages>
                            </cms:pages>
                         </select>


For populating the front end month list i tried (i am using a dropdown):
Code: Select all
<select name='feespay_month'>
                            <option>
                               Select Month
                            </option>
                            <cms:pages masterpage='fees-payment.php' id='<cms:show k_page_id />'>
                           <cms:related_pages 'feespay_month' >
                           <cms:show k_page_title /><br/>
                           </cms:related_pages>
                           </cms:pages>
                         </select>


But in either cases i am unable to populate the dropdowns and hence am unable to proceed further.

Regards,
GenXCoders
Image
where innovation meets technology
On the front-end, I don't think the 'advanced GUI' of relation will work but the normal relation GUI should show up fine.

If you use <cms:input type='bound'> (with 'name' pointing to the relation fields), e.g.
Code: Select all
<cms:input type='bound' name='feespay_student' />
<cms:input type='bound' name='feespay_month' />
you should automatically get the dropdown pre-populated. I am assuming you are using a DataBound Form (attached to fees.php), so why don't you use the 'bound' types as is the norm with DBFs?

Please let me know how it goes.
@KK Sir,

Good evening.

As suggested by you:

If you use <cms:input type='bound'> (with 'name' pointing to the relation fields), e.g.
Code: Select all
Code: Select all
<cms:input type='bound' name='feespay_student' />
<cms:input type='bound' name='feespay_month' />


I have used input with type='bound' and that populates the student name and months.

Now I am unable to do the following:
1. Alphabetically order the student names in the dropdown
2. List the months in their sequence January to December. They are displayed as December to January.
3. Unable to set the value parameter in the options tag.
4. I am using the code:
Code: Select all
<cms:db_persist_form
   _invalidate_cache='0'
   k_page_title="<cms:show frm_feespay_student />"
   k_page_name="<cms:random_name />"
/>

to set the name of the cloned page, but it happens to be blank.

The #3 is required since I want to display the fees amount to be collected. by chaining the dropdown and textbox as shown here. If this is achievable then I would have a bound field that will set the fees amount in the chained textbox and be submitted to a bound field.

Apart from the above mentioned points, after using the code suggested by you the dropdowns get populated and the form is submitted.

Please advise.

Regards,
GenXCoders
Image
where innovation meets technology
My Current code for the fees-payment.php template is:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Fees Payment' clonable='1'>
<cms:ignore>
   <cms:editable name='feesmonth' label='Fees Month' type='text' order='1' />
   <cms:editable name='feesamount' label='Fees Amount' type='text' order='2' />
   <cms:editable name='feesamount' label='Fees Amount' type='text' order='3' />
</cms:ignore>
   <cms:editable type='relation' name='feespay_student' label='Student Name' masterpage='students.php' has='one' order='1' />
   <cms:editable type='relation' name='feespay_month' label='Month' masterpage='fees.php' has='one' order='2' />
   <cms:editable name='feespay_amount' label='Fees Amount' type='text' order='3' />
</cms:template>
<html>
   <head>
      <title>Fees Payment</title>
      <link href="<cms:show k_site_link />assets/css/bootstrap.css" rel="stylesheet" />
      <link href="<cms:show k_site_link />assets/css/bootstrap-select.min.css" rel="stylesheet" />
      <link href="<cms:show k_site_link />assets/css/font-awesome.css" rel="stylesheet" />
      <style>
         body {
            margin: 0;
            padding: 0;
         }
         table > thead > tr > th,
         table > tbody > tr > td {
            padding: 5px 10px;
         }
         table > thead > tr > th {
            background-color: rgba(0,0,0,0.8);
            color: white;
         }
         .gxcpl-ptop-10 {
            padding-top: 10px;
         }
         input, select {
            padding: 5px 10px;
            border: 1px solid #ccc;
            width: 100%;
         }
         button.gxcpl-btn-text {
            text-transform: uppercase;
            font-weight: bold;
            letter-spacing: 1px;
         }
         a {
            cursor: pointer;
            color: #212121;
            font-weight: bold;
         }
         a:hover {
            text-decoration: none;
            color: #2980b9;
         }

         /* Paginator */
         div.pagination {
             padding: 5px;
             margin: 5px;
         }
         div.pagination a {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             zoom: 100%;
             text-decoration: none; /* no underline */
             color: rgba(0,0,0,0.8);
         }
         div.pagination a:hover, div.pagination a:active {
             border: 1px solid rgba(0,0,0,0.8);
             color: rgba(0,0,0,0.8);
         }
         div.pagination span.page_current {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid rgba(0,0,0,0.8);
             * zoom: 100%;
             font-weight: bold;
             background-color: rgba(0,0,0,0.8);
             color: #FFF;
         }
         div.pagination span.page_disabled {
             padding: 5px 10px;
             margin: 2px;
             border: 1px solid #ccc;
             * zoom: 100%;
             color: #ccc;
         }
         * span.elipsis {zoom:100%}
         /* Paginator */
      </style>
   </head>

   <body>
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <h1>
                  Fees Payment
               </h1>
            </div>
         </div>
      </div>

      <hr>

      <!-- FORM -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <cms:set submit_success="<cms:get_flash 'submit_success' />" />
               <cms:if submit_success >
                   <h4>Success: Fees collected.</h4>
               </cms:if>
               <cms:form masterpage=k_template_name mode='create' enctype='multipart/form-data' method='post' anchor='0' >
                   <cms:if k_success >
                       <cms:db_persist_form
                           _invalidate_cache='0'
                           k_page_title="<cms:show frm_feespay_student />"
                           k_page_name="<cms:random_name />"
                       />
                       <cms:if k_success >
                          <cms:set_flash name='submit_success' value='1' />
                          <cms:redirect k_page_link />
                      </cms:if>
                   </cms:if>

                   <cms:if k_error >
                       <div class="error" style="color: #f00;">
                           <cms:each k_error >
                               <br><cms:show item />
                           </cms:each>
                       </div>
                   </cms:if>

                   <div class="row">
                      <div class="col-md-4">
                         <label for="feespay_student">Student List</label>
                         <cms:input type='bound' name='feespay_student' />
                      </div>
                      <div class="col-md-4">
                         <label for="feespay_month">Month List</label>
                         <cms:input type='bound' id="myDropdown" name='feespay_month' value="<cms:show fees />" />
                         <cms:hide><cms:input name="feespay_month" type="bound" /></cms:hide>
                      </div>
                      <div class="col-md-4">
                         <label for="feespay_amount">Fees</label>
                         <cms:input type='bound' name='feespay_amount' id='txtBox' readonly='1' />
                      </div>
                      <div class="col-md-12">
                         <button type="submit">
                            Save
                         </button>
                      </div>
                   </div>

                  
               </cms:form>
            </div>
         </div>
      </div>

      <hr>
      <br>



      <br>
      <hr>

      <!-- Student List -->
      <div class="container">
         <div class="row">
            <div class="col-md-12">
               <table border='1' style="width: 90%; margin: auto;">
                  <thead>
                     <tr>
                        <th width='10%' style="text-align: center;">
                           Sr. No.
                        </th>
                        <th width='10%' style="text-align: center;">
                           Receipt Id
                        </th>
                        <th width='20%' style="text-align: center;">
                           Student Name
                        </th>
                        <th width='15%' style="text-align: center;">
                           Month
                        </th>
                        <th width='15%' style="text-align: center;">
                           Amount Paid
                        </th>
                        <th width='30%' style="text-align: center;">
                           Actions
                        </th>
                     </tr>
                  </thead>
                  <tbody>
                     <cms:pages masterpage=k_template_name order='asc' show_future_entries='1'>
                     <cms:no_results>
                     <tr>
                        <td colspan="6" class="text-center">
                           - No Student Data Available -
                        </td>
                     </tr>
                     </cms:no_results>
                     <tr>
                        <td style="text-align: center;">
                           <cms:show k_current_record />
                        </td>
                        <td style="text-align: center;">
                           <cms:show k_page_id />
                        </td>
                        <td>
                           <cms:show feespay_student />
                        </td>
                        <td style="text-align: center;">
                           <cms:show feespay_month />
                        </td>
                        <td>
                           NA
                        </td>
                        <td style="text-align: center;">
                           <a data-toggle="modal" data-target="#myModal-<cms:show k_page_id />"><i class="fa fa-eye"></i> View</a> &nbsp; <a href="#!"><i class="fa fa-edit"></i> Edit</a> &nbsp; <a href="#!"><i class="fa fa-inr"></i> Fees</a> &nbsp; <a href="#!"><i class="fa fa-times"></i> Delete</a>
                        </td>
                     </tr>
                     </cms:pages>
                  </tbody>
               </table>
            </div>
         </div>
      </div>
      <!-- Student List -->

      <div class="gxcpl-ptop-10"></div>

      <!-- Scripts -->
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/jquery-1.11.1.js"></script>
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/bootstrap.js"></script>
      <script type="text/javascript" src="<cms:show k_site_link />assets/js/bootstrap-select.min.js"></script>
      <script>
         $("#myDropdown").change(function () {
             var selectedValue = $(this).val();
             $("#txtBox").val($(this).find("option:selected").attr("value"))
         });
      </script>
      <!-- Scripts -->
   </body>
</html>
<?php COUCH::invoke(); ?>
Image
where innovation meets technology
@KK Sir and @All Developers,
Any input(s) on controlling the value attribute of the option tag would be really helpful.
Currently the option tags value attribute shows the k_page_id whereas I was wanting to display an editable region (names as fees) in place of the k_page_id. Any other workaround will also be helpful.
Regards,
GenXCoders
Image
where innovation meets technology
13 posts Page 1 of 2
cron