public function executeEdit() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $cd = new Criteria(); $cd->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($cd); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } $this->can_add = $acl->getAddPriv() == 1; $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $employee = EmployeePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($employee); $c = new Criteria(); $c->add(EmployeeDetailPeer::EMPLOYEE_ID, $employee->getId()); $employee_detail = EmployeeDetailPeer::doSelectOne($c); $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); if ($acl->getRemovePriv()) { array_push($actions, array('name' => 'delete', 'url' => 'employee/delete?id=' . $employee->getId(), 'color' => 'red')); } array_push($actions, array('name' => 'cancel', 'url' => 'employee/list', 'color' => 'black')); $this->subtitle = $employee->toString() . ' - id:' . $employee->getId(); $this->type = 'edit'; $this->employee = $employee; $this->employee_detail = $employee_detail; $this->actions = $actions; #Father $cw = new Criteria(); $cw->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cw->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER); $father = EmployeeParentsPeer::doSelectOne($cw); if ($father == null) { $father = new EmployeeParents(); } #Mother $ct = new Criteria(); $ct->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $ct->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER); $mother = EmployeeParentsPeer::doSelectOne($ct); if ($mother == null) { $mother = new EmployeeParents(); } #Father In Law $cwi = new Criteria(); $cwi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw = EmployeeParentsPeer::doSelectOne($cwi); if ($father_inlaw == null) { $father_inlaw = new EmployeeParents(); } #Mother In Law $cti = new Criteria(); $cti->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cti->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw = EmployeeParentsPeer::doSelectOne($cti); if ($mother_inlaw == null) { $mother_inlaw = new EmployeeParents(); } $this->father = $father; $this->mother = $mother; $this->father_inlaw = $father_inlaw; $this->mother_inlaw = $mother_inlaw; $cli = new Criteria(); $cli->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $employee_childs = EmployeeChildsPeer::doSelect($cli); $childs = array(); foreach ($employee_childs as $emp_child) { $childs[$emp_child->getRelation()] = $emp_child->getId(); } $this->childs = $childs; $this->employee_childs = $employee_childs; }
public function executeShowEmployee() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); #$c->add(JobPeer::CODE, $this->getModuleName()); $c->add(JobPeer::ID, 208); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } #$member = MemberPeer::retrieveByPk($this->getRequestParameter('id')); #$this->forward404Unless($member); #$this->subtitle = $member->toString().' - id:'.$member->getId(); $employee = EmployeePeer::retrieveByPK($this->getRequestParameter('id')); $this->forward404Unless($employee); $this->subtitle = $employee->toString() . ' - id:' . $employee->getId(); $c = new Criteria(); $c->add(EmployeeDetailPeer::EMPLOYEE_ID, $employee->getId()); $employee_detail = EmployeeDetailPeer::doSelectOne($c); if ($this->hasRequestParameter('no_reg') && $this->getRequestParameter('no_reg') != '' && $this->getRequestParameter('no_reg') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[NO_REG]=' . $this->getRequestParameter('no_reg'), 'color' => 'white')); } elseif ($this->hasRequestParameter('code') && $this->getRequestParameter('code') != '' && $this->getRequestParameter('code') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[CODE]=' . $this->getRequestParameter('code'), 'color' => 'white')); } elseif ($this->hasRequestParameter('dept_id') && $this->getRequestParameter('dept_id') != '' && $this->getRequestParameter('dept_id') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[DEPARTMENT_ID]=' . $this->getRequestParameter('dept_id'), 'color' => 'white')); } elseif ($this->hasRequestParameter('staff_type') && $this->getRequestParameter('staff_type') != '' && $this->getRequestParameter('staff_type') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[STAFF_TYPE_ID]=' . $this->getRequestParameter('staff_type'), 'color' => 'white')); } elseif ($this->hasRequestParameter('name') && $this->getRequestParameter('name') != '' && $this->getRequestParameter('name') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[NAME]=' . $this->getRequestParameter('name'), 'color' => 'white')); } else { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee', 'color' => 'white')); } $this->actions = $actions; $this->employee = $employee; $this->employee_detail = $employee_detail; #Father $cw = new Criteria(); $cw->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cw->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER); $father = EmployeeParentsPeer::doSelectOne($cw); if ($father == null) { $father = new EmployeeParents(); } #Mother $ct = new Criteria(); $ct->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $ct->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER); $mother = EmployeeParentsPeer::doSelectOne($ct); if ($mother == null) { $mother = new EmployeeParents(); } #Father In Law $cwi = new Criteria(); $cwi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw = EmployeeParentsPeer::doSelectOne($cwi); if ($father_inlaw == null) { $father_inlaw = new EmployeeParents(); } #Mother In Law $cti = new Criteria(); $cti->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cti->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw = EmployeeParentsPeer::doSelectOne($cti); if ($mother_inlaw == null) { $mother_inlaw = new EmployeeParents(); } $this->father = $father; $this->mother = $mother; $this->father_inlaw = $father_inlaw; $this->mother_inlaw = $mother_inlaw; $cli = new Criteria(); $cli->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $employee_childs = EmployeeChildsPeer::doSelect($cli); $childs = array(); foreach ($employee_childs as $emp_child) { $childs[$emp_child->getRelation()] = $emp_child->getId(); } $this->childs = $childs; $this->employee_childs = $employee_childs; }
public function executeEdit() { $employee_id = $this->getContext()->getUser()->getAttribute('user_id', '', 'bo'); $this->forward404Unless($employee_id); $employee = EmployeePeer::retrieveByPK($employee_id); $this->subtitle = $employee->toString() . ' - id:' . $employee->getId(); $c = new Criteria(); $c->add(EmployeeDetailPeer::EMPLOYEE_ID, $employee->getId()); $employee_detail = EmployeeDetailPeer::doSelectOne($c); $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); array_push($actions, array('name' => 'cancel', 'url' => 'user_profile_l/show', 'color' => 'black')); $this->subtitle = $employee->toString() . ' - id:' . $employee->getId(); $this->type = 'edit'; $this->employee = $employee; $this->employee_detail = $employee_detail; $this->actions = $actions; #Father $cw = new Criteria(); $cw->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cw->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER); $father = EmployeeParentsPeer::doSelectOne($cw); if ($father == null) { $father = new EmployeeParents(); } #Mother $ct = new Criteria(); $ct->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $ct->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER); $mother = EmployeeParentsPeer::doSelectOne($ct); if ($mother == null) { $mother = new EmployeeParents(); } #Father In Law $cwi = new Criteria(); $cwi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw = EmployeeParentsPeer::doSelectOne($cwi); if ($father_inlaw == null) { $father_inlaw = new EmployeeParents(); } #Mother In Law $cti = new Criteria(); $cti->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cti->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw = EmployeeParentsPeer::doSelectOne($cti); if ($mother_inlaw == null) { $mother_inlaw = new EmployeeParents(); } $this->father = $father; $this->mother = $mother; $this->father_inlaw = $father_inlaw; $this->mother_inlaw = $mother_inlaw; $cli = new Criteria(); $cli->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $employee_childs = EmployeeChildsPeer::doSelect($cli); $childs = array(); foreach ($employee_childs as $emp_child) { $childs[$emp_child->getRelation()] = $emp_child->getId(); } $this->childs = $childs; $this->employee_childs = $employee_childs; }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(EmployeeChildsPeer::ID, $pks, Criteria::IN); $objs = EmployeeChildsPeer::doSelect($criteria, $con); } return $objs; }