<commit_before><?php

class page_accounts_CC extends Page {
	function page_index(){

		$this->add('Controller_Acl');

		$crud=$this->add('xCRUD',array('grid_class'=>'Grid_Account','add_form_beautifier'=>false));
		$account_cc_model =$this->add('Model_Account_CC');
			
		$account_cc_model->setOrder('created_at','desc');

		$crud->addHook('myupdate',function($crud,$form){
			if($crud->isEditing('edit')) return false;
			
			$documents=$form->add('Model_Document');
			$documents->addCondition('CCAccount',true);
			foreach ($documents as $d) {
				
			    if($form[$form->api->normalizeName($documents['name'])] and $form[$form->api->normalizeName($documents['name'].' value')]=='')
			    	$form->displayError($form->api->normalizeName($documents['name'].' value'),'Please Specify');
			}

			$cc_account_model = $crud->add('Model_Account_CC');
			
			try {
				$crud->api->db->beginTransaction();
			    $cc_account_model->createNewAccount($form['member_id'],$form['scheme_id'],$crud->api->current_branch, $form['AccountNumber'],$form->getAllFields(),$form);
			    $crud->api->db->commit();
			} catch (Exception $e) {
			   	$crud->api->db->rollBack();
			   	throw $e;
			}
			
			return true;
		});

		if($crud->isEditing("add")){
		    $o=$crud->form->add('Order');
			$k = 1;
			$documents=$this->add('Model_Document');
			$documents->addCondition('CCAccount',true);
			foreach ($documents as $d) {
			    $f1=$crud->form->addField('checkbox',$this->api->normalizeName($documents['name']));
			   	$o->move($f1,'last');
			    $f2=$crud->form->addField('line',$this->api->normalizeName($documents['name'].' value'));
			   	$f1->js(true)->univ()->bindConditionalShow(array(
					''=>array(''),
					'*'=>array($this->api->normalizeName($documents['name'].' value'))
					),'div .atk-form-row');
			   	$o->move($f2,'last');
			    $k++;
			}

			$account_cc_model->getElement('member_id')->getModel()->addCondition('is_active',true);
		}

		if($crud->isEditing('edit')){
			$account_cc_model->hook('editing');
		}

		$crud->setModel($account_cc_model,array('AccountNumber','AccountDisplayName','member_id','scheme_id','Amount','agent_id','ActiveStatus'),array('AccountNumber','created_at','AccountDisplayName','member','scheme','Amount','agent','ActiveStatus','CurrentInterest','LastCurrentInterestUpdatedAt'));
		$crud->add('Controller_DocumentsManager',array('doc_type'=>'CCAccount'));
		
		if(!$crud->isEditing()){
			$crud->grid->addPaginator(50);<commit_msg>Added Signature Image in CC<commit_after><?php

class page_accounts_CC extends Page {
	function page_index(){

		$this->add('Controller_Acl');

		$crud=$this->add('xCRUD',array('grid_class'=>'Grid_Account','add_form_beautifier'=>false));
		$account_cc_model =$this->add('Model_Account_CC');
			
		$account_cc_model->setOrder('created_at','desc');

		$crud->addHook('myupdate',function($crud,$form){
			if($crud->isEditing('edit')) return false;
			
			$documents=$form->add('Model_Document');
			$documents->addCondition('CCAccount',true);
			foreach ($documents as $d) {
				
			    if($form[$form->api->normalizeName($documents['name'])] and $form[$form->api->normalizeName($documents['name'].' value')]=='')
			    	$form->displayError($form->api->normalizeName($documents['name'].' value'),'Please Specify');
			}

			if(!$form['sig_image_id']){
				$form->displayError('sig_image_id','Signature File is must to provide');
			}

			$cc_account_model = $crud->add('Model_Account_CC');
			
			try {
				$crud->api->db->beginTransaction();
			    $cc_account_model->createNewAccount($form['member_id'],$form['scheme_id'],$crud->api->current_branch, $form['AccountNumber'],$form->getAllFields(),$form);
			    $crud->api->db->commit();
			} catch (Exception $e) {
			   	$crud->api->db->rollBack();
			   	throw $e;
			}
			
			return true;
		});

		if($crud->isEditing("add")){
		    $o=$crud->form->add('Order');
			$k = 1;
			$documents=$this->add('Model_Document');
			$documents->addCondition('CCAccount',true);
			foreach ($documents as $d) {
			    $f1=$crud->form->addField('checkbox',$this->api->normalizeName($documents['name']));
			   	$o->move($f1,'last');
			    $f2=$crud->form->addField('line',$this->api->normalizeName($documents['name'].' value'));
			   	$f1->js(true)->univ()->bindConditionalShow(array(
					''=>array(''),
					'*'=>array($this->api->normalizeName($documents['name'].' value'))
					),'div .atk-form-row');
			   	$o->move($f2,'last');
			    $k++;
			}

			$account_cc_model->getElement('member_id')->getModel()->addCondition('is_active',true);
		}

		if($crud->isEditing('edit')){
			$account_cc_model->hook('editing');
		}

		$crud->setModel($account_cc_model,array('AccountNumber','AccountDisplayName','member_id','scheme_id','Amount','agent_id','ActiveStatus','sig_image_id'),array('AccountNumber','created_at','AccountDisplayName','member','scheme','Amount','agent','ActiveStatus','CurrentInterest','LastCurrentInterestUpdatedAt'));
		$crud->add('Controller_DocumentsManager',array('doc_type'=>'CCAccount'));
		
		if(!$crud->isEditing()){
			$crud->grid->addPaginator(50);
{'fraction_non_alphanumeric': 0.23187266653566516, 'fraction_numerical': 0.003144036156415799, 'mean_word_length': 5.550836550836551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 132, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3996772', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1694, 'n_words': 156}