예제 #1
0
 public function admin_delete_milestone($admin)
 {
     if (!isset($_GET['id'])) {
         error(__("Error"), __("No milestone ID specified.", "progress"));
     }
     $milestone = new Milestone($_GET['id']);
     if ($milestone->no_results) {
         error(__("Error"), __("Invalid milestone ID specified.", "progress"));
     }
     if (!$milestone->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this milestone.", "progress"));
     }
     $admin->display("delete_milestone", array("milestone" => $milestone, "milestones" => Milestone::find(array("where" => array("id not" => $milestone->id)))), _f("Delete Milestone “%s”", array(fix($milestone->name)), "progress"));
 }
예제 #2
0
        private function getMilestones($wantedid, $wantedstatus
                , $whowantsid, $whowantstype, $isForChart = false, &$chartData){
            $isperm = false;
            $conditions = array();
            if($isForChart){
                if($wantedid > 0){
                    $tmpcondition = array('order_id=?',$wantedid);
                    \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
                }
            }else{
                if($wantedid > 0){
                    $tmpcondition = array('id=?',$wantedid);
                    \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
                }
            }
            if($wantedstatus !== ''){
                if(strtolower($wantedstatus) !== 'latest'){
                    $tmpcondition = array('LCASE(status)=?', strtolower($wantedstatus));
                    \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
                }else{
                    $tmpcondition =  array($this->getConditionforLatestMilestones());
                    \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
                }
            }
            if(($whowantstype !== Menu::ppl_type_admin && !$isperm)){
                //whatever id, status been asked give if they are their related records only                
                $tmpcondition = array('person_id=?', $whowantsid);
                \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
            }
            $result = \Milestone::find('all', array('select' => 'milestones.*, DATEDIFF(milestones.end_at, milestones.start_at) AS duration', 'conditions' => $conditions, 'order' => 'start_at'));            
            $include = array('order');
            $except = array();
//            "id":1, "text":"Project #1", "start_date":"01-04-2013", "duration":"11", "progress": 0.6, "open": true,
//            {"id": "dd2e7a97-1622-4521-a807-f29960218785", "description": "Create concept", "order": 3, "tasks": [
//                {"id": "9c17a6c8-ce8c-4426-8693-a0965ff0fe69", "subject": "Create concept", "color": "#F1C232", "from": new Date(2013,9,10,8,0,0), "to": new Date(2013,9,16,18,0,0)}
//            ]}
//{
//"cols": [
//        {"id":"Room","label":"Room","pattern":"","type":"string"},
//        {"id":"Name","label":"Name","pattern":"","type":"string"}
//        {"id":"Start","label":"Start","pattern":"","type":"date"},
//        {"id":"End","label":"End","pattern":"","type":"date"}
//      ],
//"rows": [
//        {"c":[{"v":"WATCH","f":null},{"v":"TODAYS","f":null},{"v": new Date(2013,10,10,01,46,0),"f":null},{"v": new Date(2013,10,10,06,31,0),"f":null}]},
//        {"c":[{"v":"WATCH","f":null},{"v":"AVERAGE","f":null},{"v": new Date(2013,10,10,01,52,0),"f":null},{"v": new Date(2013,10,10,06,37,0),"f":null}]}
//        
//      ]
//}            
            if(count($result) > 0){
                $chartData = array();
                $order = 0;
                $rowid = 1;
                if($isForChart){
                    switch(Menu::chart_type_current){
                        case Menu::chart_type_angulargantt:
                            $chartRow = array();
                            $chartRow["id"] = $rowid++;
                            $chartRow["description"] = "Milestones";
                            $chartRow["order"] = $order++;
                            $chartRow["tasks"] = array();
                            $chartData[] = $chartRow;
                            break;
                        case Menu::chart_type_googletimeline:
//                            $chartData = new \stdClass();
//                            $colary = array();
//                            $colobj = new \stdClass();
//                            $colobj->id= "Details";
//                            $colobj->label= "Details";
//                            $colobj->pattern= "";
//                            $colobj->type= "string";
//                            $colary[] = $colobj;
//                            $colobj = new \stdClass();
//                            $colobj->id= "Completed";
//                            $colobj->label= "Completed";
//                            $colobj->pattern= "";
//                            $colobj->type= "string";
//                            $colary[] = $colobj;
//                            $colobj = new \stdClass();
//                            $colobj->id= "Start";
//                            $colobj->label= "Start";
//                            $colobj->pattern= "";
//                            $colobj->type= "date";
//                            $colary[] = $colobj;
//                            $colobj = new \stdClass();
//                            $colobj->id= "End";
//                            $colobj->label= "End";
//                            $colobj->pattern= "";
//                            $colobj->type= "date";
//                            $colary[] = $colobj;
//                            $chartData->cols = $colary;
//                            $chartrows = array();
                            break;
                    }
                }
                foreach ($result as &$rec) {
                    //$rec = $rec->to_array(array('include' => $include, 'except' => $except));
                    if($isForChart){
                        switch(Menu::chart_type_current){
                            case Menu::chart_type_angulargantt:
                                $tmprec = array();
                                $this->fillRecForMstaskChart($tmprec, $rec);                                
                                $chartData[0]["tasks"][] = $tmprec;
                                break;
                            case Menu::chart_type_googletimeline:
                                $chartRow = array();
                                $chartRow[] = $rec->details;
                                $chartRow[] = 0;// number_format($rec->completed,0,'.','');//$rec->completed;//
                                $chartRow[] = $rec->start_at;
                                $chartRow[] = $rec->start_at;//$rec->end_at;
                                $chartRow[] = 1;
//                                //another method
//                                $chartrowobj = new \stdClass();
//                                $volobj = new \stdClass();
//                                $volobj->v = $rec['details'];
//                                //$volobj->f = null;
//                                $chartRow[] = $volobj;
//                                $volobj = new \stdClass();
//                                $volobj->v = number_format($rec['completed'],2,'.','');
//                                //$volobj->f = null;
//                                $chartRow[] = $volobj;
//                                $volobj = new \stdClass();
//                                $volobj->v = $this->formJSdateJson($rec['start_at']);
//                                //$volobj->f = null;
//                                $chartRow[] = $volobj;
//                                $volobj = new \stdClass();
//                                $volobj->v = $this->formJSdateJson($rec['end_at']);
//                                //$volobj->f = null;
//                                $chartRow[] = $volobj;
//                                $chartrowobj->c = $chartRow;
//                                $chartrows[] = $chartrowobj;
//                                $chartRow[] = $rec['details'];
//                                $chartRow[] = number_format($rec['completed'],2,'.','');
//                                $chartRow[] = $this->formJSdateJson($rec['start_at']);
//                                $chartRow[] = $this->formJSdateJson($rec['end_at']);
                                $chartData[] = $chartRow;
                                break;
                        }
                    }
                    $rec = $rec->to_array(array('include' => $include, 'except' => $except));
                }
                //$chartData->rows = $chartrows;
                if($isForChart){//collect ordertasks too.
                    $conditions = array();
                    if($wantedid > 0){
                        $tmpcondition = array('order_id=?',$wantedid);
                        \ActiveRecord\Utils::add_condition($conditions, $tmpcondition);
                    }
                    if(($whowantstype !== Menu::ppl_type_admin && !$isperm)){                
                        $allordertasksresult = \Ordertask::find('all', array('joins' => array('ordertaskpeople'), 'select' => 'ordertasks.*, DATEDIFF(ordertasks.end_at, ordertasks.start_at) AS duration', 'conditions' => $conditions, 'order' => 'start_at'));
                    }else{
                        $allordertasksresult = \Ordertask::find('all', array('select' => 'ordertasks.*, DATEDIFF(ordertasks.end_at, ordertasks.start_at) AS duration', 'conditions' => $conditions, 'order' => 'start_at'));
                    }
                    foreach ($allordertasksresult as &$otrec) {
                        //$otrec = $otrec->to_array(array('include' => $include, 'except' => $except));
                        switch(Menu::chart_type_current){
                            case Menu::chart_type_angulargantt://each task as each row
                                $chartRow = array();
                                $chartRow["id"] = $rowid++;
                                $chartRow["description"] = $otrec['details'];
                                $chartRow["order"] = $order++;

                                $chartRow["tasks"] = array();                            
                                $tmprec = array();
                                $this->fillRecForMstaskChart($tmprec, $otrec);                            
                                $chartRow["tasks"][] = $tmprec;

                                $chartData[] = $chartRow;
                                break;
                            case Menu::chart_type_googletimeline:
                                $chartRow = array();
                                $chartRow[] = $otrec->details;
                                $chartRow[] = number_format($otrec->completed,2,'.','');//number_format($otrec->completed,2,'.','');$rec->completed
                                $chartRow[] = $otrec->start_at;
                                $chartRow[] = $otrec->end_at;
                                $chartRow[] = 0;
    //                            $chartRow[] = $otrec['details'];
    //                            $chartRow[] = number_format($otrec['completed'],2,'.','');
    //                            $chartRow[] = $this->formJSdateJson($otrec['start_at']);
    //                            $chartRow[] = $this->formJSdateJson($otrec['end_at']);
                                $chartData[] = $chartRow;
                                break;
                        }
                        $otrec = $otrec->to_array(array('include' => $include, 'except' => $except));
                    }
                }
            }
            return $result;
        }
