コード例 #1
0
ファイル: Dutyday.php プロジェクト: saqibtalib/EMR-ex-
 public static function updateSlots($start_time, $end_time, $day_id)
 {
     $fifteen_mins = 15 * 60;
     $start = strtotime($start_time);
     $end = strtotime($end_time);
     Timeslot::where('dutyday_id', '=', $day_id)->delete();
     while ($start <= $end) {
         $timeslot = new Timeslot();
         $timeslot->slot = date("H:i:s", $start);
         $timeslot->save();
         $timeslot->dutyday_id = $day_id;
         $timeslot->save();
         $start += $fifteen_mins;
     }
 }
コード例 #2
0
function createPHPClassesFromJS()
{
    $firefighter = Firefighter::getFirefighterFromJSON(getFirefighterJSJson());
    $timeslot = Timeslot::getTimeslotFromJSON(getTimeslotJSJson());
    $scheduleTimeslot = ScheduleTimeslot::getScheduleTimeslotFromJSON(getScheduleTimeslotJSJson());
    $content = "" . ("Old JSON <br>" . getFirefighterJSJson() . "<br><br>") . ("To PHP JSON: <br>" . $firefighter->getJSON() . "<br><br>") . ("Old JSON <br>" . getTimeslotJSJson() . "<br><br>") . ("To PHP JSON: <br>" . $timeslot->getJSON() . "<br><br>") . ("Old JSON: <br>" . getScheduleTimeslotJSJson() . "<br><br>") . ("To PHP JSON: <br>" . $scheduleTimeslot->getJSON() . "<br><br>");
    return $content;
}
コード例 #3
0
ファイル: OptController.php プロジェクト: saqibtalib/EMR-ex-
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $opt = Opt::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Opt::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['time'] = Timeslot::findOrFail($data['timeslot_id'])->slot;
     if (Input::get('status') == '3' || Input::get('status') == '4' || Input::get('status') == '5') {
         $data['time'] = null;
     }
     $opt->update($data);
     return Redirect::route('opt.index');
 }
