Yii Framework Forum: Error Summary Not Showing When Using Multiple Models - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error Summary Not Showing When Using Multiple Models validation errorsummart not working Rate Topic: -----

#1 User is offline   vinoth.mohan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 08-June 13
  • Location:Malaysia

Posted 05 February 2014 - 05:19 AM

Hi,

Im facing the problem of validation ,errorsummary is not throwing the error message after i combine with more then one models.
so far i tried tutorials in google search i still couldnt manage to solve the issue.

when i wana UPDATE if i insert invalid data the data cannot be save into database but if i insert proper valid data the data able to save into database.

Yes data able to save but why error not showing during the validation time?

The thing is why the errorsummary and ajax validation is not showing the errorsummary or message.
im creaking my head because if this issue.

i want the error summary to display during update,if user insert invali

i seeking help from Senior member please help me to sort this issue.


than you.


_form

 
       
 <?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'sitemasterlist-form',
	//'enableClientValidation'=>true,
	 'enableAjaxValidation'=>true,
      //  'clientOptions'=>array(
        //  'validateOnSubmit'=>true,
         //),
     ));
    ?>
 



<!--Begin of form-->
<div class="form">
 <p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary(array($model,$jss,$taapproval,$laapproval,$lafees,$document,$laapproval));?>      
 
 
 
<div id="main" class="round roundB">
<div id="tabs">
  <ul>
    <li><a href="#tab1">New Site Info</a> </li>      
    <li><a href="#tab2">Technical Agency Application</a> </li>
    <li><a href="#tab3">Local Authority Application</a> </li>
   </ul>

<div class='span-23'>
<div class="tab-pane active" id="tab1">
 

<div id="accordionA">
 

   
<div>
<h3><a href="#">Applicant Info</a></h3>
<div><p>
   
<table id="yw0" class="caps table table-striped table-bordered table-hover"><tbody>
<tr class="odd">
  <th colspan="4" style="<?php echo $tblth;?>">Applicant Details</th>
   </tr>
<tr class="odd">
  <th><strong>Organization Name</strong></th><td>
  	 <?php 
  	 if($model->isNewRecord){
	  	    echo $form->dropDownList($model,'fkorganisationid', CHtml::listData(Organisation::model()->findAll('active =1'), 'id','name'),
	        array(
	        'prompt' => '--Select --',
	        'value' => '0',
	        'onChange' => 'getOrganisation()',
			'ajax'  => array(
			'type'  => 'POST',
	        'url' => CController::createUrl('sitemasterlist/orgdropdown'),
	        'update' => '#Sitemasterlist_fkorganisationcpid',   //selector to update value
	        'data' => array('clientid'=>'js:this.value'),
	        ),
	        'class'=>'lolcat dropdownCSSi','title'=>'Select Organisation'));
      }else{
	        echo $form->dropDownList($model,'fkorganisationid', CHtml::listData(Organisation::model()->findAll('active =1'), 'id','name'),
	        array(
	        'prompt' => '--Select --',
	        'value' => '0',
	        'onChange' => 'getOrganisation()',
			'ajax'  => array(
			'type'  => 'POST',
	        'url' => CController::createUrl('sitemasterlist/orgdropdown'),
	        'update' => '#Sitemasterlist_fkorganisationcpid',   //selector to update value
	        'data' => array('clientid'=>'js:this.value'),
	        ),
	        'class'=>'lolcat dropdownCSSi','disabled'=>'disabled','readonly'=>'readonly','title'=>'Select Organisation'));		
        }
      
      ?>      
   </td>
  <th><strong>Project Name</strong></th><td><?php echo $form->textArea($model,'projectname',array('rows'=>2, 'cols'=>8,'class'=>'lolcat','title'=>'Enter Project Name','style'=>$width)); ?></td>
</tr>

<tr class="even">
  <th><strong>License No</strong></th><td><span id="license"></span></td>
  <th><strong>Date of Application</strong></th>
  <td>
  <?php               	
			$this->widget('zii.widgets.jui.CJuiDatePicker',array(
		    'name'=>'Sitemasterlist[applieddate]',
		    'id'=>'Sitemasterlist_applieddate',
		    'model'=>$model,
			'value'=>$model->applieddate,
		    // additional javascript options for the date picker plugin
		    'options'=>array(
                'changeMonth'=>'true', 
                'changeYear'=>'true',   
                'yearRange' => '-99:+2',        
                'showAnim'=>'slideDown', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
                'showOn'=>'button', // 'focus', 'button', 'both'
                'dateFormat'=>'yy-mm-dd',
                'defaultDate'=>$model->applieddate,
			    'theme'=>'start',
                'buttonText'=>Yii::t('ui','Select form calendar'), 
                'buttonImage'=>Yii::app()->request->baseUrl.'/images/framework/cal.png', 
                'buttonImageOnly'=>true,
            ),
		    'htmlOptions'=>array(
		        'style'=>'height:20px;vertical-align: 5px;width:50%',
		        'class'=>($model->getError('applieddate'))? 'error lolcat':'lolcat',
		        'maxlength' =>'10' ,
		        'size'=> '10',
		        'title'=>'Select Date',
		    ),
		));
		?>
	</td>
</tr>
<tr class="odd">
 <th colspan="4" style="<?php echo $tblth;?>">Contact Person</th>
 <tr class="odd">
  <th><strong>Name</strong></th><td>
 <?php
	   $criteria = new CDbCriteria();
	   $criteria->select='id,name';
 	   $variable=Contactperson::model()->findAll('fksetupcategory=21');
	   $listdd = CHtml::listData($variable, 'id', 'name'); 
	   echo $form->dropDownList($model,'fkorganisationcpid',$listdd, array('empty'=>'--Select--','class'=>'lolcat dropdownCSSi',
	   	    'title'=>'Select Contact Person','onChange' => 'getContactperson()',
	   ));
	?>
</td>
  <th><strong>Department</strong></th><td><span id="department" ></span></td>
</tr>
<tr class="even">
  <th><strong>Designation</strong></th><td><span id="designation"></span></td>
  <th><strong>H/P No</strong></th><td><span id="mobile"></span></td>
</tr>
<tr class="odd">
   <th><strong>Email</strong></th><td><span id="email"></span></td>
   <th></th><td></td>
</tr>

</tbody>
</table>



</p></div>
</div>
    
    
    
    <div>
        <h3><a href="#">Site Info</a></h3>
        <div><p>


        	
<table id="yw0" class="caps table table-striped table-bordered table-hover"><tbody>
<tr class="odd">
  <th colspan="2" style="<?php echo $tblth;?>">Site Details</th>
  <td colspan="2" style="<?php echo $tblth;?>"><strong>Land Status/Building Category</strong></td>
 </tr>
