Esempio n. 1
0
   You should have received a copy of the GNU General Public License
   along with CoDev-Timetracking.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../path.inc.php';
// Note: i18n is included by the Controler class, but Ajax dos not use it...
require_once 'i18n/i18n.inc.php';
if (Tools::isConnectedUser() && (isset($_GET['action']) || isset($_POST['action']))) {
    if (isset($_GET['action'])) {
        $smartyHelper = new SmartyHelper();
        if ($_GET['action'] == 'updateDetailedCharges') {
            $servicecontractid = Tools::getSecureGETIntValue('selectFiltersSrcId');
            $selectedFilters = Tools::getSecureGETStringValue('selectedFilters', '');
            $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
            $session_user->setServiceContractFilters($selectedFilters, $servicecontractid);
            $servicecontract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
            $isManager = $session_user->isTeamManager($servicecontract->getTeamid());
            $isObserver = $session_user->isTeamObserver($servicecontract->getTeamid());
            // DetailedChargesIndicator
            $data = ServiceContractTools::getDetailedCharges($servicecontract, $isManager || $isObserver, $selectedFilters);
            foreach ($data as $smartyKey => $smartyVariable) {
                $smartyHelper->assign($smartyKey, $smartyVariable);
            }
            $smartyHelper->display(DetailedChargesIndicator::getSmartySubFilename());
        } else {
            Tools::sendNotFoundAccess();
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Esempio n. 2
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             // use the servicecontractid set in the form, if not defined (first page call) use session servicecontractid
             $servicecontractid = 0;
             if (isset($_POST['servicecontractid'])) {
                 $servicecontractid = Tools::getSecurePOSTIntValue('servicecontractid');
                 $_SESSION['servicecontractid'] = $servicecontractid;
             } else {
                 if (isset($_GET['servicecontractid'])) {
                     $servicecontractid = Tools::getSecureGETIntValue('servicecontractid');
                     $_SESSION['servicecontractid'] = $servicecontractid;
                 } else {
                     if (isset($_SESSION['servicecontractid'])) {
                         $servicecontractid = $_SESSION['servicecontractid'];
                     }
                 }
             }
             // set TeamList (including observed teams)
             $oTeamList = $this->session_user->getObservedTeamList();
             $mTeamList = $this->session_user->getManagedTeamList();
             $teamList = $oTeamList + $mTeamList;
             // array_merge does not work ?!
             if (empty($teamList) || !array_key_exists($this->teamid, $teamList)) {
                 // only managers (and observers) can access this page.
                 return;
             }
             $isManager = $this->session_user->isTeamManager($this->teamid);
             $isObserver = $this->session_user->isTeamObserver($this->teamid);
             if ($isManager || $isObserver) {
                 $this->smartyHelper->assign('isManager', true);
             }
             $this->smartyHelper->assign('servicecontracts', ServiceContractTools::getServiceContracts($this->teamid, $servicecontractid));
             if (0 != $servicecontractid) {
                 $servicecontract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
                 if ($this->teamid == $servicecontract->getTeamid()) {
                     $this->smartyHelper->assign('servicecontractid', $servicecontractid);
                     // get selected filters
                     $selectedFilters = "";
                     if (isset($_GET['selectedFilters'])) {
                         $selectedFilters = Tools::getSecureGETStringValue('selectedFilters');
                     } else {
                         $selectedFilters = $this->session_user->getServiceContractFilters($servicecontractid);
                     }
                     ServiceContractTools::displayServiceContract($this->smartyHelper, $servicecontract, $isManager || $isObserver, $selectedFilters);
                     // ConsistencyCheck
                     $consistencyErrors = $this->getConsistencyErrors($servicecontract);
                     if (0 != $consistencyErrors) {
                         $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("Errors"));
                         $this->smartyHelper->assign('ccheckErrList', $consistencyErrors);
                     }
                     // access rights
                     if ($isManager || $this->session_user->isTeamLeader($servicecontract->getTeamid())) {
                         $this->smartyHelper->assign('isEditGranted', true);
                     }
                     // old-style plugins (deprecated)
                     $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename());
                     // Dashboard
                     ServiceContractTools::dashboardSettings($this->smartyHelper, $servicecontract, $this->session_userid);
                 }
             } else {
                 unset($_SESSION['cmdid']);
                 unset($_SESSION['commandsetid']);
                 $action = filter_input(INPUT_POST, 'action');
                 if ('displayServiceContract' == $action) {
                     header('Location:servicecontract_edit.php?servicecontractid=0');
                 }
             }
         }
     }
 }
Esempio n. 3
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('isEditGranted', FALSE);
         } else {
             // only managers can edit the SC
             $isManager = $this->session_user->isTeamManager($this->teamid);
             if (!$isManager) {
                 return;
             }
             $this->smartyHelper->assign('isEditGranted', true);
             // use the servicecontractid set in the form, if not defined (first page call) use session servicecontractid
             $servicecontractid = 0;
             if (isset($_POST['servicecontractid'])) {
                 $servicecontractid = Tools::getSecurePOSTIntValue('servicecontractid');
                 $_SESSION['servicecontractid'] = $servicecontractid;
             } else {
                 if (isset($_GET['servicecontractid'])) {
                     $servicecontractid = Tools::getSecureGETIntValue('servicecontractid');
                     $_SESSION['servicecontractid'] = $servicecontractid;
                 } else {
                     if (isset($_SESSION['servicecontractid'])) {
                         $servicecontractid = $_SESSION['servicecontractid'];
                     }
                 }
             }
             $action = filter_input(INPUT_POST, 'action');
             if (0 == $servicecontractid) {
                 //  CREATE service contract
                 if ("createContract" == $action) {
                     if (self::$logger->isDebugEnabled()) {
                         self::$logger->debug("create new ServiceContract for team {$this->teamid}<br>");
                     }
                     $contractName = Tools::getSecurePOSTStringValue('servicecontractName');
                     try {
                         $servicecontractid = ServiceContract::create($contractName, $this->teamid);
                         $contract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
                     } catch (Exception $e) {
                         // Smartify
                         echo "Can't create the ServiceContract because the ServiceContract name is already used";
                     }
                 }
                 // Display Empty Command Form
                 // Note: this will be overridden by the 'update' section if the 'createCommandset' action has been called.
                 $this->smartyHelper->assign('contractInfoFormBtText', T_('Create'));
                 $this->smartyHelper->assign('contractInfoFormAction', 'createContract');
                 // Note: StateList is empty, uncomment following lines if ServiceContract::$stateNames is used
                 //$this->smartyHelper->assign('servicecontractStateList', ServiceContractTools::getServiceContractStateList($contract));
             }
             // Edited or created just before
             if (0 != $servicecontractid) {
                 // UPDATE CMDSET
                 $contract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
                 // Actions
                 if ("addCommandSet" == $action) {
                     # TODO
                     $commandsetid = Tools::getSecurePOSTIntValue('commandsetid');
                     if (0 == $commandsetid) {
                         #$_SESSION['commandsetid'] = 0;
                         header('Location:command_edit.php?commandsetid=0');
                     } else {
                         $contract->addCommandSet($commandsetid, CommandSet::type_general);
                     }
                 } else {
                     if ("removeCmdSet" == $action) {
                         $commandsetid = Tools::getSecurePOSTIntValue('commandsetid');
                         $contract->removeCommandSet($commandsetid);
                     } else {
                         if ("updateContractInfo" == $action) {
                             $this->updateServiceContractInfo($contract);
                             header('Location:servicecontract_info.php');
                         } else {
                             if ("addProject" == $action) {
                                 # TODO
                                 $projectid = Tools::getSecurePOSTIntValue('projectid');
                                 if (0 != $projectid) {
                                     $contract->addSidetaskProject($projectid, Project::type_sideTaskProject);
                                 }
                             } else {
                                 if ("removeProject" == $action) {
                                     $projectid = Tools::getSecurePOSTIntValue('projectid');
                                     $contract->removeSidetaskProject($projectid);
                                 } else {
                                     if ("deleteContract" == $action) {
                                         if (self::$logger->isDebugEnabled()) {
                                             self::$logger->debug("delete ServiceContract servicecontractid (" . $contract->getName() . ")");
                                         }
                                         ServiceContract::delete($servicecontractid);
                                         unset($_SESSION['servicecontractid']);
                                         header('Location:servicecontract_info.php');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Display ServiceContract
                 $this->smartyHelper->assign('servicecontractid', $servicecontractid);
                 $this->smartyHelper->assign('contractInfoFormBtText', T_('Save'));
                 $this->smartyHelper->assign('contractInfoFormAction', 'updateContractInfo');
                 $commandsetCandidates = $this->getCmdSetCandidates($contract, $this->session_user);
                 $this->smartyHelper->assign('commandsetCandidates', $commandsetCandidates);
                 $projectCandidates = $this->getProjectCandidates($contract);
                 $this->smartyHelper->assign('projectCandidates', $projectCandidates);
                 $projects = $this->getProjects($contract);
                 $this->smartyHelper->assign('projectList', $projects);
                 $isManager = $this->session_user->isTeamManager($contract->getTeamid());
                 ServiceContractTools::displayServiceContract($this->smartyHelper, $contract, $isManager);
             }
             // you can create OR move SC only to managed teams
             $mTeamList = $this->session_user->getManagedTeamList();
             $this->smartyHelper->assign('grantedTeams', SmartyTools::getSmartyArray($mTeamList, $this->teamid));
         }
     }
 }