コード例 #4
0
 function quick_edit_task()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $task = ProjectTasks::findById(get_id());
     if (!$task instanceof ProjectTask) {
         flash_error(lang('task list dnx'));
         return;
     }
     // if
     if (!$task->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     // if
     $task_data = array_var($_POST, 'task');
     if (is_array($task_data)) {
         $task_data['due_date'] = getDateValue(array_var($task_data, 'task_due_date'));
         $task_data['start_date'] = getDateValue(array_var($task_data, 'task_start_date'));
         $old_milestone_id = $task->getMilestoneId();
         $task->setFromAttributes($task_data);
         $project = Projects::findById(array_var($task_data, 'project_id', 0));
         //$task->setOrder(ProjectTasks::maxOrder(array_var($task_data, "parent_id", 0), array_var($task_data, "milestone_id", 0)));
         // Set assigned to
         $assigned_to = explode(':', array_var($task_data, 'assigned_to', ''));
         $company_id = array_var($assigned_to, 0, 0);
         $user_id = array_var($assigned_to, 1, 0);
         $can_assign = can_assign_task_to_company_user(logged_user(), $task, $company_id, $user_id);
         if ($can_assign !== true) {
             flash_error($can_assign);
             return;
         }
         $task->setAssignedToCompanyId($company_id);
         $task->setAssignedToUserId($user_id);
         //$task->setIsPrivate(false); // Not used, but defined as not null.
         /*if (array_var($task_data,'is_completed',false) == 'true'){
         		$task->setCompletedOn(DateTimeValueLib::now());
         		$task->setCompletedById(logged_user()->getId());
         		}*/
         if (array_var($_GET, 'dont_mark_as_read')) {
             $is_read = $task->getIsRead(logged_user()->getId());
         }
         try {
             DB::beginWork();
             $task->save();
             if (array_var($_GET, 'dont_mark_as_read') && !$is_read) {
                 $task->setIsRead(logged_user()->getId(), false);
             }
             if ($project instanceof Project && $task->canAdd(logged_user(), $project)) {
                 $task->setProject($project);
             }
             $task->setTagsFromCSV(array_var($task_data, 'tags'));
             // apply values to subtasks
             $subtasks = $task->getAllSubTasks();
             $project = $task->getProject();
             $milestone_id = $task->getMilestoneId();
             //Check for milestone workspace restrictions, update the task's workspace if milestone changed
             if ($milestone_id > 0 && $old_milestone_id != $milestone_id) {
                 $milestone = ProjectMilestones::findById($milestone_id);
                 $milestoneWs = $milestone->getProject();
                 if ($milestoneWs->getId() != $project->getId() && !$milestoneWs->isParentOf($project)) {
                     $project = $milestoneWs;
                     if ($task->canAdd(logged_user(), $project)) {
                         $task->setProject($project);
                     } else {
                         throw new Exception(lang('no access permissions'));
                     }
                 }
             }
             $apply_ws = array_var($task_data, 'apply_ws_subtasks', '') == "checked";
             $apply_ms = array_var($task_data, 'apply_milestone_subtasks', '') == "checked";
             $apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked";
             $modified_subtasks = array();
             foreach ($subtasks as $sub) {
                 $modified = false;
                 if ($apply_at || !$sub->getAssignedTo() instanceof ApplicationDataObject) {
                     $sub->setAssignedToCompanyId($company_id);
                     $sub->setAssignedToUserId($user_id);
                     $modified = true;
                 }
                 if ($apply_ws) {
                     $sub->setProject($project);
                     $modified = true;
                 }
                 if ($apply_ms) {
                     $sub->setMilestoneId($milestone_id);
                     $modified = true;
                 }
                 if ($modified) {
                     $sub->save();
                     $modified_subtasks[] = $sub;
                 }
             }
             //Add new work timeslot for this task
             if (array_var($task_data, 'hours') != '' && array_var($task_data, 'hours') > 0) {
                 $hours = array_var($task_data, 'hours');
                 if (strpos($hours, ',') && !strpos($hours, '.')) {
                     $hours = str_replace(',', '.', $hours);
                 }
                 $timeslot = new Timeslot();
                 $dt = DateTimeValueLib::now();
                 $dt2 = DateTimeValueLib::now();
                 $timeslot->setEndTime($dt);
                 $dt2 = $dt2->add('h', -$hours);
                 $timeslot->setStartTime($dt2);
                 $timeslot->setUserId(logged_user()->getId());
                 $timeslot->setObjectManager("ProjectTasks");
                 $timeslot->setObjectId($task->getId());
                 $timeslot->save();
             }
             ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_EDIT);
             $assignee = $task->getAssignedToUser();
             if ($assignee instanceof User) {
                 $task->subscribeUser($assignee);
             }
             DB::commit();
             // notify asignee
             if (array_var($task_data, 'notify') == 'true') {
                 try {
                     Notifier::taskAssigned($task);
                 } catch (Exception $e) {
                 }
                 // try
             }
             $task->getTagNames(true);
             //Forces reload of task tags to update changes
             $subt_info = array();
             foreach ($modified_subtasks as $sub) {
                 $subt_info[] = $sub->getArrayInfo();
             }
             ajx_extra_data(array("task" => $task->getArrayInfo(), 'subtasks' => $subt_info));
             flash_success(lang('success edit task', $task->getTitle()));
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
コード例 #5
0
 function add_timespan()
 {
     $object_id = get_id('object_id');
     $object = Objects::findObject($object_id);
     if (!$object instanceof ContentDataObject || !$object->canAddTimeslot(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $timeslot_data = array_var($_POST, 'timeslot');
     $hours = array_var($timeslot_data, 'hours');
     $minutes = array_var($timeslot_data, 'minutes');
     if (strpos($hours, ',') && !strpos($hours, '.')) {
         $hours = str_replace(',', '.', $hours);
     }
     if ($minutes) {
         $min = str_replace('.', '', $minutes / 6);
         $hours = $hours + ("0." . $min);
     }
     $timeslot = new Timeslot();
     $dt = DateTimeValueLib::now();
     $dt2 = DateTimeValueLib::now();
     $timeslot->setEndTime($dt);
     $dt2 = $dt2->add('h', -$hours);
     $timeslot->setStartTime($dt2);
     $timeslot->setDescription(array_var($timeslot_data, 'description'));
     $timeslot->setContactId(array_var($timeslot_data, 'contact_id', logged_user()->getId()));
     $timeslot->setRelObjectId($object_id);
     $billing_category_id = logged_user()->getDefaultBillingId();
     $bc = BillingCategories::findById($billing_category_id);
     if ($bc instanceof BillingCategory) {
         $timeslot->setBillingId($billing_category_id);
         $hourly_billing = $bc->getDefaultValue();
         $timeslot->setHourlyBilling($hourly_billing);
         $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
         $timeslot->setIsFixedBilling(false);
     }
     try {
         DB::beginWork();
         $timeslot->save();
         /*	dont add timeslots to members, members are taken from the related object
         			$object_controller = new ObjectController();
         			$object_controller->add_to_members($timeslot, $object->getMemberIds());
         		*/
         ApplicationLogs::createLog($timeslot, ApplicationLogs::ACTION_OPEN);
         $task = ProjectTasks::findById($object_id);
         if ($task->getTimeEstimate() > 0) {
             $timeslots = $task->getTimeslots();
             if (count($timeslots) == 1) {
                 $task->setPercentCompleted(0);
             }
             $timeslot_percent = round($hours * 100 / ($task->getTimeEstimate() / 60));
             $total_percentComplete = $timeslot_percent + $task->getPercentCompleted();
             if ($total_percentComplete < 0) {
                 $total_percentComplete = 0;
             }
             $task->setPercentCompleted($total_percentComplete);
             $task->save();
             $this->notifier_work_estimate($task);
         }
         DB::commit();
         flash_success(lang('success create timeslot'));
         ajx_current("reload");
     } catch (Exception $e) {
         DB::rollback();
         ajx_current("empty");
         flash_error($e->getMessage());
     }
 }
コード例 #6
0
 function add_project_timeslot()
 {
     if (!can_manage_time(logged_user(), true)) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['object_id'] = array_var($timeslot_data, 'project_id');
         $timeslot_data['object_manager'] = 'Projects';
         $timeslot = new Timeslot();
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'user_id', false) || !logged_user()->isAdministrator()) {
             $timeslot_data['user_id'] = logged_user()->getId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         /* Billing */
         $user = Users::findById($timeslot_data['user_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $project = Projects::findById(array_var($timeslot_data, 'project_id'));
         $timeslot->setBillingId($billing_category_id);
         $hourly_billing = $project->getBillingAmount($billing_category_id);
         $timeslot->setHourlyBilling($hourly_billing);
         $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
         $timeslot->setIsFixedBilling(false);
         DB::beginWork();
         $timeslot->save();
         DB::commit();
         $show_billing = can_manage_security(logged_user()) && logged_user()->isAdministrator();
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo($show_billing)));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
コード例 #7
0
 function add_timeslot()
 {
     if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['name'] = $timeslot_data['description'];
         $timeslot_data['object_id'] = 0;
         //array_var($timeslot_data,'project_id');
         $timeslot = new Timeslot();
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'contact_id', false) || !logged_user()->isAdministrator()) {
             $timeslot_data['contact_id'] = logged_user()->getId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $member_ids = array();
         $context = active_context();
         foreach ($context as $selection) {
             if ($selection instanceof Member) {
                 $member_ids[] = $selection->getId();
             }
         }
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         $show_billing = can_manage_billing(logged_user());
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo($show_billing)));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
コード例 #8
0
 function add_timeslot()
 {
     $object_id = array_var($_REQUEST, "object_id", false);
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     if ($object_id) {
         $object = Objects::findObject($object_id);
         if (!$object instanceof ContentDataObject || !$object->canAddTimeslot(logged_user())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
         $member_ids = $object->getMemberIds();
     } else {
         $member_ids = json_decode(array_var($_POST, 'members', array()));
         // clean member_ids
         $tmp_mids = array();
         foreach ($member_ids as $mid) {
             if (!is_null($mid) && trim($mid) != "") {
                 $tmp_mids[] = $mid;
             }
         }
         $member_ids = $tmp_mids;
         if (empty($member_ids)) {
             if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
                 flash_error(lang('no access permissions'));
                 ajx_current("empty");
                 return;
             }
         } else {
             if (count($member_ids) > 0) {
                 $enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
             } else {
                 $enteredMembers = array();
             }
             if (!can_add(logged_user(), $enteredMembers, Timeslots::instance()->getObjectTypeId())) {
                 flash_error(lang('no access permissions'));
                 ajx_current("empty");
                 return;
             }
         }
         $object_id = 0;
     }
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         //use current time
         if (array_var($_REQUEST, "use_current_time", false)) {
             $currentStartTime = DateTimeValueLib::now();
             $currentEndTime = DateTimeValueLib::now();
             $currentStartTime = $currentStartTime->add('h', -$hoursToAdd);
             $startTime->setHour($currentStartTime->getHour());
             $startTime->setMinute($currentStartTime->getMinute());
             $endTime->setHour($currentEndTime->getHour());
             $endTime->setMinute($currentEndTime->getMinute());
         }
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['description'] = html_to_text($timeslot_data['description']);
         $timeslot_data['name'] = $timeslot_data['description'];
         $timeslot_data['rel_object_id'] = $object_id;
         //array_var($timeslot_data,'project_id');
         $timeslot = new Timeslot();
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'contact_id', false) || !SystemPermissions::userHasSystemPermission(logged_user(), 'can_manage_time')) {
             $timeslot_data['contact_id'] = logged_user()->getId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $task = ProjectTasks::findById($object_id);
         if ($task instanceof ProjectTask) {
             $task->calculatePercentComplete();
         }
         if (!isset($member_ids) || !is_array($member_ids) || count($member_ids) == 0) {
             $member_ids = json_decode(array_var($_POST, 'members'));
         }
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         ApplicationLogs::createLog($timeslot, ApplicationLogs::ACTION_ADD);
         $show_billing = can_manage_billing(logged_user());
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo($show_billing), "real_obj_id" => $timeslot->getRelObjectId()));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
コード例 #9
0
 public function getFreeSlots()
 {
     $id = Input::get('id');
     // Get Employee id
     $date = Input::get('date');
     // Get selected date
     $day = date('l', strtotime($date));
     // Get day name from date
     $duty_day = Dutyday::where('employee_id', $id)->where('day', $day)->get()->first();
     if ($duty_day) {
         $slot = null;
         $appointments = Appointment::where('date', $date)->where('employee_id', $id)->get();
         if (count($appointments) > 0) {
             $timeslots = Timeslot::where('dutyday_id', $duty_day->id)->where('employee_id', $id);
             foreach ($appointments as $appointment) {
                 $slot = $timeslots->where('slot', '!=', $appointment->time)->get()->toJson();
             }
         } else {
             $slot = Timeslot::where('dutyday_id', $duty_day->id)->get()->toJson();
         }
         return JsonResponse::create($slot);
     }
     return 'false';
 }
