当前位置: 首页>>代码示例>>PHP>>正文


PHP Result::setResult方法代码示例

本文整理汇总了PHP中Result::setResult方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::setResult方法的具体用法?PHP Result::setResult怎么用?PHP Result::setResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Result的用法示例。


在下文中一共展示了Result::setResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Result

 function validate_cancel_input()
 {
     $result = new Result();
     if (!isset($_POST['leave_to_cancel']) || empty($_POST['leave_to_cancel'])) {
         $result->setResult(FALSE);
         $result->addError("Please select leave to cancel");
     }
     return $result;
 }
开发者ID:pkdism,项目名称:ISM-MIS,代码行数:9,代码来源:leave_cancel.php

示例2: Result

 function is_valid_casual_leave($emp_id, $leave_start_date, $leave_end_date)
 {
     $result = new Result();
     // check if leave is comming into already taken leaves period
     $this->load->model('leave/leave_helper', 'lh');
     $clash_verification = $this->lh->verify_leaves_period($emp_id, $leave_start_date, $leave_end_date);
     $result->updateResult($clash_verification);
     // check if valid balance of casual leaves
     $avail_bal = $this->get_casual_leave_balance($emp_id);
     $applied_period = strtotime($leave_end_date) - strtotime($leave_start_date);
     $applied_period = floor($applied_period / (60 * 60 * 24)) + 1;
     if ($avail_bal < $applied_period) {
         $result->setResult(FALSE);
         $error = "Your leave length is more than available balance. " . "Your available casual leave balance is " . $avail_bal;
         $result->addError($error);
     }
     // check for maximum allowed casual leaves in one stretch
     if ($applied_period > 5) {
         $result->setResult(FALSE);
         $error = "You can take atmost 5 casual leaves in one stretch.";
         $result->addError($error);
     }
     return $result;
 }
开发者ID:pkdism,项目名称:ISM-MIS,代码行数:24,代码来源:leave_casual_model.php

示例3: Result

 function is_valid_restricted_leave($emp_id, $leave_date)
 {
     $result = new Result();
     // modify date to match db date format
     $leave_date = date('Y-m-d', strtotime($leave_date));
     // check if restricted holiday available
     $sql = "SELECT * FROM " . Leave_constants::$TABLE_RESTRICTED_HOLIDAYS . " WHERE holiday_date = '{$leave_date}'";
     $query = $this->db->query($sql);
     if ($query->num_rows() == 0) {
         $result->setResult(FALSE);
         $result->addError("No restricted holiday available.");
     }
     // check if leave is comming into already taken leaves period
     $this->load->model('leave/leave_helper', 'lh');
     $clash_verification = $this->lh->verify_leaves_period($emp_id, $leave_date, $leave_date);
     $result->updateResult($clash_verification);
     // check if balance for leave available
     $balance = $this->get_restricted_leave_balance($emp_id);
     if ($balance < 1) {
         $result->setResult(FALSE);
         $result->addError("Your don't have restricted leaves left.");
     }
     return $result;
 }
开发者ID:pkdism,项目名称:ISM-MIS,代码行数:24,代码来源:leave_restricted_model.php

示例4: add

 /**
  * Добавление сущности
  *
  * @param $data
  */
 public function add($data)
 {
     $data = $this->factoryEntity($data)->toArray();
     // Фильтруем данные
     $data = $this->filterOnAdd($data);
     // Валидируем данные
     $validator = $this->validateOnAdd($data);
     $result = new Result();
     if ($validator->isValid()) {
         try {
             $id = $this->insert($this->getName(), $data);
             if (!$id) {
                 $result->addError('Add ' . $this->getName() . ' failed', 'add_product_failed');
             }
         } catch (Exception $e) {
             $result->addError($e->getMessage(), $e->getCode());
         }
     }
     return $result->setResult($id);
 }
开发者ID:meniam,项目名称:model,代码行数:25,代码来源:Adapter.php

示例5: Result

 function check_for_weekend()
 {
     // result to resturn
     $result = new Result();
     $time = $this->leave_start_time;
     while ($this->leave_end_time >= $time) {
         $day_of_week = date('w', $time);
         if ($day_of_week == 0 || $day_of_week == 6) {
             $result->setResult(FALSE);
             $result->addError("Your leave includes weekend(s) please break it around them.");
             break;
         }
         $time += 24 * 60 * 60;
     }
     return $result;
 }
开发者ID:pkdism,项目名称:ISM-MIS,代码行数:16,代码来源:leave_helper.php

示例6: Result

 function is_valid_date_field()
 {
     // validate emptiness and format of date
     // start date <= end date
     // start date > todays date
     // start date must be less than 3 months from today
     // result to return
     $result = new Result();
     // check for valid start date
     $start_date = strtotime($_POST[Leave_application::LEAVE_START_DATE]);
     if (empty($start_date) || $start_date == FALSE) {
         $result->setResult(FALSE);
         $result->addError("Invalid start date format. It should be in format mm/dd/yyyy");
     }
     // check for valid end date if not restricted leave
     if (Leave_constants::$TYPE_RESTRICTED_LEAVE != $_POST[Leave_application::LEAVE_TYPE]) {
         // check for empty or invalid date field
         $end_date = strtotime($_POST[Leave_application::LEAVE_END_DATE]);
         if (empty($end_date) || $end_date == FALSE) {
             $result->setResult(FALSE);
             $result->addError("Invalid end date format. It should be in format mm/dd/yyyy");
         }
         // check if start date <= end date
         $diff = $end_date - $start_date;
         if ($diff < 0) {
             $result->setResult(FALSE);
             $result->addError("End date can not be before start date. Valid date format mm/dd/yyyy");
         }
     }
     // check if start date > todays date
     $today = strtotime(date('Y-m-d'));
     $diff = $start_date - $today;
     if ($diff <= 0) {
         $result->setResult(FALSE);
         $result->addError("Start date should be after today's date. Valid date format mm/dd/yyyy");
     }
     // leave can be applied only before 90 days from today
     $three_months_time = 90 * 24 * 60 * 60;
     if ($diff > $three_months_time) {
         $result->setResult(FALSE);
         $result->addError("Leave can be applied within 90 days from today");
     }
     return $result;
 }
开发者ID:pkdism,项目名称:ISM-MIS,代码行数:44,代码来源:leave_application.php


注:本文中的Result::setResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。