<tr class="odd">
  <th><strong>Site Name</strong></th><td><?php echo $form->textField($model,'sitename',array('size'=>10,'maxlength'=>10,'style'=>$width,'title'=>'Enter Site Name','class'=>'lolcat')); ?></td>
  <th><strong>Land Status</strong></th>
  <td><?php
		    $criteria = new CDbCriteria();
            $criteria->addCondition("fkvariablecategoryid = 6");
		 	$variable = Variable::model()->findAll($criteria);
		    $list = CHtml::listData($variable, 'id', 'name');
		    echo $form->dropDownList($model,'fklandstatus', $list,
		    array('empty' => '--Select--', 'id'=>'landstatus','class'=>'lolcat','title'=>'Select Land status','style'=>$width,'class'=>'lolcat')); 
	  ?></td>
</tr>
<tr class="even">
  <th><strong>Site ID</strong></th><td><?php echo $form->textField($model,'siteid',array('size'=>10,'maxlength'=>10,'title'=>'Enter Site Id','style'=>$width,'class'=>'lolcat')); ?></td>
  <th><strong>Building Category</strong></th>
  <td><?php
		    $criteria = new CDbCriteria();
            $criteria->addCondition("fkvariablecategoryid = 7");
		 	$variable = Variable::model()->findAll($criteria);
		    $list = CHtml::listData($variable, 'id', 'name');
		    echo $form->dropDownList($model,'fkbuildingcategory', $list,
		    array('empty' => '--Select--', 'id'=>'buildingcategory','class'=>'lolcat','title'=>'Select Building Category','style'=>$width)); 
	  ?></td>
</td>
</tr>
<tr class="odd">
  <th><strong>Site Address</strong></th>
  <td>
  	<?php echo $form->textArea($model,'siteaddress',
  	array('rows'=>2, 'cols'=>8,'class'=>'lolcat','title'=>'Enter Site address','style'=>$width)); 
  	?>
  </td>
  <th colspan="2" style="<?php echo $tblth;?>"><strong> Tower/Rooftop/Dual Function Information</strong></th>
</tr>
<tr class="even">
  <th><strong>Postcode</strong></th><td><?php echo $form->textField($model,'postcode',array('maxlength'=>5,'style'=>$width)); ?></td>
  <th><strong>Structure Category</strong></th>
  <td><?php 
	    $criteria = new CDbCriteria();
	    $criteria->addCondition("fkvariablecategoryid = 8");
	 	$variable = Variable::model()->findAll($criteria);
	    $list = CHtml::listData($variable, 'id', 'name');
	    echo $form->dropDownList($model,'fkstructurecategoy', $list,
	                array(
	                'prompt' => '--Select--',
	                'value' => '0',
					'ajax'  => array(
	                'type'  => 'POST',
	                'url' => CController::createUrl('sitemasterlist/structurecategory'),
	                'update' => '#Sitemasterlist_structuretype',   //selector to update value
	                'data' => array('id'=>'js:this.value'),
	                ) ,  'class'=>'lolcat dropdownCSSi','title'=>'Select Structure Catergory'));
      	?>
  </td>
</tr>
<tr class="odd">
  <th><strong>State</strong></th>
  <td><?php
		    $criteria = new CDbCriteria();
            $criteria->addCondition("fkvariablecategoryid = 1");
		 	$variable = Variable::model()->findAll($criteria);
		    $list = CHtml::listData($variable, 'id', 'name');
		    echo $form->dropDownList($model,'fkstateid', $list,
		    array('empty' => '--Select--', 'id'=>'state','class'=>'lolcat','title'=>'Select State','style'=>$width)); 
	 ?>
  </td>
 <th><strong>Structure Type</strong></th>
 <td><?php
	   $criteria = new CDbCriteria();
	   $criteria->select='id,name';
 	   $variable=Variable::model()->findAll('fkvariablecategoryid=9');
	   $listdd = CHtml::listData($variable, 'id', 'name'); 
	   echo $form->dropDownList($model,'structuretype',$listdd, array('empty'=>'--Select--','class'=>'lolcat dropdownCSSi',
	   	    'title'=>'Select Structure Type',
	   ));
	?>
  </td>
</tr>
<tr class="even">
  <th><strong>City</strong></th><td><?php echo $form->textField($model,'city',array('size'=>20,'maxlength'=>20,'style'=>$width)); ?></td>
  <th><strong>Structure Height (Meter)</strong></th><td><?php echo $form->textField($model,'structureheight',array('style'=>$width)); ?></td>
</tr>
<tr class="odd">
  <th><strong>District</strong></th>
  <td><?php 
	    $criteria = new CDbCriteria();
	    $criteria->addCondition("fkvariablecategoryid = 3  AND id != 29 AND id !=30");
	 	$variable = Variable::model()->findAll($criteria);
	    $list = CHtml::listData($variable, 'id', 'name');
	    echo $form->dropDownList($model,'fkdistrict', $list,
	                array(
	                'prompt' => '--Select--',
	                'value' => '0',
					'ajax'  => array(
	                'type'  => 'POST',
	                'url' => CController::createUrl('sitemasterlist/district'),
	                'update' => '#Sitemasterlist_fkmukimid',   //selector to update value
	                'data' => array('id'=>'js:this.value'),
	                ) ,  'class'=>'lolcat dropdownCSSi','title'=>'Select District'));
      	?>      
   </td>
  <th><strong>Distance From Nearest Building (Meter)</strong></th><td><?php echo $form->textField($model,'distancenearest',array('style'=>$width)); ?></td>
</tr>
<tr class="even">
  <th><strong>Mukim</strong></th>
  <td><?php
	   $criteria = new CDbCriteria();
	   $criteria->select='id,name';
 	   $variable=Variable::model()->findAll('fkvariablecategoryid=5');
	   $listdd = CHtml::listData($variable, 'id', 'name'); 
	   echo $form->dropDownList($model,'fkmukimid',$listdd, array('empty'=>'--Select--','class'=>'lolcat dropdownCSSi',
	   	    'title'=>'Select Mukim',
	   ));
	?>
  </td>
  <th><strong>Building Height (Meter)</strong></th><td><?php echo $form->textField($model,'buildingheight',array('style'=>$width)); ?></td>
 </tr> 
<tr class="odd">  
	<td colspan="2" style="<?php echo $tblth;?>"><strong>Related Information</strong></td>
	<td colspan="2" style="<?php echo $tblth;?>"><strong>Coordinate</strong></td>