コード例 #10
0
 /**
  * Return # of specific timeslot
  *
  * @param Timeslot $timeslot
  * @return integer
  */
 function getTimeslotNum(Timeslot $timeslot)
 {
     $timeslots = $this->getTimeslots();
     if (is_array($timeslots)) {
         $counter = 0;
         foreach ($timeslots as $object_timeslot) {
             $counter++;
             if ($timeslot->getId() == $object_timeslot->getId()) {
                 return $counter;
             }
         }
     }
     return 0;
 }
コード例 #11
0
 public function getAllslot()
 {
     $timeslot = Timeslot::all();
     return Response::json($timeslot);
 }
コード例 #12
0
?>
<table><tr><td style="padding-right:15px" id="<?php 
echo $genid;
?>
tdstartwork">
<form class="internalForm" action="<?php 
echo Timeslot::getOpenUrl($timeslot_form_object);
?>
" method="post" enctype="multipart/form-data">
<?php 
echo submit_button(lang('start work'));
?>
</form>
</td><td>
<form class="internalForm" action="<?php 
echo Timeslot::getAddTimespanUrl($timeslot_form_object);
?>
" method="post" enctype="multipart/form-data">
<button id="<?php 
echo $genid;
?>
buttonAddWork" type="button" class="submit" onclick="addWork('<?php 
echo $genid;
?>
')"><?php 
echo lang('add work');
?>
</button>

<div id="<?php 
echo $genid;
コード例 #13
0
 function add_timespan()
 {
     if (!can_manage_time(logged_user(), true)) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $object_id = get_id('object_id');
     $object_manager = array_var($_GET, 'object_manager');
     if (!is_valid_function_name($object_manager)) {
         flash_error(lang('invalid request'));
         ajx_current("empty");
         return;
     }
     // if
     $object = get_object_by_manager_and_id($object_id, $object_manager);
     if (!$object instanceof ProjectDataObject || !$object->canAddTimeslot(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $timeslot_data = array_var($_POST, 'timeslot');
     $hours = array_var($timeslot_data, 'time');
     if (strpos($hours, ',') && !strpos($hours, '.')) {
         $hours = str_replace(',', '.', $hours);
     }
     $timeslot = new Timeslot();
     $dt = DateTimeValueLib::now();
     $dt2 = DateTimeValueLib::now();
     $timeslot->setEndTime($dt);
     $dt2 = $dt2->add('h', -$hours);
     $timeslot->setStartTime($dt2);
     $timeslot->setDescription(array_var($timeslot_data, 'description'));
     $timeslot->setUserId(logged_user()->getId());
     $timeslot->setObjectManager($object_manager);
     $timeslot->setObjectId($object_id);
     /* Billing */
     $billing_category_id = logged_user()->getDefaultBillingId();
     $project = $object->getProject();
     $timeslot->setBillingId($billing_category_id);
     $hourly_billing = $project->getBillingAmount($billing_category_id);
     $timeslot->setHourlyBilling($hourly_billing);
     $timeslot->setFixedBilling($hourly_billing * $hours);
     $timeslot->setIsFixedBilling(false);
     try {
         DB::beginWork();
         $timeslot->save();
         ApplicationLogs::createLog($timeslot, $timeslot->getWorkspaces(), ApplicationLogs::ACTION_OPEN);
         DB::commit();
         flash_success(lang('success create timeslot'));
         ajx_current("reload");
     } catch (Exception $e) {
         DB::rollback();
         ajx_current("empty");
         flash_error($e->getMessage());
     }
     // try
 }
コード例 #14
0
<?php $genid = gen_id(); ?>
<table><tr><td style="padding-right:15px" id="<?php echo $genid?>tdstartwork">
<form class="internalForm" action="<?php echo Timeslot::getOpenUrl($timeslot_form_object) ?>" method="post" enctype="multipart/form-data">
<?php echo submit_button(lang('start work')) ?>
</form>
</td><td>
<form class="internalForm" action="<?php echo Timeslot::getAddTimespanUrl($timeslot_form_object) ?>" method="post" enctype="multipart/form-data">
<button id="<?php echo $genid?>buttonAddWork" type="button" class="submit" onclick="addWork('<?php echo $genid?>')"><?php echo lang('add work') ?></button>

<div id="<?php echo $genid?>addwork" style="display:none;">

<div style="float:left;margin-left:10px;">
<?php
	if (can_manage_time(logged_user())) {
		echo label_tag(lang("person"), $genid . "closeTimeslotDescription", false);
		
		if (logged_user()->isMemberOfOwnerCompany()) {
			$users = Contacts::getAllUsers();
		} else {
			$users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = ". logged_user()->getCompanyId()) : array(logged_user());
		}
		$tmp_users = array();
		foreach ($users as $user) {
			$is_assigned = ($timeslot_form_object instanceof ProjectTask && $timeslot_form_object->getAssignedToContactId() == $user->getId());
			if ($is_assigned || can_add($user, active_context(), Timeslots::instance()->getObjectTypeId())) {
				$tmp_users[] = $user;
			}
		}
		$users = $tmp_users;
		
		$user_options = array();