<commit_before><?php

class page_agents extends Page{
	public $title ="Agent Management";

	function init(){
		parent::init();

		$this->add('Controller_Acl');

		$crud = $this->add('CRUD');
		$agent=$this->add('Model_Agent');
		$agent->setOrder('id','desc');

		if($crud->isEditing('edit')){
			$agent->hook('editing');
		}
		$agent->addExpression('sponsor_name')->set(function($m,$q){
			return $m->refSQL('sponsor_id')->fieldQuery('member');
		});

		$agent->addExpression('sponsor_cadre')->set(function($m,$q){
			return $m->refSQL('sponsor_id')->fieldQuery('cadre');	
		});

		// $agent->addCondition('sponsor_id','>',0);

		$crud->setModel($agent,array('member_id','sponsor_id','account_id','cadre_id','ActiveStatus','username','password','added_by'),array('code','created_at','member','sponsor_name','sponsor_cadre','account','cadre','current_individual_crpb','ActiveStatus','username','password','added_by'));

		if($crud and !$crud->isEditing('add') and ! $crud->isEditing('edit')){
			$crud->add('Controller_DocumentsManager',array('doc_type'=>'AgentDocuments'));
			
			$agent_guarantor_crud = $crud->addRef('AgentGuarantor');
			if($agent_guarantor_crud and !$agent_guarantor_crud->isEditing('add') and !$agent_guarantor_crud->isEditing('edit')){
				$agent_guarantor_crud->add('Controller_DocumentsManager',array('doc_type'=>'AgentGuarantor'));
				$agent_guarantor_crud->add('Controller_Acl');
			}

			$crud->grid->addPaginator(50);
			$crud->grid->addQuickSearch(array('member','account','code'));
			$crud->grid->addFormatter('sponsor_name','Wrap');
		}


		if($crud->isEditing('add')){			//TODO 
			
			$account_of_member_field = $crud->form->getElement('account_id');
			
			$account_of_member_field->send_other_fields = array($crud->form->getElement('member_id'));
			if($member_selected = $_GET['o_'.$crud->form->getElement('member_id')->name]){
				$account_of_member_field->model->addCondition('member_id',$member_selected);
				$account_of_member_field->model->addCondition('ActiveStatus',true);
			}

		}

		if($crud->isEditing('edit')){			//TODO 
			
			$account_of_member_field = $crud->form->getElement('account_id');<commit_msg>deactivated agents cut through<commit_after><?php

class page_agents extends Page{
	public $title ="Agent Management";

	function init(){
		parent::init();

		$this->add('Controller_Acl');

		$crud = $this->add('CRUD');
		$agent=$this->add('Model_Agent');
		$agent->setOrder('id','desc');

		if($crud->isEditing('edit')){
			$agent->hook('editing');
		}
		$agent->addExpression('sponsor_name')->set(function($m,$q){
			return $m->refSQL('sponsor_id')->fieldQuery('member');
		});

		$agent->addExpression('sponsor_cadre')->set(function($m,$q){
			return $m->refSQL('sponsor_id')->fieldQuery('cadre');	
		});

		// $agent->addCondition('sponsor_id','>',0);

		$crud->setModel($agent,array('member_id','sponsor_id','account_id','cadre_id','ActiveStatus','username','password','added_by'),array('code','created_at','member','sponsor_name','sponsor_cadre','account','cadre','current_individual_crpb','ActiveStatus','username','password','added_by'));

		if($crud and !$crud->isEditing('add') and ! $crud->isEditing('edit')){
			$crud->add('Controller_DocumentsManager',array('doc_type'=>'AgentDocuments'));
			
			$agent_guarantor_crud = $crud->addRef('AgentGuarantor');
			if($agent_guarantor_crud and !$agent_guarantor_crud->isEditing('add') and !$agent_guarantor_crud->isEditing('edit')){
				$agent_guarantor_crud->add('Controller_DocumentsManager',array('doc_type'=>'AgentGuarantor'));
				$agent_guarantor_crud->add('Controller_Acl');
			}

			$crud->grid->addHook('formatRow',function($g){
				if(!$g->model['ActiveStatus']){
					$g->setTDParam('member','style/color','red');
					$g->setTDParam('member','style/text-decoration','line-through');
				}
				else
					$g->setTDParam('member','style/color','');
			});

			$crud->grid->addPaginator(50);
			$crud->grid->addQuickSearch(array('member','account','code'));
			$crud->grid->addFormatter('sponsor_name','Wrap');
		}


		if($crud->isEditing('add')){			//TODO 
			
			$account_of_member_field = $crud->form->getElement('account_id');
			
			$account_of_member_field->send_other_fields = array($crud->form->getElement('member_id'));
			if($member_selected = $_GET['o_'.$crud->form->getElement('member_id')->name]){
				$account_of_member_field->model->addCondition('member_id',$member_selected);
				$account_of_member_field->model->addCondition('ActiveStatus',true);
			}

		}

		if($crud->isEditing('edit')){			//TODO 
			
			$account_of_member_field = $crud->form->getElement('account_id');
{'fraction_non_alphanumeric': 0.2215231069646344, 'fraction_numerical': 0.0013018008244738556, 'mean_word_length': 6.934595524956971, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 107, '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': '2045042', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1596, 'n_words': 126}