Значения скрытой формы Orange HRM основаны на пользователе. Основано на Symfony Framework - PullRequest
0 голосов
/ 03 мая 2018

Мне было поручено изменить форму в нашем собственном приложении для управления персоналом, основанном на OrangeHRM.

FileName: AddEmployeeForm.php

Код формы:

  $this->widgets = array(
            /* 
                Menyra sesi kodi arranzhon input format eshte e tille.

                Input button eshte i pari qe duhet te i pari pastaj duhet label forma


            */
            'employeeId' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 10, "colspan" => 3)),
            'firstName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'lastName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'personalNumber' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

            'dateofBirth' => new sfWidgetFormI18nDate(array('culture' => 'en')),
            'gender' => new sfWidgetFormSelect(array('choices' => $gender), array("class" => "formInputText","br" => true)),
            'nationality' => new sfWidgetFormI18nChoiceCountry(array('culture' => 'en'),array("br" => true)),
            'martial_status' => new sfWidgetFormSelect(array('choices' => $martial_status), array("class" => "formInputText","br" => true)), 
            'contact_address' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'contact_phone' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'empty' => new ohrmWidgetDiv(),
            // Gender duhet me qene drop-down,Google search qysh duhet me bo dropdown.
            // Gjitheashtu Nationatily,Martial Status.
            // Contact Address dhe Contacnt phone nr munen mu kon tekstbokse.

             'emstatus' => new sfWidgetFormSelect(array('choices' => $emp_status), array("class" => "formInputText","br" => true)),
             'jbtitle' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),


             'photofile' => new sfWidgetFormInputFileEditable(array('edit_mode' => false, 'with_delete' => false, 'file_src' => ''), array("class" => "duplexBox", "colspan" => 3,"br" => true)),
//            'helpText' => new ohrmWidgetDiv(),  

             'bankName' => new sfWidgetFormSelect(array('choices' => $banks), array("class" => "formInputText","br" => true)), 
             'bankNumber' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
             'lineSeperator' => new ohrmWidgetDiv(array(), array("colspan" => 3,"br" => true)),
            'chkLogin' => new sfWidgetFormInputCheckbox(array('value_attribute_value' => 1), array("style" => "vertical-align:top", "colspan" => 3,"br" => true)),
            'user_name' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 20,"br" => true)),
            'status' => new sfWidgetFormSelect(array('choices' => $status), array("class" => "formInputText", "br" => true,"br" => true)),
            'user_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20,"br" => true)),
            're_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20, "br" => true)),
            'empNumber' => new sfWidgetFormInputHidden(),
            //'Nationality' => new sfWidgetFormSelect(array('choices' => Duhet mi marr prej databazes), array("class" => "formInputText", "br" => true)),

                'userID' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'job_email_adress' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'ac_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'lp_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'phone_imei' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

Я добавил большую часть формы, но виджеты требуют особого внимания:

'userID' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'job_email_adress' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'ac_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'lp_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'phone_imei' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

Сценарий состоит в том, что есть два пользователя: PIM и IT, как только PIM отправит форму. После отправки формы ИТ-пользователю будет предложено заполнить эти поля. Однако эти поля не могут быть просмотрены PIM.

Мой вопрос, есть ли способ изменить эти поля в соответствии с приведенным выше сценарием?

1 Ответ

0 голосов
/ 03 мая 2018

Я полагаю, ваши пользователи разделены на группы, поэтому вы можете попробовать что-то вроде этого:

if (sfContext::getInstance()->getUser()->hasGroup('IT')) {
    $this->setWidget('my_field', new sfMyWidgetFormHtmlTextarea());
    $this->setValidator('my_field', new sfValidatorPass());
    $this->getWidgetSchema()->moveField('my_field', sfWidgetFormSchema::AFTER, 'another_base_field');

    $this->setWidget('my_another_field', new sfWidgetFormInput());
    $this->setValidator('my_another_field', new sfValidatorInteger());
    $this->getWidgetSchema()->moveField('my_another_field', sfWidgetFormSchema::AFTER, 'my_field');
}
...