Ejemplo n.º 1
0
    		<tr>
    			<th>ID</th>
    			<th>วันที่</th>
    			<th>เริ่มเวลา</th>
    			<th>สิ้นสุดเวลา</th>
    			<th>จำนวนชั่วโมง</th>
    		</tr>
    	</thead>
		<tbody>
			<tr>
				<td><?php 
echo $query["wot_id"];
?>
</td>
				<td><?php 
echo dateThaiFormatFromDB($query["wot_date"]);
?>
 </td>
				<td><?php 
echo $query["wot_time_from"];
?>
</td>
				<td><?php 
echo $query["wot_time_to"];
?>
</td>
				<td><?php 
echo $query["wot_request_hour"];
?>
</td>
			</tr>
Ejemplo n.º 2
0
			<th>เวลาที่ขอทำ</th>
			<th>เวลาที่มาทำจริง</th>
			<th>จำนวนเงิน</th>
		</tr>
	</thead>
	<tbody>
<?php 
foreach ($history as $row) {
    ?>
			<tr>	
				<td><?php 
    echo get_month_name_thai($row['sapay_month']);
    ?>
</td>
				<td><?php 
    echo dateThaiFormatFromDB($row['spldot_wot_date']);
    ?>
</td>
				<td><?php 
    echo $row['spldot_wot_time_from'], "-", $row['spldot_wot_time_to'];
    ?>
</td>
				<td><?php 
    echo $row['spldot_real_wot_time_from'], "-", $row['spldot_real_wot_time_to'];
    ?>
</td>
				<td><?php 
    echo $row['spldot_money'];
    ?>
</td>
			</tr>
Ejemplo n.º 3
0
 private function send_email_to_headman()
 {
     $body;
     $search = array();
     $replace = array();
     $subject = "";
     $returner = "";
     $ci =& get_instance();
     if ($this->type == "leave") {
         $leave_id = $this->main_id;
         $leave_type = $this->main_detail['LTName'];
         $leave_because = $this->main_detail['LBecause'];
         $leave_start_date = $this->main_detail['LStartDate'] . ' ' . $this->main_detail['LStartTime'];
         $leave_end_date = $this->main_detail['LEndDate'] . ' ' . $this->main_detail['LEndTime'];
         if ($this->main_detail["LAttachFile"] != NULL && $this->main_detail["LAttachFile"] != "") {
             $leave_attach_file = $this->main_detail['LAttachFile'];
             $leave_attach_file_name = $this->main_detail["LAttachFilename"];
             //อย่าลืมเปลี่ยนการวนลูปเพราะมีการเปลี่ยนแลง table ใหม่
             $this->email_attach_file[0]["filepath"] = $leave_attach_file;
             $this->email_attach_file[0]["filename"] = $leave_attach_file_name;
         }
         //get leave time detail
         $query_time = $ci->leavetime->getDetailByLeaveID($leave_id);
         $leave_sum = $this->sum_show_leave_time($query_time->result_array());
         $owner_emp_id = $this->user_detail['EmpID'];
         $owner_firstname = $this->user_detail['EmpFirstnameThai'];
         $owner_fullname = $this->user_detail["EmpFullnameThai"];
         $owner_email = $this->user_detail['EmpEmail'];
         $headman_user_id = $this->headman_user_id;
         $headman_email = $this->headman_detail['EmpEmail'];
         $headman_fullname = $this->headman_detail['EmpFullnameThai'];
         if ($this->condition == 'request' || $this->condition == 'approve') {
             $subject = '[ใบขอเลขที่ ' . $leave_id . '] ลูกทีม ' . $owner_firstname . ' ขออนุญาต ' . $leave_type;
             $body = file_get_contents(APPPATH . 'views/Email/ask_approve_to_headman.html');
             $search = array('{{headman_fullname}}', '{{leave_type}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{leave_because}}', '{{leave_start_date}}', '{{leave_end_date}}', '{{leave_sum}}', '{{siteurl}}', '{{headmanid}}', '{{leaveid}}');
             $replace = array($headman_fullname, $leave_type, $owner_emp_id, $owner_fullname, $leave_because, $leave_start_date, $leave_end_date, $leave_sum, site_url(), encrypt_decrypt('encrypt', $headman_user_id), encrypt_decrypt('encrypt', $leave_id));
         } else {
             if ($this->condition == "edit request") {
                 $subject = '[ใบขอเลขที่ ' . $leave_id . '][มีการแก้ไขใบลา] ลูกทีม ' . $owner_firstname . ' ขออนุญาต ' . $leave_type;
                 $body = file_get_contents(APPPATH . 'views/Email/edit_ask_approve_to_headman.html');
                 $search = array('{{headman_fullname}}', '{{leave_type}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{leave_because}}', '{{leave_start_date}}', '{{leave_end_date}}', '{{leave_old_start_date}}', '{{leave_old_end_date}}', '{{leave_sum}}', '{{siteurl}}', '{{headmanid}}', '{{leaveid}}');
                 $replace = array($headman_fullname, $leave_type, $owner_emp_id, $owner_fullname, $leave_because, $leave_start_date, $leave_end_date, $leave_detail['LStartDate'] . ' ' . $leave_detail['LStartTime'], $leave_detail['LEndDate'] . ' ' . $leave_detail['LEndTime'], $leave_sum, site_url(), encrypt_decrypt('encrypt', $headman_user_id), encrypt_decrypt('encrypt', $leave_id));
             }
         }
     } else {
         if ($this->type === "overtime") {
             $ot_id = $this->main_id;
             $ot_date = $this->main_detail['wot_date'];
             $ot_remark = $this->main_detail['wot_remark'];
             $ot_time_from = $this->main_detail['wot_time_from'];
             $ot_time_to = $this->main_detail['wot_time_to'];
             $owner_emp_id = $this->user_detail['EmpID'];
             $owner_firstname = $this->user_detail['EmpFirstnameThai'];
             $owner_fullname = $this->user_detail["EmpFullnameThai"];
             $owner_email = $this->user_detail['EmpEmail'];
             $owner_position = $this->user_detail['PositionName'];
             $headman_user_id = $this->headman_user_id;
             $headman_email = $this->headman_detail['EmpEmail'];
             $headman_fullname = $this->headman_detail['EmpFullnameThai'];
             if ($this->condition == 'request' || $this->condition == 'approve') {
                 $subject = '[ใบขอเลขที่ ' . $ot_id . '] ลูกทีม ' . $owner_firstname . ' ขอทำงานล่วงเวลา';
                 $body = file_get_contents(APPPATH . '/views/Email/request_ot_to_headman.html');
                 $search = array('{{headman_fullname}}', '{{owner_emp_id}}', '{{owner_fullname}}', '{{owner_positionname}}', '{{ot_date}}', '{{ot_time_from}}', '{{ot_time_to}}', '{{ot_id}}', '{{headman_user_id}}', '{{en_ot_id}}', '{{site_url}}');
                 $replace = array($headman_fullname, $owner_emp_id, $owner_fullname, $owner_position, dateThaiFormatFromDB($ot_date), $ot_time_from, $ot_time_to, $ot_id, encrypt_decrypt('encrypt', $headman_user_id), encrypt_decrypt('encrypt', $ot_id), site_url());
             }
         }
     }
     $body = str_replace($search, $replace, $body);
     $this->body = $body;
     $this->subject = $subject;
     //send mail library
     //non config because default set in phpmailer class
     $ci->load->library('Phpmailer', 'phpmailer');
     $ci->phpmailer->ClearAllRecipients();
     $ci->phpmailer->IsSMTP();
     $ci->phpmailer->Subject = $this->subject;
     if (count($this->email_attach_file) > 0) {
         foreach ($this->email_attach_file as $email) {
             $ci->phpmailer->AddAttachment($email["filepath"], $email["filename"]);
         }
     }
     $ci->phpmailer->Body = $this->body;
     //ส่วนนี้รายละเอียดสามารถส่งเป็นรูปแบบ HTML ได้
     $ci->phpmailer->AddAddress($this->headman_detail["EmpEmail"], $this->headman_detail["EmpFullnameThai"]);
     if (!$ci->phpmailer->Send()) {
         log_message('error', 'Error send mail ' . var_dump($ci->phpmailer->ErrorInfo));
         return $ci->phpmailer->ErrorInfo;
     } else {
         return 'success';
     }
 }
Ejemplo n.º 4
0
					<td><?php 
    echo $row["ehw_company"];
    ?>
</td>
					<td><?php 
    echo $row["ehw_position"];
    ?>
</td>
					<td><?php 
    echo $row["ehw_district"];
    ?>
</td>
					<td><?php 
    echo $row["ehw_desc"];
    ?>
</td>
					<td><?php 
    echo dateThaiFormatFromDB($row["ehw_date_from"]);
    ?>
 <br>ถึง<br> <?php 
    echo dateThaiFormatFromDB($row["ehw_date_to"]);
    ?>
</td>
				</tr>
			<?php 
}
?>
		</tbody>
	</table>
	</div>