</tr>
<tr class="even">
   <th><strong>Construction/Installation Purpose</strong></th><td><?php echo $form->textField($model,'purpose',array('size'=>50,'maxlength'=>50,'style'=>$width)); ?></td>
   <th><strong>Latitude</strong></th><td><?php echo $form->textField($model,'latitude',array('size'=>10,'maxlength'=>10,'style'=>$width)); ?></td>
</tr> 
<tr class="odd">
  <th><strong>No.Of antennas to be installed</strong></th><td><?php echo $form->textField($model,'noofantennas',array('size'=>50,'maxlength'=>50,'style'=>$width)); ?></td>
  <th><strong>Longtitude</strong></th><td><?php echo $form->textField($model,'longtitude',array('size'=>10,'maxlength'=>10,'style'=>$width)); ?></td>
</tr>
<tr class="even">
  <th colspan="2" style="<?php echo $tblth;?>"><strong>Tower Picture</strong></th> 
  <th colspan="2" style="<?php echo $tblth;?>"><strong>Google Map</strong></th> 
</tr> 
<tr class="odd">
    <th><strong><div class="buttons">
         <p class="submit">
		<?php 
		  if($model->isNewRecord){   //false due to constructor){
			$this->widget('bootstrap.widgets.TbButton', array(
		    'buttonType'=>'button',
		    'type'=>'inverse',
		    'label'=>'Upload',
		    'size' => 'small',
		    'htmlOptions'=>array('id'=>'towerpicture',
		    					  'name'=>'towerpicture',
		    					  'onclick'=>'javascript:alert("Please save this new tower application first !")')));
		  }else{
			//get picture id
			$picture = new CDbCriteria();
			$picture->select = 'encrypt,folderpath';
			$picture->condition = 'id=:id';
			$picture->params = array(':id'=>$model->fktowerpictureid);
			$pictureid = Picture::model()->find($picture);
			
			//call tower image
			$towerimgpath = Yii::app()->request->baseUrl.$pictureid['folderpath'].$pictureid['encrypt'].'?'.time();
 			echo  CHtml::link(CHtml::image(''.$towerimgpath.'',"image",
					 array("width"=>160,'class'=>'pictureCSS','alt'=>$pictureid->name, 'title'=>$pictureid->name)),
		    $towerimgpath, array("class"=>"image-popup-no-margins",'rel'=>'tooltip','title'=>$pictureid->name)); 
		    
				 
	      $this->widget("ext.magnific-popup.EMagnificPopup", array('target' => '.image-popup-no-margins',));
 

			echo '<p>';		
				
			$this->widget('bootstrap.widgets.TbButton', array(
		    'buttonType'=>'submitLink',
		    'type'=>'inverse',
		    'label'=>'Upload',
		    'size' => 'small',
		    'htmlOptions'=>array('id'=>'towerpicture',
		    					  'name'=>'towerpicture','style'=>'color:#FFF',
		    						'submit'=> array('picture/update','id'=>$model->fktowerpictureid,'app'=>$model->id),
		    )));		
			}
		   ?>
 		 </p>
         </div></strong>
       </th>
      <td colspan="3">
      	<div id="map_canvas" style="width: auto; height: 250px"></div>
      </td>
</tr> 
<!--tr class="even">
  <th><strong>Picture</strong></th><td>
</td>
  <th><strong></strong></th><td></td>
</tr--> 
<tr class="odd">
 <th><strong>Co-Location with parties</strong></th>
 <td><?php echo $form->dropDownList($model,'colocation', 
              array(1 => 'Yes', 0 => 'No'),
              array('empty' => '-Select-','class'=>'lolcat dropdownCSSi','title'=>'Select Co-Location')); ?>
  </td>
  <th><strong>Owner of tower</strong></th><td><?php echo $form->textField($model,'owneroftower',array('style'=>$width)); ?></td>
</tr>
<tr class="even">
  <th><strong>List Of Parties</strong></th><td><?php echo $form->textField($model,'listofparties',array('style'=>$width)); ?></td>
  <th><strong></strong></th><td></td>
</tr> 

</tbody>
</table>
      	
        	
        	
</p></div>
</div>
    
    
    
    

<div>
	<h3><a href="#">Consultant Info</a></h3>
	<div>
	<p>
<table id="yw0" class="caps table table-striped table-bordered table-hover"><tbody>
<tr class="odd">
  <th colspan="4" style="<?php echo $tblth;?>">Consultant</th>
   </tr>
<tr class="odd">
  <th><strong>Name</strong></th>
  <td><?php 
  		echo $form->dropDownList($model,'fkconsultantid', CHtml::listData(Consultant::model()->findAll('active = 1'), 'id','name'),
        array(
        'prompt' => '--Select --',
        'value' => '0',
        'onChange' => 'getConsultant()',
		'ajax'  => array(
		'type'  => 'POST',
        'url' => CController::createUrl('sitemasterlist/consultant'),
        'update' => '#Sitemasterlist_fkconsultantcpid',   //selector to update value
        'data' => array('clientid'=>'js:this.value'),
        ),
        'class'=>'lolcat dropdownCSSi','title'=>'Select Consultant'));
      ?>
   </td>
  <th>No Tel. Office</th>
  <td><span id="tel"></span></td>
</tr>
<tr class="even">
  <th><strong>Refistration No.</strong></th><td><span id="regno"></span></td>
  <th>Email</th><td><span id="emailconsultant"></span></td>
</tr> 
<tr class="odd">
  <th colspan="4" style="<?php echo $tblth;?>">Contact Person</th>
 </tr>
<tr class="even">
  <th><strong>Name</strong></th>
  <td><?php
	   $criteria = new CDbCriteria();
	   $criteria->select='id,name';
 	   $variable=Contactperson::model()->findAll('fksetupcategory=18');
	   $listdd = CHtml::listData($variable, 'id', 'name'); 
	   echo $form->dropDownList($model,'fkconsultantcpid',$listdd, array('empty'=>'--Select--','class'=>'lolcat dropdownCSSi',
	   	    'title'=>'Select Contact Person','onChange' => 'getContactperson_consultant()',
	   ));
	?></td>
  <th><strong>Department</strong></th><td><span id="departmentconsultant"></span></td>
</tr>
<tr class="odd">
  <th><strong>Designation</strong></th><td><span id="designationconsultant"></span></td>
  <th><strong>H/P No</strong></th><td><span id="mobileconsultant"></span></td>
</tr>
<tr class="even">
  <th><strong>Email</strong></th><td><span id="emailconsultantcp"></span></td>
  <th><strong></strong></th><td></td>
</tr>
</tbody>
</table>			
	</p>	
	</div>
</div>
    
    

<div>
	<h3><a href="#">Remark</a></h3>
	<div>
		

