$perms =& $AppUI->acl(); $canRead = $perms->checkModuleItem($m, 'view', $company_id); $canEdit = $perms->checkModuleItem($m, 'edit', $company_id); if (!$canRead) { $AppUI->setMsg('Access denied', UI_MSG_ERROR); $AppUI->redirect(); } // retrieve any state parameters if (isset($_GET['tab'])) { $AppUI->setState('CompVwTab', $_GET['tab']); } $tab = $AppUI->getState('CompVwTab') !== NULL ? $AppUI->getState('CompVwTab') : 0; // check if this record has dependencies to prevent deletion $msg = ''; $obj = new CCompany(); $canDelete = $obj->canDelete($msg, $company_id); // load the record data $q = new DBQuery(); $q->addTable('companies', 'c'); $q->addQuery('c.*, u.user_id'); $q->addQuery('CONCAT(co.contact_first_name, " ", co.contact_last_name) AS contact_name'); $q->addJoin('users', 'u', 'u.user_id = c.company_owner'); $q->addJoin('contacts', 'co', 'u.user_contact = co.contact_id'); $q->addWhere('c.company_id = ' . $company_id); $sql = $q->prepare(); $q->clear(); $obj = null; if (!db_loadObject($sql, $obj)) { $AppUI->setMsg('Company'); $AppUI->setMsg("invalidID", UI_MSG_ERROR, true); $AppUI->redirect();
/* COMPANIES $Id: do_company_aed.php 5872 2009-04-25 00:09:56Z merlinyoda $ */ if (!defined('DP_BASE_DIR')) { die('You should not access this file directly.'); } $del = dPgetParam($_POST, 'del', 0); $obj = new CCompany(); $msg = ''; if (!$obj->bind($_POST)) { $AppUI->setMsg($obj->getError(), UI_MSG_ERROR); $AppUI->redirect(); } require_once $AppUI->getSystemClass('CustomFields'); // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Company'); if ($del) { if (!$obj->canDelete($msg)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg('deleted', UI_MSG_ALERT, true); $AppUI->redirect('m=companies'); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $custom_fields = new CustomFields($m, 'addedit', $obj->company_id, 'edit');
$company_id = (int) w2PgetParam($_GET, 'company_id', 0); // check permissions for this record $perms =& $AppUI->acl(); $canRead = $perms->checkModuleItem($m, 'view', $company_id); if (!$canRead) { $AppUI->redirect('m=public&a=access_denied'); } $canAdd = $perms->checkModuleItem($m, 'add'); $canEdit = $perms->checkModuleItem($m, 'edit', $company_id); $canDelete = $perms->checkModuleItem($m, 'delete', $company_id); $tab = $AppUI->processIntState('CompVwTab', $_GET, 'tab', 0); $company = new CCompany(); $company->loadFull($AppUI, $company_id); // check if this record has dependencies to prevent deletion $msg = ''; $deletable = $company->canDelete($msg, $company_id); // load the record data if (!$company) { $AppUI->setMsg('Company'); $AppUI->setMsg('invalidID', UI_MSG_ERROR, true); $AppUI->redirect(); } else { $AppUI->savePlace(); } // setup the title block $titleBlock = new CTitleBlock('View Company', 'handshake.png', $m, "{$m}.{$a}"); $titleBlock->addCell(); if ($canAdd) { $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new company') . '" />', '', '<form action="?m=companies&a=addedit" method="post" accept-charset="utf-8">', '</form>'); } if ($canEdit) {
<?php if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } $company_id = (int) w2PgetParam($_GET, 'company_id', 0); $tab = $AppUI->processIntState('CompVwTab', $_GET, 'tab', 0); $company = new CCompany(); if (!$company->load($company_id)) { $AppUI->redirect(ACCESS_DENIED); } $canEdit = $company->canEdit(); $canDelete = $company->canDelete(); $deletable = $canDelete; //TODO: this should be removed once the $deletable variable is removed $contact = new CContact(); $canCreateContacts = $contact->canCreate(); // setup the title block $titleBlock = new w2p_Theme_TitleBlock('View Company', 'icon.png', $m); $titleBlock->addCrumb('?m=' . $m, $m . ' list'); if ($canCreateContacts) { $titleBlock->addButton('New contact', '?m=contacts&a=addedit&company_id=' . $company_id); } if ($canEdit) { if ($AppUI->isActiveModule('departments')) { $titleBlock->addButton('New department', '?m=departments&a=addedit&company_id=' . $company_id); } $titleBlock->addButton('New project', '?m=projects&a=addedit&company_id=' . $company_id); $titleBlock->addCrumb('?m=companies&a=addedit&company_id=' . $company_id, 'edit this company'); if ($canDelete && $deletable) { $titleBlock->addCrumbDelete('delete company', $deletable, $msg);