Jump to content

[Solved] CustomerController Override Help


belyza

Recommended Posts

Hi. I was able to modify the customercontroller to show one more value for customers. I am adding an option in the create/edit customer page. Here is the section of code Im having trouble with. 

 

array(
                                       'type' => 'select',
                                       'label' => $this->l('Salesman'),
                                       'name' => 'salesman',
                                       'required' => true,
                                        'options' => array(
						'query' => $salesman,
						'id' => 'id_employee',
						'name' => 'lastname'
					),
                                       'col' => '4',
                                       'hint' => $this->l('Salesman who is linked to this customer')
                                ), 	

This works. In the selection box, I see the salesmen lastnames. If I change it to

array(
                                       'type' => 'select',
                                       'label' => $this->l('Salesman'),
                                       'name' => 'salesman',
                                       'required' => true,
                                        'options' => array(
						'query' => $salesman,
						'id' => 'id_employee',
						'name' => 'firstname'
					),
                                       'col' => '4',
                                       'hint' => $this->l('Salesman who is linked to this customer')
                                ), 	

obviously now I see the firstnames in the list. What I would like is for the list to show firstname and last name on the same line. Is this possible?

 

Edited by belyza (see edit history)
Link to comment
Share on other sites

override function:

 

public static function getEmployees()
{
return Db::getInstance()->executeS('
SELECT `id_employee`, `firstname`, `lastname`, CONCAT(`firstname`, \' \', `lastname`) as `employee_name`
FROM `'._DB_PREFIX_.'employee`
WHERE `active` = 1
ORDER BY `lastname` ASC
');
}
 
and use "employee_name"
Link to comment
Share on other sites

Thank you it works! I ended up using the following code: 

$salesman = Db::getInstance()->executeS('
                SELECT `id_employee`, `firstname`, `lastname`, CONCAT(`firstname`, \' \', 
`lastname`) as `employee_name`
                FROM `'._DB_PREFIX_.'employee`
                WHERE `active` = 1
                ORDER BY `lastname` ASC
                ');
		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Customer'),
				'icon' => 'icon-user'
			),
			'input' => array(
				array(
					'type' => 'radio',
					'label' => $this->l('Social title'),
					'name' => 'id_gender',
					'required' => false,
					'class' => 't',
					'values' => $list_genders
				),
				array(
					'type' => 'text',
					'label' => $this->l('First name'),
					'name' => 'firstname',
					'required' => true,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"째{}_$%:'
				),
				array(
					'type' => 'text',
					'label' => $this->l('Last name'),
					'name' => 'lastname',
					'required' => true,
					'col' => '4',
					'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"째{}_$%:'
				),
				array(
					'type' => 'text',
					'prefix' => '<i class="icon-envelope-o"></i>',
					'label' => $this->l('Email address'),
					'name' => 'email',
					'col' => '4',
					'required' => true,
					'autocomplete' => false
				),
				array(
					'type' => 'password',
					'label' => $this->l('Password'),
					'name' => 'passwd',
					'required' => ($obj->id ? false : true),
					'col' => '4',
					'hint' => ($obj->id ? $this->l('Leave this field blank if there\'s no change.') :
						sprintf($this->l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH))
				),
				array(
					'type' => 'birthday',
					'label' => $this->l('Birthday'),
					'name' => 'birthday',
					'options' => array(
						'days' => $days,
						'months' => $months,
						'years' => $years
					)
				),
                                array(
                                       'type' => 'select',
                                       'label' => $this->l('Salesman'),
                                       'name' => 'salesman',
                                       'required' => true,
                                        'options' => array(
						'query' => $salesman,
						'id' => 'id_employee',
						'name' => 'employee_name'
					),
                                       'col' => '4',
                                       'hint' => $this->l('Salesman who is linked to this customer')
                                ), 	
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...