<table id="yw0" class="caps table table-striped table-bordered table-hover"><tbody>
<tr class="even">
  <th colspan="2" style="width:10%">Remark</th>
  <td colspan="2">
	<?php echo $form->textArea($model,'remark',
  		array('rows'=>4, 'cols'=>30,'class'=>'lolcat','title'=>'Enter Remark','style'=>$width)); 
  	?>
  </td>
  </tr>
  	
</tbody>
</table>	
</div>
</div>   
</div> <br/>
<div class="button-right">
<button type="submit" class="btn btn-inverse btn-small" name="Tab1Save" id="Tab1Save">Save</button> |
<button type="button"  class="btn btn-inverse btn-small" <?php if($model->isNewRecord){echo 'disabled';}?>  name="Tab1Next" id="Tab1Next">Next</button>
</div>
</div>
</div>





</div>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->






controller


<?php

class SitemasterlistController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'postOnly + delete', // we only allow deletion via POST request
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array(''),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update','index','view','admin','application','orgdropdown','orglicense',
								 'contactperson','district','structurecategory','consultant','consultantvalue',
								 'contactpersonconsultant','techagency1','techagency1branch','techagency1_cpdetails',
								 'localauthority','contactpersonla','laapplicationfees','download','delete','permit'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array(''),
				'users'=>array('admin'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	/**
	 * Displays a particular model.
	 * @param integer $id the ID of the model to be displayed
	 */
	public function actionView($id)
	{
		$picture     = new Picture;
		$jss         = new Jss;	
		$taapproval  = new Taapproval;
        $lafees      = new Lafees;
		$document    = new Document;
		$laapproval  = new Laapproval;
 
		$this->render('view',array(
			'model'=>$this->loadModel($id),
			'jss'=>$jss,'taapproval'=>$taapproval,
			'lafees'=>$lafees,'document'=>$document,
			'laapproval'=>$laapproval,		
		));
	}

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model       = new Sitemasterlist;
		$picture     = new Picture;
		$jss         = new Jss;	
		$taapproval  = new Taapproval;
        $lafees      = new Lafees;
		$document    = new Document;
		$laapproval  = new Laapproval;
 
		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Sitemasterlist']))
		{
			$model->attributes    = $_POST['Sitemasterlist'];
			$generatename         = Util::ReferenceNo(7);//generate application folder name
			$model->applicationid = Yii::app()->params['folder_application'].$generatename; 
			if($model->save())
			//$this->redirect(array('application'));

			if($model->applicationid){
			//get organisation folder path 
		    $organisation = Organisation::model()->findByAttributes(array('id'=>$model->fkorganisationid,));
			$orgpath = $organisation['folderpath'];
			//create  new organisation's application folder path		
			Util::CreateFolder_Application($orgpath, $model->applicationid);
			
		
		   //insert new default picture
			$picture->name       = 'no_image';
			$picture->encrypt    = 'no_image.gif';
			$picture->folderpath = '/'.Yii::app()->params['folderPath'].'/'.$orgpath.'/'.$model->applicationid.'/';
			$picture->type       = 2;//default 1=profile ,2=tower picture
		    $picture->save(false);
			
			//assign newly created picture id to sitemasterlist to save picture id 
			$model->fktowerpictureid = $picture->id; 
			$model->save(false);
			
			
			//local authority fees-application fees
			/* Two category = application fees and penalthy fees
			 *  1=permit, 2=license 3=buildingprocess 4=planningprocess, 5=signboard,
			 */
			$applicationfees = array('permit'=>1,'license'=>2,'buildingprocess'=>3,'planningprocess'=>4);
			$penalthyfees    = array('signboard'=>5,'permit'=>1,'buildingprocess'=>3,'planningprocess'=>4);
			
			//application fees
	        $sql1 = "INSERT INTO `lafees` (`id`, `fksitemasterlist`, `feecategory`, `feestype`, `date`, `cheque`) VALUES 
					('', '".$model->id."', '1', '".$applicationfees['permit']."', '0000-00-00', ''),
					('', '".$model->id."', '1', '".$applicationfees['license']."', '0000-00-00', ''),
					('', '".$model->id."', '1', '".$applicationfees['buildingprocess']."', '0000-00-00', ''),
					('', '".$model->id."', '1', '".$applicationfees['planningprocess']."', '0000-00-00', '');";
			$this->InsertRecords($sql1);//insert as application fees
 			//penalthy fees
		    $sql2 = "INSERT INTO `lafees` (`id`, `fksitemasterlist`, `feecategory`, `feestype`, `date`, `cheque`) VALUES 
					('', '".$model->id."', '2', '".$penalthyfees['signboard']."', '0000-00-00', ''),
					('', '".$model->id."', '2', '".$penalthyfees['permit']."', '0000-00-00', ''),
					('', '".$model->id."', '2', '".$penalthyfees['buildingprocess']."', '0000-00-00', ''),
					('', '".$model->id."', '2', '".$penalthyfees['planningprocess']."', '0000-00-00', '');";
			$this->InsertRecords($sql2);//insert as application fees
 		
 			//Local Authority Documentation insert
	 		$variable  = Variable::model()->findAll('fkvariablecategoryid = 12');
			foreach ($variable as $key => $value) {
			  $sql3 = "INSERT INTO `document` (`id`, `docselection`, `fkdocid`, `fksitemasterlist`, `fkorganisation`) VALUES
					   (NULL, '0', '".$value['id']."', '".$model->id."', '".$model->fkorganisationid."');";
			  $this->InsertRecords($sql3);//insert as application fees
			} 		
		
 			//copy defalt no image availabe to new application directory
			$oriPlace = Yii::app() -> getBasePath()."/../images/framework/no_image.gif";
			$copyTo   = Yii::app() -> getBasePath()."/../".Yii::app()->params['folderPath']."/".$orgpath."/".$model->applicationid."/no_image.gif";
			
			//throw error if cannot copy
			if(!copy($oriPlace, $copyTo));
			Yii::app() -> user -> setFlash('success-create', '');
			$this->redirect($this->createUrl('sitemasterlist/update', array('id'=>$model->id)));			
			
			}
			
		}
		$this->render('create',array(
			'model'=>$model,'jss'=>$jss,'taapproval'=>$taapproval,'lafees'=>$lafees,'document'=>$document,'laapproval'=>$laapproval,
		));
	}

	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id)
	{
		$jss        = new Jss('search');	
		$taapproval = new Taapproval('search');
		$lafees     = new Lafees; 
		$document	= new Document;
		$laapproval = new Laapproval;
		$model      = $this->loadModel($id);
		

 		$jss->unsetAttributes();  // filter for jss - clear any default values
  		$taapproval->unsetAttributes();  // filter for jss - clear any default values
 		if(isset($_GET['Jss'])){
			$jss->attributes=$_GET['Jss'];
			$this->render('update',array('model'=>$model,'jss'=>$jss,'taapproval'=>$taapproval,'lafees'=>$lafees,'document'=>$document,'laapproval'=>$laapproval));
		}else if(isset($_GET['Taapproval'])){
			$taapproval->attributes=$_GET['Taapproval'];
			$this->render('update',array('model'=>$model,'jss'=>$jss,'taapproval'=>$taapproval,'lafees'=>$lafees,'document'=>$document,'laapproval'=>$laapproval));
		}else if(isset($_GET['Laapproval'])){
			$laapproval->attributes=$_GET['Laapproval'];
			$this->render('update',array('model'=>$model,'jss'=>$jss,'taapproval'=>$taapproval,'lafees'=>$lafees,'document'=>$document,'laapproval'=>$laapproval));
		}else{
			// Uncomment the following line if AJAX validation is needed
			$this->performAjaxValidation(array($model,$jss,$taapproval,$lafees,$document,$laapproval));
           if(isset($_POST['Sitemasterlist']))
			{
				
//		if(isset($_POST['Sitemasterlist'],$_POST['Jss'],$_POST['Taapproval'],$_POST['Lafees'],$_POST['Document'],$_POST['Laapproval']))
	//	{		
				$model->attributes = $_POST['Sitemasterlist'];
				
				$finalplan         = isset($_POST['Sitemasterlist']['finalplan']);
				$model->finalplan  = ($finalplan == 1)? '1':'0';
			
				$valid = $model->validate();
				$valid = $jss->validate(false) && $valid;
				$valid = $taapproval->validate(false) && $valid;
				$valid = $lafees->validate(false) && $valid;
				$valid = $document->validate(false) && $valid;
				$valid = $laapproval->validate(false) && $valid;			
				
 				if($valid){
					$model->save();
				 		
				
				//save pdate local authority fees- application
	 			$this->UpdateRecord('lafees', $_POST['Laappfees']['appfeespermitdate'], $_POST['Laappfees']['permitcheque'], $model->id, 1, 1);
				$this->UpdateRecord('lafees', $_POST['Laappfees']['appfeeslicensedate'], $_POST['Laappfees']['licensecheque'], $model->id, 1, 2);
				$this->UpdateRecord('lafees', $_POST['Laappfees']['apfeesbuildingdate'], $_POST['Laappfees']['buildingcheque'], $model->id, 1, 3);
				$this->UpdateRecord('lafees', $_POST['Laappfees']['apfeesplanningdate'], $_POST['Laappfees']['planningcheque'], $model->id, 1, 4);
				
				
				
 				//save update for penalthy application fees
		 		$this->UpdateRecord('lafees', $_POST['Lapenalthyfees']['penalhtysignboarddate'], $_POST['signboardcheque'], $model->id, 2, 5);
				$this->UpdateRecord('lafees', $_POST['Lapenalthyfees']['penalhtypermitdate'], $_POST['permitcheque'], $model->id, 2, 1);
				$this->UpdateRecord('lafees', $_POST['Lapenalthyfees']['penalhtybuildingdate'], $_POST['buildingcheque'], $model->id, 2, 3);
				$this->UpdateRecord('lafees', $_POST['Lapenalthyfees']['penalhtyplanningdate'], $_POST['planningcheque'], $model->id, 2, 4);
				
				
				//Local Authority Documentation insert
	 			//$docselection      = $_POST['Document']['docselection'];	
				$site_report_ckbx          = isset($_POST['site_report_ckbx']);	
				$site_report_name          = $_POST['Document']['site_report_name'];
				$site_report_id            = $_POST['Document']['site_report_id'];
				
				$drawings_ckbx             = isset($_POST['drawings_ckbx']);	
				$drawings_name			   = $_POST['Document']['drawings_name'];
				$drawings_id               = $_POST['Document']['drawings_id'];
				
				$tenancy_aggerement_ckbx   = isset($_POST['tenancy_aggerement_ckbx']);	
				$tenancy_aggerement_name   = $_POST['Document']['tenancy_aggerement_name'];
				$tenancy_aggerement_id     = $_POST['Document']['tenancy_aggerement_id'];
				
				$submission_ckbx           = isset($_POST['submission_ckbx']);	
				$submission_name		   = $_POST['Document']['submission_name'];
				$submission_id             = $_POST['Document']['submission_id'];
			
				$assesment_tax_ckbx        = isset($_POST['assesment_tax_ckbx']);	
				$assesment_tax_name   	   = $_POST['Document']['assesment_tax_name'];
				$assesment_tax_id   	   = $_POST['Document']['assesment_tax_id'];
				
				$quit_rent_ckbx            = isset($_POST['quit_rent_ckbx']);	
				$quit_rent_name 		   = $_POST['Document']['quit_rent_name'];
				$quit_rent_id		   	   = $_POST['Document']['quit_rent_id'];
				
				$design_calculation_ckbx   = isset($_POST['design_calculation_ckbx']);	
				$design_calculation_name   = $_POST['Document']['design_calculation_name'];
				$design_calculation_id 	   = $_POST['Document']['design_calculation_id'];
				
				$insurance_ckbx            = isset($_POST['insurance_ckbx']);	
				$insurance_name			   = $_POST['Document']['insurance_name'];
				$insurance_id 	  		   = $_POST['Document']['insurance_id'];
				
				$engineer_certificates_ckbx = isset($_POST['engineer_certificates_ckbx']);	
				$engineer_certificates_name = $_POST['Document']['engineer_certificates_name'];
				$engineer_certificates_id   = $_POST['Document']['engineer_certificates_id'];
				
				$other_documents_ckbx      = isset($_POST['other_documents_ckbx']);	
				$other_documents_name      = $_POST['Document']['other_documents_name'];
				$other_documents_id        = $_POST['Document']['other_documents_id'];
					
				$this->InsertRecordsDocumentation($site_report_ckbx,$site_report_id,$model->id,$model->fkorganisationid);
			  	$this->InsertRecordsDocumentation($drawings_ckbx,$drawings_id,$model->id,$model->fkorganisationid);
			   	$this->InsertRecordsDocumentation($tenancy_aggerement_ckbx,$tenancy_aggerement_id,$model->id,$model->fkorganisationid);
			   	$this->InsertRecordsDocumentation($submission_ckbx,$submission_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($assesment_tax_ckbx,$assesment_tax_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($quit_rent_ckbx,$quit_rent_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($design_calculation_ckbx,$design_calculation_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($insurance_ckbx,$insurance_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($engineer_certificates_ckbx,$engineer_certificates_id,$model->id,$model->fkorganisationid);
				$this->InsertRecordsDocumentation($other_documents_ckbx,$other_documents_id,$model->id,$model->fkorganisationid);
				
				
				//Notes:avoid using chekcbox as array insertion of values for above codes.	
				 
   					//$this->redirect(array('application'));
					Yii::app() -> user -> setFlash('success-update', '');
					$this->redirect($this->createUrl('sitemasterlist/update', array('id'=>$model->id)));			
				}else{
					Yii::app() -> user -> setFlash('success-save-error', '');
					$this->redirect($this->createUrl('sitemasterlist/update', array('id'=>$model->id)));				
				}
			}
	
			$this->render('update',array(
				'model'=>$model,'jss'=>$jss,'taapproval'=>$taapproval,'lafees'=>$lafees,'document'=>$document,'laapproval'=>$laapproval
			));
	    }
	}

	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
			
		try{
				if(Yii::app()->session['roleid'] == 1){//if login as admin prform to delete
			 
		    	     $this->loadModel($id)->delete();//load id delete
					
					   if(isset($_GET['ajax'])){
	 				     //success of deletion 	
	 			         Yii::app()->user->setFlash('success-delete','');
					  }else{
						//not success of deletion
			      		   Yii::app()->user->setFlash('success-error','');
					 }
				}else{//if not login as admin not auhtorized to delete 
					Yii::app()->user->setFlash('you-not-authorized','');	
					}	
		   }catch(CDbException $e){
				if(!isset($_GET['ajax'])){
			  		 Yii::app()->user->setFlash('you-cannot-delete-this-record','');
			   }else{
		      		 Yii::app()->user->setFlash('you-cannot-delete-this-record','');
			//	throw $e;
	        	}
			}
	
	 
     	
	}


	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
	/*
		$dataProvider=new CActiveDataProvider('Sitemasterlist');
			$this->render('index',array(
				'dataProvider'=>$dataProvider,
			));*/
	
	}

	/**
	 * Manages all models.
	 */
	public function actionAdmin()
	{
		$model=new Sitemasterlist('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Sitemasterlist']))
			$model->attributes=$_GET['Sitemasterlist'];

		$this->render('admin',array(
			'model'=>$model,
		));
	}
	
		/**
	 * Manages all models.
	 */
	public function actionPermit()
	{
		$model=new Sitemasterlist('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Sitemasterlist']))
			$model->attributes=$_GET['Sitemasterlist'];

		$this->render('permit',array(
			'model'=>$model,
		));
	}
	
	
	/**
	 * Manages all models.
	 */
	public function actionApplication()
	{
		$model=new Sitemasterlist('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Sitemasterlist']))
			$model->attributes=$_GET['Sitemasterlist'];

		$this->render('application',array(
			'model'=>$model,
		));
	}

	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer $id the ID of the model to be loaded
	 * @return Sitemasterlist the loaded model
	 * @throws CHttpException
	 */
	public function loadModel($id)
	{
		$model=Sitemasterlist::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}

	/**
	 * Performs the AJAX validation.
	 * @param Sitemasterlist $model the model to be validated
	 */
	protected function performAjaxValidation($model)
	{
		if(isset($_POST['ajax']) && $_POST['ajax']==='sitemasterlist-form')
		{
		//echo CActiveForm::validate($model);
		echo CActiveForm::validate(array($model,$jss,$taapproval,$lafees,$document,$laapproval));
			
			Yii::app()->end();
		}
	}


	/* Insert recors to make multiple records especially  for foregin key
	*
	*/
	public function InsertRecords($sql){
		$connection = Yii::app() -> db;
		$command = $connection -> createCommand($sql);
		$command -> execute();
	}



	/* Insert recors to make multiple records especially  for foregin key
	*
	*/
	public function InsertRecordsDocumentation($docs,$doc_id,$model_id,$modelorg_id){
		if($docs == 1){//if checked get the value
		$sql	= "UPDATE `document` SET `docselection` = 1
           		   WHERE `id` = '".$doc_id."' AND `fksitemasterlist` = '".$model_id."' AND
	       	      `fkorganisation` = '".$modelorg_id."'  ;<br/>";		
		}else{
		$sql	= "UPDATE `document` SET `docselection` = 0
           		   WHERE `id` = '".$doc_id."' AND `fksitemasterlist` = '".$model_id."' AND
	       	      `fkorganisation` = '".$modelorg_id."'  ;<br/>";		
		}
		$connection = Yii::app() -> db;
		$command = $connection -> createCommand($sql);
		$command -> execute();
	}




	/*
	 *Multiple insert of record 
	 */
	 public function UpdateRecord($db,$date,$cheque,$fksitemasterlist,$feecategory,$feestype){
	 	
		 $sql = "UPDATE `".$db."` SET  
		 		`date` = '".$date."',
				`cheque` ='".$cheque."' WHERE 
				`fksitemasterlist` =".$fksitemasterlist."  AND 
				`feecategory`='".$feecategory."'  AND `feestype` = '".$feestype."';";
		$this->InsertRecords($sql);
	 }