</div>
Ejemplo n.º 5
0
		<tr>
			<th class="center-align">เริ่ม</th>
			<th class="center-align">สิ้นสุด</th>
		</tr>
	</thead>
	<tbody>
		<?php 
foreach ($query as $row) {
    ?>
			<tr>
				<td><?php 
    echo $row['wot_id'];
    ?>
</td>
				<td><?php 
    echo dateThaiFormatFromDB($row['wot_date']);
    ?>
</td>
				<td class="center-align"><?php 
    echo $row['wot_time_from'];
    ?>
</td>
				<td class="center-align"><?php 
    echo $row['wot_time_to'];
    ?>
</td>
				<td class="center-align"><?php 
    echo timeDiff($row['wot_time_from'], $row["wot_time_to"]);
    ?>
				<td><?php 
    echo $row['EmpFullnameThai'];
Ejemplo n.º 6
0
	</table>
	&nbsp;<br>&nbsp;<br>&nbsp;
	<table class="salary" cellpadding="10">
		<tbody>
			<tr class="header">
				<td>วันที่</td>
				<td>เวลาเข้างาน</td>
				<td>เวลาออกงาน</td>
				<td>หมายเหตุ</td>
			</tr>
			<?php 
foreach ($query as $row) {
    ?>
				<tr>
					<td><?php 
    echo dateThaiFormatFromDB($row["WTDate"]);
    ?>
</td>
					<td><?php 
    echo $row["WTTimeStart"];
    ?>
</td>
					<td><?php 
    echo $row["WTTimeEnd"];
    ?>
</td>
					<td>-</td>
				</tr>
			<?php 
}
?>
Ejemplo n.º 7
0
		<br>
		เนื่องจาก : <?php 
echo $leave_detail['LBecause'];
?>
		<br>
		เพราะฉะนั้นจึงขอลาหยุดในวันที่ :
		<br>
		<?php 
echo dateThaiFormatFromDB($leave_detail['LStartDate']);
?>
 เวลา <?php 
echo $leave_detail['LStartTime'];
?>
		<br>
		จนถึงวันที่ <?php 
echo dateThaiFormatFromDB($leave_detail['LEndDate']);
?>
 เวลา <?php 
echo $leave_detail['LEndTime'];
?>
		<br>
		รวมเป็นจำนวนทั้งสิ้น <?php 
echo sum_show_leave_time($leave_time_detail);
?>
		<br>
		เอกสารเพิ่มเติม
		<br>
		<?php 
if ($leave_detail['LAttachFile'] != '') {
    ?>
			<a href="<?php 
Ejemplo n.º 8
0
 public function save_exchange_ot()
 {
     if ($_POST) {
         $this->load->model('Worktime_ot_model', 'ot');
         $this->load->model('Worktime_ot_exchange_model', 'otexchange');
         $this->load->model('Worktime_ot_exchange_detail_model', 'otexchangedetail');
         $post = $this->input->post();
         $input_ot = $post['input_ot'];
         //array
         $exchange_type = $post['input_exchange_type'];
         //money or leave
         $exchange_type_thai = '';
         $exchange_value = 0;
         $exchange_value_type = '';
         $exchange_date = '';
         $money = 0;
         $leave = 0;
         $cond_id = '';
         $new_otx_id = 0;
         //sum ot hour
         $sum_ot_hour = 0;
         foreach ($input_ot as $id) {
             $query = $this->ot->get_detail_by_id($id);
             if ($query->num_rows() > 0) {
                 $query = $query->row_array();
                 $sum_ot_hour = $sum_ot_hour + intval($query['wot_request_hour']);
                 $exchange_date .= dateThaiFormatFromDB($query['wot_date']) . ' , ';
             }
         }
         $exchange_date = substr($exchange_date, 0, -1);
         //remove last character
         //use sum ot hour for can use?
         $spliter = $this->calculate_exchange_ot_condition($sum_ot_hour, false);
         $spliter = explode('//--//', $spliter);
         if ($exchange_type === 'money') {
             $money = $spliter[0];
             $exchange_type_thai = 'เงิน';
             $exchange_value = $money;
             $exchange_value_type = 'บาท';
         } else {
             if ($exchange_type === 'leave') {
                 $leave = $spliter[1];
                 $exchange_type_thai = 'วันหยุด';
                 $exchange_value = $leave;
                 $exchange_value_type = 'วัน';
             }
         }
         $cond_id = substr($spliter[2], 0, -1);
         //in last character have comma(,) remove it.
         $cond_id = explode(',', $cond_id);
         //split to array
         //insert to t_worktime_ot_exchange
         $data = array();
         $data['otx_hour'] = $sum_ot_hour;
         $data['otx_type'] = $exchange_type;
         $data['otx_money'] = $money;
         $data['otx_leave'] = $leave;
         $data['otx_by'] = $this->user_id;
         $data['otx_date'] = getDateTimeNow();
         $new_otx_id = $this->otexchange->insert($data);
         //update id to t_worktime_ot
         foreach ($input_ot as $id) {
             $data = array();
             $data['wot_otx_id'] = $new_otx_id;
             $where = array('wot_id' => $id);
             $this->ot->update($data, $where);
         }
         //insert detail to t_worktime_ot_exchange_detail
         foreach ($cond_id as $id) {
             $query = $this->otconditions->get_detail_by_id($id);
             if ($query->num_rows() > 0) {
                 $query = $query->row_array();
                 $cond_hour = $query['wotcond_ot_hour'];
                 $cond_money = $query['wotcond_money'];
                 $cond_leave = $query['wotcond_leave'];
                 $data = array();
                 $data['otxd_otx_id'] = $new_otx_id;
                 $data['otxd_cond_id'] = $id;
                 $data['otxd_money'] = $cond_money;
                 $data['otxd_leave'] = $cond_leave;
                 $this->otexchangedetail->insert($data);
             }
         }
         //insert log about ot exchange process
         $log_type = 'user exchange ot for ' . $exchange_type;
         $log_detail = $this->emp_id . ' ทำการขอแลกจำนวนชั่วโมงทำ OT จำนวน ' . $sum_ot_hour . ' ชั่วโมง เป็น ' . $exchange_type_thai . ' จำนวน ' . $exchange_value . ' ' . $exchange_value_type . ' โดยใช้วันทำ OT วันที่ ' . $exchange_date;
         insert_log_ot_exchange($new_otx_id, $log_type, $log_detail, $this->user_id);
         echo swalc('บันทึกเรียบร้อยแล้ว', '', 'success', 'window.location.href = "' . site_url('Overtime') . '"');
     }
 }
Ejemplo n.º 9
0
			<th>เริ่มเวลา</th>
			<th>สิ้นสุดเวลา</th>
			<th>จำนวนชั่วโมง</th>
		</tr>
	</thead>
	<tbody>
		<?php 
foreach ($query_ot as $row) {
    ?>
			<tr>
				<td><?php 
    echo $row["wot_id"];
    ?>
</td>
				<td><?php 
    echo dateThaiFormatFromDB($row["wot_date"]);
    ?>
 </td>
				<td><?php 
    echo $row["wot_time_from"];
    ?>
</td>
				<td><?php 
    echo $row["wot_time_to"];
    ?>
</td>
				<td><?php 
    echo $row["wot_request_hour"];
    ?>
</td>
			</tr>
Ejemplo n.º 10
0
?>
เนื่องจาก <?php 
echo $query["LBecause"];
?>
	<br>&nbsp;<br>
	เป็นเวลา <?php 
echo $query["sum_leave_time"];
?>
 ตั้งแต่วันที่ <?php 
echo dateThaiFormatFromDB($query["LStartDate"]);
?>
 เวลา <?php 
echo timeFormatNotSecond($query["LStartTime"]);
?>
น. จนถึง <?php 
echo dateThaiFormatFromDB($query["LEndDate"]);
?>
 เวลา <?php 
echo timeFormatNotSecond($query["LEndTime"]);
?>
น.
	</p>
	<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>
	<div class="right-align">
		<table>
			<tr>
				<td></td>
				<td class="center-align">
					จึงเรียนมาเพื่อทราบ
					<br>&nbsp;<br>&nbsp;<br>
					________________________________
Ejemplo n.º 11
0
 public function Detail($empID)
 {
     $user_id = 0;
     $data = $this->setDefaultDataPage();
     $data["nowTitle"] = "แก้ไขข้อมูลพนักงาน";
     $data["FormUrl"] = site_url("hr/Employee/EditEmployee");
     $query = $this->employees->getDetailByEmpID($empID);
     if ($query->num_rows() > 0) {
         $query = $query->result_array();
         $query = $query[0];
         $user_id = $query["UserID"];
         $data["empID"] = $query['EmpID'];
         $data['empInstitutionID'] = $query['Emp_InstitutionID'];
         $data['queryDepartment'] = $this->department->getListForDropDown($data['empInstitutionID']);
         $data["empDepartmentID"] = $query['Emp_DepartmentID'];
         $data['queryPosition'] = $this->position->getListForDropDown($data['empDepartmentID']);
         $data['empPositionID'] = $query['Emp_PositionID'];
         //get headman
         $query_headman = $this->empheadman->get_list_by_user_id($user_id);
         if ($query_headman->num_rows() > 0) {
             foreach ($query_headman->result_array() as $qh) {
                 $data["empHeadmanID_level_" . $qh["eh_headman_level"]] = $qh["eh_headman_user_id"];
             }
         }
         //dateThaiFormatFromDB is function from common_helper.
         $data['empStartWorkDate'] = dateThaiFormatFromDB($query['EmpStartWorkDate']);
         $data['empPromiseStartWorkDate'] = dateThaiFormatFromDB($query['EmpPromiseStartWorkDate']);
         $data['empSuccessTrialWorkDate'] = dateThaiFormatFromDB($query['EmpSuccessTrialWorkDate']);
         $data['empSalary'] = $query['EmpSalary'];
         $data["empUsername"] = $query['Username'];
         $data["empPassword"] = $query['Password'];
         $data["empNameTitleThai"] = $query['EmpNameTitleThai'];
         $data["empFirstnameThai"] = $query['EmpFirstnameThai'];
         $data["empLastnameThai"] = $query['EmpLastnameThai'];
         $data["empNameTitleEnglish"] = $query['EmpNameTitleEnglish'];
         $data["empFirstnameEnglish"] = $query['EmpFirstnameEnglish'];
         $data["empLastnameEnglish"] = $query['EmpLastnameEnglish'];
         $data["empCallName"] = $query['EmpCallname'];
         $data["empTelePhone"] = $query['EmpTelephone'];
         $data["empMobilePhone"] = $query['EmpMobilePhone'];
         $data["empEmail"] = $query['EmpEmail'];
         $data["empBirthPlace"] = $query['EmpBirthPlace'];
         $data["empSex"] = $query['EmpSex'];
         $data["empHeight"] = $query['EmpHeight'];
         $data["empWeight"] = $query['EmpWeight'];
         $data["empBlood"] = $query['EmpBlood'];
         $data["empNationality"] = $query['EmpNationality'];
         $data["empRace"] = $query['EmpRace'];
         $data["empReligion"] = $query['EmpReligion'];
         $data["empMartialStatus"] = $query['Emp_MARSID'];
         $data["empMilitaryStatus"] = $query['EmpMilitaryStatus'];
         $data["empMilitaryReason"] = $query['EmpMilitaryReason'];
         $data["empIDCard"] = $query['EmpIDCard'];
         $data["empIDCardImg"] = $query['EmpIDCardImg'];
         $data["empAddressNumber"] = $query['EmpAddressNumber'];
         $data["empAddressMoo"] = $query['EmpAddressMoo'];
         $data["empAddressRoad"] = $query['EmpAddressRoad'];
         //bind dropdownlist district,amphur,province
         $data["empAddressProvince"] = $query['Emp_ProvinceID'];
         $data['queryAmphur'] = $this->amphur->getListForDropDown($data['empAddressProvince']);
         $data["empAddressAmphur"] = $query['Emp_AmphurID'];
         $data['queryDistrict'] = $this->district->getListForDropDown($data['empAddressProvince'], $data['empAddressAmphur']);
         $data["empAddressDistrict"] = $query['Emp_DistrictID'];
         $data['queryZipcode'] = $this->zipcode->getListForDropDown($data['empAddressProvince'], $data['empAddressAmphur'], $data['empAddressDistrict']);
         $data["empAddressZipcode"] = $query['Emp_ZipcodeID'];
         $data["empAddressImg"] = $query['EmpAddressImg'];
         $data["empPictureImg"] = $query['EmpPictureImg'];
         $data["empNameTitleFriend"] = $query['EmpFriendNameTitleThai'];
         $data["empFirstnameFriend"] = $query['EmpFriendFirstnameThai'];
         $data["empLastnameFriend"] = $query['EmpFriendLastnameThai'];
         //bind dropdownlist district,amphur,province
         $data["empAddressNumberFriend"] = $query['EmpFriendAddressNumber'];
         $data["empAddressMooFriend"] = $query['EmpFriendAddressMoo'];
         $data["empAddressRoadFriend"] = $query['EmpFriendAddressRoad'];
         $data["empAddressProvinceFriend"] = $query['EmpFriend_ProvinceID'];
         $data["empAddressAmphurFriend"] = $query['EmpFriend_AmphurID'];
         $data["empAddressDistrictFriend"] = $query['EmpFriend_DistrictID'];
         $data["empAddressZipcodeFriend"] = $query['EmpFriend_ZipcodeID'];
         if ($data['empAddressProvinceFriend'] != 0) {
             $data['queryAmphurFriend'] = $this->amphur->getListForDropDown($data['empAddressProvinceFriend']);
             $data['queryDistrictFriend'] = $this->district->getListForDropDown($data['empAddressProvinceFriend'], $data['empAddressAmphurFriend']);
             $data['queryZipcodeFriend'] = $this->zipcode->getListForDropDown($data['empAddressProvinceFriend'], $data['empAddressAmphurFriend'], $data['empAddressDistrictFriend']);
         }
         $data["empTelePhoneFriend"] = $query['EmpFriendTelephone'];
         $data["empMobilePhoneFriend"] = $query['EmpFriendMobilePhone'];
         $data["empDocumentRegisterJobImg"] = $query['EmpDocRegisterJobImg'];
         $empBirthDay = $query['EmpBirthDay'];
         if ($empBirthDay !== '0000-00-00' && $empBirthDay !== null) {
             $empBirthDay = array();
             $empBirthDay = explode('-', $query['EmpBirthDay']);
             $data["birthDayDay"] = $empBirthDay[2];
             $data["birthDayMonth"] = $empBirthDay[1];
             $data["birthDayYear"] = $empBirthDay[0];
         }
         $data["empBankID"] = $query['Emp_BankID'];
         $data["empBankType"] = $query['Emp_BankTypeID'];
         $data["empBankBranch"] = $query['EmpBankBranch'];
         $data["empBankNumber"] = $query['EmpBankNumber'];
         $data["empBankImg"] = $query['EmpBankImg'];
         //get history work & study
         $query = $this->hiswork->get_list_by_user_id($user_id);
         $data["query_history_work"] = $query->result_array();
         $query = $this->hisstudy->get_list_by_user_id($user_id);
         $data["query_history_study"] = $query->result_array();
     }
     parent::setHeader('รายละเอียดพนักงาน');
     $this->load->view("hr/Employee/Register", $data);
     parent::setFooter();
 }
Ejemplo n.º 12
0
 public function edit($actID)
 {
     $query = $this->activity->getDetail($actID);
     if ($query->num_rows() > 0) {
         $query = $query->result_array();
         $query = $query[0];
         $data = array();
         $data["formURL"] = site_url("hr/Activity/saveEdit/");
         $data["actID"] = $actID;
         $data["valueTopic"] = $query["ACTTopic"];
         $data["valueContent"] = $query["ACTContent"];
         $data["valueStartDate"] = dateThaiFormatFromDB($query["ACTStartDate"]);
         $data["valueEndDate"] = dateThaiFormatFromDB($query["ACTEndDate"]);
         $data["valueShowDateFrom"] = dateThaiFormatFromDB($query["ACTShowDateFrom"]);
         $data["valueShowDateTo"] = dateThaiFormatFromDB($query["ACTShowDateTo"]);
         parent::setHeader("แก้ไขกิจกรรม");
         $this->load->view("hr/Activity/Add", $data);
         parent::setFooter();
     } else {
         redirect(site_url("hr/Activity/"));
     }
 }
Ejemplo n.º 13
0
    echo $row["news_topic"];
    ?>
</td>
				<td>
					<?php 
    if ($row["news_show_start_date"] === "0000-00-00" || $row["news_show_end_date"] === "0000-00-00") {
        ?>
						แสดงตลอด
					<?php 
    } else {
        ?>
						<?php 
        echo dateThaiFormatFromDB($row["news_show_start_date"]);
        ?>
 - <?php 
        echo dateThaiFormatFromDB($row["news_show_end_date"]);
        ?>
					<?php 
    }
    ?>
				</td>
				<td><?php 
    echo date_time_thai_format_from_db($row["news_latest_update_date"]);
    ?>
</td>
				<td>
					<a href="<?php 
    echo site_url('News/detail/' . $row["news_id"]);
    ?>
" 
						class="btn-floating btn-small waves-effect waves-light" target="_blank">
Ejemplo n.º 14
0
 public function save()
 {
     if ($_POST) {
         //get post
         $pData = $this->input->post(NULL, TRUE);
         //input data
         $leaveTypeID = $pData["ddlLeaveType"];
         //ประเภทการลา
         $leave_because = $pData['txtBecause'];
         $leave_start_date = dbDateFormatFromThaiUn543($pData["txtStartDate"]);
         //วันที่ลา
         $leave_start_time = $pData["txtStartTime"];
         //เวลาที่ลา
         $leave_end_date = dbDateFormatFromThaiUn543($pData["txtEndDate"]);
         //วันสิ้นสุดที่ลา
         $leave_end_time = $pData["txtEndTime"];
         //เวลาสิ้นสุดของวันที่ลา
         //hidden data
         $this->user_id = $pData["hdUserID"];
         $this->emp_id = $pData["hdEmpID"];
         $leaveID = $pData["hdLID"];
         $pagetype = $pData['hd_pagetype'];
         $pass = $this->leave->checkExistsDate($this->user_id, $leave_start_date, $leave_end_date, $leaveID);
         if (!$pass) {
             echo swalc("ลาไม่ได้นะ", "วันที่คุณลามีการลาอยู่แล้ว", "error", "history.back();");
         } else {
             if ($pagetype == 'add') {
                 $data = array();
                 $data["L_LTID"] = $leaveTypeID;
                 $data["L_UserID"] = $this->user_id;
                 $data["LBecause"] = $leave_because;
                 $data["LStartDate"] = $leave_start_date;
                 $data["LStartTime"] = $leave_start_time;
                 $data["LEndDate"] = $leave_end_date;
                 $data["LEndTime"] = $leave_end_time;
                 $data["L_WFID"] = 1;
                 $data["L_StatusID"] = 1;
                 $data["LCreatedDate"] = getDateTimeNow();
                 $data["LLatestUpdate"] = getDateTimeNow();
                 $leaveID = $this->leave->insertLeave($data);
                 $uploadPath = $this->config->item('upload_employee') . $this->user_id . '/leave/';
                 $uploadPath = uploadFileControl("fuDocument", $uploadPath, $leaveID, "leave");
             } else {
                 if ($pagetype == 'edit' || $pagetype == "editdoc") {
                     //Get old data for insert into log after update new leave data.
                     $query = $this->leave->getDetailByLeaveID($leaveID);
                     $query = $query->row_array();
                     $old_leave_detail = $query;
                     //ใช้สำหรับส่งไปฟังก์ชั่นส่งเมล์หาหัวหน้า
                     $old_start_date = dateThaiFormatFromDB($query["LStartDate"]);
                     $old_start_time = $query["LStartTime"];
                     $old_end_date = dateThaiFormatFromDB($query["LEndDate"]);
                     $old_end_time = $query["LEndTime"];
                     $old_data = array();
                     $old_data["LL_LID"] = $leaveID;
                     $old_data["LL_Type"] = "edit";
                     $old_data["LLDetail"] = "แก้ไขใบลา จากขอลาวันที่ " . $old_start_date . " " . $old_start_time . " จนถึงวันที่ " . $old_end_date . " " . $old_end_time . " แก้ไขเป็นขอลาวันที่ " . $leave_start_date . " " . $leave_start_time . " จนถึงวันที่ " . $leave_end_date . " " . $leave_end_time;
                     $old_data["LLDate"] = getDateTimeNow();
                     $old_date["LLBy"] = $this->user_id;
                     $return_wfid = $old_leave_detail["LReturn_WFID"] == NULL ? 1 : $old_leave_detail["LReturn_WFID"];
                     if ($pagetype !== "editdoc") {
                         $data = array();
                         $data["L_LTID"] = $leaveTypeID;
                         $data["L_UserID"] = $this->user_id;
                         $data["LBecause"] = $leave_because;
                         $data["LStartDate"] = $leave_start_date;
                         $data["LStartTime"] = $leave_start_time;
                         $data["LEndDate"] = $leave_end_date;
                         $data["LEndTime"] = $leave_end_time;
                         $data["L_WFID"] = $return_wfid;
                         $data["L_StatusID"] = 1;
                         $data["LLatestUpdate"] = getDateTimeNow();
                         $data["LReturn_WFID"] = NULL;
                         $where = array();
                         $where["LID"] = $leaveID;
                         $this->leave->update($data, $where);
                     } else {
                         $data = array();
                         $data["L_WFID"] = $return_wfid;
                         $data["LLatestUpdate"] = getDateTimeNow();
                         $data["LReturn_WFID"] = NULL;
                         $where = array();
                         $where["LID"] = $leaveID;
                         $this->leave->update($data, $where);
                         $old_data["LL_LID"] = $leaveID;
                         $old_data["LL_Type"] = "editdoc";
                         $old_data["LLDetail"] = "อัพโหลดเอกสารเพิ่มเติม";
                         $old_data["LLDate"] = getDateTimeNow();
                         $old_date["LLBy"] = $this->user_id;
                     }
                     $uploadPath = $this->config->item('upload_employee') . $this->user_id . '/leave/';
                     $uploadPath = uploadFileControl("fuDocument", $uploadPath, $leaveID, "editleave");
                     //update log for change data
                     $this->load->model('Leavelog_model', 'leavelog');
                     $this->leavelog->insert($old_data);
                 }
             }
             /***********************************************************************************
              * คำนวณจำนวนวันลาแล้วบันทึกลง T_LeaveTimeDetail จะเก็บเกี่ยวกับจำนวนชั่วโมงในการลาของแต่ละวัน
              * โดยคำนวณจาก T_Config ที่เก็บเวลาเริ่มทำงาน + เวลาสิ้นสุดการทำงาน โดยหักลบด้วย เวลาพัก
              * จะได้ชั่วโมงทำงานที่แท้จริง จากนั้นเอามาหักลบจากที่ลา เช่นลาตอน 4 โมงเย็น เลิกงาน 6 โมงเย็น
              * ก็บันทึกลงไปใน T_LeaveTimeDetail ว่า ลา 2  ชั่วโมงของวันที่ 23/03/2558
              * จากนั้นเวลาเอาไปคิดว่าลาไปจำนวนกี่วันแล้วก็ใช้สูตร จำนวนชั่วโมงที่ลา / เวลาทำงาน
              * แล้วบันทึกลงไปใน T_LeaveQuota
              ***********************************************************************************/
             /* This sector is find total work hour of day */
             $query = $this->configuration->getWorkTime();
             $workTimeStart = $query["workTimeStart"];
             //เวลาเริ่มทำงาน
             $workTimeEnd = $query["workTimeEnd"];
             //เวลาเลิกงาน
             $query = $this->configuration->getBreakTime();
             $breakTimeStart = $query["breakTimeStart"];
             //เวลาเริ่มพัก
             $breakTimeEnd = $query["breakTimeEnd"];
             //เวลาเลิกพัก
             $workHour = timeDiff($workTimeStart, $workTimeEnd);
             $breakHour = timeDiff($breakTimeStart, $breakTimeEnd);
             $totalWorkHour = $workHour - $breakHour;
             //Normal about time is 8 hours.
             /**
              * วนลูปเพื่อเช็คแต่ละวันใช้ลาไปวันละกี่ชั่วโมง
              * 1. ใช้ function get ว่าระหว่างวันที่เริ่ม กับ วันที่สิ้นสุดลามีวันอะไรบ้างลงใน array
              * 2. หาจำนวนชั่วโมงของวันที่ลาว่าลากี่ชั่วโมง
              * 3. บันทึกลง T_LeaveTimeDetail
              */
             $dateLeave = createDateRangeArray($leave_start_date, $leave_end_date);
             $totalLeaveHour = 0;
             $numHour = 0;
             $dataTime = array();
             $dataTime["LTD_LID"] = $leaveID;
             $dataTime["LTDDate"] = "";
             $dataTime["LTDHour"] = "";
             $dataWorkDate = $this->configuration->getWorkDate();
             $workDayStart = $dataWorkDate["workDateStart"];
             $workDayEnd = $dataWorkDate["workDateEnd"];
             //ต้องคำนวณด้วยว่าเป็นวันทำงานหรือเปล่า อย่างเช่นตอนนี้มีการผิดพลาดเกิดขึ้นเมื่อลา
             //วันศุกร์ - วันจันทร์ ตย. วันศุกร์ลา 9:00 - วันจันทร์ 9:00 จะถูกนับเป็น 4 วัน
             //ต้องเอาวันที่หยุดใน config มาหักลบด้วย ถึงจะได้ตัวเลขที่แท้จริง
             for ($i = 0; $i < count($dateLeave); $i++) {
                 if (checkWeekDay($dateLeave[$i]) >= $workDayStart && checkWeekDay($dateLeave[$i]) <= $workDayEnd) {
                     //เช็คว่าวันที่ลาอยู่ระหว่างวันทำงานหรือไม่
                     if (count($dateLeave) == 1) {
                         $numHour = timeDiff($leave_start_time, $leave_end_time);
                         if ($numHour > 6) {
                             $numHour = $numHour - $breakHour;
                         }
                         $totalLeaveHour = $totalLeaveHour + $numHour;
                     } else {
                         if ($dateLeave[$i] == $leave_start_date) {
                             $numHour = timeDiff($leave_start_time, $workTimeEnd);
                             if ($numHour > 6) {
                                 $numHour = $numHour - $breakHour;
                             }
                             //ถ้าเป็นวันเริ่มต้นให้เอาเวลาของวันเริ่มมาคำนวณหาจำนวนชั่วโมงการลา
                             $totalLeaveHour = $totalLeaveHour + $numHour;
                         } else {
                             $numHour = $totalWorkHour;
                             //ถ้าเป็นวันที่อยู่ระหว่างวันเริ่มกับวันสิ้นสุดให้เอาจำนวนชั่วโมงที่ทำงานมาเลย
                             $totalLeaveHour = $totalLeaveHour + $totalWorkHour;
                         }
                         if ($dateLeave[$i] == $leave_end_date) {
                             $numHour = timeDiff($workTimeStart, $leave_end_time);
                             //ถ้าเป็นวันสิ้นสุดการลาให้เอาเวลาของวันสิ้นสุดมาคำนวณหาจำนวนชั่วโมงการลา
                             $totalLeaveHour = $totalLeaveHour + $numHour;
                         }
                     }
                     $dataTime["LTDDate"] = $dateLeave[$i];
                     $dataTime["LTDHour"] = $numHour;
                     //case edit delete old leave time detail
                     if ($pagetype == 'edit') {
                         $this->leavetimedetail->deleteByLeaveID($leaveID);
                     }
                     $this->leavetimedetail->insertTime($dataTime);
                 }
             }
             /**
              * เอาจำนวนชั่วโมงทั้งหมด มาหารจำนวนชั่วโมงที่ต้องทำงานแต่ละวัน หาว่าใช้ไปกี่วัน
              * แล้วบันทึกลงไปที่ T_LeaveQuota
              **/
             //change to calculate all leave request to get quota
             $this->leavequota->calculate_quota($this->user_id, $leaveTypeID);
             //ใช้การคำนวณร่วมกับ leavetimedetail
             //หลังจากบันทึกทุกอย่างเสร็จแล้ว ส่ง อีเมล์บอกหัวหน้างานของตัวเองว่ามีการขอลา
             //insert log
             log_leave("send leave request", $leaveID, "ส่งใบลา", $this->user_id);
             //run workflow system
             $this->load->library("WorkflowSystem");
             $process = '';
             if ($pagetype == 'add') {
                 $this->workflowsystem->set_require_data($leaveID, "leave", "request");
                 $process = $this->workflowsystem->run();
                 //$process = $this->send_mail_to_leave_headman($leaveID,1);
             } else {
                 if ($pagetype == 'edit') {
                     $this->workflowsystem->set_require_data($leaveID, "leave", "edit request");
                     $process = $this->workflowsystem->run();
                     //$process = $this->send_mail_to_leave_headman($leaveID,1,'edit',$old_leave_detail);
                 } else {
                     if ($pagetype == 'editdoc') {
                         $this->workflowsystem->set_require_data($leaveID, "leave", "edit document");
                         $process = $this->workflowsystem->run();
                         //$process = $this->send_mail_to_leave_headman($leaveID,1,'edit',$old_leave_detail);
                     }
                 }
             }
             if ($process != 'success') {
                 echo swalc('ผิดพลาด!!', 'ระบบบันทึกการลาของคุณแล้ว แต่ไม่สามารถส่งอีเมล์ถึงหัวหน้าของคุณได้<br/>' + $this->phpmailer->ErrorInfo, 'error', "window.location.href = '" . site_url("Leave") . "'");
             } else {
                 echo swalc('สำเร็จ!!', 'บันทึกการลาของคุณพร้อมส่งอีเมล์ให้หัวหน้าเรียบร้อยแล้ว', 'success', "window.location.href = '" . site_url("Leave") . "'");
             }
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * ส่งรายละเอียด OT ให้ HR
  * @param  [type]
  * @return [type]
  */
 private function _send_email_ot_to_hr($ot_id)
 {
     $body = '';
     $search = array();
     $replace = array();
     //var owner request detail
     $owner_user_id = 0;
     $owner_emp_id = "";
     $owner_fullname = '';
     $owner_department = '';
     $owner_position = '';
     //var headman detail
     $headman_user_id = 0;
     $headman_emp_id = "";
     $headman_fullname = array();
     $headman_department = "";
     $headman_position = "";
     //var hr detail
     $hr_user_id = '';
     $hr_fullname = '';
     $hr_email = '';
     //var ot detail
     $ot_date = '';
     $ot_time_from = '';
     $ot_time_to = '';
     $query = $this->ot->get_detail_by_id($ot_id);
     if ($query->num_rows() > 0) {
         $query = $query->row_array();
         //ot detail
         $ot_date = $query['wot_date'];
         $ot_time_from = $query['wot_time_from'];
         $ot_time_to = $query['wot_time_to'];
         //owner detail
         $owner_user_id = $query['wot_request_by'];
         $owner_detail = getEmployeeDetailByUserID($owner_user_id);
         $owner_emp_id = $owner_detail['EmpID'];
         $owner_fullname = $owner_detail['EmpFullnameThai'];
         $owner_department = $owner_detail['DepartmentName'];
         $owner_position = $owner_detail['PositionName'];
         //headman detail
         $headman_detail = getEmployeeDetailByUserID($query["wot_headman_user_id_send_instead"]);
         $headman_fullname = $headman_detail['EmpFullnameThai'];
         $headman_emp_id = $headman_detail['EmpID'];
         $headman_fullname = $headman_detail['EmpFullnameThai'];
         $headman_department = $headman_detail['DepartmentName'];
         $headman_position = $headman_detail['PositionName'];
         //hr detail
         $hr_detail = get_hr_detail();
         //send mail library
         //non config because default set in phpmailer class
         $this->load->library('phpmailer');
         $this->phpmailer->ClearAllRecipients();
         $this->phpmailer->IsSMTP();
         foreach ($hr_detail as $hr) {
             $hr_user_id = $hr['userid'];
             $hr_fullname = $hr['fullname'];
             $hr_email = $hr['email'];
             $mail_subject = '[' . dateThaiFormatFromDB($ot_date) . '] ส่งคำขอทำงานล่วงเวลาแทนโดยหัวหน้า';
             $body = file_get_contents(APPPATH . 'views/Email/ot/Send_instead_team_to_hr.html');
             $search = array("{{emp_id}}", "{{emp_fullname}}", "{{emp_department}}", "{{emp_position}}", "{{ot_date}}", "{{ot_time_from}}", "{{ot_time_to}}", "{{headman_emp_id}}", "{{headman_fullname}}", "{{headman_department}}", "{{headman_position}}");
             $replace = array($owner_emp_id, $owner_fullname, $owner_department, $owner_position, dateThaiFormatFromDB($ot_date), $ot_time_from, $ot_time_to, $headman_emp_id, $headman_fullname, $headman_department, $headman_position);
             $body = str_replace($search, $replace, $body);
             $this->phpmailer->Subject = $mail_subject;
             $this->phpmailer->Body = $body;
             //ส่วนนี้รายละเอียดสามารถส่งเป็นรูปแบบ HTML ได้
             $this->phpmailer->AddAddress($hr_email, $hr_fullname);
             if (!$this->phpmailer->Send()) {
                 return $this->phpmailer->ErrorInfo;
             } else {
                 return 'success';
             }
         }
     }
 }
Ejemplo n.º 16
0
    echo $row["ACTTopic"];
    ?>
</a>
		</td>
		<td><?php 
    echo $row["ACTCreatedBy"];
    ?>
</td>
		<td>
			<?php 
    echo dateThaiFormatFromDB($row["ACTStartDate"]);
    ?>
		</td>
		<td>
			<?php 
    echo dateThaiFormatFromDB($row["ACTEndDate"]);
    ?>
		</td>
		<td>
			<a href="<?php 
    echo site_url('hr/Activity/edit/' . $row["ACTID"]);
    ?>
">แก้ไข</a>
			<a href="javascript:void(0);" onclick="deleteThis(this,'<?php 
    echo site_url('hr/Activity/delete/');
    ?>
','<?php 
    echo $row['ACTID'];
    ?>
');">ลบ</a>
		</td>