sangwork - 2015-11-03

Dear master
would u like to help me?
I want to add field 'bpjs' on part depents ( name, relationship_type, relatinship, birthofdate,bpjs).
so i have done
1. add field bpjs ( varchar) on table hs_hr_emp_dependents
2. i add
$this->hasColumn('bpjs', 'string', 100, array( 'type' => 'string', 'default' => '', 'length' => 100, ));

         on symfony\lib\model\doctrine\orangehrmPimPlugin\base\BaseEmpDependent.class.php
  1. edit employeedependentform.php
    public function getDependentWidgets(){
        $widgets = array();
        // Note: Widget names were kept from old non-symfony version
        $i18nHelper = sfContext::getInstance()->getI18N();
        $relationshipChoices = array('' => "-- " . __('Select') . " --", 'child'=> $i18nHelper->__('Child'), 'other'=> $i18nHelper->__('Other'));

        //creating widgets
        $widgets['seqNo'] = new sfWidgetFormInputHidden();
        $widgets['name'] = new sfWidgetFormInputText();
        $widgets['relationshipType'] = new sfWidgetFormSelect(array('choices' => $relationshipChoices));
        $widgets['relationship'] = new sfWidgetFormInputText();
        $widgets['dateOfBirth'] = new ohrmWidgetDatePicker(array(), array('id' => 'dependent_dateOfBirth'));
        $widgets['bpjs'] = new sfWidgetFormInputText();
        unset($relationshipChoices['']);
        return $widgets;
    }

    public function getDependentValidators(){
        $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat();
        $i18nHelper = sfContext::getInstance()->getI18N();
        $relationshipChoices = array('' => "-- " . __('Select') . " --", 'child'=> $i18nHelper->__('Child'), 'other'=> $i18nHelper->__('Other'));

        $validators = array(
            'seqNo' => new sfValidatorNumber(array('required' => false, 'min'=> 0)),
            'name' => new sfValidatorString(array('required' => true, 'trim'=>true, 'max_length'=>100)),
            'relationshipType' => new sfValidatorChoice(array('choices' => array_keys($relationshipChoices))),
            'relationship' => new sfValidatorString(array('required' => false, 'trim'=>true, 'max_length'=>100)),
            'dateOfBirth' =>  new ohrmDateValidator(array('date_format'=>$inputDatePattern, 'required'=>false),
                              array('invalid'=>'Date format should be '. $inputDatePattern)),
            'bpjs' => new sfValidatorString(array('required' => true, 'trim'=>true, 'max_length'=>25)),               

        );

        return $validators;
    }

              public function save() {

        $empNumber = $this->getValue('empNumber');
        $seqNo = $this->getValue('seqNo');

        $dependent = false;

        if (empty($seqNo)) {

            $q = Doctrine_Query::create()
                    ->select('MAX(d.seqno)')
                    ->from('EmpDependent d')
                    ->where('d.emp_number = ?', $empNumber);
            $result = $q->execute(array(), Doctrine::HYDRATE_ARRAY);

            if (count($result) != 1) {
                throw new PIMServiceException('MAX(seqno) failed.');
            }
            $seqNo = is_null($result[0]['MAX']) ? 1 : $result[0]['MAX'] + 1;

        } else {
            $dependent = Doctrine::getTable('EmpDependent')->find(array('emp_number' => $empNumber,
                                                                      'seqno' => $seqNo));

            if ($dependent == false) {
                throw new PIMServiceException('Invalid dependent');
            }
        }

        if ($dependent === false) {
            $dependent = new EmpDependent();
            $dependent->emp_number = $empNumber;
            $dependent->seqno = $seqNo;
        }

        $dependent->name = $this->getValue('name');
        $dependent->relationship = $this->getValue('relationship');
        $dependent->relationship_type = $this->getValue('relationshipType');
        $dependent->date_of_birth = $this->getValue('dateOfBirth');
        $dependent->bpjs = $this->getValue('bpjs')
        $dependent->save();
  1. edit view dependentssuccess.php
<li>
                            <?php echo $form['bpjs']->renderLabel(__('bpjs') . ' <em>*</em>'); ?>
                            <?php echo $form['bpjs']->render(array("class" => "formInputText", "maxlength" => 50)); ?>
                        </li>
<th><?php echo __("bpjs"); ?></th>
<td class="bpjs"><?php echo $bpjs; ?></td>
var bpjs =  $(this).closest("tr").find('td.bpjs').text(); $("#dependent_bpjs").val(bpjs);

but after that display on dependent --> still error

please any idea for this problem

 

Last edit: sangwork 2015-11-03