Advertisement
fahmihilmansyah

phpemployee

Feb 16th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.64 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Fhh\HrisPayroll\Bundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. /**
  8.  * HrGender
  9.  *
  10.  * @ORM\Table(name="hr_gender")
  11.  * @ORM\Entity
  12.  */
  13. class HrGender
  14. {
  15.     /**
  16.      * @var integer
  17.      *
  18.      * @ORM\Column(name="id_gender", type="integer", nullable=false)
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="IDENTITY")
  21.      */
  22.     private $idGender;
  23.  
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="gender_name", type="string", length=255, nullable=true)
  28.      */
  29.     private $genderName;
  30.  
  31.  
  32.  
  33.     /**
  34.      * Get idGender
  35.      *
  36.      * @return integer
  37.      */
  38.     public function getIdGender()
  39.     {
  40.         return $this->idGender;
  41.     }
  42.  
  43.     /**
  44.      * Set genderName
  45.      *
  46.      * @param string $genderName
  47.      *
  48.      * @return HrGender
  49.      */
  50.     public function setGenderName($genderName)
  51.     {
  52.         $this->genderName = $genderName;
  53.  
  54.         return $this;
  55.     }
  56.  
  57.     /**
  58.      * Get genderName
  59.      *
  60.      * @return string
  61.      */
  62.     public function getGenderName()
  63.     {
  64.         return $this->genderName;
  65.     }
  66. }
  67. ==========================================================
  68. <?php
  69.  
  70. namespace Fhh\HrisPayroll\Bundle\Entity;
  71.  
  72. use Doctrine\ORM\Mapping as ORM;
  73.  
  74. /**
  75.  * HrEmployee
  76.  *
  77.  * @ORM\Table(name="hr_employee", indexes={@ORM\Index(name="emp_job_title", columns={"emp_job_title"}), @ORM\Index(name="emp_gender", columns={"emp_gender"}), @ORM\Index(name="emp_religion", columns={"emp_religion", "emp_status"}), @ORM\Index(name="emp_status", columns={"emp_status"}), @ORM\Index(name="IDX_E67AB75B7EB126E7", columns={"emp_religion"})})
  78.  * @ORM\Entity
  79.  */
  80. class HrEmployee
  81. {
  82.     /**
  83.      * @var string
  84.      *
  85.      * @ORM\Column(name="id_employee", type="string", length=150, nullable=false)
  86.      * @ORM\Id
  87.      * @ORM\GeneratedValue(strategy="IDENTITY")
  88.      */
  89.     private $idEmployee;
  90.  
  91.     /**
  92.      * @var string
  93.      *
  94.      * @ORM\Column(name="emp_nik", type="string", length=255, nullable=true)
  95.      */
  96.     private $empNik;
  97.  
  98.     /**
  99.      * @var string
  100.      *
  101.      * @ORM\Column(name="emp_fullname", type="string", length=255, nullable=true)
  102.      */
  103.     private $empFullname;
  104.  
  105.     /**
  106.      * @var \DateTime
  107.      *
  108.      * @ORM\Column(name="emp_birthday", type="date", nullable=true)
  109.      */
  110.     private $empBirthday;
  111.  
  112.     /**
  113.      * @var string
  114.      *
  115.      * @ORM\Column(name="emp_place_birthday", type="string", length=250, nullable=true)
  116.      */
  117.     private $empPlaceBirthday;
  118.  
  119.     /**
  120.      * @var \DateTime
  121.      *
  122.      * @ORM\Column(name="emp_join_date", type="date", nullable=true)
  123.      */
  124.     private $empJoinDate;
  125.  
  126.     /**
  127.      * @var \DateTime
  128.      *
  129.      * @ORM\Column(name="date_created", type="datetime", nullable=true)
  130.      */
  131.     private $dateCreated;
  132.  
  133.     /**
  134.      * @var \DateTime
  135.      *
  136.      * @ORM\Column(name="date_updated", type="datetime", nullable=true)
  137.      */
  138.     private $dateUpdated;
  139.  
  140.     /**
  141.      * @var boolean
  142.      *
  143.      * @ORM\Column(name="is_activ", type="boolean", nullable=true)
  144.      */
  145.     private $isActiv = '1';
  146.  
  147.     /**
  148.      * @var \HrGender
  149.      *
  150.      * @ORM\ManyToOne(targetEntity="HrGender")
  151.      * @ORM\JoinColumns({
  152.      *   @ORM\JoinColumn(name="emp_gender", referencedColumnName="id_gender")
  153.      * })
  154.      */
  155.     private $empGender;
  156.  
  157.     /**
  158.      * @var \HrJobs
  159.      *
  160.      * @ORM\ManyToOne(targetEntity="HrJobs")
  161.      * @ORM\JoinColumns({
  162.      *   @ORM\JoinColumn(name="emp_job_title", referencedColumnName="id_jobs")
  163.      * })
  164.      */
  165.     private $empJobTitle;
  166.  
  167.     /**
  168.      * @var \HrReligion
  169.      *
  170.      * @ORM\ManyToOne(targetEntity="HrReligion")
  171.      * @ORM\JoinColumns({
  172.      *   @ORM\JoinColumn(name="emp_religion", referencedColumnName="id_religion")
  173.      * })
  174.      */
  175.     private $empReligion;
  176.  
  177.     /**
  178.      * @var \HrCatStatus
  179.      *
  180.      * @ORM\ManyToOne(targetEntity="HrCatStatus")
  181.      * @ORM\JoinColumns({
  182.      *   @ORM\JoinColumn(name="emp_status", referencedColumnName="id_status")
  183.      * })
  184.      */
  185.     private $empStatus;
  186.  
  187.  
  188.  
  189.     /**
  190.      * Get idEmployee
  191.      *
  192.      * @return string
  193.      */
  194.     public function getIdEmployee()
  195.     {
  196.         return $this->idEmployee;
  197.     }
  198.  
  199.     /**
  200.      * Set empNik
  201.      *
  202.      * @param string $empNik
  203.      *
  204.      * @return HrEmployee
  205.      */
  206.     public function setEmpNik($empNik)
  207.     {
  208.         $this->empNik = $empNik;
  209.  
  210.         return $this;
  211.     }
  212.  
  213.     /**
  214.      * Get empNik
  215.      *
  216.      * @return string
  217.      */
  218.     public function getEmpNik()
  219.     {
  220.         return $this->empNik;
  221.     }
  222.  
  223.     /**
  224.      * Set empFullname
  225.      *
  226.      * @param string $empFullname
  227.      *
  228.      * @return HrEmployee
  229.      */
  230.     public function setEmpFullname($empFullname)
  231.     {
  232.         $this->empFullname = $empFullname;
  233.  
  234.         return $this;
  235.     }
  236.  
  237.     /**
  238.      * Get empFullname
  239.      *
  240.      * @return string
  241.      */
  242.     public function getEmpFullname()
  243.     {
  244.         return $this->empFullname;
  245.     }
  246.  
  247.     /**
  248.      * Set empBirthday
  249.      *
  250.      * @param \DateTime $empBirthday
  251.      *
  252.      * @return HrEmployee
  253.      */
  254.     public function setEmpBirthday($empBirthday)
  255.     {
  256.         $this->empBirthday = $empBirthday;
  257.  
  258.         return $this;
  259.     }
  260.  
  261.     /**
  262.      * Get empBirthday
  263.      *
  264.      * @return \DateTime
  265.      */
  266.     public function getEmpBirthday()
  267.     {
  268.         return $this->empBirthday;
  269.     }
  270.  
  271.     /**
  272.      * Set empPlaceBirthday
  273.      *
  274.      * @param string $empPlaceBirthday
  275.      *
  276.      * @return HrEmployee
  277.      */
  278.     public function setEmpPlaceBirthday($empPlaceBirthday)
  279.     {
  280.         $this->empPlaceBirthday = $empPlaceBirthday;
  281.  
  282.         return $this;
  283.     }
  284.  
  285.     /**
  286.      * Get empPlaceBirthday
  287.      *
  288.      * @return string
  289.      */
  290.     public function getEmpPlaceBirthday()
  291.     {
  292.         return $this->empPlaceBirthday;
  293.     }
  294.  
  295.     /**
  296.      * Set empJoinDate
  297.      *
  298.      * @param \DateTime $empJoinDate
  299.      *
  300.      * @return HrEmployee
  301.      */
  302.     public function setEmpJoinDate($empJoinDate)
  303.     {
  304.         $this->empJoinDate = $empJoinDate;
  305.  
  306.         return $this;
  307.     }
  308.  
  309.     /**
  310.      * Get empJoinDate
  311.      *
  312.      * @return \DateTime
  313.      */
  314.     public function getEmpJoinDate()
  315.     {
  316.         return $this->empJoinDate;
  317.     }
  318.  
  319.     /**
  320.      * Set dateCreated
  321.      *
  322.      * @param \DateTime $dateCreated
  323.      *
  324.      * @return HrEmployee
  325.      */
  326.     public function setDateCreated($dateCreated)
  327.     {
  328.         $this->dateCreated = $dateCreated;
  329.  
  330.         return $this;
  331.     }
  332.  
  333.     /**
  334.      * Get dateCreated
  335.      *
  336.      * @return \DateTime
  337.      */
  338.     public function getDateCreated()
  339.     {
  340.         return $this->dateCreated;
  341.     }
  342.  
  343.     /**
  344.      * Set dateUpdated
  345.      *
  346.      * @param \DateTime $dateUpdated
  347.      *
  348.      * @return HrEmployee
  349.      */
  350.     public function setDateUpdated($dateUpdated)
  351.     {
  352.         $this->dateUpdated = $dateUpdated;
  353.  
  354.         return $this;
  355.     }
  356.  
  357.     /**
  358.      * Get dateUpdated
  359.      *
  360.      * @return \DateTime
  361.      */
  362.     public function getDateUpdated()
  363.     {
  364.         return $this->dateUpdated;
  365.     }
  366.  
  367.     /**
  368.      * Set isActiv
  369.      *
  370.      * @param boolean $isActiv
  371.      *
  372.      * @return HrEmployee
  373.      */
  374.     public function setIsActiv($isActiv)
  375.     {
  376.         $this->isActiv = $isActiv;
  377.  
  378.         return $this;
  379.     }
  380.  
  381.     /**
  382.      * Get isActiv
  383.      *
  384.      * @return boolean
  385.      */
  386.     public function getIsActiv()
  387.     {
  388.         return $this->isActiv;
  389.     }
  390.  
  391.     /**
  392.      * Set empGender
  393.      *
  394.      * @param \Fhh\HrisPayroll\Bundle\Entity\HrGender $empGender
  395.      *
  396.      * @return HrEmployee
  397.      */
  398.     public function setEmpGender(\Fhh\HrisPayroll\Bundle\Entity\HrGender $empGender = null)
  399.     {
  400.         $this->empGender = $empGender;
  401.  
  402.         return $this;
  403.     }
  404.  
  405.     /**
  406.      * Get empGender
  407.      *
  408.      * @return \Fhh\HrisPayroll\Bundle\Entity\HrGender
  409.      */
  410.     public function getEmpGender()
  411.     {
  412.         return $this->empGender;
  413.     }
  414.  
  415.     /**
  416.      * Set empJobTitle
  417.      *
  418.      * @param \Fhh\HrisPayroll\Bundle\Entity\HrJobs $empJobTitle
  419.      *
  420.      * @return HrEmployee
  421.      */
  422.     public function setEmpJobTitle(\Fhh\HrisPayroll\Bundle\Entity\HrJobs $empJobTitle = null)
  423.     {
  424.         $this->empJobTitle = $empJobTitle;
  425.  
  426.         return $this;
  427.     }
  428.  
  429.     /**
  430.      * Get empJobTitle
  431.      *
  432.      * @return \Fhh\HrisPayroll\Bundle\Entity\HrJobs
  433.      */
  434.     public function getEmpJobTitle()
  435.     {
  436.         return $this->empJobTitle;
  437.     }
  438.  
  439.     /**
  440.      * Set empReligion
  441.      *
  442.      * @param \Fhh\HrisPayroll\Bundle\Entity\HrReligion $empReligion
  443.      *
  444.      * @return HrEmployee
  445.      */
  446.     public function setEmpReligion(\Fhh\HrisPayroll\Bundle\Entity\HrReligion $empReligion = null)
  447.     {
  448.         $this->empReligion = $empReligion;
  449.  
  450.         return $this;
  451.     }
  452.  
  453.     /**
  454.      * Get empReligion
  455.      *
  456.      * @return \Fhh\HrisPayroll\Bundle\Entity\HrReligion
  457.      */
  458.     public function getEmpReligion()
  459.     {
  460.         return $this->empReligion;
  461.     }
  462.  
  463.     /**
  464.      * Set empStatus
  465.      *
  466.      * @param \Fhh\HrisPayroll\Bundle\Entity\HrCatStatus $empStatus
  467.      *
  468.      * @return HrEmployee
  469.      */
  470.     public function setEmpStatus(\Fhh\HrisPayroll\Bundle\Entity\HrCatStatus $empStatus = null)
  471.     {
  472.         $this->empStatus = $empStatus;
  473.  
  474.         return $this;
  475.     }
  476.  
  477.     /**
  478.      * Get empStatus
  479.      *
  480.      * @return \Fhh\HrisPayroll\Bundle\Entity\HrCatStatus
  481.      */
  482.     public function getEmpStatus()
  483.     {
  484.         return $this->empStatus;
  485.     }
  486. }
  487. =====================================================================================
  488. di controller nya gini
  489. function empCreateAction(Request $request){
  490.         $employee = $request->get('employee');
  491.         $HrEmployee = new HrEmployee();
  492.         $HrEmployee->setEmpNik($employee['nik']);
  493.         $HrEmployee->setEmpFullname($employee['fullname']);
  494.         $HrEmployee->setEmpBirthday(new \DateTime($employee['dob']));
  495.         $HrEmployee->setEmpPlaceBirthday($employee['pob']);
  496.         $gender = new HrGender();
  497.         $gender->?????#isinya apa om
  498.        $HrEmployee->setEmpGender();
  499.         $HrEmployee->setEmpReligion($employee['religion']);
  500.         $HrEmployee->setEmpJobTitle($employee['jobs']);
  501.         $HrEmployee->setEmpStatus($employee['status']);
  502.         $HrEmployee->setEmpJoinDate(new \DateTime($employee['datejoin']));
  503.         $HrEmployee->setDateCreated(new \DateTime($employee['datejoin']));
  504.         $HrEmployee->setDateUpdated(new \DateTime($employee['datejoin']));
  505.         $em = $this->getDoctrine()->getManager();
  506.         $em->persist($HrEmployee);
  507.         $em->flush();
  508.  
  509.         echo $employee['fullname'];
  510.         return new Response("sukses");
  511.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement