Ejemplo n.º 1
0
 /**
  * @param int $servicecontractid
  * @return mixed[]
  */
 private static function getContractTotalDetailedMgr($servicecontractid, $provDaysByType)
 {
     $detailledMgr = NULL;
     if (0 != $servicecontractid) {
         $contract = ServiceContractCache::getInstance()->getServiceContract($servicecontractid);
         $issueSelection = new IssueSelection("Total");
         // sidetasks
         $sidetasksPerCategory = $contract->getSidetasksPerCategoryType(true);
         foreach ($sidetasksPerCategory as $id => $iSel) {
             if (is_numeric($id) && Project::cat_st_inactivity == $id) {
                 continue;
             }
             $issueSelection->addIssueList($iSel->getIssueList());
         }
         // tasks
         $cmdsetsIssueSelection = $contract->getIssueSelection(CommandSet::type_general, Command::type_general);
         $issueSelection->addIssueList($cmdsetsIssueSelection->getIssueList());
         // provisions
         foreach ($provDaysByType as $nbDays) {
             $issueSelection->addProvision($nbDays);
         }
         #echo 'TotalSideTasks provision = '.$issueSelection->getProvision().'<br>';
         $detailledMgr = SmartyTools::getIssueSelectionDetailedMgr($issueSelection);
         $detailledMgr['name'] = $issueSelection->name;
     }
     return $detailledMgr;
 }
Ejemplo n.º 2
0
 /**
  * ServiceContracts for this team
  * @return ServiceContract[] : array id => ServiceContract
  */
 public function getServiceContractList()
 {
     if (NULL == $this->serviceContractList) {
         $query = "SELECT * " . "FROM `codev_servicecontract_table` " . "WHERE team_id = {$this->id};";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         $this->serviceContractList = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $this->serviceContractList[$row->id] = ServiceContractCache::getInstance()->getServiceContract($row->id, $row);
         }
     }
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("getServiceContractList(teamid={$this->id}) nbServiceContracts=" . count($this->serviceContractList));
     }
     return $this->serviceContractList;
 }
Ejemplo n.º 3
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');
                 }
             }
         }
     }
 }
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
0
 /**
  * A CommandSet can be included in several ServiceContract from different teams.
  *
  * This returns the list of ServiceContracts where this CommandSet is defined.
  *
  * @return ServiceContract[]
  */
 public function getServiceContractList()
 {
     if (NULL == $this->serviceContractList) {
         $query = "SELECT servicecontract.* FROM `codev_servicecontract_table` as servicecontract " . "JOIN `codev_servicecontract_cmdset_table` as servicecontract_cmdset ON servicecontract.id = servicecontract_cmdset.servicecontract_id " . "WHERE servicecontract_cmdset.commandset_id = " . $this->id . ";";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         // a Command can belong to more than one commandset
         $this->serviceContractList = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $srvContract = ServiceContractCache::getInstance()->getServiceContract($row->id, $row);
             $this->serviceContractList[$row->id] = $srvContract;
             if (self::$logger->isDebugEnabled()) {
                 self::$logger->debug("CommandSet {$this->id} is in ServiceContract {$row->id} (" . $srvContract->getName() . ")");
             }
         }
     }
     return $this->serviceContractList;
 }
Ejemplo n.º 6
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));
         }
     }
 }