예제 #3
0
 public function search()
 {
     fallback($_GET['query'], "");
     $config = Config::current();
     if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) {
         # Searches with / and clean URLs = server 404
         redirect("search/" . urlencode($_GET['query']) . "/");
     }
     if (empty($_GET['query'])) {
         return Flash::warning(__("Please enter a search term."));
     }
     list($where, $params) = keywords($_GET['query'], "title LIKE :query OR description LIKE :query OR url LIKE :query", "tickets");
     $tickets = Ticket::find(array("placeholders" => true, "where" => $where, "params" => $params, "done" => true));
     list($where, $params) = keywords($_GET['query'], "body LIKE :query", "revisions");
     $revisions = Revision::find(array("placeholders" => true, "where" => $where, "params" => $params));
     list($where, $params) = keywords($_GET['query'], "name LIKE :query", "milestones");
     $milestones = Milestone::find(array("placeholders" => true, "where" => $where, "params" => $params));
     $this->display("progress/search", array("tickets" => new Paginator($tickets, 25, "tickets_page"), "revisions" => new Paginator($revisions, 25, "revisions_page"), "milestones" => new Paginator($milestones, 25, "milestones_page"), "search" => $_GET['query']), fix(_f("Search results for \"%s\"", $_GET['query'])));
 }
 public function milestoneSubject($milestone_id)
 {
     $milestone_info = Milestone::find($milestone_id);
     $subject = $milestone_info->subject;
     return $subject;
 }