function getDepartment($department_id, $fieldname) { $department = new CDepartment(); $department->load((int) $department_id); $response = new xajaxResponse(); $response->assign($fieldname, 'value', $department->dept_name); return $response; }
public function getDepartmentDetails() { $dept = new CDepartment(); $dept->load((int) $this->contact_department); return array('dept_id' => $dept->dept_id, 'dept_name' => $dept->dept_name); }
/* DEPARTMENTS $Id$ */ if (!defined('DP_BASE_DIR')) { die('You should not access this file directly.'); } $del = isset($_POST['del']) ? $_POST['del'] : 0; $dept = new CDepartment(); if ($msg = $dept->bind($_POST)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Department'); if ($del) { $dep = new CDepartment(); $msg = $dep->load($dept->dept_id); if ($msg = $dept->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg("deleted", UI_MSG_ALERT, true); $AppUI->redirect('m=companies&a=view&company_id=' . $dep->dept_company); } } else { if ($msg = $dept->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $isNotNew = @$_POST['department_id']; $AppUI->setMsg($isNotNew ? 'updated' : 'inserted', UI_MSG_OK, true); } $AppUI->redirect();
<?php /* $Id$ $URL$ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } $contact_id = intval(w2PgetParam($_GET, 'contact_id', 0)); $company_id = intval(w2PgetParam($_GET, 'company_id', 0)); $dept_id = intval(w2PgetParam($_GET, 'dept_id', 0)); $company = new CCompany(); $company->load($company_id); $company_name = $company->company_name; $dept = new CDepartment(); $dept->load($dept_id); $dept_name = $dept->dept_name; // check permissions for this record $perms =& $AppUI->acl(); $canAuthor = $perms->checkModule('contacts', 'add'); $canEdit = $perms->checkModuleItem('contacts', 'edit', $contact_id); // check permissions if (!$canAuthor && !$contact_id) { $AppUI->redirect('m=public&a=access_denied'); } if (!$canEdit && $contact_id) { $AppUI->redirect('m=public&a=access_denied'); } if ($msg == $AppUI->_('contactsDeleteUserError', UI_OUTPUT_JS)) { $userDeleteProtect = true; } // load the record data $row = new CContact();
<?php if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } $dept_id = (int) w2PgetParam($_GET, 'dept_id', 0); $department_id = (int) w2PgetParam($_GET, 'department_id', 0); $dept_id = max($dept_id, $department_id); $tab = $AppUI->processIntState('DeptVwTab', $_GET, 'tab', 0); $department = new CDepartment(); if (!$department->load($dept_id)) { $AppUI->redirect(ACCESS_DENIED); } $canEdit = $department->canEdit(); $canDelete = $department->canDelete(); $titleBlock = new w2p_Theme_TitleBlock('View Department', 'icon.png', $m); $titleBlock->addCrumb('?m=companies', 'company list'); $titleBlock->addCrumb('?m=companies&a=view&company_id=' . $department->dept_company, 'view this company'); $titleBlock->addCrumb('?m=' . $m, $m . ' list'); if ($canEdit) { $titleBlock->addCell(); $titleBlock->addButton('New department', '?m=departments&a=addedit&company_id=' . $department->dept_company . '&dept_parent=' . $dept_id); $titleBlock->addCrumb('?m=departments&a=addedit&dept_id=' . $dept_id, 'edit this department'); if ($canDelete) { $titleBlock->addCrumbDelete('delete department', $canDelete, $msg); } } $titleBlock->show(); $view = new w2p_Controllers_View($AppUI, $department, 'Department'); $view->setDoSQL('do_dept_aed'); $view->addField('dept_company', $department->dept_company);
/** * Tests the delete of a dept */ public function testDelete() { $this->obj->bind($this->post_data); $result = $this->obj->store(); $this->assertTrue($result); $original_id = $this->obj->dept_id; $result = $this->obj->delete(); $item = new CDepartment(); $item->overrideDatabase($this->mockDB); $this->mockDB->stageHash(array('dept_name' => '', 'dept_owner' => '')); $item->load($original_id); $this->assertEquals('', $item->dept_name); $this->assertEquals('', $item->dept_owner); }
$AppUI->redirect('m=public&a=access_denied'); } } else { if (!$perms->checkModule('departments', 'add')) { $AppUI->redirect('m=public&a=access_denied'); } } $obj = new CDepartment(); if ($msg = $obj->bind($_POST)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } // prepare (and translate) the module name ready for the suffix if ($del) { $dep = new CDepartment(); $msg = $dep->load($obj->dept_id); if ($msg = $obj->delete($AppUI)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg('deleted', UI_MSG_ALERT, true); $AppUI->redirect('m=companies&a=view&company_id=' . $dep->dept_company); } } else { if ($result = $obj->store($AppUI)) { if (is_array($result)) { $AppUI->setMsg($result, UI_MSG_ERROR, true); $AppUI->holdObject($obj); $AppUI->redirect('m=departments&a=addedit'); } } else {
foreach ($_POST['dept_id'] as $value) { $deptId = $value; $dept->load($deptId); $dept->dept_batching_maintenance = $updateall; if ($msg = $dept->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } } } else { $dept = new CDepartment(); foreach ($_POST['dept_id'] as $key => $value) { $deptId = $value; $maintExpireDate = $_POST['dept_batching_maintenance'][$key]; // echo"<pre>"; // print_r($_POST); // echo"</pre>"; // exit; if (strlen($maintExpireDate) > 0) { $msg = $dept->load($deptId); $dept->last_report_accept_date = date("Y-m-d H:i:s", strtotime($_POST['last_report_accept_date_hidden'][$key])); $dept->dept_batching_maintenance = date("Y-m-d H:i:s", strtotime($_POST['last_report_accept_date_hidden'][$key]) + 365 * 24 * 3600); //$batch_maintenance_touched=(substr_count($_POST['batch_expiration_touched'],":"))?explode(":",$_POST['batch_expiration_touched']):array(); //if(in_array($key,$batch_maintenance_touched)) $dept->dept_batching_maintenance = $maintExpireDate; if ($msg = $dept->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } } } } $AppUI->redirect();