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


PHP MY_Model::edit方法代码示例

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


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

示例1: edit

 /**
  * If technician is changed, updated order_technicians
  */
 public function edit($assignment_id, $params)
 {
     $assignment = $this->get($assignment_id);
     $previous_technician_id = $assignment->technician_id;
     // Multiple technicians can be assigned to a single unit. In this case, create other assignments as needed, and delete existing ones if needed
     if (!empty($params['technician_id']) && is_array($params['technician_id'])) {
         $all_assignments = $this->get(array('order_id' => $assignment->order_id, 'unit_id' => $assignment->unit_id));
         foreach ($params['technician_id'] as $new_technician_id) {
             $technician_is_already_assigned = false;
             foreach ($all_assignments as $existing_assignment) {
                 if ($existing_assignment->technician_id == $new_technician_id) {
                     $technician_is_already_assigned = true;
                 }
             }
             if (!$technician_is_already_assigned) {
                 $assignment_params = array('order_id' => $assignment->order_id, 'unit_id' => $assignment->unit_id, 'workflow_id' => $assignment->workflow_id, 'technician_id' => $new_technician_id, 'appointment_date' => $assignment->appointment_date, 'estimated_duration' => $assignment->estimated_duration);
                 if (!$this->get(array('order_id' => $assignment->order_id, 'unit_id' => $assignment->unit_id, 'technician_id' => $new_technician_id))) {
                     $this->add($assignment_params);
                 }
             }
         }
         $all_assignments = $this->get(array('order_id' => $assignment->order_id, 'unit_id' => $assignment->unit_id));
         foreach ($all_assignments as $existing_assignment) {
             $assignment_has_a_technician = false;
             foreach ($params['technician_id'] as $new_technician_id) {
                 if ($existing_assignment->technician_id == $new_technician_id) {
                     $assignment_has_a_technician = true;
                 }
             }
             if (!$assignment_has_a_technician) {
                 $this->delete($existing_assignment->id);
             }
         }
         unset($params['technician_id']);
         $result = parent::edit($assignment_id, $params);
         // Update appointment_date and estimated_duration
         return true;
     } else {
         if (empty($params['technician_id'])) {
             return parent::edit($assignment_id, $params);
         } else {
             $this->order_technician_model->add_if_new($assignment->order_id, $params['technician_id']);
         }
         // If the order/unit/tech combination already exists, delete this assignment instead of editing it
         if ($params['technician_id'] != $assignment->technician_id && $this->get(array('order_id' => $assignment->order_id, 'unit_id' => $assignment->unit_id, 'technician_id' => $params['technician_id']))) {
             $result = parent::delete($assignment_id);
         } else {
             $result = parent::edit($assignment_id, $params);
         }
         $this->order_technician_model->delete_if_last($assignment->order_id, $previous_technician_id, $assignment->id);
         return $result;
     }
 }
开发者ID:nicolasconnault,项目名称:streamliner,代码行数:56,代码来源:Assignment_model.php

示例2: edit

 public function edit($unit_id, $params)
 {
     $unit = $this->get($unit_id);
     if (!empty($params['tenancy_id']) && $unit->tenancy_id != $params['tenancy_id']) {
         if (!empty($unit->tenancy_id)) {
             $this->tenancy_log_model->remove_unit($unit->tenancy_id, $unit->id);
         }
         $this->tenancy_log_model->add_unit($params['tenancy_id'], $unit->id);
     }
     return parent::edit($unit_id, $params);
 }
开发者ID:nicolasconnault,项目名称:streamliner,代码行数:11,代码来源:Unit_model.php


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