/** * Show and process edit milestone form * * @access public * @param void * @return null */ function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_milestone'); if (array_var($_REQUEST, "template_milestone")) { $milestone = TemplateMilestones::findById(get_id()); $this->setTemplate(get_template_path('add_template_milestone', 'template_milestone')); if (!$milestone instanceof TemplateMilestone) { flash_error(lang('milestone dnx')); ajx_current("empty"); return; } // if } else { $milestone = ProjectMilestones::findById(get_id()); if (!$milestone instanceof ProjectMilestone) { flash_error(lang('milestone dnx')); ajx_current("empty"); return; } // if } if (!$milestone->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $milestone_data = array_var($_POST, 'milestone'); if (!is_array($milestone_data)) { // set layout for modal form if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); tpl_assign('modal', true); } $milestone_data = array('name' => $milestone->getObjectName(), 'due_date' => $milestone->getDueDate(), 'description' => $milestone->getDescription(), 'is_urgent' => $milestone->getIsUrgent()); // array } // if tpl_assign('milestone_data', $milestone_data); tpl_assign('milestone', $milestone); if (is_array(array_var($_POST, 'milestone'))) { if (array_var($milestone_data, 'due_date_value') != '') { $milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value')); } else { $now = DateTimeValueLib::now(); $milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), $now->getDay(), $now->getYear()); } $milestone->setFromAttributes($milestone_data); $urgent = array_var($milestone_data, 'is_urgent'); $milestone->setIsUrgent($urgent); try { $member_ids = json_decode(array_var($_POST, 'members')); DB::beginWork(); $milestone->save(); $object_controller = new ObjectController(); $object_controller->add_to_members($milestone, $member_ids); $object_controller->add_subscribers($milestone); $object_controller->link_to_new_object($milestone); $object_controller->add_custom_properties($milestone); $object_controller->add_reminders($milestone); DB::commit(); ApplicationLogs::createLog($milestone, ApplicationLogs::ACTION_EDIT); //Send Template milestone to view if ($milestone instanceof TemplateMilestone) { $object = array("action" => "edit", "object_id" => $milestone->getObjectId(), "type" => $milestone->getObjectTypeName(), "id" => $milestone->getId(), "name" => $milestone->getObjectName(), "ico" => "ico-milestone", "manager" => get_class($milestone->manager())); evt_add("template object added", array('object' => $object)); } $is_template = $milestone instanceof TemplateMilestone; if (array_var($_REQUEST, 'modal')) { ajx_current("empty"); $this->setLayout("json"); $this->setTemplate(get_template_path("empty")); // reload milestone info because plugins may have updated some task info (for example: name prefix) if ($is_template) { $milestone = TemplateMilestones::findById($milestone->getId()); $params = array('msg' => lang('success edit milestone', $milestone->getObjectName()), 'milestone' => $milestone->getArrayInfo(), 'reload' => array_var($_REQUEST, 'reload')); if ($milestone instanceof TemplateMilestone) { $params = $object; } print_modal_json_response($params, true, array_var($_REQUEST, 'use_ajx')); } else { $milestone = ProjectMilestones::findById($milestone->getId()); flash_success(lang('success edit milestone', $milestone->getObjectName())); evt_add("reload current panel"); } } else { if ($milestone instanceof TemplateMilestone) { flash_success(lang('success edit template', $milestone->getObjectName())); } else { flash_success(lang('success edit milestone', $milestone->getObjectName())); } if (array_var($task_data, 'inputtype') != 'taskview') { ajx_current("back"); } else { ajx_current("reload"); } } /* flash_success(lang('success edit milestone', $milestone->getObjectName())); if (array_var($_REQUEST, 'modal')) { evt_add("reload current panel"); } ajx_current("back");*/ } catch (Exception $e) { DB::rollback(); if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); $this->setTemplate(get_template_path("empty")); print_modal_json_response(array('errorCode' => 1, 'errorMessage' => $e->getMessage())); } else { flash_error($e->getMessage()); } ajx_current("empty"); } // try } // if }
function saveMember($member_data, Member $member, $is_new = true) { try { DB::beginWork(); if (!$is_new) { $old_parent = $member->getParentMemberId(); } $member->setFromAttributes($member_data); /* @var $member Member */ $object_type = ObjectTypes::findById($member->getObjectTypeId()); if (!$object_type instanceof ObjectType) { throw new Exception(lang("you must select a valid object type")); } if ($member->getParentMemberId() == 0) { $dot = DimensionObjectTypes::findById(array('dimension_id' => $member->getDimensionId(), 'object_type_id' => $member->getObjectTypeId())); if (!$dot->getIsRoot()) { throw new Exception(lang("member cannot be root", lang($object_type->getName()))); } $member->setDepth(1); } else { $allowedParents = $this->getAssignableParents($member->getDimensionId(), $member->getObjectTypeId()); if (!$is_new) { $childrenIds = $member->getAllChildrenIds(true); } $hasValidParent = false; if ($member->getId() == $member->getParentMemberId() || !$is_new && in_array($member->getParentMemberId(), $childrenIds)) { throw new Exception(lang("invalid parent member")); } foreach ($allowedParents as $parent) { if ($parent['id'] == $member->getParentMemberId()) { $hasValidParent = true; break; } } if (!$hasValidParent) { throw new Exception(lang("invalid parent member")); } $parent = Members::findById($member->getParentMemberId()); if ($parent instanceof Member) { $member->setDepth($parent->getDepth() + 1); } else { $member->setDepth(1); } } if ($object_type->getType() == 'dimension_object') { $handler_class = $object_type->getHandlerClass(); if ($is_new || $member->getObjectId() == 0) { eval('$dimension_object = ' . $handler_class . '::instance()->newDimensionObject();'); } else { $dimension_object = Objects::findObject($member->getObjectId()); } if ($dimension_object) { $dimension_object->modifyMemberValidations($member); $dimension_obj_data = array_var($_POST, 'dim_obj'); if (!array_var($dimension_obj_data, 'name')) { $dimension_obj_data['name'] = $member->getName(); } eval('$fields = ' . $handler_class . '::getPublicColumns();'); foreach ($fields as $field) { if (array_var($field, 'type') == DATA_TYPE_DATETIME) { $dimension_obj_data[$field['col']] = getDateValue($dimension_obj_data[$field['col']]); } } $member->save(); $dimension_object->setFromAttributes($dimension_obj_data, $member); $dimension_object->save(); $member->setObjectId($dimension_object->getId()); $member->save(); Hook::fire("after_add_dimension_object_member", $member, $null); } } else { $member->save(); } // Other dimensions member restrictions $restricted_members = array_var($_POST, 'restricted_members'); if (is_array($restricted_members)) { MemberRestrictions::clearRestrictions($member->getId()); foreach ($restricted_members as $dim_id => $dim_members) { foreach ($dim_members as $mem_id => $member_restrictions) { $restricted = isset($member_restrictions['restricted']); if ($restricted) { $order_num = array_var($member_restrictions, 'order_num', 0); $member_restriction = new MemberRestriction(); $member_restriction->setMemberId($member->getId()); $member_restriction->setRestrictedMemberId($mem_id); $member_restriction->setOrder($order_num); $member_restriction->save(); } } } } // Save member property members (also check for required associations) if (array_var($_POST, 'save_properties')) { $required_association_ids = DimensionMemberAssociations::getRequiredAssociatations($member->getDimensionId(), $member->getObjectTypeId(), true); $missing_req_association_ids = array_fill_keys($required_association_ids, true); // if keeps record change is_active, if not delete record $old_properties = MemberPropertyMembers::getAssociatedPropertiesForMember($member->getId()); foreach ($old_properties as $property) { $association = DimensionMemberAssociations::findById($property->getAssociationId()); if (!$association->getKeepsRecord()) { $property->delete(); } } $new_properties = array(); $associated_members = array_var($_POST, 'associated_members', array()); foreach ($associated_members as $prop_member_id => $assoc_id) { $active_association = null; if (isset($missing_req_association_ids[$assoc_id])) { $missing_req_association_ids[$assoc_id] = false; } $conditions = "`association_id` = {$assoc_id} AND `member_id` = " . $member->getId() . " AND `is_active` = 1"; $active_associations = MemberPropertyMembers::find(array('conditions' => $conditions)); if (count($active_associations) > 0) { $active_association = $active_associations[0]; } $association = DimensionMemberAssociations::findById($assoc_id); if ($active_association instanceof MemberPropertyMember) { if ($active_association->getPropertyMemberId() != $prop_member_id) { if ($association->getKeepsRecord()) { $active_association->setIsActive(false); $active_association->save(); } // save current association $mpm = new MemberPropertyMember(); $mpm->setAssociationId($assoc_id); $mpm->setMemberId($member->getId()); $mpm->setPropertyMemberId($prop_member_id); $mpm->setIsActive(true); $mpm->save(); $new_properties[] = $mpm; } } else { // save current association $mpm = new MemberPropertyMember(); $mpm->setAssociationId($assoc_id); $mpm->setMemberId($member->getId()); $mpm->setPropertyMemberId($prop_member_id); $mpm->setIsActive(true); $mpm->save(); $new_properties[] = $mpm; } } $missing_names = array(); $missing_count = 0; foreach ($missing_req_association_ids as $assoc => $missing) { $assoc_instance = DimensionMemberAssociations::findById($assoc); if ($assoc_instance instanceof DimensionMemberAssociation) { $assoc_dim = Dimensions::getDimensionById($assoc_instance->getAssociatedDimensionMemberAssociationId()); if ($assoc_dim instanceof Dimension) { if (!in_array($assoc_dim->getName(), $missing_names)) { $missing_names[] = $assoc_dim->getName(); } } } if ($missing) { $missing_count++; } } if ($missing_count > 0) { throw new Exception(lang("missing required associations", implode(", ", $missing_names))); } $args = array($member, $old_properties, $new_properties); Hook::fire('edit_member_properties', $args, $ret); } if ($is_new) { // set all permissions for the creator $dimension = $member->getDimension(); $allowed_object_types = array(); $dim_obj_types = $dimension->getAllowedObjectTypeContents(); foreach ($dim_obj_types as $dim_obj_type) { // To draw a row for each object type of the dimension if (!in_array($dim_obj_type->getContentObjectTypeId(), $allowed_object_types) && $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) { $allowed_object_types[] = $dim_obj_type->getContentObjectTypeId(); } } $allowed_object_types[] = $object_type->getId(); foreach ($allowed_object_types as $ot) { $cmp = ContactMemberPermissions::findOne(array('conditions' => 'permission_group_id = ' . logged_user()->getPermissionGroupId() . ' AND member_id = ' . $member->getId() . ' AND object_type_id = ' . $ot)); if (!$cmp instanceof ContactMemberPermission) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId(logged_user()->getPermissionGroupId()); $cmp->setMemberId($member->getId()); $cmp->setObjectTypeId($ot); } $cmp->setCanWrite(1); $cmp->setCanDelete(1); $cmp->save(); } // set all permissions for permission groups that has allow all in the dimension $permission_groups = ContactDimensionPermissions::findAll(array("conditions" => array("`dimension_id` = ? AND `permission_type` = 'allow all'", $dimension->getId()))); if (is_array($permission_groups)) { foreach ($permission_groups as $pg) { foreach ($allowed_object_types as $ot) { $cmp = ContactMemberPermissions::findById(array('permission_group_id' => $pg->getPermissionGroupId(), 'member_id' => $member->getId(), 'object_type_id' => $ot)); if (!$cmp instanceof ContactMemberPermission) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId($pg->getPermissionGroupId()); $cmp->setMemberId($member->getId()); $cmp->setObjectTypeId($ot); } $cmp->setCanWrite(1); $cmp->setCanDelete(1); $cmp->save(); } } } // Inherit permissions from parent node, if they are not already set if ($member->getDepth() && $member->getParentMember()) { $parentNodeId = $member->getParentMember()->getId(); $condition = "member_id = {$parentNodeId}"; foreach (ContactMemberPermissions::instance()->findAll(array("conditions" => $condition)) as $parentPermission) { /* @var $parentPermission ContactMemberPermission */ $g = $parentPermission->getPermissionGroupId(); $t = $parentPermission->getObjectTypeId(); $w = $parentPermission->getCanWrite(); $d = $parentPermission->getCanDelete(); $existsCondition = "member_id = " . $member->getId() . " AND permission_group_id= {$g} AND object_type_id = {$t}"; if (!ContactMemberPermissions::instance()->count(array("conditions" => $existsCondition))) { $newPermission = new ContactMemberPermission(); $newPermission->setPermissionGroupId($g); $newPermission->setObjectTypeId($t); $newPermission->setCanWrite($w); $newPermission->setCanDelete($d); $newPermission->setMemberId($member->getId()); $newPermission->save(); } } } // Fill sharing table if is a dimension object (after permission creation); if (isset($dimension_object) && $dimension_object instanceof ContentDataObject) { $dimension_object->addToSharingTable(); } } else { // if parent changed rebuild object_members for every object in this member if ($old_parent != $member->getParentMemberId()) { $sql = "SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om WHERE om.member_id=" . $member->getId(); $object_ids = DB::executeAll($sql); if (!is_array($object_ids)) { $object_ids = array(); } foreach ($object_ids as $row) { $content_object = Objects::findObject($row['object_id']); if (!$content_object instanceof ContentDataObject) { continue; } $parent_ids = array(); if ($old_parent > 0) { $all_parents = Members::findById($old_parent)->getAllParentMembersInHierarchy(true); foreach ($all_parents as $p) { $parent_ids[] = $p->getId(); } if (count($parent_ids) > 0) { DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id=" . $content_object->getId() . " AND member_id IN (" . implode(",", $parent_ids) . ")"); } } $content_object->addToMembers(array($member)); $content_object->addToSharingTable(); } } } DB::commit(); flash_success(lang('success save member', lang(ObjectTypes::findById($member->getObjectTypeId())->getName()), $member->getName())); ajx_current("back"); // Add od to array on new members if ($is_new) { $member_data['member_id'] = $member->getId(); } evt_add("after member save", $member_data); return $member; } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } }
$i = 1; $td_class = "table_row"; ?> <tr> <td width="4%" class="<?php echo $td_class; ?> "><?php echo $i; ?> )</td> <td width="19%" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsInvoice->invoice_date); ?> </td> <td width="32%" class="<?php echo $td_class; ?> "><?php echo $nameplan; ?> </td> <td width="15%" class="<?php echo $td_class; ?> _end">N$ <?php echo number_format($pp, 2); ?>
$msg .= "\n\t\t\t<table width='95%' cellpadding='6' cellspacing='0' class='table_black_border'>\n\t\t\t <tr>\n\t\t\t\t<td class='table_head'>Invoice ID </td>\n\t\t\t\t<td class='table_head'>Invoice Date</td>\n\t\t\t\t<td class='table_head'>"; if ($rsInvoice->invoice_type == 1) { $msg .= "Plan Name"; } else { if ($rsInvoice->invoice_type == 2) { $msg .= "Shortlisted Jobseeker"; } } $msg .= "</td>\n\t\t\t\t<td width='16%' class='table_head' "; if ($rsInvoice->invoice_type == 1) { $msg .= "style='display:none;'"; } $msg .= ">Rate Per Position</td>\n\t\t\t\t<td class='table_head'>Amount</td>\n\t\t\t\t\n\t\t\t </tr> "; $i = 1; $td_class = 'table_row'; $msg .= "\n\t\t\t <tr>\n\t\t\t\t<td width='11%' class=" . $td_class . ">" . sprintf('%05d', $rsInvoice->invoice_id) . "</td>\n\t\t\t\t<td width='11%' class=" . $td_class . ">" . getDateValue($rsInvoice->invoice_date) . "</td>\n\t\t\t\t<td width='21%' class=" . $td_class . ">"; if ($rsInvoice->invoice_type == 1) { $msg .= $rsInvoice->plan_name; } else { if ($rsInvoice->invoice_type == 2) { $msg .= $rsInvoice->shortlisted_jobseekers; } } $msg .= " </td>\n\t\t\t\t\n\t\t\t\t<td class='" . $td_class . "' "; if ($rsInvoice->invoice_type == 1) { $msg .= "style='display:none;'"; } $msg .= ">" . $rsInvoice->shortlist_rate_per_position . "</td>\n\t\t\t\t<td width='12%' class='" . $td_class . "'>N\$\n\t\t\t\t\t" . number_format($rsInvoice->rate, 2) . "</td>\n\t\t\t\t\n\t\t\t </tr>\n\t\t\t</table>"; } $msg .= "</html>"; $msg .= "<br><br>Regards, <br>NamRecruit";
function total_task_times_vs_estimate_comparison($report_data = null, $task = null) { $this->setTemplate('report_wrapper'); if (!$report_data) { $report_data = array_var($_POST, 'report'); } $workspace = Projects::findById(array_var($report_data, 'project_id')); if ($workspace instanceof Project) { if (array_var($report_data, 'include_subworkspaces')) { $workspacesCSV = $workspace->getAllSubWorkspacesQuery(false); } else { $workspacesCSV = $workspace->getId(); } } else { $workspacesCSV = null; } $start = getDateValue(array_var($report_data, 'start_value')); $end = getDateValue(array_var($report_data, 'end_value')); $st = $start->beginningOfDay(); $et = $end->endOfDay(); $st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600); $et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600); $timeslots = Timeslots::getTimeslotsByUserWorkspacesAndDate($st, $et, 'ProjectTasks', null, $workspacesCSV, array_var($report_data, 'task_id', 0)); tpl_assign('timeslots', $timeslots); tpl_assign('workspace', $workspace); tpl_assign('start_time', $st); tpl_assign('end_time', $et); tpl_assign('user', $user); tpl_assign('post', $report_data); tpl_assign('template_name', 'total_task_times'); tpl_assign('title', lang('task time report')); }
<tr align="left"> <td width="13%" class="<?php echo $td_class; ?> "><a href="#" onClick="chequeDetails(<?php echo $rsPaid->pay_id; ?> );" class="blue_title_small" title="Click to view cheque details."><?php echo $rsPaid->cheque_number; ?> </a></td> <td width="13%" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsPaid->pay_date); ?> </td> <td width="14%" class="<?php echo $td_class; ?> "><?php echo sprintf("%05d", $rsPaid->pay_id); ?> </td> <td width="12%" class="<?php echo $td_class; ?> "><a href="#" onClick="viewDetails('invoice_details.php?invoice_id=<?php echo $rsPaid->invoice_id; ?>
</tr> </table> <?php } else { if ($cntPlan > 0) { ?> <table width="100%" cellpadding="3" cellspacing="0"> <tr> <td width="16"> </td> <td width="754"> <br> The previous plan of this recruiter was <span class="subhead_gray_small"><u><?php echo $plan_name; ?> </u></span> and expiry date of this plan was <span class="subhead_gray_small"><u><?php echo getDateValue($expire_date); ?> </u></span>. <br> <br> </td> </tr> </table> <?php } else { if ($cntPlan == 0) { ?> <table width="100%" cellpadding="3" cellspacing="0"> <tr> <td width="16"> </td> <td width="754"> <br>
function edit_timeslot() { ajx_current("empty"); $timeslot_data = array_var($_POST, 'timeslot'); $timeslot = Timeslots::findById(array_var($timeslot_data, 'id', 0)); if (!$timeslot instanceof Timeslot) { flash_error(lang('timeslot dnx')); return; } //context permissions or members $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; } } 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']; //Only admins can change timeslot user if (!array_var($timeslot_data, 'contact_id') && !logged_user()->isAdministrator()) { $timeslot_data['contact_id'] = $timeslot->getContactId(); } $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 = 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_EDIT); ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo())); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); } // try }
$i = 1; $td_class = "table_row"; ?> <tr> <td width="4%" class="<?php echo $td_class; ?> "><?php echo $i; ?> )</td> <td width="16%" align="left" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsPay->cheque_date); ?> </td> <td width="15%" align="left" class="<?php echo $td_class; ?> "><?php echo $rsPay->ref; ?> </td> <td width="21%" align="left" class="<?php echo $td_class; ?> "><?php echo $rsPay->bank; ?>
private function save_object($request) { $response = false; if (!empty($request ['args'])) { $service = $request ['srv']; switch ($service) { case "task" : if ($request ['args'] ['id']) { $object = ProjectTasks::instance()->findByid($request ['args'] ['id']); } else { $object = new ProjectTask (); } if ($object instanceof ProjectTask) { if (!empty($request ['args'] ['title'])) { $object->setObjectName($request ['args'] ['title']); } if (!empty($request ['args'] ['description'])) { $object->setText($request ['args'] ['description']); } if (!empty($request ['args'] ['due_date'])) { $object->setDueDate(getDateValue($request ['args'] ['due_date'])); } if (!empty($request ['args'] ['completed'])) { $object->setPercentCompleted($request ['args'] ['completed']); } if (!empty($request ['args'] ['assign_to'])) { $object->setAssignedToContactId($request ['args'] ['assign_to']); } if (!empty($request ['args'] ['priority'])) { $object->setPriority($request ['args'] ['priority']); } } break; case 'note' : if ($request ['args'] ['id']) { $object = ProjectMessages::instance()->findByid($request ['args'] ['id']); } else { $object = new ProjectMessage(); } if ($object instanceof ProjectMessage) { if (!empty($request ['args'] ['title'])) { $object->setObjectName($request ['args'] ['title']); } if (!empty($request ['args'] ['title'])) { $object->setText($request ['args'] ['text']); } } break; }// END SWITCH if ($object) { try { $context = array(); $members = array(); if (!empty($request['args']['members'])) { $members = $request['args']['members']; $context = get_context_from_array($members); } //Check permissions: if ($request['args']['id'] && $object->canEdit(logged_user()) || !$request['args']['id'] && $object->canAdd(logged_user(), $context)) { DB::beginWork(); $object->save(); $object_controller = new ObjectController (); if (!$request['args']['id']) { $object_controller->add_to_members($object, $members); } DB::commit(); $response = true; } } catch (Exception $e) { DB::rollback(); return false; } } } return $this->response('json', $response); }
"><?php echo $rsComp->comp_name; ?> </td> <td width="16%" class="<?php echo $td_class; ?> "><?php echo $rsSeeker->town; ?> </td> <td width="16%" class="<?php echo $td_class; ?> _end"><?php echo getDateValue($rsSeeker->ad_date, 3); ?> </td> </tr> <?php $i++; } ?> </table> <?php } ?> </td> </tr> <tr align="center"> <td valign="middle" height="10"></td>
" ><?php echo $period; ?> </td> <td width="16%" class="<?php echo $td_class; ?> " ><?php echo getDateValue($rstemp->{$seeker_period_from}); ?> </td> <td width="18%" class="<?php echo $td_class; ?> " ><?php echo getDateValue($rstemp->{$seeker_period_to}); ?> </td> <td class="<?php echo $td_class; ?> _end" ><?php echo $rstemp->{$seeker_period_reason}; ?> </td> </tr> <?php $j++; } ?> </table></td>
"><input type="checkbox" name="chk[]" id= "chk" value="<?php echo $rsRec->rec_id; ?> "></td> <td class="<?php echo $td_class; ?> "><?php echo $rsRec->rec_uid; ?> </td> <td width="8%" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsRec->rec_reg_date); ?> </td> <td width="11%" class="<?php echo $td_class; ?> "><?php echo $rsRec->comp_name; ?> </td> <td width="10%" class="<?php echo $td_class; ?> "><?php echo $rsRec->rec_name; ?>
$subject = "Login information of namrecruit.com"; $msg = "Dear " . $rsRec->rec_name . ",<br><br>"; $msg .= "Thank you for registering with NamRecruit. <br><br>"; $msg .= "Use following information to login namrecruit.com.<br>"; $msg .= "Username : "******"<br>Password : "******"<br><br>Regards, <br>NamRecruit."; $from = "NamRecruit <*****@*****.**>"; $headers = "From: {$from}\nContent-Type: text/html; charset=iso-8859-1"; @mail($emailto, $subject, $msg, $headers); } $sqlPay = "select * from job_rec_payments where pay_id=" . $_GET["pid"]; $resultPay = mysql_query($sqlPay); $rsPay = mysql_fetch_object($resultPay); $invoice_no = sprintf("%05d", $_GET["Iid"]); $pay_date = getDateValue($rsPay->pay_date); $msg = ""; $emailto = $rsRec->rec_email; $subject = "Payment Recieved (Invoice No. " . $invoice_no . ")"; $msg = "Dear " . $rsRec->rec_name . ",<br><br>"; $msg .= "Your payment to namrecruit.com for invoice no <u>" . $invoice_no . "</u> was successful. Your account has been updated.<br><br><b>Payment Details : </b><br>"; $msg .= "Payment Date : " . $pay_date . "<br>"; $msg .= "Paid Amount : N\$ " . number_format($rsPay->pay_amount, 2); $msg .= "<br><br>To view/print your invoice details, <a href='http://www.namrecruit.com/recruiter/view_invoice.php?paid_by=" . $rsPay->paid_by . "&vi=" . base64_encode($invoice_no) . "'>click here</a>."; $msg .= "<br><br>Regards, <br>NamRecruit."; $from = "NamRecruit <*****@*****.**>"; $headers = "From: {$from}\nContent-Type: text/html; charset=iso-8859-1"; @mail($emailto, $subject, $msg, $headers); if ($rsComp->type == "rec") { $array_comp["comp_type"] = "2"; } else {
function icalendar_export() { $this->setTemplate('cal_export'); $calendar_name = array_var($_POST, 'calendar_name'); if ($calendar_name != '') { $from = getDateValue(array_var($_POST, 'from_date')); $to = getDateValue(array_var($_POST, 'to_date')); $events = ProjectEvents::getRangeProjectEvents($from, $to); $buffer = CalFormatUtilities::generateICalInfo($events, $calendar_name); $filename = rand().'.tmp'; $handle = fopen(ROOT.'/tmp/'.$filename, 'wb'); fwrite($handle, $buffer); fclose($handle); $_SESSION['calendar_export_filename'] = $filename; $_SESSION['calendar_name'] = $calendar_name; flash_success(lang('success export calendar', count($events))); ajx_current("empty"); } else { unset($_SESSION['calendar_export_filename']); unset($_SESSION['calendar_name']); return; } }
"></td> <td width="12%" align="left" class="<?php echo $td_class; ?> "><a href="#" onClick="chequeDetails(<?php echo $rsPaid->pay_id; ?> );" class="blue_title_small" title="Click to view cheque details."><?php echo $rsPaid->cheque_number; ?> </a></td> <td width="13%" align="left" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsPaid->received_date); ?> </td> <td width="14%" align="left" class="<?php echo $td_class; ?> "><?php echo sprintf("%05d", $rsPaid->pay_id); ?> </td> <td width="12%" align="left" class="<?php echo $td_class; ?> "><a href="#" onClick="viewDetails('invoice_details.php?invoice_id=<?php echo $rsPaid->invoice_id; ?>
/** * Edit timeslot * * @param void * @return null */ function edit() { $this->setTemplate('add_timeslot'); $timeslot = Timeslots::findById(get_id()); if (!$timeslot instanceof Timeslot) { flash_error(lang('timeslot dnx')); ajx_current("empty"); return; } $object = $timeslot->getRelObject(); if (!$object instanceof ContentDataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } if (!$object->canAddTimeslot(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } if (!$timeslot->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $timeslot_data = array_var($_POST, 'timeslot'); if (!is_array($timeslot_data)) { $timeslot_data = array('contact_id' => $timeslot->getContactId(), 'description' => $timeslot->getDescription(), 'start_time' => $timeslot->getStartTime(), 'end_time' => $timeslot->getEndTime(), 'is_fixed_billing' => $timeslot->getIsFixedBilling(), 'hourly_billing' => $timeslot->getHourlyBilling(), 'fixed_billing' => $timeslot->getFixedBilling()); } tpl_assign('timeslot_form_object', $object); tpl_assign('timeslot', $timeslot); tpl_assign('timeslot_data', $timeslot_data); tpl_assign('show_billing', BillingCategories::count() > 0); if (is_array(array_var($_POST, 'timeslot'))) { try { $this->percent_complete_delete($timeslot); $timeslot->setContactId(array_var($timeslot_data, 'contact_id', logged_user()->getId())); $timeslot->setDescription(array_var($timeslot_data, 'description')); $st = getDateValue(array_var($timeslot_data, 'start_value'), DateTimeValueLib::now()); $st->setHour(array_var($timeslot_data, 'start_hour')); $st->setMinute(array_var($timeslot_data, 'start_minute')); $et = getDateValue(array_var($timeslot_data, 'end_value'), DateTimeValueLib::now()); $et->setHour(array_var($timeslot_data, 'end_hour')); $et->setMinute(array_var($timeslot_data, 'end_minute')); $st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600); $et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600); $timeslot->setStartTime($st); $timeslot->setEndTime($et); if ($timeslot->getStartTime() > $timeslot->getEndTime()) { flash_error(lang('error start time after end time')); ajx_current("empty"); return; } $seconds = array_var($timeslot_data, 'subtract_seconds', 0); $minutes = array_var($timeslot_data, 'subtract_minutes', 0); $hours = array_var($timeslot_data, 'subtract_hours', 0); $subtract = $seconds + 60 * $minutes + 3600 * $hours; if ($subtract < 0) { flash_error(lang('pause time cannot be negative')); ajx_current("empty"); return; } $testEndTime = new DateTimeValue($timeslot->getEndTime()->getTimestamp()); $testEndTime->add('s', -$subtract); if ($timeslot->getStartTime() > $testEndTime) { flash_error(lang('pause time cannot exceed timeslot time')); ajx_current("empty"); return; } $timeslot->setSubtract($subtract); if ($timeslot->getUser()->getDefaultBillingId()) { $timeslot->setIsFixedBilling(array_var($timeslot_data, 'is_fixed_billing', false)); $timeslot->setHourlyBilling(array_var($timeslot_data, 'hourly_billing', 0)); if ($timeslot->getIsFixedBilling()) { $timeslot->setFixedBilling(array_var($timeslot_data, 'fixed_billing', 0)); } else { $timeslot->setFixedBilling($timeslot->getHourlyBilling() * $timeslot->getMinutes() / 60); } if ($timeslot->getBillingId() == 0 && ($timeslot->getHourlyBilling() > 0 || $timeslot->getFixedBilling() > 0)) { $timeslot->setBillingId($timeslot->getUser()->getDefaultBillingId()); } } DB::beginWork(); $timeslot->save(); $timeslot_time = ($timeslot->getEndTime()->getTimestamp() - ($timeslot->getStartTime()->getTimestamp() + $timeslot->getSubtract())) / 3600; $task = ProjectTasks::findById($timeslot->getRelObjectId()); if ($task->getTimeEstimate() > 0) { $timeslot_percent = round($timeslot_time * 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 edit timeslot')); ajx_current("back"); } catch (Exception $e) { DB::rollback(); Logger::log($e->getTraceAsString()); flash_error(lang('error edit timeslot') . ": " . $e->getMessage()); ajx_current("empty"); } } }
if ($rsTotalPay = mysql_fetch_object($resultTotalPay)) { $paid = $rsTotalPay->pay_sum; } } //for payment $email = "NamRecruit"; $emailto = $rsRec->rec_email; $subject = "Your cheque is bounced."; $msg = "<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t<style type='text/css'>\n\t\t\t\t\t\t\t\t\t.table_black_border\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tborder: 1px solid #000000;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\t\t.table_head\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tfont-weight:bold;\n\t\t\t\t\t\t\t\t\tbackground-color:#DDDAD9;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\tborder:1px;\n\t\t\t\t\t\t\t\t\tborder-style:none solid solid none; \n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.table_head_end\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tfont-weight:bold;\n\t\t\t\t\t\t\t\t\tbackground-color:#DDDAD9;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\tborder:1px;\n\t\t\t\t\t\t\t\t\tborder-style:none none solid none; \n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.table_row\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\tborder:1px;\n\t\t\t\t\t\t\t\t\tborder-style:none solid none none; \n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.table_row_end\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.table_alternate_row\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tbackground-color:#E6E6E6;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\tborder:1px;\n\t\t\t\t\t\t\t\t\tborder-style:none solid none none; \n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.table_alternate_row_end\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfont-family:Arial, Helvetica, sans-serif;\n\t\t\t\t\t\t\t\t\tfont-size:12px;\n\t\t\t\t\t\t\t\t\tbackground-color:#E6E6E6;\n\t\t\t\t\t\t\t\t\tcolor: #333333;\n\t\t\t\t\t\t\t\t\ttext-decoration:none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t</head>"; $msg .= "Dear " . $rsRec->rec_name . ",<br><br>"; $msg .= "Your cheque is bounced.<br><br>"; //for cheque $msg .= "Your cheque details are shown below :<br><br>"; $msg .= "\n\t\t\t\t\t<table width='95%' cellpadding='6' cellspacing='0' class='table_black_border'>\n\t\t\t\t\t <tr>\n\t\t\t\t\t\t<td class='table_head'>Cheque Number</td>\n\t\t\t\t\t\t<td class='table_head'>Cheque Date</td>\n\t\t\t\t\t\t<td class='table_head'>Bank Name</td>\n\t\t\t\t\t\t<td class='table_head'>Branch</td>\n\t\t\t\t\t\t<td class='table_head_end'>Cheque Amount</td>\n\t\t\t\t\t\t\n\t\t\t\t\t </tr> "; $td_class = 'table_row'; $msg .= "\n\t\t\t\t\t <tr>\n\t\t\t\t\t\t<td width='11%' class=" . $td_class . ">" . $rsCheque->cheque_number . "</td>\n\t\t\t\t\t\t<td width='11%' class=" . $td_class . ">" . getDateValue($rsCheque->cheque_date) . "</td>\n\t\t\t\t\t\t<td width='11%' class=" . $td_class . ">" . $rsCheque->bank . "</td>\n\t\t\t\t\t\t<td width='11%' class=" . $td_class . ">" . $rsCheque->branch . "</td>\n\t\t\t\t\t\t<td width='11%' class=" . $td_class . "_end>N\$" . $rsCheque->pay_amount . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</table><br>"; //end for cheque $msg .= "<br><b>Please send us another cheque as soon as possible.</b>"; $msg .= "<br><br>Regards, <br>NamRecruit"; $from = "NamRecruit <*****@*****.**>"; $headers = "From: {$from}\nContent-Type: text/html; charset=iso-8859-1"; @mail($emailto, $subject, $msg, $headers); } } } } } } if (isset($_GET["link"]) && $_GET["link"] == "new") { header("location:cheque_list.php?msg=edit"); } else {
/** * Show and process edit milestone form * * @access public * @param void * @return null */ function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_milestone'); $milestone = ProjectMilestones::findById(get_id()); if (!$milestone instanceof ProjectMilestone) { flash_error(lang('milestone dnx')); ajx_current("empty"); return; } // if if (!$milestone->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $milestone_data = array_var($_POST, 'milestone'); if (!is_array($milestone_data)) { $tag_names = $milestone->getTagNames(); $milestone_data = array('name' => $milestone->getName(), 'due_date' => $milestone->getDueDate(), 'description' => $milestone->getDescription(), 'assigned_to' => $milestone->getAssignedToCompanyId() . ':' . $milestone->getAssignedToUserId(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $milestone->isPrivate(), 'is_urgent' => $milestone->getIsUrgent()); // array } // if tpl_assign('milestone_data', $milestone_data); tpl_assign('milestone', $milestone); if (is_array(array_var($_POST, 'milestone'))) { if (array_var($milestone_data, 'due_date_value') != '') { $milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value')); } else { $now = DateTimeValueLib::now(); $milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), $now->getDay(), $now->getYear()); } $old_owner = $milestone->getAssignedTo(); // remember the old owner $assigned_to = explode(':', array_var($milestone_data, 'assigned_to', '')); $old_is_private = $milestone->isPrivate(); $milestone->setFromAttributes($milestone_data); $urgent = array_var($milestone_data, 'is_urgent') == 'checked'; $milestone->setIsUrgent($urgent); if (!logged_user()->isMemberOfOwnerCompany()) { $milestone->setIsPrivate($old_is_private); } $old_project_id = $milestone->getProjectId(); $project_id = array_var($_POST, 'ws_ids'); if ($old_project_id != $project_id) { $newProject = Projects::findById($project_id); if (!$milestone->canAdd(logged_user(), $newProject)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $milestone->move_inconsistent_tasks($newProject); } $milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0)); $milestone->setAssignedToUserId(array_var($assigned_to, 1, 0)); try { DB::beginWork(); $milestone->save(); $milestone->setTagsFromCSV(array_var($milestone_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($milestone); $object_controller->link_to_new_object($milestone); $object_controller->add_subscribers($milestone); $object_controller->add_custom_properties($milestone); $object_controller->add_reminders($milestone); ApplicationLogs::createLog($milestone, $milestone->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); // If owner is changed send notification but don't break submission try { $new_owner = $milestone->getAssignedTo(); if (array_var($milestone_data, 'send_notification') == 'checked') { if ($old_owner instanceof User) { // We have a new owner and it is different than old owner if ($new_owner instanceof User && $new_owner->getId() != $old_owner->getId()) { Notifier::milestoneAssigned($milestone); } } else { // We have new owner if ($new_owner instanceof User) { Notifier::milestoneAssigned($milestone); } } // if } // if } catch (Exception $e) { } // try flash_success(lang('success edit milestone', $milestone->getName())); ajx_current("back"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
/** * Edit specific contact * * @access public * @param void * @return null */ function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('edit_contact'); $contact = Contacts::findById(get_id()); if (!$contact instanceof Contact) { flash_error(lang('contact dnx')); ajx_current("empty"); return; } // if if (!$contact->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $im_types = ImTypes::findAll(array('order' => '`id`')); // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); tpl_assign('all_telephone_types', $all_telephone_types); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); tpl_assign('all_address_types', $all_address_types); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); tpl_assign('all_webpage_types', $all_webpage_types); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); tpl_assign('all_email_types', $all_email_types); $contact_data = array_var($_POST, 'contact'); // Populate form fields if (!is_array($contact_data)) { // set layout for modal form if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); tpl_assign('modal', true); } $contact_data = $this->get_contact_data_from_contact($contact); if ($contact->isUser()) { $_REQUEST['is_user'] = 1; tpl_assign('user_type', $contact->getUserType()); } if (is_array($im_types)) { foreach ($im_types as $im_type) { $contact_data['im_' . $im_type->getId()] = $contact->getImValue($im_type); } // foreach } // if $null = null; Hook::fire('before_edit_contact_form', array('object' => $contact), $null); } // if tpl_assign('isEdit', array_var($_GET, 'isEdit', false)); tpl_assign('contact', $contact); tpl_assign('contact_data', $contact_data); tpl_assign('im_types', $im_types); tpl_assign('active_tab', array_var($_REQUEST, 'active_tab')); //Contact Submit if (is_array(array_var($_POST, 'contact'))) { foreach ($contact_data as $k => &$v) { $v = remove_scripts($v); } try { DB::beginWork(); $contact_data['email'] = trim($contact_data['email']); $contact_data['contact_type'] = 'contact'; Contacts::validate($contact_data, get_id()); $newCompany = false; if (array_var($contact_data, 'isNewCompany') == 'true' && is_array(array_var($_POST, 'company'))) { $company_data = array_var($_POST, 'company'); $company_data['contact_type'] = 'company'; Contacts::validate($company_data); $company = new Contact(); $company->setFromAttributes($company_data); $company->setIsCompany(true); $company->setObjectName(); $company->save(); // save phones, addresses and webpages $this->save_phones_addresses_webpages($company_data, $company); if ($company_data['email'] != "") { $company->addEmail($company_data['email'], 'work', true); } $newCompany = true; } $contact_data['birthday'] = getDateValue($contact_data["birthday"]); if (isset($contact_data['specify_username'])) { if ($contact_data['user']['username'] != "") { $contact_data['name'] = $contact_data['user']['username']; } else { $contact_data['name'] = $contact_data['first_name'] . " " . $contact_data['surname']; } } else { $contact_data['name'] = $contact_data['first_name'] . " " . $contact_data['surname']; } $user_data = array_var($_POST, 'user'); if (is_array($user_data) && trim(array_var($user_data, 'username', '')) != "") { $contact_data['username'] = trim(array_var($user_data, 'username', '')); } $contact->setFromAttributes($contact_data); if ($newCompany) { $contact->setCompanyId($company->getId()); } $contact->setObjectName(); $contact->save(); // save phones, addresses and webpages $this->save_phones_addresses_webpages($contact_data, $contact); //Emails $personal_email_type_id = EmailTypes::getEmailTypeId('personal'); $main_emails = $contact->getMainEmails(); $more_main_emails = array(); $main_mail = null; foreach ($main_emails as $me) { if ($main_mail == null) { $main_mail = $me; } else { $more_main_emails[] = $me; } } if ($main_mail) { $main_mail->editEmailAddress($contact_data['email']); } else { if ($contact_data['email'] != "") { $contact->addEmail($contact_data['email'], 'personal', true); } } foreach ($more_main_emails as $mme) { $mme->setIsMain(false); $mme->save(); } // save additional emails $this->save_non_main_emails($contact_data, $contact); // autodetect timezone $autotimezone = array_var($contact_data, 'autodetect_time_zone', null); if ($autotimezone !== null) { set_user_config_option('autodetect_time_zone', $autotimezone, $contact->getId()); } // IM values $contact->clearImValues(); foreach ($im_types as $im_type) { $value = trim(array_var($contact_data, 'im_' . $im_type->getId())); if ($value != '') { $contact_im_value = new ContactImValue(); $contact_im_value->setContactId($contact->getId()); $contact_im_value->setImTypeId($im_type->getId()); $contact_im_value->setValue($value); $contact_im_value->setIsMain(array_var($contact_data, 'default_im') == $im_type->getId()); $contact_im_value->save(); } // if } // foreach $member_ids = json_decode(array_var($_POST, 'members')); $object_controller = new ObjectController(); if (!is_null($member_ids)) { $object_controller->add_to_members($contact, $member_ids); } $no_perm_members_ids = json_decode(array_var($_POST, 'no_perm_members')); if (count($no_perm_members_ids)) { $object_controller->add_to_members($contact, $no_perm_members_ids); } if ($newCompany) { $object_controller->add_to_members($company, $member_ids); } $object_controller->link_to_new_object($contact); $object_controller->add_subscribers($contact); $object_controller->add_custom_properties($contact); // User settings $user = array_var(array_var($_POST, 'contact'), 'user'); if ($user && $contact->canUpdatePermissions(logged_user())) { $user_type_changed = false; if (array_var($user, 'type')) { $user_type_changed = $contact->getUserType() != array_var($user, 'type'); $contact->setUserType(array_var($user, 'type')); $contact->save(); } if ($user_type_changed) { $this->cut_max_user_permissions($contact); } // update user groups if (isset($_REQUEST['user_groups'])) { $insert_values = ""; $group_ids = explode(',', $_REQUEST['user_groups']); foreach ($group_ids as $gid) { if (trim($gid) == "" || !is_numeric($gid)) { continue; } $insert_values .= ($insert_values == "" ? "" : ",") . "(" . $contact->getId() . ", {$gid})"; } ContactPermissionGroups::instance()->delete("contact_id=" . $contact->getId() . " AND permission_group_id <> " . $contact->getPermissionGroupId()); if ($insert_values != "") { DB::execute("INSERT INTO " . TABLE_PREFIX . "contact_permission_groups VALUES {$insert_values} ON DUPLICATE KEY UPDATE contact_id=contact_id;"); } ContactMemberCaches::updateContactMemberCacheAllMembers($contact); } } $null = null; Hook::fire('after_edit_contact', $contact, $null); DB::commit(); // save user permissions if ($user && $contact->canUpdatePermissions(logged_user())) { save_user_permissions_background(logged_user(), $contact->getPermissionGroupId(), $contact->isGuest()); } if (array_var($contact_data, 'isNewCompany') == 'true' && is_array(array_var($_POST, 'company'))) { ApplicationLogs::createLog($company, ApplicationLogs::ACTION_ADD); } ApplicationLogs::createLog($contact, ApplicationLogs::ACTION_EDIT); flash_success(lang('success edit contact', $contact->getObjectName())); ajx_current("back"); if (array_var($_REQUEST, 'modal')) { evt_add("reload current panel"); } } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
function cron_events() { if (!can_manage_configuration(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $events = CronEvents::getUserEvents(); tpl_assign("events", $events); $cron_events = array_var($_POST, 'cron_events'); if (is_array($cron_events)) { try { DB::beginWork(); foreach ($cron_events as $id => $data) { $event = CronEvents::findById($id); $date = getDateValue($data['date']); if ($date instanceof DateTimeValue) { $this->parseTime($data['time'], $hour, $minute); $date->add("m", $minute); $date->add("h", $hour); $date = new DateTimeValue($date->getTimestamp() - logged_user()->getTimezone() * 3600); $event->setDate($date); } $delay = $data['delay']; if (is_numeric($delay)) { $event->setDelay($delay); } $enabled = array_var($data, 'enabled') == 'checked'; $event->setEnabled($enabled); $event->save(); } DB::commit(); flash_success(lang("success update cron events")); ajx_current("back"); } catch (Exception $ex) { DB::rollback(); flash_error($ex->getMessage()); } } }
/** * Show and process edit milestone form * * @access public * @param void * @return null */ function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_milestone'); $milestone = ProjectMilestones::findById(get_id()); if(!($milestone instanceof ProjectMilestone)) { flash_error(lang('milestone dnx')); ajx_current("empty"); return; } // if if(!$milestone->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $milestone_data = array_var($_POST, 'milestone'); if(!is_array($milestone_data)) { $milestone_data = array( 'name' => $milestone->getObjectName(), 'due_date' => $milestone->getDueDate(), 'description' => $milestone->getDescription(), 'is_urgent' => $milestone->getIsUrgent() ); // array } // if tpl_assign('milestone_data', $milestone_data); tpl_assign('milestone', $milestone); if(is_array(array_var($_POST, 'milestone'))) { if (array_var($milestone_data, 'due_date_value') != ''){ $milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value')); } else { $now = DateTimeValueLib::now(); $milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, $now->getMonth(), $now->getDay(), $now->getYear()); } $milestone->setFromAttributes($milestone_data); $urgent = array_var($milestone_data, 'is_urgent') == 'checked'; $milestone->setIsUrgent($urgent); try { $member_ids = json_decode(array_var($_POST, 'members')); DB::beginWork(); $milestone->save(); $object_controller = new ObjectController(); $object_controller->add_to_members($milestone, $member_ids); $object_controller->add_subscribers($milestone); $object_controller->link_to_new_object($milestone); $object_controller->add_custom_properties($milestone); $object_controller->add_reminders($milestone); ApplicationLogs::createLog($milestone, ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit milestone', $milestone->getObjectName())); ajx_current("back"); } catch(Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if } // edit
function sendMail($ad_id) { //echo "subodh"; exit; global $objDb; $sqlJob = "select * from job_ad where ad_id='" . $ad_id . "' and (option_radio='2' or option_radio='3') and mail_sent_comp=0 "; $resultJob = $objDb->ExecuteQuery($sqlJob); $rsJob = mysql_fetch_object($resultJob); $refno = $rsJob->ad_id; if (mysql_num_rows($resultJob) > 0) { $sqlAddress = "SELECT * FROM job_company_addressbook \r\n\t\t\t\t\t WHERE rec_id = " . $rsJob->rec_id; $resultAddress = $objDb->ExecuteQuery($sqlAddress); $sqlComp = "select * from job_recruiter where rec_id='" . $rsJob->rec_id . "'"; $resultComp = $objDb->ExecuteQuery($sqlComp); $rsComp = mysql_fetch_object($resultComp); if (mysql_num_rows($resultAddress) > 0) { while ($rsAddress = mysql_fetch_object($resultAddress)) { $str = '<style type="text/css" type="text/css"> .sectionheading { font-family: Arial, Helvetica, sans-serif; font-size:20px; font-weight:normal; color: #329900; text-decoration: none; } .table_alternate_row_noboder { font-family:Arial, Helvetica, sans-serif; font-size:12px; background-color:#E6E6E6; color: #333333; text-decoration:none; } .subhead_gray_small { font-family: Arial, Helvetica, sans-serif; font-size:13px; font-weight:bold; color: #333333; text-decoration:none; } .normal { font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-style:normal; color: #000000; text-decoration:none; } </style> <table width="100%" cellpadding="6" cellspacing="0" class="normal"> <tr> <td colspan="3"> job advert <span class="subhead_gray_small">ref.' . sprintf("%05d", $refno) . '</span> entitled <span class="subhead_gray_small">' . $rsJob->position_name . '</span> posted by <span class="subhead_gray_small">' . $rsComp->comp_name . '</span><br><br></td> </tr> <tr> <td colspan="3" class="sectionheading"> Job Ad Details</td> </tr> <tr> <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Job Reference</td> <td width="70%" class="normal"><b>' . str_pad($ad_id, 5, "0", STR_PAD_LEFT) . '</b></td> </tr> <tr class="table_alternate_row_noboder"> <td bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Job Title</td> <td width="70%" class="normal">' . $rsJob->position_name . '</td> </tr> <tr> <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Job Category </td> <td width="70%" class="normal">' . $rsJob->level . '</td> </tr> <tr class="table_alternate_row_noboder"> <td bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Job Description</td> <td width="70%" class="normal">' . $rsJob->job_desc . '</td> </tr> <tr> <td bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Skills</td> <td width="70%" class="normal">' . $rsJob->job_skills . '</td> </tr> <tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small">Employement Type </td> <td width="70%" class="normal">' . $rsJob->type . '</td> </tr> <tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#FFFFFF"> </td> <td width="26%" class="subhead_gray_small" >Benefits </td> <td width="70%" class="normal">' . $rsJob->job_benefits . '</td> </tr>'; $min_sec_qualification = $rsJob->min_sec_qualification != "" ? " or " . $rsJob->min_sec_qualification : ''; $str .= '<tr> <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Qualification </td> <td width="70%" class="normal">' . $min_sec_qualification . '</td> </tr> <tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#FFFFFF"> </td> <td width="26%" class="subhead_gray_small">Experience</td> <td width="70%" class="normal">' . $rsJob->experience . ' years experience </td> </tr> <tr > <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Job location</td> <td width="70%" class="normal">' . $rsJob->town . '</td> </tr> <tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#FFFFFF"> </td> <td width="26%" class="subhead_gray_small" >Post Date</td> <td width="70%" class="normal">' . getDateValue($rsJob->ad_date) . '</td> </tr> <tr > <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Equity Status</td> <td width="70%" class="normal">' . $rsJob->filter_equity_status . '</td> </tr>'; $filter_gender = $rsJob->filter_gender == "Either" ? "Male of Female" : $rsJob->filter_gender; $str .= '<tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#FFFFFF" > </td> <td width="26%" class="subhead_gray_small">Gender</td> <td width="70%" class="normal">' . $filter_gender . '</td> </tr>'; $str .= '<tr> <td colspan="3" class="sectionheading"> </td> </tr> <tr> <td colspan="3" class="sectionheading"> Contact Information</td> </tr>'; $str .= '<tr> <td colspan="3" class="normal"> To apply for this position, please contact the employer using the following:<br> <br> </td> </tr> <tr class="table_alternate_row_noboder"> <td bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Company</td> <td width="70%" class="normal">' . $rsComp->comp_name . '</td> </tr> <tr> <td width="4%"> </td> <td width="26%" class="subhead_gray_small">Contact Person </td> <td width="70%" class="normal">' . $rsComp->rec_name . '</td> </tr> <tr class="table_alternate_row_noboder"> <td bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Contact email </td> <td width="70%" class="normal"><span class="terms">' . $rsComp->rec_email . '</span></td> </tr> <tr> <td height="32" bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small" >Postal address</td> <td width="70%" class="normal">' . $rsComp->rec_address . '</td> </tr> <tr class="table_alternate_row_noboder"> <td width="4%" bgcolor="#ffffff"> </td> <td width="26%" class="subhead_gray_small">Contact Telphone </td> <td width="70%" class="normal">' . $rsComp->rec_phone . '</td> </tr>'; $str .= '</table>'; $from = $rsComp->rec_email; $subject = "job advert ref." . sprintf("%05d", $refno) . " entitled " . $rsJob->position_name . " posted by " . $rsComp->comp_name; $headers = "From: {$from}\nContent-Type: text/html; charset=iso-8859-1"; @mail(trim($rsAddress->comp_email_id), $subject, $str, $headers); $data = array(); $data["mail_sent_comp"] = 1; $objDb->UpdateData("job_ad", $data, "ad_id", $ad_id); } } } }
function edit_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'); $timeslot = Timeslots::findById(array_var($timeslot_data, 'id', 0)); if (!$timeslot instanceof Timeslot) { flash_error(lang('timeslot dnx')); return; } 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']; //Only admins can change timeslot user if (array_var($timeslot_data, 'contact_id', false) && !logged_user()->isAdministrator()) { $timeslot_data['contact_id'] = $timeslot->getContactId(); } $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 = json_decode(array_var($_POST, 'members', '')); if ($member_ids && count($member_ids)) { ajx_add("time-panel", "reload"); } else { foreach (active_context() as $dimension) { $names[] = $dimension->getName(); } flash_error(lang('select member to add timeslots', implode(", ", $names))); //flash_error(lang('must choose at least one member')); DB::rollback(); return; } $object_controller = new ObjectController(); $object_controller->add_to_members($timeslot, $member_ids); DB::commit(); ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo())); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); } // try }
private function setRepeatOptions(&$task_data) { // repeat options $repeat_d = 0; $repeat_m = 0; $repeat_y = 0; $repeat_h = 0; $rend = ''; $forever = 0; $jump = array_var($task_data, 'occurance_jump'); if (array_var($task_data, 'repeat_option') == 1) { $forever = 1; } elseif (array_var($task_data, 'repeat_option') == 2) { $rnum = array_var($task_data, 'repeat_num'); } elseif (array_var($task_data, 'repeat_option') == 3) { $rend = getDateValue(array_var($task_data, 'repeat_end')); } // verify the options above are valid if (isset($rnum) && $rnum) { if (!is_numeric($rnum) || $rnum < 1 || $rnum > 1000) { throw new Exception(lang('repeat x times must be a valid number between 1 and 1000')); } } else { $rnum = 0; } if (isset($jump) && $jump) { if (!is_numeric($jump) || $jump < 1 || $jump > 1000) { throw new Exception(lang('repeat period must be a valid number between 1 and 1000')); } } else { $occurrance = array_var($task_data, 'occurance'); if ($occurrance && $occurrance != 1) { return lang('repeat period must be a valid number between 1 and 1000'); } } // check for repeating options // 1=repeat once, 2=repeat daily, 3=weekly, 4=monthy, 5=yearly, 6=holiday repeating $oend = null; switch (array_var($task_data, 'occurance')) { case "1": $forever = 0; $task_data['repeat_d'] = 0; $task_data['repeat_m'] = 0; $task_data['repeat_y'] = 0; $task_data['repeat_by'] = ''; break; case "2": $task_data['repeat_d'] = $jump; if (isset($forever) && $forever == 1) { $oend = null; } else { $oend = $rend; } break; case "3": $task_data['repeat_d'] = 7 * $jump; if (isset($forever) && $forever == 1) { $oend = null; } else { $oend = $rend; } break; case "4": $task_data['repeat_m'] = $jump; if (isset($forever) && $forever == 1) { $oend = null; } else { $oend = $rend; } break; case "5": $task_data['repeat_y'] = $jump; if (isset($forever) && $forever == 1) { $oend = null; } else { $oend = $rend; } break; default: break; } $task_data['repeat_num'] = $rnum; $task_data['repeat_forever'] = $forever; $task_data['repeat_end'] = $oend; if ($task_data['repeat_num'] || $task_data['repeat_forever'] || $task_data['repeat_end']) { if ($task_data['repeat_by'] == 'start_date' && !$task_data['start_date'] instanceof DateTimeValue) { return lang('to repeat by start date you must specify task start date'); } if ($task_data['repeat_by'] == 'due_date' && !$task_data['due_date'] instanceof DateTimeValue) { return lang('to repeat by due date you must specify task due date'); } } return null; }
function edit_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'); $timeslot = Timeslots::findById(array_var($timeslot_data, 'id', 0)); if (!$timeslot instanceof Timeslot) { flash_error(lang('timeslot dnx')); return; } 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'; //Only admins can change timeslot user if (array_var($timeslot_data, 'user_id', false) && !logged_user()->isAdministrator()) { $timeslot_data['user_id'] = $timeslot->getUserId(); } $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(); ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo(true))); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); } // try }
/** * Edit specific contact * * @access public * @param void * @return null */ function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('edit_contact'); $contact = Contacts::findById(get_id()); if(!($contact instanceof Contact)) { flash_error(lang('contact dnx')); ajx_current("empty"); return; } // if if(!$contact->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $im_types = ImTypes::findAll(array('order' => '`id`')); $personal_emails = $contact->getContactEmails('personal'); $contact_data = array_var($_POST, 'contact'); // Populate form fields if(!is_array($contact_data)) { $contact_data = array( 'first_name' => $contact->getFirstName(), 'surname' => $contact->getSurname(), 'username' => $contact->getUsername(), 'department' => $contact->getDepartment(), 'job_title' => $contact->getJobTitle(), 'email' => $contact->getEmailAddress(), 'email2' => !is_null($personal_emails) && isset($personal_emails[0]) ? $personal_emails[0]->getEmailAddress() : '', 'email3' => !is_null($personal_emails) && isset($personal_emails[1])? $personal_emails[1]->getEmailAddress() : '', 'w_web_page'=> $contact->getWebpageUrl('work'), 'birthday'=> $contact->getBirthday(), 'w_phone_number'=> $contact->getPhoneNumber('work', true), 'w_phone_number2'=> $contact->getPhoneNumber('work'), 'w_fax_number'=> $contact->getPhoneNumber('fax', true), 'w_assistant_number'=> $contact->getPhoneNumber('assistant'), 'w_callback_number'=> $contact->getPhoneNumber('callback'), 'h_web_page'=> $contact->getWebpageUrl('personal'), 'h_phone_number'=> $contact->getPhoneNumber('home', true), 'h_phone_number2'=> $contact->getPhoneNumber('home'), 'h_fax_number'=> $contact->getPhoneNumber('fax'), 'h_mobile_number'=> $contact->getPhoneNumber('mobile'), 'h_pager_number'=> $contact->getPhoneNumber('pager'), 'o_web_page'=> $contact->getWebpageUrl('other'), 'o_phone_number'=> $contact->getPhoneNumber('other',true), 'o_phone_number2'=> $contact->getPhoneNumber('other'), 'comments' => $contact->getCommentsField(), 'picture_file' => $contact->getPictureFile(), 'timezone' => $contact->getTimezone(), 'company_id' => $contact->getCompanyId(), ); // array $w_address = $contact->getAddress('work'); if($w_address){ $contact_data['w_address'] = $w_address->getStreet(); $contact_data['w_city'] = $w_address->getCity(); $contact_data['w_state'] = $w_address->getState(); $contact_data['w_zipcode'] = $w_address->getZipCode(); $contact_data['w_country'] = $w_address->getCountry(); } $h_address = $contact->getAddress('home'); if($h_address){ $contact_data['h_address'] = $h_address->getStreet(); $contact_data['h_city'] = $h_address->getCity(); $contact_data['h_state'] = $h_address->getState(); $contact_data['h_zipcode'] = $h_address->getZipCode(); $contact_data['h_country'] = $h_address->getCountry(); } $o_address = $contact->getAddress('other'); if($o_address){ $contact_data['o_address'] = $o_address->getStreet(); $contact_data['o_city'] = $o_address->getCity(); $contact_data['o_state'] = $o_address->getState(); $contact_data['o_zipcode'] = $o_address->getZipCode(); $contact_data['o_country'] = $o_address->getCountry(); } if(is_array($im_types)) { foreach($im_types as $im_type) { $contact_data['im_' . $im_type->getId()] = $contact->getImValue($im_type); } // foreach } // if $default_im = $contact->getMainImType(); $contact_data['default_im'] = $default_im instanceof ImType ? $default_im->getId() : ''; } // if tpl_assign('isEdit', array_var($_GET, 'isEdit',false)); tpl_assign('contact', $contact); tpl_assign('contact_data', $contact_data); tpl_assign('im_types', $im_types); //Contact Submit if(is_array(array_var($_POST, 'contact'))) { try { DB::beginWork(); $contact_data['email']= trim ($contact_data['email']); Contacts::validate($contact_data, get_id()); $newCompany = false; if (array_var($contact_data, 'isNewCompany') == 'true' && is_array(array_var($_POST, 'company'))){ $company_data = array_var($_POST, 'company'); Contacts::validate($company_data); $company = new Contact(); $company->setFromAttributes($company_data); $company->setIsCompany(true); $company->setObjectName(); $company->save(); if($company_data['address'] != "") $company->addAddress($company_data['address'], $company_data['city'], $company_data['state'], $company_data['country'], $company_data['zipcode'], 'work', true); if($company_data['phone_number'] != "") $company->addPhone($company_data['phone_number'], 'work', true); if($company_data['fax_number'] != "") $company->addPhone($company_data['fax_number'], 'fax', true); if($company_data['homepage'] != "") $company->addWebpage($company_data['homepage'], 'work'); if($company_data['email'] != "") $company->addEmail($company_data['email'], 'work' , true); ApplicationLogs::createLog($company,ApplicationLogs::ACTION_ADD); $newCompany = true; } $contact_data['birthday'] = getDateValue($contact_data["birthday"]); if(isset($contact_data['specify_username'])){ if($contact_data['user']['username'] != ""){ $contact_data['name'] = $contact_data['user']['username']; }else{ $contact_data['name'] = $contact_data['first_name']." ".$contact_data['surname']; } }else{ $contact_data['name'] = $contact_data['first_name']." ".$contact_data['surname']; } $contact->setFromAttributes($contact_data); if($newCompany) { $contact->setCompanyId($company->getId()); } //telephones $mainPone = $contact->getPhone('work', true); if($mainPone){ $mainPone->editNumber($contact_data['w_phone_number']); }else{ if($contact_data['w_phone_number'] != "") $contact->addPhone($contact_data['w_phone_number'], 'work', true); } $pone2 = $contact->getPhone('work'); if($pone2){ $pone2->editNumber($contact_data['w_phone_number2']); }else{ if($contact_data['w_phone_number2'] != "") $contact->addPhone($contact_data['w_phone_number2'], 'work'); } $faxPhone = $contact->getPhone('fax',true); if($faxPhone){ $faxPhone->editNumber($contact_data['w_fax_number']); }else{ if($contact_data['w_fax_number'] != "") $contact->addPhone($contact_data['w_fax_number'], 'fax', true); } $assistantPhone = $contact->getPhone('assistant'); if($assistantPhone){ $assistantPhone->editNumber($contact_data['w_assistant_number']); }else{ if($contact_data['w_assistant_number'] != "") $contact->addPhone($contact_data['w_assistant_number'], 'assistant'); } $callbackPhone = $contact->getPhone('callback'); if($callbackPhone){ $callbackPhone->editNumber($contact_data['w_callback_number']); }else{ if($contact_data['w_callback_number'] != "") $contact->addPhone($contact_data['w_callback_number'], 'callback'); } $o_phone = $contact->getPhone('other',true); if($o_phone){ $o_phone->editNumber($contact_data['o_phone_number']); }else{ if($contact_data['o_phone_number'] != "") $contact->addPhone($contact_data['o_phone_number'], 'other', true); } $o_pone2 = $contact->getPhone('other'); if($o_pone2){ $o_pone2->editNumber($contact_data['o_phone_number2']); }else{ if($contact_data['o_phone_number2'] != "") $contact->addPhone($contact_data['o_phone_number2'], 'other'); } $h_phone = $contact->getPhone('home', true); if($h_phone){ $h_phone->editNumber($contact_data['h_phone_number']); }else{ if($contact_data['h_phone_number'] != "") $contact->addPhone($contact_data['h_phone_number'], 'home', true); } $h_phone2 = $contact->getPhone('home'); if($h_phone2){ $h_phone2->editNumber($contact_data['h_phone_number2']); }else{ if($contact_data['h_phone_number2'] != "") $contact->addPhone($contact_data['h_phone_number2'], 'home'); } $h_faxPhone = $contact->getPhone('fax'); if($h_faxPhone){ $h_faxPhone->editNumber($contact_data['h_fax_number']); }else{ if($contact_data['h_fax_number'] != "") $contact->addPhone($contact_data['h_fax_number'], 'fax'); } $h_mobilePhone = $contact->getPhone('mobile'); if($h_mobilePhone){ $h_mobilePhone->editNumber($contact_data['h_mobile_number']); }else{ if($contact_data['h_mobile_number'] != "") $contact->addPhone($contact_data['h_mobile_number'], 'mobile'); } $h_pagerPhone = $contact->getPhone('pager'); if($h_pagerPhone){ $h_pagerPhone->editNumber($contact_data['h_pager_number']); }else{ if($contact_data['h_pager_number'] != "") $contact->addPhone($contact_data['h_pager_number'], 'pager'); } //Emails $personal_email_type_id = EmailTypes::getEmailTypeId('personal'); $main_emails = ContactEmails::getContactMainEmails($contact, $personal_email_type_id); $more_main_emails = array(); $mail = null; foreach ($main_emails as $me) { if ($mail == null) $mail = $me; else $more_main_emails[] = $me; } if($mail){ $mail->editEmailAddress($contact_data['email']); }else{ if($contact_data['email'] != "") $contact->addEmail($contact_data['email'], 'personal' , true); } foreach ($more_main_emails as $mme) { $mme->setIsMain(false); $mme->save(); } $mail2 = !is_null($personal_emails) && isset($personal_emails[0])? $personal_emails[0] : null; if($mail2){ $mail2->editEmailAddress($contact_data['email2']); }else{ if($contact_data['email2'] != "") $contact->addEmail($contact_data['email2'], 'personal'); } $mail3 = !is_null($personal_emails) && isset($personal_emails[1])? $personal_emails[1] : null; if($mail3){ $mail3->editEmailAddress($contact_data['email3']); }else{ if($contact_data['email3'] != "") $contact->addEmail($contact_data['email3'], 'personal'); } //Addresses $w_address = $contact->getAddress('work'); if($w_address){ $w_address->edit($contact_data['w_address'], $contact_data['w_city'], $contact_data['w_state'], $contact_data['w_country'], $contact_data['w_zipcode'],2,0); }else{ if($contact_data['w_address'] != "" || $contact_data['w_city'] != "" || $contact_data['w_state'] != "" || $contact_data['w_country'] != "" || $contact_data['w_zipcode'] != "") $contact->addAddress($contact_data['w_address'], $contact_data['w_city'], $contact_data['w_state'], $contact_data['w_country'], $contact_data['w_zipcode'], 'work'); } $h_address = $contact->getAddress('home'); if($h_address){ $h_address->edit($contact_data['h_address'], $contact_data['h_city'], $contact_data['h_state'], $contact_data['h_country'], $contact_data['h_zipcode'],1,0); }else{ if($contact_data['h_address'] != "" || $contact_data['h_city'] != "" || $contact_data['h_state'] != "" || $contact_data['h_country'] != "" || $contact_data['h_zipcode'] != "") $contact->addAddress($contact_data['h_address'], $contact_data['h_city'], $contact_data['h_state'], $contact_data['h_country'], $contact_data['h_zipcode'], 'home'); } $o_address = $contact->getAddress('other'); if($o_address){ $o_address->edit($contact_data['o_address'], $contact_data['o_city'], $contact_data['o_state'], $contact_data['o_country'], $contact_data['o_zipcode'],3,0); }else{ if($contact_data['o_address'] != "" || $contact_data['o_city'] != "" || $contact_data['o_state'] != "" || $contact_data['o_country'] != "" || $contact_data['o_zipcode'] != "") $contact->addAddress($contact_data['o_address'], $contact_data['o_city'], $contact_data['o_state'], $contact_data['o_country'], $contact_data['o_zipcode'], 'other'); } //Webpages $w_homepage = $contact->getWebpage('work'); if($w_homepage){ $w_homepage->editWebpageURL($contact_data['w_web_page']); }else{ if($contact_data['w_web_page'] != "") $contact->addWebpage($contact_data['w_web_page'], 'work'); } $h_homepage = $contact->getWebpage('personal'); if($h_homepage){ $h_homepage->editWebpageURL($contact_data['h_web_page']); }else{ if($contact_data['h_web_page'] != "") $contact->addWebpage($contact_data['h_web_page'], 'personal'); } $o_homepage = $contact->getWebpage('other'); if($o_homepage){ $o_homepage->editWebpageURL($contact_data['o_web_page']); }else{ if($contact_data['o_web_page'] != "") $contact->addWebpage($contact_data['o_web_page'], 'other'); } $contact->setObjectName(); $contact->save(); $contact->clearImValues(); foreach($im_types as $im_type) { $value = trim(array_var($contact_data, 'im_' . $im_type->getId())); if($value <> '') { $contact_im_value = new ContactImValue(); $contact_im_value->setContactId($contact->getId()); $contact_im_value->setImTypeId($im_type->getId()); $contact_im_value->setValue($value); $contact_im_value->setIsMain(array_var($contact_data, 'default_im') == $im_type->getId()); $contact_im_value->save(); } // if } // foreach $member_ids = json_decode(array_var($_POST, 'members')); $object_controller = new ObjectController(); if (count($member_ids)){ $object_controller->add_to_members($contact, $member_ids); } if ($newCompany) $object_controller->add_to_members($company, $member_ids); $object_controller->link_to_new_object($contact); $object_controller->add_subscribers($contact); $object_controller->add_custom_properties($contact); ApplicationLogs::createLog($contact, ApplicationLogs::ACTION_EDIT ); // User settings $user = array_var(array_var($_POST, 'contact'),'user'); if($user){ $user['username'] = str_replace(" ","",strtolower($name)); $this->createUserFromContactForm($user, $contact->getId(), $contact->getEmailAddress()); // Reload contact again due to 'createUserFromContactForm' changes Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret); } DB::commit(); flash_success(lang('success edit contact', $contact->getObjectName())); ajx_current("back"); } catch(Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if } // edit
<tr align="left"> <td width="14%" class="<?php echo $td_class; ?> "><a href="#" onClick="chequeDetails(<?php echo $rsPaid->pay_id; ?> );" class="blue_title_small" title="Click to view cheque details."><?php echo $rsPaid->cheque_number; ?> </a></td> <td width="12%" class="<?php echo $td_class; ?> "><?php echo getDateValue($rsPaid->bounce_date); ?> </td> <td width="14%" class="<?php echo $td_class; ?> "><?php echo sprintf("%05d", $rsPaid->pay_id); ?> </td> <td width="13%" class="<?php echo $td_class; ?> "><a href="#" onClick="viewDetails('invoice_details.php?invoice_id=<?php echo $rsPaid->invoice_id; ?>
</tr> <tr> <td> </td> <td>Ad Running time </td> <td colspan="2" class="comment"><table width="100%" cellpadding="2" cellspacing="0"> <tr> <td width="23%" class="normal_black">From</td> <td width="77%" class="normal_black">To</td> </tr> <tr> <td><?php echo getDateValue($adFrom); ?> </td> <td><?php echo getDateValue($adTo); ?> </td> </tr> </table></td> </tr> <tr> <td> </td> <td>Required Institution</td> <td colspan="2" class="comment"><?php echo fill_dropdown("bursary_institution", "job_options", "option_name", "option_name", trim($bursary_institution), "Select", "where category_id=387"); ?> </td> </tr> <tr> <td> </td>
function instantiate_template_task_parameters(TemplateTask $object, ProjectTask $copy, $parameterValues = array()) { $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($object->getTemplateId(), $object->getId()); $manager = $copy->manager(); foreach ($objProp as $property) { $propName = $property->getProperty(); $value = $property->getValue(); if ($manager->getColumnType($propName) == DATA_TYPE_STRING || $manager->getColumnType($propName) == DATA_TYPE_INTEGER) { if (is_array($parameterValues)) { $is_present = false; foreach ($parameterValues as $param => $val) { if (strpos($value, '{' . $param . '}') !== FALSE) { $value = str_replace('{' . $param . '}', $val, $value); $is_present = true; } } // if parameter not present replace the parameter code with empty string if (!$is_present) { $value = preg_replace('/[{].*[}]/U', '', $value); } } } else { if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) { $operator = '+'; if (strpos($value, '+') === false) { $operator = '-'; } $opPos = strpos($value, $operator); if ($opPos !== false) { // Is parametric $dateParam = substr($value, 1, strpos($value, '}') - 1); if ($dateParam == 'task_creation') { $date = DateTimeValueLib::now(); } else { $date = getDateValue($parameterValues[$dateParam]); if (!$date instanceof DateTimeValue) { $date = DateTimeValueLib::now(); } if ($copy instanceof ProjectTask && config_option('use_time_in_task_dates') && $propName == "due_date") { $copy->setUseDueTime(1); $hour_min = getTimeValue(user_config_option('work_day_end_time')); $hour_min['hours']; $hour_min['mins']; $date->setHour($hour_min['hours']); $date->setMinute($hour_min['mins']); $date = $date->add('s', -logged_user()->getTimezone() * 3600); } if ($copy instanceof ProjectTask && config_option('use_time_in_task_dates') && $propName == "start_date") { $copy->setUseStartTime(1); $hour_min = getTimeValue(user_config_option('work_day_start_time')); $hour_min['hours']; $hour_min['mins']; $date->setHour($hour_min['hours']); $date->setMinute($hour_min['mins']); $date = $date->add('s', -logged_user()->getTimezone() * 3600); } } $dateUnit = substr($value, strlen($value) - 1); // d, w or m (for days, weeks or months) if ($dateUnit == 'm') { $dateUnit = 'M'; // make month unit uppercase to call DateTimeValue::add with correct parameter } $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2); //Hook::fire('template_param_date_calculation', array('op' => $operator, 'date' => $date, 'template_id' => $object->getTemplateId(), 'original' => $object, 'copy' => $copy), $dateNum); $value = $date->add($dateUnit, $dateNum); } else { $value = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $value); } } } if ($value != '') { if (!$copy->setColumnValue($propName, $value)) { $copy->object->setColumnValue($propName, $value); } if ($propName == 'text' && $copy->getTypeContent() == 'text') { $copy->setText(html_to_text($copy->getText())); } $copy->save(); } } // Ensure that assigned user is subscribed if ($copy instanceof ProjectTask && $copy->getAssignedTo() instanceof Contact) { $copy->subscribeUser($copy->getAssignedTo()); } $ret = null; Hook::fire('after_template_object_param_instantiation', array('template_id' => $object->getTemplateId(), 'original' => $object, 'copy' => $copy, 'parameter_values' => $parameterValues), $ret); }