######################################Begin of tab2#####################################  

	/*
	 *Dropdown change based on dependent ont anter dropdown for Organisation
	 */
	public function actionOrgdropdown()
	{
	   
	   $giatUnit = (!empty($_POST['clientid'])) ? $_POST['clientid']: '0';  
	   $data=Contactperson::model()->findAll('fksubcategory=:clientid AND fksetupcategory=21',
                                array(':clientid'=>$giatUnit));
	   $data=CHtml::listData($data,'id','name');		
		
		if(!empty($data)){
			foreach($data as $value=>$name)
			{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			//echo CHtml::textField('licenseid',$name,array('width'=>'95%' )); 
			//echo $name;
			}        
		}	
	}  	  


     /*
	 *Dropdown change based on dependent ont anter dropdown get license value
	 */
	public function actionOrglicense()
	{
	   $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	   $data=Organisation::model()->findAll('id=:id',
									   array(':id'=>$id));
		$data=CHtml::listData($data,'id','license');		
		
		if(!empty($data)){
			foreach($data as $value=>$license)
			{
 			echo $license;
			}        
		}	   		 	   		
	}


	/*
	 *Dropdown change based on dependent ont anter dropdown-contact person for organisation
	 */
	public function actionContactperson()
	{
	   
	  $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	  $data=Contactperson::model()->findAll('id=:id AND fksetupcategory=21',
                                array(':id'=>$id));
	  	if(!empty($data)){
	   		echo $data[0]->mobile.','.$data[0]->email.','.$data[0]->designation.','.$data[0]->department;
	  	}else{
	   		echo ''.','.','.''.',';//remove all element
		 }     			      
	}  	  


	/*
	 *Dropdown change based on dependent ont anter dropdown- dostrict 
	 */
	public function actionDistrict()
	{
	  /*  31 	Nilai 	N.S district name 	3	 
		  28 	Tampin 	N.S district name 	3
		  27 	Jempol 	N.S district name 	3
		  26 	Kuala Pilah 	N.S district name 	3
		  25 	Jelebu 	N.S district name 	3
		  24 	Rembau 	N.S district name 	3
		  23 	Port Dickson 	N.S district name 	3
		  22 	Seremban 	N.S district name 	
	   * */
	   
	   $giatUnit = (!empty($_POST['id'])) ? $_POST['id']: '0';      
	 	if($giatUnit == 22){//seremban
 			$match = addcslashes('seremban', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 23){//port dickson
 			$match = addcslashes('port dickson', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 24){//rembau
 			$match = addcslashes('rembau', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 25){//jelebu
 			$match = addcslashes('jelebu', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 26){//kuala pilah
 			$match = addcslashes('kuala pilah', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 27){//jempol
 			$match = addcslashes('jempol', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 28){//tampin
 			$match = addcslashes('tampin', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 31){//nilai
 			$match = addcslashes('nilai', '%_'); // escape LIKE's special characters
		}
		
		$q = new CDbCriteria( array(
			    'condition' => "description LIKE :match",         // no quotes around :match
			    'params'    => array(':match' => "%$match%")  // Aha! Wildcards go here
			) );
	   $data = Variable::model()->findAll( $q );  
	   $data=CHtml::listData($data,'id','name');		
		
		if(!empty($data)){
			foreach($data as $value=>$name)
			{
				echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);			 
			}        
		}	
	 }  	  

	/*
	 *Dropdown change based on dependent ont anter dropdown - structure catagory
	 */ 
	public function actionStructurecategory()
	{ 
	   /*
		147 	Temporary BTS 	type category tower 	8
		146 	Dual-Function 	type category tower 	8
 		145 	Rooftop 	type category tower 	8
		144 	Tower 	type category tower 	8
	   */
	   
	   $giatUnit = (!empty($_POST['id'])) ? $_POST['id']: '0';
      
	 	if($giatUnit == 144){//tower
 			$match = addcslashes('tower type', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 145){//rooftop
 			$match = addcslashes('rooftop type', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 146){//dual function
 			$match = addcslashes('dual function type', '%_'); // escape LIKE's special characters
		}
		if($giatUnit == 147){//temporary bts
 			$match = addcslashes('temporary bts type', '%_'); // escape LIKE's special characters
		} 
		
		$q = new CDbCriteria( array(
			    'condition' => "description LIKE :match",         // no quotes around :match
			    'params'    => array(':match' => "%$match%")  // Aha! Wildcards go here
			) );
	   $data = Variable::model()->findAll( $q );  
	   $data=CHtml::listData($data,'id','name');		
		
		if(!empty($data)){
			foreach($data as $value=>$name)
			{
				echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			}        
		}	
 	}  	
 
    /*
	 *Dropdown change based on dependent ont anter dropdown - consultant name
	 */ 
	public function actionConsultant()
	{   
	   $giatUnit = (!empty($_POST['clientid'])) ? $_POST['clientid']: '0';
	   $data=Contactperson::model()->findAll('fksubcategory=:clientid AND fksetupcategory=18 AND active=1',
                                array(':clientid'=>$giatUnit));
	   $data=CHtml::listData($data,'id','name');		
		
		if(!empty($data)){
			foreach($data as $value=>$name)
			{
				echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			}        
		}	
	} 
  
 
     /*
	 *Dropdown change based on dependent ont anter dropdown -consultant attributes 
	 */
	public function actionConsultantvalue()
	{
	   $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	   $data=Consultant::model()->findAll('id=:id',
									   array(':id'=>$id));
		if(!empty($data)){
	  		echo $data[0]->tel.','.$data[0]->regno.','.$data[0]->email.',';
		} else{
	 		echo ''.','.','.',';//remove all element
		}      		
	}
  
  
     /*
	 *Dropdown change based on dependent ont anter dropdown - consultant contact person
	 */
	 public function actionContactpersonconsultant()
	 {
	   
	   $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	   $data=Contactperson::model()->findAll('id=:id AND fksetupcategory=18',
                                array(':id'=>$id));
		if(!empty($data)){
		  echo $data[0]->mobile.','.$data[0]->email.','.$data[0]->designation.','.$data[0]->department;
		} else{
		 echo ''.','.','.''.',';//remove all element
		}     	
     }
  
  
  
     /*
	 *Dropdown change based on dependent ont anter dropdown for Organisation
	 */
	public function actionTechagency1()
	{
	   
	   $giatUnit = (!empty($_POST['clientid'])) ? $_POST['clientid']: '0';  
	   $sql      = 'SELECT variable.id, variable.name FROM `variable`
                    INNER JOIN technicalagency ON technicalagency.fktechagecnytype ='.$giatUnit.' AND technicalagency.active=1
                    AND variable.id = technicalagency.fkdistrict'; 
       $variable = Variable::model()->findAllBySql($sql);
	   $data     = CHtml::listData($variable, 'id', 'name'); 
	   				
 		
		if(!empty($data)){
			echo CHtml::tag('option',array('value'=>''),CHtml::encode('--Select--'),true);
			foreach($data as $value=>$name)
			{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			}        
		}	
	}  	  
  
  
    /*
	 *Dropdown change based on dependent ont anter dropdown for Organisation
	 */
	public function actionTechagency1branch()
	{
	  	
	echo   $agency    = (!empty($_POST['agency'])) ? $_POST['agency']: '0';   
	 echo  $district  = (!empty($_POST['district'])) ? $_POST['district']: '0';  
	   
	   $sql  = 'SELECT contactperson.id, contactperson.name FROM contactperson INNER JOIN technicalagency ON 
	   			technicalagency.fktechagecnytype = '.$agency.'
                AND technicalagency.fkdistrict = '.$district.' AND contactperson.fksetupcategory=19 AND contactperson.active=1
                AND contactperson.fksubcategory = technicalagency.id';
			   
 	  $variable = Contactperson::model()->findAllBySql($sql);
 	  $data     = CHtml::listData($variable, 'id', 'name'); 
	   				
					
		if(!empty($data)){
			echo CHtml::tag('option',array('value'=>''),CHtml::encode('--Select--'),true);
			foreach($data as $value=>$name)
			{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			}        
		}else{
			echo CHtml::tag('option',array('value'=>''),CHtml::encode('--Select--'),true);
		}
	}  	  
  
  
  
  /*
	 *Dropdown change based on dependent ont anter dropdown-contact person for organisation
	 */
	public function actionTechagency1_cpdetails()
	{
	   
	  $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	  $data=Contactperson::model()->findAll('id=:id AND fksetupcategory=19',
                                array(':id'=>$id));
	  	if(!empty($data)){
	   		echo $data[0]->mobile.','.$data[0]->email.','.$data[0]->designation.',';
	  	}else{
	   		echo ''.','.','.'';//remove all element
		 }     			      
	}  	  
  
  
######################################End of tab2#####################################  
  
  
  
######################################Begin of tab3################################### 
  
   /*
	 *Dropdown change based on dependent ont anter dropdown for Organisation
	 */
	public function actionLocalauthority()
	{
	   
	   $giatUnit = (!empty($_POST['laid'])) ? $_POST['laid']: '0';  
	   $data=Contactperson::model()->findAll('fksubcategory=:laid AND fksetupcategory=20',
                                array(':laid'=>$giatUnit));
	   $data=CHtml::listData($data,'id','name');		
		
						
		if(!empty($data)){
			echo CHtml::tag('option',array('value'=>''),CHtml::encode('--Select--'),true);
			foreach($data as $value=>$name)
			{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
			}        
		}else{
			echo CHtml::tag('option',array('value'=>''),CHtml::encode('--Select--'),true);
		}
	}  	  
  
  /*
	 *Dropdown change based on dependent ont anter dropdown-contact person for local authority
	 */
	public function actionContactpersonla()
	{
	   
	  $id = (!empty($_POST['id'])) ? $_POST['id']: '0';
	  $data=Contactperson::model()->findAll('id=:id AND fksetupcategory=20',
                                array(':id'=>$id));
	  	if(!empty($data)){
	   		echo $data[0]->mobile.','.$data[0]->email.','.$data[0]->designation.'';
	  	}else{
	   		echo ''.','.','.''.',';//remove all element
		 }     			      
	}  	  
  
    /*
	 *Dropdown change based on dependent ont anter dropdown-contact person for la application fees
	 */
	public function actionLaapplicationfees()
	{
	   
	  $id   = (!empty($_POST['id'])) ? $_POST['id']: '0';
	  $data = Localcouncil::model()->findAll('id=:id AND active=1',
                                array(':id'=>$id));
	  	if(!empty($data)){
	   		echo ''.$data[0]->apppermit.',
	   			 '.$data[0]->applicense.',
	   			 '.$data[0]->appbuildingprocess.',
	   			 '.$data[0]->appplaningprocess.',
	   		     '.$data[0]->penalthysignboard.',
	   		     '.$data[0]->penalthypermit.',
	   		     '.$data[0]->penalthybuildingprocess.',
	   		     '.$data[0]->penalthyplaningprocess.'';
	  	}else{
	   		echo '','','','','','','','';//remove all element
		 }     			      
	}
   
  
  
######################################End of tab3#####################################  
    
  
 /*
 * Download fucntion to show popup browser to download attachment
 */
  public function actionDownload($id){
  	
	
	
	 $criteria=new CDbCriteria;
     $criteria->select='encryptname,folderpath'; //select id field
     $criteria->condition = 'id=:id';  
	 $criteria->params = array(':id'=>$id);
     $attachment = Attachment::model()->find($criteria);
	 
	 if(!empty($attachment)){
	 	$folder  = $attachment->attributes['folderpath'];
	 	$encrypt = $attachment->attributes['encryptname'];
		$path = Yii::app() -> getBasePath() . '/..'.$folder.'/'.$encrypt.'';
	    if(file_exists( $path ) ){
		  Yii::app()->getRequest()->sendFile( $encrypt , file_get_contents( $path ) );
		}else{
			//if success
			Yii::app() -> user -> setFlash('success-attachmentmissing', '');
			//$this->refresh();
			//$this -> redirect(array('sitemasterlist/update', 'id' => $id,));
             throw new CHttpException(404,'The requested download file does not exist.');
  		} 
	 }else{
			//if success
			Yii::app() -> user -> setFlash('success-attachmentmissing', '');
			//$this->refresh();
			//$this -> redirect(array('sitemasterlist/update', 'id' => $id,));
             throw new CHttpException(404,'The requested download file does not exist.');
  		} 
  }
  
  
 
}

0

#2 User is offline   vinoth.mohan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 08-June 13
  • Location:Malaysia

Posted 06 February 2014 - 09:35 PM

mieu awww any1? :unsure:
0

#3 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 07 February 2014 - 05:03 AM

Hi,

Have you tried seperate error message like

why are you adding laapproval twice in array :(


<?php echo $form->errorSummary($model);?>
<?php echo $form->errorSummary($document);?>
<?php echo $form->errorSummary($laapproval);?>
<?php echo $form->errorSummary($taapproval);?>
<?php echo $form->errorSummary($lafees);?>
<?php echo $form->errorSummary($jss);?>



Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#4 User is offline   vinoth.mohan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 08-June 13
  • Location:Malaysia

Posted 10 February 2014 - 12:09 AM

Hi Chandran,

First of all thanks for your reply.


<?php echo $form->errorSummary($model);?>
<?php echo $form->errorSummary($document);?>
<?php echo $form->errorSummary($laapproval);?>
<?php echo $form->errorSummary($taapproval);?>
<?php echo $form->errorSummary($lafees);?>
<?php echo $form->errorSummary($jss);?>



I did as per u told but still no changes.
validation is working but not throwing the error summary.


Also the $laapproval its a mistake,changed to $permit.
0

#5 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 10 February 2014 - 03:11 AM

Hi,

Goto validation method and include this two lines
print_r($model->errors)
print_r($model->hasErrors('field_name'))

you should get validation message printed..if your validation method is called correctly for your request..
I hope for positive result. cheers
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#6 User is offline   vinoth.mohan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 08-June 13
  • Location:Malaysia

Posted 11 February 2014 - 01:41 AM

Hi Bro,

 <?php
	print_r($model->errors);
	print_r($model->hasErrors('fktechagencyid1'));				
 ?>




output - >Array() is empty.


nop.still no changes. :(
0

#7 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 11 February 2014 - 03:46 AM

Hi,

when error array is empty .. then i am sure two things

first one

you dont have any error in your model activerecord :)

or

your validation not called properly during save :(

you have to analyse now :D
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#8 User is offline   vinoth.mohan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 08-June 13
  • Location:Malaysia

Posted 11 February 2014 - 10:05 PM

I'm not sure where Im making mistake but i tried so many possibilities.

Still couldn't find solution.

Anyhow i will revise this matter again.

Thanks bro.(chandran)
0

#9 User is offline   craigpotter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-August 12

Posted 24 April 2014 - 03:27 PM

Have you checked to make sure that you are passing your variables to the Partial correctly?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users